@fto-consult/expo-ui 8.74.2 → 8.76.0
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/bin/create-app/src/database/tables/index.js +1 -1
- package/package.json +108 -108
- package/src/components/Chart/appexChart/appexChart.html +3 -3
- package/src/components/Datagrid/Accordion/index.js +529 -545
- package/src/components/Datagrid/Common/Common.js +109 -13
- package/src/components/Datagrid/Common/index.js +0 -4
- package/src/components/Datagrid/Dashboard/index.js +3 -4
- package/src/components/Datagrid/IndexComponent.js +8 -9
- package/src/components/Datagrid/Table/index.js +311 -327
- package/src/components/Dropdown/index.js +20 -10
- package/src/layouts/Screen/TableData.js +9 -3
- package/src/pdf/index.js +1 -1
- package/src/screens/Help/openLibraries.js +76 -123
- package/src/components/Datagrid/Common/TableData.js +0 -66
- package/src/components/Datagrid/Common/factory.js +0 -9
- package/src/components/Datagrid/factory.js +0 -12
@@ -46,6 +46,8 @@ import ActivityIndicator from "$ecomponents/ActivityIndicator";
|
|
46
46
|
import {createTableHeader,fields as pdfFields,pageHeaderMargin,sprintf as pdfSprintf} from "$cpdf";
|
47
47
|
import {isWeb,isMobileNative} from "$cplatform";
|
48
48
|
import { createPDF,getFields as getPdfFields } from '$expo-ui/pdf';
|
49
|
+
import actions from '$cactions';
|
50
|
+
import {printTableData} from "$epdf";
|
49
51
|
|
50
52
|
export const TIMEOUT = 100;
|
51
53
|
|
@@ -178,13 +180,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
178
180
|
exportToExcelIsAllowed,
|
179
181
|
renderSectionListIsAllowed,
|
180
182
|
checkPerms : customCheckPerms,
|
183
|
+
tableName,
|
184
|
+
table,
|
185
|
+
dataSource,
|
181
186
|
...rest
|
182
187
|
} = props;
|
183
|
-
if(this.bindResizeEvents()){
|
184
|
-
extendObj(this._events,{
|
185
|
-
SET_DATAGRID_QUERY_LIMIT : this.onSetQueryLimit.bind(this),
|
186
|
-
});
|
187
|
-
}
|
188
188
|
if(this.props.resetSessionData === true){
|
189
189
|
this.resetSessionData();
|
190
190
|
}
|
@@ -230,8 +230,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
230
230
|
Object.map(displayTypes,(t,i)=>{
|
231
231
|
if(t.isChart && !perm) return;
|
232
232
|
allowedDisplayTypes[i] = Object.clone(t);
|
233
|
-
})
|
233
|
+
});
|
234
|
+
dataSource = CommonDatagridComponent.getDataSource({...props,dataSource,context:this});
|
235
|
+
tableName = defaultStr(tableName,table).toUpperCase();
|
234
236
|
Object.defineProperties(this,{
|
237
|
+
tableName : {value:tableName,override:false,writable:false},
|
235
238
|
layoutRef : {
|
236
239
|
value : React.createRef(null),
|
237
240
|
},
|
@@ -347,6 +350,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
347
350
|
this.setSessionData({selectedDataSources:this.currentDataSources});
|
348
351
|
this.persistDisplayType(this.state.displayType);
|
349
352
|
}
|
353
|
+
/*** lorsque la données est modifiée */
|
354
|
+
onUpsertData =(arg) =>{
|
355
|
+
return this.refresh({force:true,renderProgressBar:false});
|
356
|
+
}
|
350
357
|
/*** si l'on peut récuperer à distance, les colonnes seulement visibles */
|
351
358
|
canFetchOnlyVisibleColumns(){
|
352
359
|
return this.isTableData() && this.props.canFetchOnlyVisibleColumns && this.isFilterable() && true || false;
|
@@ -825,15 +832,21 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
825
832
|
}
|
826
833
|
return copyToClipboard({...rest,isDatagrid:true,data:row,fields : this.props.columns,sessionName:defaultStr(this.props.sessionName,"datagrid")});
|
827
834
|
}
|
828
|
-
|
835
|
+
isPrintable(){
|
836
|
+
if(!this.isTableData() || this.props.printAction === false) return false;
|
837
|
+
if(typeof this.props.printable ==='function'){
|
838
|
+
return !!this.props.printable({context:this,tableName:this.tableName,table:this.tableName,context:this,isDatagrid:true,isTableData:false});
|
839
|
+
}
|
840
|
+
return this.props.printable === true;
|
841
|
+
}
|
829
842
|
/*** les actions représentes les différents menus apparaissant lorsqu'une ligne est sélectionnée
|
830
843
|
* ou pas.
|
831
844
|
*/
|
832
845
|
renderSelectedRowsActions(sActions){
|
833
846
|
let {makePhoneCallProps,canMakePhoneCall,archivable} = this.props;
|
834
847
|
const size = this.getSelectedRowsCount();
|
835
|
-
|
836
|
-
|
848
|
+
const r = [];
|
849
|
+
const endActs = [];
|
837
850
|
if(size <=0) {
|
838
851
|
return r
|
839
852
|
};
|
@@ -845,6 +858,28 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
845
858
|
if(isFunction(selectedR)) {
|
846
859
|
selectedR = selectedR.call(this,sArgs)
|
847
860
|
}
|
861
|
+
if(this.isPrintable()){
|
862
|
+
const {filter:printFilter,onPress,...printAction} = defaultObj(this.props.printAction);
|
863
|
+
r.push({
|
864
|
+
icon : "printer",
|
865
|
+
...printAction,
|
866
|
+
text : printAction.text || printAction.label || "Imprimer",
|
867
|
+
label : printAction.label || printAction.label || 'Imprimer',
|
868
|
+
onPress : (r)=>{
|
869
|
+
const opts2 = {isTableData:false,context:this,isDatagrid:true,tableName:this.tableName,table:this.tableName};
|
870
|
+
const args = {...React.getOnPressArgs(r),...sArgs,...opts2};
|
871
|
+
if(typeof onPress =='function' && onPress(args) === false) return;
|
872
|
+
const printDat = [];
|
873
|
+
const filter = typeof printFilter =="function" ? printFilter : x=>true;
|
874
|
+
Object.map(args.selectedRows,(row,rowKey,index)=>{
|
875
|
+
if(!!!filter({...args,data:row,key:rowKey,rowData:row,index,rowIndex:index})) return;
|
876
|
+
printDat.push(row);
|
877
|
+
});
|
878
|
+
if(!printDat.length) return notify.error(printAction.noDataError,"Aucune données sélectionnée pour l'impression");
|
879
|
+
return this.print(printDat,opts2);
|
880
|
+
},
|
881
|
+
});
|
882
|
+
}
|
848
883
|
Object.map(sActions,(o,i)=>{
|
849
884
|
if(isObj(o)){
|
850
885
|
let {onPress, ...rest} = o;
|
@@ -872,7 +907,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
872
907
|
}
|
873
908
|
r.push(rest)
|
874
909
|
}
|
875
|
-
})
|
910
|
+
});
|
876
911
|
endActs.map((a)=>{
|
877
912
|
r.push(a);
|
878
913
|
})
|
@@ -908,7 +943,18 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
908
943
|
}
|
909
944
|
return r;
|
910
945
|
}
|
911
|
-
|
946
|
+
getTableName(){
|
947
|
+
return defaultStr(this.tableName,this.props.table,this.props.tableName).toUpperCase().trim();
|
948
|
+
}
|
949
|
+
print(data,options){
|
950
|
+
if(!this.isPrintable()) return;
|
951
|
+
if(!isObj(data) && !Array.isArray(data)) return;
|
952
|
+
const opts = {...defaultObj(options),tableName:this.getTableName(),table:this.getTableName(),isTableData:false,isDatagrid:true,context:this};
|
953
|
+
if(typeof this.props.print ==='function'){
|
954
|
+
return this.props.print.call(this,data,opts);
|
955
|
+
}
|
956
|
+
return printTableData(data,opts);
|
957
|
+
}
|
912
958
|
/*** le trie du tableau prend en paramètre
|
913
959
|
: le nom de la colonne de trie, la direction de la conne de trie
|
914
960
|
par défaut, le trie se fait en ignorant la casse
|
@@ -3595,12 +3641,38 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3595
3641
|
}
|
3596
3642
|
componentDidMount(){
|
3597
3643
|
super.componentDidMount();
|
3644
|
+
extendObj(this._events,{
|
3645
|
+
SET_DATAGRID_QUERY_LIMIT : this.onSetQueryLimit.bind(this),
|
3646
|
+
});
|
3598
3647
|
APP.on(APP.EVENTS.SET_DATAGRID_QUERY_LIMIT,this._events.SET_DATAGRID_QUERY_LIMIT);
|
3648
|
+
if(isNonNullString(this.tableName)){
|
3649
|
+
extendObj(this._events,{
|
3650
|
+
onUpsertData : this.onUpsertData.bind(this),
|
3651
|
+
});
|
3652
|
+
this.onUpsertDataSubscription = APP.on(actions.upsert(this.tableName),this._events.onUpsertData);
|
3653
|
+
this.onRemoteDataSubscription = APP.on(actions.remove(this.tableName),this._events.onUpsertData);
|
3654
|
+
}
|
3655
|
+
if(isNonNullString(this.tableName)){
|
3656
|
+
this.fetchData({force:true});
|
3657
|
+
}
|
3599
3658
|
}
|
3600
3659
|
componentWillUnmount(){
|
3601
3660
|
super.componentWillUnmount();
|
3661
|
+
if(isNonNullString(this.tableName)){
|
3662
|
+
if(typeof this.onUpsertDataSubscription?.remove =="function"){
|
3663
|
+
this.onUpsertDataSubscription.remove();
|
3664
|
+
}
|
3665
|
+
if(this._events.onUpsertData){
|
3666
|
+
APP.off(actions.upsert(this.tableName),this._events.onUpsertData);
|
3667
|
+
APP.off(actions.remove(this.tableName),this._events.onUpsertData);
|
3668
|
+
}
|
3669
|
+
if(typeof this.onRemoteDataSubscription?.remove =="function"){
|
3670
|
+
this.onRemoteDataSubscription.remove();
|
3671
|
+
}
|
3672
|
+
}
|
3602
3673
|
APP.off(APP.EVENTS.SET_DATAGRID_QUERY_LIMIT,this._events.SET_DATAGRID_QUERY_LIMIT);
|
3603
3674
|
this.clearEvents();
|
3675
|
+
this.setSelectedRows();
|
3604
3676
|
}
|
3605
3677
|
|
3606
3678
|
/*** s'il s'agit d'un datagrid virtualisé, ie à utiliser le composant react-base-table */
|
@@ -3731,7 +3803,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3731
3803
|
return "auto";
|
3732
3804
|
}
|
3733
3805
|
isTableData(){
|
3734
|
-
return
|
3806
|
+
return isNonNullString(this.tableName);
|
3735
3807
|
}
|
3736
3808
|
UNSAFE_componentWillReceiveProps(nextProps){
|
3737
3809
|
if(false && !React.areEquals(this.props.columns,nextProps.columns)){
|
@@ -3894,6 +3966,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
3894
3966
|
getRowsKeysIndexes(){
|
3895
3967
|
return Array.isArray(this.rowsKeysIndexes) ? this.rowsKeysIndexes : [];
|
3896
3968
|
}
|
3969
|
+
/****
|
3970
|
+
attention cette fonction est uniquement valide lorsque les données ne sont pas groupées
|
3971
|
+
Lorsque les données sont groupées, cette fonction est inutile
|
3972
|
+
*/
|
3897
3973
|
getRowKeyByIndex(rowIndex){
|
3898
3974
|
if(typeof rowIndex !='number') return undefined;
|
3899
3975
|
const idx = this.getRowsKeysIndexes();
|
@@ -4033,7 +4109,12 @@ CommonDatagridComponent.propTypes = {
|
|
4033
4109
|
/*** si le pied de page sera affiché */
|
4034
4110
|
showFooters : PropTypes.bool,
|
4035
4111
|
/*** les donnnées peuvent être soient retournées par une fonction, soit par un tableau soit une promesse */
|
4036
|
-
data : PropTypes.oneOfType([
|
4112
|
+
data : PropTypes.oneOfType([
|
4113
|
+
PropTypes.func,
|
4114
|
+
PropTypes.string,
|
4115
|
+
PropTypes.object,
|
4116
|
+
PropTypes.array,
|
4117
|
+
]),
|
4037
4118
|
/****
|
4038
4119
|
la prop column def contient dans la propriété datagrid, la prop maxItemsToRender, le nombre d'items maximal à rendre pour le composant de type select table data multiple
|
4039
4120
|
la prop column def de la colonne de type number, qui contient dans la prop datagrid, la fonction render doit retourner un nombre pour otenir les valeur léie à ladite colonne
|
@@ -4242,6 +4323,21 @@ CommonDatagridComponent.propTypes = {
|
|
4242
4323
|
abreviateValues : PropTypes.bool, //si les valeurs numériques seront abregées
|
4243
4324
|
handleTitle : PropTypes.bool,//si le titre du datagrid, props title, sera pris en compte dans les actions du datagrid, pour le rendu du DataSourceSelector, fonction renderDataSourceSelector
|
4244
4325
|
checkPerms : PropTypes.func,//la fonction utilisée pour vérifier les permissions de l'utilisateur
|
4326
|
+
printAction : PropTypes.oneOfType([
|
4327
|
+
PropTypes.bool,
|
4328
|
+
PropTypes.shape({
|
4329
|
+
label : PropTypes.any,
|
4330
|
+
text : PropTypes.any,
|
4331
|
+
icon : PropTypes.any,
|
4332
|
+
onPress : PropTypes.func, //({selectedRows,context,.....})=><boolean | any>,
|
4333
|
+
filter : PropTypes.func,//la fonction permettant de filtrer les données à imprimer,
|
4334
|
+
noDataError : PropTypes.oneOfType([ //le message d'erreur lorsque aucune données n'a été selectionnée pour l'impression
|
4335
|
+
PropTypes.string,
|
4336
|
+
PropTypes.object,
|
4337
|
+
]),
|
4338
|
+
///....rest, les options similaires à celles du composant Menu où de l'AppBar en fonction des cas
|
4339
|
+
}), //les props à passer à l'action d'impression du datagrid
|
4340
|
+
]), //si l'action d'impression sera affiché dans le datagrid
|
4245
4341
|
}
|
4246
4342
|
|
4247
4343
|
const styles = StyleSheet.create({
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import Datagrid from "../Common";
|
2
2
|
import {defaultObj,defaultArray,defaultStr,defaultNumber} from "$cutils";
|
3
3
|
import View from "$ecomponents/View";
|
4
4
|
import { StyleSheet,Dimensions,Pressable } from "react-native";
|
@@ -9,7 +9,7 @@ import { chartTypes } from "../Common/Common";
|
|
9
9
|
import theme from "$theme";
|
10
10
|
import FiltersAccordionComponent from "../Accordion/Filters";
|
11
11
|
|
12
|
-
export default class DatagridDashboard extends
|
12
|
+
export default class DatagridDashboard extends Datagrid {
|
13
13
|
constructor(props){
|
14
14
|
super(props);
|
15
15
|
Object.map(this.displayTypes,(t,i)=>{
|
@@ -121,10 +121,9 @@ export default class DatagridDashboard extends TableData {
|
|
121
121
|
DatagridDashboard.displayName = "DatagridDashboardComponent";
|
122
122
|
|
123
123
|
DatagridDashboard.propTypes = {
|
124
|
-
...defaultObj(
|
124
|
+
...defaultObj(Datagrid.propTypes),
|
125
125
|
}
|
126
126
|
|
127
|
-
|
128
127
|
const styles = StyleSheet.create({
|
129
128
|
paginationContainer : {
|
130
129
|
flexDirection : 'row',
|
@@ -2,8 +2,8 @@
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
3
3
|
// license that can be found in the LICENSE file.
|
4
4
|
|
5
|
-
import Accordion
|
6
|
-
import Table
|
5
|
+
import Accordion from "./Accordion";
|
6
|
+
import Table from "./Table";
|
7
7
|
import {isDesktopMedia,isMobileMedia} from "$cplatform/dimensions";
|
8
8
|
import {isFunction,defaultVal,defaultStr} from "$cutils";
|
9
9
|
import React from "$react";
|
@@ -13,18 +13,17 @@ import useExpoUI from "$econtext/hooks";
|
|
13
13
|
|
14
14
|
const DatagridMainComponent = React.forwardRef((props,ref)=>{
|
15
15
|
const isDesk = isDesktopMedia();
|
16
|
-
const isMob =
|
16
|
+
const isMob = isMobileMedia();
|
17
17
|
const {components:{datagrid}} = useExpoUI();
|
18
|
-
const isTableData = typeof props.isTableData =='boolean'? props.isTableData : defaultStr(props.tableName,props.table).trim() || typeof props.fetchData ==='function'?true : false;
|
19
18
|
const rType = defaultStr(getRenderType()).toLowerCase().trim();
|
20
19
|
const renderType = defaultStr(rType && ['table','accordion'].includes(rType) ? rType : "",isDesk? "table":'accordion').trim().toLowerCase();
|
21
20
|
const canRenderAccordion = (isFunction(props.accordion) || (isObj(props.accordionProps) && isFunction(props.accordionProps.accordion)) || props.accordion === true);
|
22
21
|
const Component = React.useMemo(()=>{
|
23
22
|
if((renderType == 'accordion' || (renderType !=='table' && isMob)) && canRenderAccordion){
|
24
|
-
return
|
23
|
+
return Accordion;
|
25
24
|
}
|
26
|
-
return
|
27
|
-
},[
|
25
|
+
return Table;
|
26
|
+
},[renderType,canRenderAccordion,isMob]);
|
28
27
|
return <Component
|
29
28
|
{...datagrid}
|
30
29
|
{...props}
|
@@ -37,6 +36,6 @@ export default DatagridMainComponent;
|
|
37
36
|
DatagridMainComponent.displayName = "DatagridMainComponent";
|
38
37
|
|
39
38
|
DatagridMainComponent.propTypes = {
|
40
|
-
...
|
39
|
+
...Table.propTypes
|
41
40
|
}
|
42
|
-
DatagridMainComponent.LinesProgressBar = DatagridMainComponent.LineProgressBar =
|
41
|
+
DatagridMainComponent.LinesProgressBar = DatagridMainComponent.LineProgressBar = Table.LineProgressBar;
|