@fto-consult/expo-ui 7.6.31 → 7.6.33

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.31",
3
+ "version": "7.6.33",
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.26",
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",
@@ -1822,7 +1822,9 @@ export default class CommonDatagridComponent extends AppComponent {
1822
1822
  return this.SetExportOptions({excel:false,pdf:true}).then((opts)=>{
1823
1823
  const {data,config:cConfig,pdfConfig} = opts;
1824
1824
  const config = extendObj({},pdfConfig,cConfig);
1825
- data[0] = createTableHeader(data[0],config);
1825
+ data[0] = createTableHeader(data[0],{...config,filter:(a)=>{
1826
+ return true;
1827
+ }});
1826
1828
  const pT = defaultStr(config.pdfDocumentTitle).trim();
1827
1829
  const pdfDocumentTitle = pT ? pdfSprintf(pT,{fontSize : 20,color : "red"}) : null;
1828
1830
  const content = [{
@@ -1858,8 +1860,8 @@ export default class CommonDatagridComponent extends AppComponent {
1858
1860
  const hasFields = !!config.fields.length;
1859
1861
  const fields = config.fields;
1860
1862
  const headers = [];
1863
+ const fValues = this.getFooterValues();
1861
1864
  if(displayOnlyHeader && config.aggregatedValues){
1862
- const fValues = this.getFooterValues();
1863
1865
  headers.push("Fonction d'agrégation");
1864
1866
  const aggregatorFunctions = this.aggregatorFunctions;
1865
1867
  Object.map(footers,(f,i)=>{
@@ -1874,7 +1876,8 @@ export default class CommonDatagridComponent extends AppComponent {
1874
1876
  const d = [defaultStr(ag.label,ag.text,i)];
1875
1877
  Object.map(fValues,(footer,field)=>{
1876
1878
  if(!cols[field]) return;
1877
- d.push(defaultNumber(footer[i]))
1879
+ const v = defaultNumber(footer[i]);
1880
+ d.push(pdf ? this.formatValue(v,footer.format,field):v);
1878
1881
  });
1879
1882
  data.push(d);
1880
1883
  })
@@ -1883,41 +1886,76 @@ export default class CommonDatagridComponent extends AppComponent {
1883
1886
  const agFunc = this.state.aggregatorFunction;
1884
1887
  const canExportOnlyTotal = isOnlytotal || (config.exportOnlyTotal && displayOnlyHeader);
1885
1888
  if(canExportOnlyTotal){
1886
- headers.push("");
1889
+ headers.push(pdf?{text:""}:"");
1887
1890
  }
1888
1891
  Object.map(this.state.columns,(col,i)=>{
1889
1892
  if(hasFields && !fields.includes(i)) return;
1890
1893
  if(!isObj(col) || col.visible === false || this.isSelectableColumn(col,i) || i === this.getIndexColumnName()) return;
1891
1894
  if(canExportOnlyTotal && !(i in footers)) return;
1892
1895
  cols[i] = col;
1893
- 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
+ }
1894
1902
  totalColumns++;
1895
1903
  });
1896
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
+ }
1897
1915
  Object.map(this.state.data,(dat,index)=>{
1898
1916
  ///si l'on a a faire à une colonne de type entete
1899
1917
  const d = [];
1900
1918
  if(dat.isSectionListHeader){
1901
1919
  if(!config.displayTotals && !canExportOnlyTotal) return;
1902
1920
  const {sectionListHeaderKey:key} = dat;
1903
- 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
+ }
1904
1925
  d.push(val);
1905
1926
  if(!canExportOnlyTotal){
1906
1927
  for(let i = 1;i<totalColumns;i++){
1907
1928
  d.push(null);
1908
1929
  }
1909
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
+ }
1910
1946
  } else {
1911
1947
  const hF = hFooters[key];
1912
1948
  if(isObj(hF) && isNonNullString(agFunc)){
1913
1949
  const dd = [];
1914
1950
  Object.map(cols,(col,i)=>{
1915
1951
  if(i in hF){
1916
- const ff = hF[i];
1917
- dd.push(defaultNumber(ff[agFunc]));
1918
- } else {
1919
- dd.push(null);
1920
- }
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
+ }
1921
1959
  });
1922
1960
  if(canExportOnlyTotal){
1923
1961
  dd.unshift(val);
@@ -1927,6 +1965,9 @@ export default class CommonDatagridComponent extends AppComponent {
1927
1965
  data.push(dd);
1928
1966
  }
1929
1967
  } else {
1968
+ if(canExportOnlyTotal){
1969
+ d.push(null);
1970
+ }
1930
1971
  data.push(d);
1931
1972
  }
1932
1973
  }
@@ -1938,7 +1979,7 @@ export default class CommonDatagridComponent extends AppComponent {
1938
1979
  rowData : dat,
1939
1980
  rowCounterIndex : index,
1940
1981
  rowIndex : index,
1941
- formatValue : false,
1982
+ formatValue : !pdf,
1942
1983
  renderRowCell : false,
1943
1984
  columnField : defaultStr(col.field,i),
1944
1985
  columnDef :{
@@ -161,6 +161,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
161
161
  const sortRef = React.useRef({});
162
162
  const innerRef = React.useRef(null);
163
163
  const showProgressRef = React.useRef(true);
164
+ const forceRefreshRef = React.useRef(true);
164
165
  const pageRef = React.useRef(1);
165
166
  const canHandlePagination = handlePagination !== false ? true : false;
166
167
  const canHandleLimit = handleQueryLimit !== false && canHandlePagination ? true : false;
@@ -238,7 +239,8 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
238
239
  showProgressRef.current = showProgress || typeof showProgress ==='boolean' ? showProgress : false;
239
240
  const fPath = isNonNullString(fetchPath)? fetchPath : fPathRef.current;
240
241
  const rKey = `${setQueryParams(fPath,"swrRefreshKeyId",uniqid("swr-refresh-key"))}`;
241
- refresh(rKey,data);
242
+ forceRefreshRef.current = true;
243
+ refresh(rKey);
242
244
  }
243
245
  const canPaginate = ()=>{
244
246
  if(!canHandlePagination) return false;
@@ -302,6 +304,8 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
302
304
  showProgressRef.current = false;
303
305
  }
304
306
  },[showProgressRef.current]);
307
+ const isAppLoading = loading && showProgressRef.current && forceRefreshRef.current || false;
308
+ forceRefreshRef.current = undefined;
305
309
  return (
306
310
  <Datagrid
307
311
  testID = {testID}
@@ -408,7 +412,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
408
412
  handleQueryLimit = {false}
409
413
  handlePagination = {false}
410
414
  autoSort = {canSortRemotely()? false : true}
411
- isLoading = {loading && showProgressRef.current || false}
415
+ isLoading = {isAppLoading}
412
416
  beforeFetchData = {(args)=>{
413
417
  let {fetchOptions:opts,force,renderProgressBar} = args;
414
418
  opts = getFetchOptions({showError:showProgressRef.current,...opts});