@fto-consult/expo-ui 8.74.2 → 8.75.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.
@@ -147,7 +147,7 @@ class DropdownComponent extends AppComponent {
147
147
  nState = defaultObj(nState);
148
148
  //this.countEee = defaultNumber(this.countEee)+1;
149
149
  if(!("selectedText" in nState)){
150
- nState.selectedText = this.getSelectedText(nState.selected,nState.selectedValuesKeys);
150
+ nState.selectedText = this.getSelectedText(nState);
151
151
  }
152
152
  const previousSelected = this.state.selected;
153
153
  const prevValueKey = this.getValueKey(previousSelected);
@@ -290,11 +290,19 @@ class DropdownComponent extends AppComponent {
290
290
  content,
291
291
  }
292
292
  }
293
- getSelectedText (selectedValues,selectedValuesKeys,valuesKeys){
293
+ /****
294
+ @param {object {
295
+ selected, la nouvelle valeur sélectionnée
296
+ selectedKeys {object}, les clés des valeurs sélectionnées
297
+
298
+ }}
299
+ */
300
+ getSelectedText (opts){
301
+ if(!isObj(opts)) return this.state.selectedText;
302
+ let selectedValues = "selected" in opts ? opts.selected : this.state.selected;
303
+ let selectedValuesKeys = isObj(opts.selectedValuesKeys) ? opts.selectedValuesKeys : isObj(this.state.selectedValuesKeys) ? this.state.selectedValuesKeys: {};
304
+ const valuesKeys = isObj(opts.valuesKeys) && Object.size(opts.valuesKeys,true)? opts.valuesKeys : isObj(this.state.valuesKeys)? this.state.valuesKeys: {};
294
305
  let counter = 0,sDText = "";
295
- selectedValuesKeys = isObj(selectedValuesKeys)? selectedValuesKeys : isObj(this.state.selectedValuesKeys) ? this.state.selectedValuesKeys: {};
296
- selectedValues = selectedValues !== undefined ? selectedValues : this.state.selected;
297
- valuesKeys = isObj(valuesKeys) && Object.size(valuesKeys,true)? valuesKeys : isObj(this.state.valuesKeys)? this.state.valuesKeys: {};
298
306
  const maxCount = MAX_SELECTED_ITEMS;
299
307
  for(let valueKey in selectedValuesKeys){
300
308
  if(isObj(valuesKeys[valueKey])){
@@ -391,7 +399,7 @@ class DropdownComponent extends AppComponent {
391
399
  data.push(item);
392
400
  keys.push(key);
393
401
  });
394
- return ({selected,selectedValuesKeys,currentSelected,selectedText:this.getSelectedText(selected,selectedValuesKeys,valuesKeys),valuesKeys,nodes,valuesKeys,data,keys,initialized:true});
402
+ return ({selected,selectedValuesKeys,currentSelected,selectedText:this.getSelectedText({selected,selectedValuesKeys,valuesKeys}),valuesKeys,nodes,valuesKeys,data,keys,initialized:true});
395
403
  }
396
404
  getDefaultValue(){
397
405
  return this.state.currentSelected;
@@ -446,14 +454,14 @@ class DropdownComponent extends AppComponent {
446
454
 
447
455
  selectAll (){
448
456
  if(!this.canHandleMultiple()) return;
449
- const newSelected = [],selectedValuesKeys={};
457
+ const selected = [],selectedValuesKeys={};
450
458
  this.state.data.map((item,_index)=>{
451
459
  const key = this.keysRefs[_index];
452
460
  if(!this.state.nodes[key]) return;
453
- newSelected.push(this.state.nodes[key].value);
461
+ selected.push(this.state.nodes[key].value);
454
462
  selectedValuesKeys[this.state.nodes[key].valueKey] = true;
455
463
  });
456
- this.updateSelected({selected:newSelected,selectedValuesKeys,selectedText:this.getSelectedText(newSelected,selectedValuesKeys)});
464
+ this.updateSelected({selected,selectedValuesKeys,selectedText:this.getSelectedText({selected,selectedValuesKeys})});
457
465
  }
458
466
  unselectAll() {
459
467
  if(!this.canHandleMultiple()) return;
@@ -664,6 +672,7 @@ class DropdownComponent extends AppComponent {
664
672
  const {items,defaultValue,selected} = nextProps;
665
673
  const isFunc = typeof nextProps.items == "function";
666
674
  if(nextProps.isLoading === true) return;
675
+ const isThirdParty = this.props.name == "thirdParty";
667
676
  if(isFunc || !React.areEquals(items,this.props.items)){
668
677
  const nState = this.prepareItems({items,defaultValue,selected});
669
678
  return this.updateSelected(nState,!isFunc);
@@ -707,7 +716,7 @@ class DropdownComponent extends AppComponent {
707
716
  this.updateSelected({
708
717
  selectedValuesKeys,
709
718
  selected:newSelected,
710
- selectedText : this.getSelectedText(newSelected,selectedValuesKeys)
719
+ selectedText : this.getSelectedText({selected:newSelected,selectedValuesKeys})
711
720
  });
712
721
  }
713
722
  isVisible(){
@@ -909,6 +918,7 @@ class DropdownComponent extends AppComponent {
909
918
  error = error || this.hasNoValidSelectedValue() || false;
910
919
  if(error && selectedText && (!helperText || !React.isValidElement(helperText,true))){
911
920
  helperText = `Ce champ admet des valeurs par défaut invalide où innexistant dans la liste des éléments à sélectionner`;
921
+ console.warn("dropdown has invalid value for items ",error,", selectedText = ",selectedText," selected from state = ",this.state.selected,", state is ",this.state,", props is ",this.props);
912
922
  }
913
923
  helperText = <HelperText disabled={disabled} error={error}>{helperText}</HelperText>
914
924
  let labelTextField = defaultVal(label,text);
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  "@fto-consult/expo-ui": {
3
- "version": "8.73.0",
3
+ "version": "8.74.2",
4
4
  "url": "https://github.com/borispipo/expo-ui#readme",
5
5
  "license": "ISC"
6
6
  },
@@ -1,66 +0,0 @@
1
- import CommonDatagrid from "./Common";
2
- import {defaultObj,extendObj,defaultStr,isNonNullString,isFunction,isPromise} from "$cutils";
3
- import PropTypes from "prop-types";
4
- import actions from "$actions";
5
- /****
6
- * la fonction fetchOptionsMutator permet éventuellemnt de faire une mutations sur les options fetchOptions avant qu'elle ne soit appliquée pour la recherche. elle
7
- * est appelée avant que la fonction parseMangoQueriesToSQL ne soit appelée, bien évidemement si la props parseMangoQueriesToSQL est active pour le datagrid
8
- * la fonction beforeFetchData est appelée immédiatement avant l'execution de la requête fetch et après que la fonction parseMangoQueriestoSQL soit appelée
9
- */
10
- export default class CommonTableDatagrid extends CommonDatagrid{
11
- constructor(props){
12
- super(props);
13
- let {
14
- tableName,
15
- table,
16
- dataSource,
17
- } = props;
18
- dataSource = CommonDatagrid.getDataSource({...props,dataSource,context:this});
19
- tableName = defaultStr(tableName,table).toUpperCase();
20
- if(tableName){
21
- Object.defineProperties(this,{
22
- tableName : {value:tableName,override:false,writable:false}
23
- })
24
- }
25
- }
26
-
27
- /*** lorsque la données est modifiée */
28
- onUpsertData =(arg) =>{
29
- return this.refresh({force:true,renderProgressBar:false});
30
- }
31
-
32
- componentDidMount(){
33
- super.componentDidMount();
34
- extendObj(this._events,{
35
- onUpsertData : this.onUpsertData.bind(this),
36
- });
37
- if(isNonNullString(this.tableName)){
38
- APP.on(actions.upsert(this.tableName),this._events.onUpsertData)
39
- APP.on(actions.remove(this.tableName),this._events.onUpsertData)
40
- }
41
- this.fetchData({force:true});
42
- }
43
-
44
- componentWillUnmount(){
45
- super.componentWillUnmount();
46
- if(isNonNullString(this.tableName)){
47
- APP.off(actions.upsert(this.tableName),this._events.onUpsertData);
48
- APP.off(actions.remove(this.tableName),this._events.onUpsertData);
49
- }
50
- this.clearEvents();
51
- this.setSelectedRows();
52
- }
53
- isTableData(){
54
- return true;
55
- }
56
- }
57
-
58
- CommonTableDatagrid.propTypes = {
59
- ...CommonDatagrid.propTypes,
60
- data : PropTypes.oneOfType([
61
- PropTypes.func,
62
- PropTypes.string,
63
- PropTypes.objectOf(PropTypes.any),
64
- PropTypes.arrayOf(PropTypes.any)
65
- ])
66
- }
@@ -1,9 +0,0 @@
1
- import Common from "./Common";
2
- import TableDatagrid from "./TableData";
3
-
4
- export default function FactoryComponent(Factory) {
5
- if(typeof Factory ==='string' && Factory.toLowerCase().trim() === 'table'){
6
- return TableDatagrid;
7
- }
8
- return Common;
9
- }
@@ -1,12 +0,0 @@
1
- import CommonDatagrid from "./Common/Common";
2
- import TableDatagrid from "./Common/TableData"
3
- import {defaultStr} from "$cutils";
4
-
5
-
6
- export default function Factory(type) {
7
- type = defaultStr(type).toLowerCase();
8
- if(type.contains('table')){
9
- TableDatagrid;
10
- }
11
- return CommonDatagrid;
12
- }