@fto-consult/expo-ui 7.1.7 → 7.2.1
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 +2 -2
- package/src/components/Datagrid/Accordion/Row.js +3 -0
- package/src/components/Datagrid/Common/Common.js +6 -22
- package/src/components/Filter/index.js +7 -4
- package/src/components/Form/FormData/FormDataActions.js +3 -3
- package/src/layouts/Screen/TableData.js +6 -3
- package/src/pdf/index.js +29 -10
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "7.1
|
3
|
+
"version": "7.2.1",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"main": "main",
|
6
6
|
"scripts": {
|
@@ -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.
|
74
|
+
"@fto-consult/common": "^3.72.15",
|
75
75
|
"@pchmn/expo-material3-theme": "^1.3.1",
|
76
76
|
"@react-native-async-storage/async-storage": "1.18.2",
|
77
77
|
"@react-native-community/datetimepicker": "7.2.0",
|
@@ -826,7 +826,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
826
826
|
* ou pas.
|
827
827
|
*/
|
828
828
|
renderSelectedRowsActions(sActions){
|
829
|
-
let {
|
829
|
+
let {makePhoneCallProps,canMakePhoneCall,archivable} = this.props;
|
830
830
|
const size = this.getSelectedRowsCount();
|
831
831
|
let r = [];
|
832
832
|
let endActs = [];
|
@@ -841,20 +841,6 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
841
841
|
if(isFunction(selectedR)) {
|
842
842
|
selectedR = selectedR.call(this,sArgs)
|
843
843
|
}
|
844
|
-
if(isFunction(print)){
|
845
|
-
if(isFunction(printable)){
|
846
|
-
printable = printable({context:this,tableName:defaultStr(this.props.tableName,this.props.table),props:this.props});
|
847
|
-
}
|
848
|
-
if(printable !== false){
|
849
|
-
r.push({
|
850
|
-
icon : defaultVal(this.props.printButtonIcon,'printer'),
|
851
|
-
text : defaultVal(this.props.printButtonText,this.props.printButtonLabel,'Imprimer'),
|
852
|
-
onPress : ()=>{
|
853
|
-
print({title:defaultStr(this.props.title),...defaultObj(printOptions),...sArgs});
|
854
|
-
},
|
855
|
-
})
|
856
|
-
}
|
857
|
-
}
|
858
844
|
Object.map(sActions,(o,i)=>{
|
859
845
|
if(isObj(o)){
|
860
846
|
let {onPress, ...rest} = o;
|
@@ -1790,6 +1776,10 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
1790
1776
|
defaultValue : 0,
|
1791
1777
|
type : "switch",
|
1792
1778
|
} : null,
|
1779
|
+
pdfDocumentTitle : {
|
1780
|
+
text : "Titre du document",
|
1781
|
+
multiple : true,
|
1782
|
+
},
|
1793
1783
|
...sFields,
|
1794
1784
|
},
|
1795
1785
|
actions : [{text:'Exporter',icon : "check"}],
|
@@ -1844,7 +1834,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
1844
1834
|
if(pdfDocumentTitle){
|
1845
1835
|
content.unshift(pdfDocumentTitle);
|
1846
1836
|
}
|
1847
|
-
const pdf = createPDF({content}
|
1837
|
+
const pdf = createPDF({...config,content});
|
1848
1838
|
if(isWeb()){
|
1849
1839
|
return pdf.open();
|
1850
1840
|
}
|
@@ -4006,12 +3996,6 @@ CommonDatagridComponent.propTypes = {
|
|
4006
3996
|
]),
|
4007
3997
|
/*** fonction permettant de retourner l'unique clé des éléments du tableau */
|
4008
3998
|
getRowKey : PropTypes.func,
|
4009
|
-
///la fonction utilisée pour l'impression du datagrid
|
4010
|
-
print : PropTypes.func,
|
4011
|
-
printButtonIcon : PropTypes.oneOfType([PropTypes.string,PropTypes.element]),
|
4012
|
-
printButtonLabel : PropTypes.oneOfType([PropTypes.string,PropTypes.element]),
|
4013
|
-
printButtonText : PropTypes.oneOfType([PropTypes.string,PropTypes.element]),
|
4014
|
-
printOptions: PropTypes.object,
|
4015
3999
|
/*** si le datagrid est imprimable */
|
4016
4000
|
printable : PropTypes.oneOfType([
|
4017
4001
|
PropTypes.func,
|
@@ -18,6 +18,7 @@ import { ActivityIndicator } from "react-native-paper";
|
|
18
18
|
import DialogProvider from "$ecomponents/Form/FormData/DialogProvider";
|
19
19
|
import FilterBetweenComponent from "./BetweenComponent";
|
20
20
|
|
21
|
+
export const dateTypes = ["date","time","datetime","date2time"]
|
21
22
|
|
22
23
|
const manualRunKey = "manual-run";
|
23
24
|
|
@@ -137,7 +138,9 @@ export default class Filter extends AppComponent {
|
|
137
138
|
type = defaultStr(type,this.type,this.props.type).toLowerCase();
|
138
139
|
if(type.contains('select')){
|
139
140
|
return "$in";
|
140
|
-
}
|
141
|
+
}
|
142
|
+
if(dateTypes.includes(type)) return "$eq";
|
143
|
+
if(type !== 'number' && type !== 'decimal'){
|
141
144
|
return '$regexcontains';
|
142
145
|
}
|
143
146
|
return '$eq';
|
@@ -161,16 +164,16 @@ export default class Filter extends AppComponent {
|
|
161
164
|
action = '$eq';
|
162
165
|
} else if(type.contains('select')){
|
163
166
|
actions = _inActions;
|
164
|
-
} else if(type
|
167
|
+
} else if(dateTypes.includes(type)) {
|
165
168
|
actions = {...periodActions, ...actions}
|
166
169
|
delete actions.$between;
|
167
|
-
} else if(type !== '
|
170
|
+
} else if(type !== 'number' && type !== 'decimal'){
|
168
171
|
actions = {...betweenActions,...regexActions};
|
169
172
|
isTextFilter = true;
|
170
173
|
}
|
171
174
|
if(!action){
|
172
175
|
action = this.getDefaultAction(type);
|
173
|
-
}
|
176
|
+
}
|
174
177
|
let defaultValue = defaultVal(this.props.defaultValue);
|
175
178
|
operator = defaultVal(operator,"$and");
|
176
179
|
if(actions == _inActions || type.contains("select")){
|
@@ -103,7 +103,7 @@ export default class FormDataActionComponent extends FormData {
|
|
103
103
|
}
|
104
104
|
getAppBarActionsProps(props){
|
105
105
|
props = defaultObj(props,this.props);
|
106
|
-
let {actions,save2NewAction,save2printAction,save2closeAction,saveAction,newAction} = props;
|
106
|
+
let {actions,save2NewAction,save2printAction,isPrintingForm,save2closeAction,saveAction,newAction} = props;
|
107
107
|
const sArg = {context:this};
|
108
108
|
save2NewAction = typeof save2NewAction =='function' ? save2NewAction (sArg) : save2NewAction;
|
109
109
|
save2closeAction = typeof save2closeAction ==='function'? save2closeAction(sArg) : save2closeAction;
|
@@ -113,7 +113,7 @@ export default class FormDataActionComponent extends FormData {
|
|
113
113
|
const appBarProps = this.getAppBarProps();
|
114
114
|
const data = this.getDataProp();
|
115
115
|
const isEditing = this.isDocEditing(data);
|
116
|
-
let textSave = isEditing ? "Modifier": 'Enregistrer';
|
116
|
+
let textSave = isPrintingForm ? "Imprimer" : isEditing ? "Modifier": 'Enregistrer';
|
117
117
|
const newElementLabel = defaultStr(props.newElementLabel,this.props.newElementLabel,"Nouvel Element");
|
118
118
|
if(isEditing){
|
119
119
|
const t = this.getPrimaryKeysFieldsValueText(data);
|
@@ -142,7 +142,7 @@ export default class FormDataActionComponent extends FormData {
|
|
142
142
|
save : saveAction !== false ? {
|
143
143
|
isAction : true,
|
144
144
|
text : textSave,
|
145
|
-
icon : 'check',
|
145
|
+
icon : isPrintingForm ? 'printer':'check',
|
146
146
|
title : textSave,
|
147
147
|
onPress : (a)=>{
|
148
148
|
context.clickedAction = 'save';
|
@@ -350,7 +350,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
350
350
|
saveButton : isUpdated?'Modifier':'Enregistrer',
|
351
351
|
currentData:data,
|
352
352
|
hasManyData : this.hasManyData(),
|
353
|
-
|
353
|
+
onPressToPrint : this.print.bind(this),
|
354
354
|
datas,
|
355
355
|
currentDataIndex:currentIndex,
|
356
356
|
onPressToPrevious:this.goToPreviousData.bind(this),
|
@@ -581,9 +581,12 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
581
581
|
return super.isDocEditing(data);
|
582
582
|
}
|
583
583
|
print(data){
|
584
|
-
if(!this.isPrintable()
|
584
|
+
if(!this.isPrintable()) return;
|
585
585
|
data = this.isDocEditing(data)? data : isObj(data) && this.isDocEditing(data.data)? data.data : {};
|
586
|
-
|
586
|
+
if(typeof this.props.print ==='function'){
|
587
|
+
return this.props.print.call(this,data);
|
588
|
+
}
|
589
|
+
return data;
|
587
590
|
}
|
588
591
|
isClonable(){
|
589
592
|
return !!(this.props.clonable !==false);
|
package/src/pdf/index.js
CHANGED
@@ -9,6 +9,7 @@ import session from "$session";
|
|
9
9
|
|
10
10
|
const {createPdf} = pdfMake;
|
11
11
|
pdfMake.createPdf = (docDefinition,...rest)=>{
|
12
|
+
console.log("creating pdf ",docDefinition);
|
12
13
|
try {
|
13
14
|
//@see : https://pdfmake.github.io/docs/0.1/getting-started/client-side/methods/
|
14
15
|
const pdf = createPdf(docDefinition,...rest);
|
@@ -43,14 +44,7 @@ export const print = (data,options,...rest)=>{
|
|
43
44
|
|
44
45
|
export const getFields = (config)=>{
|
45
46
|
config = Object.assign({},config);
|
46
|
-
const sFields =
|
47
|
-
pdfDocumentTitle : {
|
48
|
-
text : "Titre du document",
|
49
|
-
multiple : true,
|
50
|
-
}
|
51
|
-
},pdfFields);
|
52
|
-
delete sFields.code;
|
53
|
-
delete sFields.label;
|
47
|
+
const sFields = Object.clone(pdfFields);
|
54
48
|
if(!isDataURL(config.logo)){
|
55
49
|
delete sFields.displayLogo;
|
56
50
|
delete sFields.logoWidth;
|
@@ -80,6 +74,7 @@ export const getPrintSettings = ({multiple,sessionName,formDataProps,...rest})=>
|
|
80
74
|
onValidate : ({value,context}) =>{
|
81
75
|
if(context){
|
82
76
|
const pageBreakBeforeEachDoc = context.getField("pageBreakBeforeEachDoc");
|
77
|
+
const pageMarginAfterEachDoc = context.getField("pageMarginAfterEachDoc");
|
83
78
|
if(pageBreakBeforeEachDoc){
|
84
79
|
if(value || multiple){
|
85
80
|
pageBreakBeforeEachDoc.enable();
|
@@ -87,6 +82,13 @@ export const getPrintSettings = ({multiple,sessionName,formDataProps,...rest})=>
|
|
87
82
|
pageBreakBeforeEachDoc.disable();
|
88
83
|
}
|
89
84
|
}
|
85
|
+
if(pageMarginAfterEachDoc){
|
86
|
+
if(value || multiple){
|
87
|
+
pageMarginAfterEachDoc.enable();
|
88
|
+
} else {
|
89
|
+
pageMarginAfterEachDoc.disable();
|
90
|
+
}
|
91
|
+
}
|
90
92
|
}
|
91
93
|
}
|
92
94
|
},
|
@@ -104,12 +106,29 @@ export const getPrintSettings = ({multiple,sessionName,formDataProps,...rest})=>
|
|
104
106
|
}
|
105
107
|
return v;
|
106
108
|
}
|
107
|
-
}
|
109
|
+
},
|
110
|
+
pageMarginAfterEachDoc : {
|
111
|
+
text : "Marge après chaque document",
|
112
|
+
tooltip : 'Spécifiez le nombre de ligne à ajouter comme marge après chaque document',
|
113
|
+
defaultValue : 2,
|
114
|
+
type : "number",
|
115
|
+
getValidValue : ({context,data}) => {
|
116
|
+
if(!context || !context?.isDisabled) {
|
117
|
+
return 0;
|
118
|
+
}
|
119
|
+
const v = context?.isDisabled()?0 : context.getValue();
|
120
|
+
if(isObj(data)){
|
121
|
+
data.pageMarginAfterEachDoc = v;
|
122
|
+
}
|
123
|
+
return v;
|
124
|
+
}
|
125
|
+
},
|
108
126
|
},getFields(formDataProps.data))
|
109
127
|
return new Promise((resolve,reject)=>{
|
110
128
|
return DialogProvider.open({
|
111
129
|
title : "Options d'impression",
|
112
130
|
...formDataProps,
|
131
|
+
isPrintingForm : true,
|
113
132
|
data : config,
|
114
133
|
fields,
|
115
134
|
onSuccess : (opts)=>{
|
@@ -122,7 +141,7 @@ export const getPrintSettings = ({multiple,sessionName,formDataProps,...rest})=>
|
|
122
141
|
session.set(sessionName,sessionD);
|
123
142
|
}
|
124
143
|
DialogProvider.close();
|
125
|
-
resolve({...opts,fields});
|
144
|
+
resolve({...opts,data,fields});
|
126
145
|
},
|
127
146
|
onCancel : reject,
|
128
147
|
})
|