@fto-consult/expo-ui 7.6.30 → 7.6.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.6.30",
3
+ "version": "7.6.32",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -71,7 +71,7 @@
71
71
  "@expo/html-elements": "^0.5.1",
72
72
  "@expo/vector-icons": "^13.0.0",
73
73
  "@faker-js/faker": "^8.0.2",
74
- "@fto-consult/common": "^3.73.15",
74
+ "@fto-consult/common": "^3.73.29",
75
75
  "@fto-consult/electron": "^1.0.27",
76
76
  "@pchmn/expo-material3-theme": "^1.3.1",
77
77
  "@react-native-async-storage/async-storage": "1.18.2",
@@ -295,7 +295,6 @@ export default class CommonDatagridComponent extends AppComponent {
295
295
  this.INITIAL_STATE = {
296
296
  data,
297
297
  }
298
- this.prepareFetchData();
299
298
  this._datagridId = isNonNullString(this.props.id)? this.props.id : uniqid("datagrid-id")
300
299
  this.canDoFilter = true;
301
300
  this.filters = {}
@@ -1823,7 +1822,9 @@ export default class CommonDatagridComponent extends AppComponent {
1823
1822
  return this.SetExportOptions({excel:false,pdf:true}).then((opts)=>{
1824
1823
  const {data,config:cConfig,pdfConfig} = opts;
1825
1824
  const config = extendObj({},pdfConfig,cConfig);
1826
- data[0] = createTableHeader(data[0],config);
1825
+ data[0] = createTableHeader(data[0],{...config,filter:(a)=>{
1826
+ return true;
1827
+ }});
1827
1828
  const pT = defaultStr(config.pdfDocumentTitle).trim();
1828
1829
  const pdfDocumentTitle = pT ? pdfSprintf(pT,{fontSize : 20,color : "red"}) : null;
1829
1830
  const content = [{
@@ -1859,8 +1860,8 @@ export default class CommonDatagridComponent extends AppComponent {
1859
1860
  const hasFields = !!config.fields.length;
1860
1861
  const fields = config.fields;
1861
1862
  const headers = [];
1863
+ const fValues = this.getFooterValues();
1862
1864
  if(displayOnlyHeader && config.aggregatedValues){
1863
- const fValues = this.getFooterValues();
1864
1865
  headers.push("Fonction d'agrégation");
1865
1866
  const aggregatorFunctions = this.aggregatorFunctions;
1866
1867
  Object.map(footers,(f,i)=>{
@@ -1875,7 +1876,8 @@ export default class CommonDatagridComponent extends AppComponent {
1875
1876
  const d = [defaultStr(ag.label,ag.text,i)];
1876
1877
  Object.map(fValues,(footer,field)=>{
1877
1878
  if(!cols[field]) return;
1878
- d.push(defaultNumber(footer[i]))
1879
+ const v = defaultNumber(footer[i]);
1880
+ d.push(pdf ? this.formatValue(v,footer.format,field):v);
1879
1881
  });
1880
1882
  data.push(d);
1881
1883
  })
@@ -1884,41 +1886,76 @@ export default class CommonDatagridComponent extends AppComponent {
1884
1886
  const agFunc = this.state.aggregatorFunction;
1885
1887
  const canExportOnlyTotal = isOnlytotal || (config.exportOnlyTotal && displayOnlyHeader);
1886
1888
  if(canExportOnlyTotal){
1887
- headers.push("");
1889
+ headers.push(pdf?{text:""}:"");
1888
1890
  }
1889
1891
  Object.map(this.state.columns,(col,i)=>{
1890
1892
  if(hasFields && !fields.includes(i)) return;
1891
1893
  if(!isObj(col) || col.visible === false || this.isSelectableColumn(col,i) || i === this.getIndexColumnName()) return;
1892
1894
  if(canExportOnlyTotal && !(i in footers)) return;
1893
1895
  cols[i] = col;
1894
- headers.push(defaultStr(col.label,col.text));
1896
+ const textVal = defaultStr(col.label,col.text);
1897
+ if(pdf && !textVal){
1898
+ headers.push({text:""});
1899
+ } else {
1900
+ headers.push(textVal);
1901
+ }
1895
1902
  totalColumns++;
1896
1903
  });
1897
1904
  data.push(headers);
1905
+ if(canExportOnlyTotal && isNonNullString(agFunc)){
1906
+ const totalFooter = [pdf?{text:"TOTAUX",fontSize:16,bold:true}:"TOTAUX"];
1907
+ Object.map(fValues,(f,i)=>{
1908
+ if(!isObj(f) || hasFields && !fields.includes(i) || !(agFunc in f)) return;
1909
+ const vNum = defaultNumber(f[agFunc]);
1910
+ const text = pdf ? this.formatValue(vNum,f.format,i) : vNum;
1911
+ totalFooter.push(pdf?{text,bold:true,fontSize:15,alignment:"center",color:"red"}:text);
1912
+ });
1913
+ data.push(totalFooter);
1914
+ }
1898
1915
  Object.map(this.state.data,(dat,index)=>{
1899
1916
  ///si l'on a a faire à une colonne de type entete
1900
1917
  const d = [];
1901
1918
  if(dat.isSectionListHeader){
1902
1919
  if(!config.displayTotals && !canExportOnlyTotal) return;
1903
1920
  const {sectionListHeaderKey:key} = dat;
1904
- const val = key === this.emptySectionListHeaderValue ? this.getEmptySectionListHeaderValue() : key;
1921
+ let val = key === this.emptySectionListHeaderValue ? this.getEmptySectionListHeaderValue() : key;
1922
+ if(pdf){
1923
+ val = {text : val, colSpan :totalColumns,bold:true,fontSize:15};
1924
+ }
1905
1925
  d.push(val);
1906
1926
  if(!canExportOnlyTotal){
1907
1927
  for(let i = 1;i<totalColumns;i++){
1908
1928
  d.push(null);
1909
1929
  }
1910
1930
  data.push(d);
1931
+ const hF = hFooters[key];
1932
+ if(isObj(hF) && isNonNullString(agFunc)){
1933
+ const totalSectionFooter = [];
1934
+ Object.map(cols,(col,i)=>{
1935
+ if(i in hF){
1936
+ const ff = hF[i];
1937
+ const vNum = defaultNumber(ff[agFunc]);
1938
+ const text = pdf ? this.formatValue(vNum,col.format,i) : vNum;
1939
+ totalSectionFooter.push(pdf?{text,bold:true,fontSize:15,alignment:"center"}:text);
1940
+ } else {
1941
+ totalSectionFooter.push(null);
1942
+ }
1943
+ });
1944
+ data.push(totalSectionFooter);
1945
+ }
1911
1946
  } else {
1912
1947
  const hF = hFooters[key];
1913
1948
  if(isObj(hF) && isNonNullString(agFunc)){
1914
1949
  const dd = [];
1915
1950
  Object.map(cols,(col,i)=>{
1916
1951
  if(i in hF){
1917
- const ff = hF[i];
1918
- dd.push(defaultNumber(ff[agFunc]));
1919
- } else {
1920
- dd.push(null);
1921
- }
1952
+ const ff = hF[i];
1953
+ const vNum = defaultNumber(ff[agFunc]);
1954
+ const text = pdf ? this.formatValue(vNum,col.format,i) : vNum;
1955
+ dd.push(pdf?{text,bold:true,fontSize:15,alignment:"center"}:text);
1956
+ } else {
1957
+ dd.push(null);
1958
+ }
1922
1959
  });
1923
1960
  if(canExportOnlyTotal){
1924
1961
  dd.unshift(val);
@@ -1928,6 +1965,9 @@ export default class CommonDatagridComponent extends AppComponent {
1928
1965
  data.push(dd);
1929
1966
  }
1930
1967
  } else {
1968
+ if(canExportOnlyTotal){
1969
+ d.push(null);
1970
+ }
1931
1971
  data.push(d);
1932
1972
  }
1933
1973
  }
@@ -1939,7 +1979,7 @@ export default class CommonDatagridComponent extends AppComponent {
1939
1979
  rowData : dat,
1940
1980
  rowCounterIndex : index,
1941
1981
  rowIndex : index,
1942
- formatValue : false,
1982
+ formatValue : !pdf,
1943
1983
  renderRowCell : false,
1944
1984
  columnField : defaultStr(col.field,i),
1945
1985
  columnDef :{
@@ -3243,9 +3283,6 @@ export default class CommonDatagridComponent extends AppComponent {
3243
3283
  this.refresh(true);
3244
3284
  this.previousDataSources = dataSources;
3245
3285
  }
3246
- prepareFetchData(fetchData){
3247
- this.INITIAL_STATE.fetchData = defaultVal(fetchData,this.props.fetchData);
3248
- }
3249
3286
  beforeFetchData(){}
3250
3287
  /**** retourne la liste des items, utile lorsqu'une s'agit d'une fonction
3251
3288
  Lorsque data est une chaine de caractère, alors elle doit être sous la forme recommandée par la function
@@ -3290,7 +3327,7 @@ export default class CommonDatagridComponent extends AppComponent {
3290
3327
  if(force !== true && isArray(this.INITIAL_STATE.data)) {
3291
3328
  return this.resolveFetchedDataPromise({cb,data:this.INITIAL_STATE.data}).then(resolve).catch(reject)
3292
3329
  }
3293
- let fetchData = this.INITIAL_STATE.fetchData;
3330
+ let fetchData = undefined;
3294
3331
  if(isFunction(this.props.fetchData)){
3295
3332
  /**** l'on peut définir la props fetchData, qui est la fonction appelée pour la recherche des données */
3296
3333
  fetchData = this.props.fetchData.call(this,fetchOptions);
@@ -3381,7 +3418,7 @@ export default class CommonDatagridComponent extends AppComponent {
3381
3418
  this._pagination.page = 1;
3382
3419
  this._pagination.start = 0;
3383
3420
  }
3384
- return this.fetchData({force:true});
3421
+ return this.fetchData({force:true,renderProgressBar:true});
3385
3422
  }
3386
3423
  onSetQueryLimit(){
3387
3424
  if(!this.canSetQueryLimit()) return;
@@ -208,7 +208,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
208
208
  const dataRef = React.useRef(null);
209
209
  const totalRef = React.useRef(0);
210
210
  const prevIsLoading = React.usePrevious(isLoading);
211
- const loading = (customIsLoading === true || isLoading || (prevIsLoading && isValidating && showProgressRef.current));
211
+ const loading = (customIsLoading === true || isLoading || (isValidating && showProgressRef.current));
212
212
  const {data,total} = React.useMemo(()=>{
213
213
  if((loading && customIsLoading !== false) || !isObjOrArray(result)){
214
214
  return {data:dataRef.current,total:totalRef.current};
@@ -235,8 +235,10 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
235
235
  },500);
236
236
  },[error]);
237
237
  const doRefresh = (showProgress)=>{
238
- showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : false;
239
- refresh();
238
+ showProgressRef.current = showProgress || typeof showProgress ==='boolean' ? showProgress : false;
239
+ const fPath = isNonNullString(fetchPath)? fetchPath : fPathRef.current;
240
+ const rKey = `${setQueryParams(fPath,"swrRefreshKeyId",uniqid("swr-refresh-key"))}`;
241
+ refresh(rKey,data);
240
242
  }
241
243
  const canPaginate = ()=>{
242
244
  if(!canHandlePagination) return false;