@fto-consult/expo-ui 2.9.6 → 2.10.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/package.json +2 -2
- package/src/App.js +82 -32
- package/src/components/Datagrid/Accordion/index.js +1 -1
- package/src/components/Datagrid/Common/Common.js +120 -23
- package/src/components/Datagrid/Common/ProgressBar.js +58 -0
- package/src/components/Datagrid/Common/TableData.js +15 -70
- package/src/components/Datagrid/IndexComponent.js +45 -0
- package/src/components/Datagrid/RenderTypes/index.web.js +5 -2
- package/src/components/Datagrid/Table/index.js +11 -12
- package/src/components/Datagrid/index.js +4 -40
- package/src/components/Menu/Item.js +2 -1
- package/src/layouts/Fab/index.js +0 -1
- package/src/components/Datagrid/Table/Datatable.js +0 -232
- package/src/components/Datagrid/Table/renderTable.js +0 -664
|
@@ -1,664 +0,0 @@
|
|
|
1
|
-
require("./datagrid.css");
|
|
2
|
-
let Filter = require("$ecomponents/Filter");
|
|
3
|
-
let DatagridActions = require("$wcomponents/Datagrid/DatagridActions");
|
|
4
|
-
let Tooltip = require("$ecomponents/Tooltip")
|
|
5
|
-
import {FooterItem as Footer} from "./Footer";
|
|
6
|
-
let ExportTable = require("$export-table")
|
|
7
|
-
let RenderType = require("./RenderType");
|
|
8
|
-
let LocalFilter = require("./LocalFilter")
|
|
9
|
-
let DBSelector = require("$database/dataFileManager/dbSelector");
|
|
10
|
-
import {isMobileOrTabletMedia} from "$cplatform/dimensions";
|
|
11
|
-
const {
|
|
12
|
-
Checkbox,
|
|
13
|
-
DataTable,
|
|
14
|
-
TableHeader,
|
|
15
|
-
TableBody,
|
|
16
|
-
TableRow,
|
|
17
|
-
Card,
|
|
18
|
-
TableColumn
|
|
19
|
-
} = require("$ui");
|
|
20
|
-
let DatagridTableRow= require("./renderTable/TableRow")
|
|
21
|
-
let Button= require("$ecomponents/Button")
|
|
22
|
-
let Icon = require("$ecomponents/Icon")
|
|
23
|
-
let {DocumentMenu,CheckboxListItem} = require("$ecomponents/Menu")
|
|
24
|
-
/**** tous les évenèments du datagrid sont définies dans la props events qui represente un objet
|
|
25
|
-
contenant les différents évènements
|
|
26
|
-
qu'ils s'agisse des évènements de ligne, de colonne, ....etc
|
|
27
|
-
*/
|
|
28
|
-
let DGrid = require("$ccomponents/Datagrid")
|
|
29
|
-
class DGridTableRendering extends DGrid {
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(props);
|
|
32
|
-
APP.extend(this._events,{
|
|
33
|
-
RESIZE_PAGE:this.refreshAfterMount.bind(this),
|
|
34
|
-
scroll : this.positioneScrollbar.bind(this),
|
|
35
|
-
})
|
|
36
|
-
APP.on("RESIZE_PAGE",this._events.RESIZE_PAGE)
|
|
37
|
-
this._pagination = this.initPagination(this.props.pagination);
|
|
38
|
-
window.addEventListener("resize",this._events.scroll)
|
|
39
|
-
}
|
|
40
|
-
onDrawerVisibleChanged(){
|
|
41
|
-
setTimeout(()=>{
|
|
42
|
-
this.positioneScrollbar();
|
|
43
|
-
},400);
|
|
44
|
-
}
|
|
45
|
-
isDatagrid(){
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
onScrollDom(e){
|
|
49
|
-
let pDom = document.getElementById(this.datagridDomId+"-scrollable-content-wrapper")
|
|
50
|
-
let dom = document.getElementById(this.datagridDomId)
|
|
51
|
-
if(isDOMElement(pDom) && isDOMElement(dom)){
|
|
52
|
-
let parent = dom.closest(".datagrid.datagrid-tbl");
|
|
53
|
-
if(isDOMElement(parent)){
|
|
54
|
-
parent.scrollLeft = pDom.scrollLeft;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
componentDidMount(){
|
|
59
|
-
super.componentDidMount();
|
|
60
|
-
}
|
|
61
|
-
positioneScrollbar(){
|
|
62
|
-
let dom = document.getElementById(this.datagridDomId)
|
|
63
|
-
let sDom = document.getElementById(this.datagridDomId+"-scrollable-content")
|
|
64
|
-
let pDom = document.getElementById(this.datagridDomId+"-scrollable-content-wrapper")
|
|
65
|
-
if(isDOMElement(dom) && isDOMElement(sDom) && isDOMElement(pDom)){
|
|
66
|
-
pDom.style.height = sDom.style.height = "0px";
|
|
67
|
-
sDom.style.width = "0px";
|
|
68
|
-
let parent = dom.closest(".datagrid.datagrid-tbl");
|
|
69
|
-
if(isDOMElement(parent)){
|
|
70
|
-
let pW = parent.clientWidth;
|
|
71
|
-
let sW = parent.scrollWidth;
|
|
72
|
-
if(parent.hasScrollbar('horizontal') && isDecimal(sW) && isDecimal(pW)){
|
|
73
|
-
sDom.style.width= sW+"px";
|
|
74
|
-
pDom.style.width = pW+"px";
|
|
75
|
-
pDom.style.height = sDom.style.height = "9px";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
componentDidUpdate(){
|
|
81
|
-
super.componentDidUpdate();
|
|
82
|
-
this.__canR = false;
|
|
83
|
-
APP.resizePage();
|
|
84
|
-
if(this.exportDataInstance && typeof this.exportDataInstance.createExportInstance == 'function'){
|
|
85
|
-
this.exportDataInstance.createExportInstance(true);
|
|
86
|
-
}
|
|
87
|
-
this.__canR = true;
|
|
88
|
-
this.positioneScrollbar();
|
|
89
|
-
}
|
|
90
|
-
refreshAfterMount(){
|
|
91
|
-
if(this._isMounted() && this.__canR) this.refresh(false);
|
|
92
|
-
this.positioneScrollbar();
|
|
93
|
-
}
|
|
94
|
-
canExportAskDisplayMainContent(){
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
componentWillUnmount(){
|
|
98
|
-
super.componentWillUnmount();
|
|
99
|
-
APP.off("RESIZE_PAGE",this._events.RESIZE_PAGE);
|
|
100
|
-
window.removeEventListener("resize",this._events.scroll);
|
|
101
|
-
this.clearEvents();
|
|
102
|
-
}
|
|
103
|
-
canPaginateData(){
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/*** retourne le rendu d'une cellule de la ligne du tableau
|
|
108
|
-
@parm, rowData, object, la ligne à afficher le rendu du contenu
|
|
109
|
-
@param , rowInidex, l'indice de la ligne dont on affiche le rendu en cours
|
|
110
|
-
@param, columnDef, l'objet colonne dont on veut afficher le rendu pour la ligne
|
|
111
|
-
@param, columnField, le nom du champ correspondant à la cellule,
|
|
112
|
-
//l'objet data peut être un tableau de type string si et seulement si, le tableau dispose d'une seule colonnne
|
|
113
|
-
//le formatteur de cellule, peut être :
|
|
114
|
-
soit une fonction, soit une promesse.
|
|
115
|
-
qu'il s'agisse d'une fonction où d'une promesse, la valeur retournée est un composant react
|
|
116
|
-
quant il s'agit d'une fonction, celle-ci se doit de retourner toujours un composant react
|
|
117
|
-
différent du td d'un table et ne doit pas être un TableColumn de md
|
|
118
|
-
*/
|
|
119
|
-
renderRowCell (arg){
|
|
120
|
-
let {columnDef} = arg;
|
|
121
|
-
let {render,extra,key,className} = super.renderRowCell(arg);
|
|
122
|
-
if(render===null) return null;
|
|
123
|
-
return <TableColumn key={key} className = {classNames(extra.className,columnDef.visible?"":'hidden',"datagrid-cell datagrid-row-cell selectable-content")}>
|
|
124
|
-
<div className={classNames("datagrid-rendered-cell",className)}>{render}</div>
|
|
125
|
-
</TableColumn>
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/*** chaque colonnne de la datagrid est un objet de type :
|
|
130
|
-
{
|
|
131
|
-
field : le nom du champ,
|
|
132
|
-
text || title : le texte à afficher sur la colonne
|
|
133
|
-
...props : la liste des props à passer au composant TableColumn de react-md
|
|
134
|
-
}
|
|
135
|
-
//la variable header du datagrid prend tous les props à passer au composant TableHeader de react-md
|
|
136
|
-
*/
|
|
137
|
-
render (){
|
|
138
|
-
let {
|
|
139
|
-
printOptions,
|
|
140
|
-
rowKey,
|
|
141
|
-
printButton,
|
|
142
|
-
printText,
|
|
143
|
-
printIcon,
|
|
144
|
-
printable,
|
|
145
|
-
print,
|
|
146
|
-
archive,
|
|
147
|
-
archivable,
|
|
148
|
-
progressbar,
|
|
149
|
-
header,
|
|
150
|
-
getRowKey,
|
|
151
|
-
body,
|
|
152
|
-
accordionProps,
|
|
153
|
-
footer,
|
|
154
|
-
row,
|
|
155
|
-
cell,
|
|
156
|
-
table,
|
|
157
|
-
filters,
|
|
158
|
-
filter,
|
|
159
|
-
data,
|
|
160
|
-
tableName,
|
|
161
|
-
dbName,
|
|
162
|
-
selectable,
|
|
163
|
-
selectableMultiple, //si plusieurs lignes peuvent être sélectionnées
|
|
164
|
-
columns,
|
|
165
|
-
fetchData,
|
|
166
|
-
fetchDataOpts, //les options supplémentaires à passer à la fonction fetchData, ces options doivent correspondre à ceux supportées par les requêtes mongo query du plugin pouchdb-find
|
|
167
|
-
/*** Les actions de boutons de la barre d'outil */
|
|
168
|
-
actions,
|
|
169
|
-
selectedRowsActions,
|
|
170
|
-
showPagination,
|
|
171
|
-
pagin,
|
|
172
|
-
showPaginationOnTop,
|
|
173
|
-
sortable,
|
|
174
|
-
exportable,
|
|
175
|
-
filterOrOperator,
|
|
176
|
-
filterAndOperator,
|
|
177
|
-
onRowSelected, //lorsqu'une ligne est sélectionnée
|
|
178
|
-
onRowsSelected, // lorsque toutes les lignes sont sélectionnées
|
|
179
|
-
onRowDeselected, //lorsqu'une ligne est désélectionnée
|
|
180
|
-
onRowsDeselected, //lorsque toutes les lignes sont désélectionnées
|
|
181
|
-
progressBar,
|
|
182
|
-
onRowDoubleClick,
|
|
183
|
-
onRowClick,
|
|
184
|
-
toggleFilters,
|
|
185
|
-
sessionName,
|
|
186
|
-
onMount,
|
|
187
|
-
onUnmount,
|
|
188
|
-
onFetchData,
|
|
189
|
-
dbSelector,
|
|
190
|
-
dbSelectorProps,
|
|
191
|
-
queryLimit,
|
|
192
|
-
accordion, //pour le rendu du header en accordion
|
|
193
|
-
...datagridProps
|
|
194
|
-
} = defaultObj(this.getComponentProps({...this.props}))
|
|
195
|
-
let showDBSelector = false;
|
|
196
|
-
if(dbSelector === true){
|
|
197
|
-
showDBSelector = true;
|
|
198
|
-
}
|
|
199
|
-
dbSelectorProps = defaultObj(dbSelectorProps);
|
|
200
|
-
exportable = defaultBool(exportable,true);
|
|
201
|
-
sortable = defaultVal(sortable,true);
|
|
202
|
-
let isMobile = isMobileOrTabletMedia();
|
|
203
|
-
const rowsPerPageLabel = ''
|
|
204
|
-
datagridProps = defaultObj(datagridProps);
|
|
205
|
-
let exportTableProps = this.getExportableProps();
|
|
206
|
-
delete datagridProps.exportTableProps;
|
|
207
|
-
delete datagridProps.showFilters;
|
|
208
|
-
delete datagridProps.showFooter;
|
|
209
|
-
header = defaultObj(header);
|
|
210
|
-
body = defaultObj(body);
|
|
211
|
-
row = defaultObj(row);
|
|
212
|
-
let _headerProps = {...header, className :classNames(header.className,"datagrid-header")};
|
|
213
|
-
let _bodyProps = {...body,className : classNames(body.className,"datagrid-body")};
|
|
214
|
-
_bodyProps.id = isNonNullString(_bodyProps.id)? _bodyProps.id : uniqid("body-id");
|
|
215
|
-
this._bodyDomId = _bodyProps.id;
|
|
216
|
-
datagridProps.className = classNames("datagrid datagrid-render-table datagrid-tbl",datagridProps.className);
|
|
217
|
-
selectable = defaultVal(selectable,true);
|
|
218
|
-
selectableMultiple = defaultBool(selectableMultiple,true);
|
|
219
|
-
datagridProps.selectableRows = false;
|
|
220
|
-
datagridProps.fixedHeader = false//defaultBool(datagridProps.fixedHeader,false);
|
|
221
|
-
datagridProps.fixedFooter = defaultBool(datagridProps.fixedFooter,true);
|
|
222
|
-
|
|
223
|
-
pagin = defaultVal(pagin,true)
|
|
224
|
-
showPagination = defaultVal(showPagination,true);
|
|
225
|
-
showPaginationOnTop = defaultVal(showPaginationOnTop,true);
|
|
226
|
-
|
|
227
|
-
let colSpan = (Object.size(this.state.columns)+((selectable?1:0)))
|
|
228
|
-
this.visibleColsMenu = [];//la liste des colonnes visible pour le menu
|
|
229
|
-
let pPos = showPaginationOnTop?'top':'bottom';
|
|
230
|
-
let pagination = this._pagination;
|
|
231
|
-
pagination.rowsPerPageItems = defaultArray(pagination.rowsPerPageItems,this.getDefaultPaginationRowsPerPageItems())
|
|
232
|
-
pagination.className = classNames(pagination.className,"pagination"," pagination-pos-"+pPos,pPos)
|
|
233
|
-
let countPages = this.countPages.call(this);
|
|
234
|
-
let paginationLabel = defaultFunc(pagination.label,({start, last, total}) => `${start}-${last} / ${total}`);
|
|
235
|
-
let pagLast = Math.min(pagination.rows, pagination.start + pagination.limit);
|
|
236
|
-
|
|
237
|
-
paginationLabel = paginationLabel({
|
|
238
|
-
start:pagination.start + 1,
|
|
239
|
-
last:pagLast,
|
|
240
|
-
total:pagination.rows,pages:countPages
|
|
241
|
-
})
|
|
242
|
-
let headerFilters = [];
|
|
243
|
-
filters = defaultVal(filters,true);
|
|
244
|
-
if(toggleFilters === false){
|
|
245
|
-
filters = false;
|
|
246
|
-
}
|
|
247
|
-
let {showFilters,showFooter} = this.state;
|
|
248
|
-
let isAllRowsSelected = this.isAllRowsSelected();
|
|
249
|
-
let _progressBar = this.state.progressBar;
|
|
250
|
-
datagridProps.id = defaultStr(datagridProps.id, this.datagridDomId,uniqid("datagrid-id"));
|
|
251
|
-
this.datagridDomId = datagridProps.id;
|
|
252
|
-
let rowCounterIndex = 0;
|
|
253
|
-
let datagridBody = undefined;
|
|
254
|
-
if(isArray(this.state.data) && this.state.data.length){
|
|
255
|
-
datagridBody = []
|
|
256
|
-
pagination.limit = defaultDecimal(pagination.limit);
|
|
257
|
-
let pLength = this.state.data.length;
|
|
258
|
-
for(let rowIndex = 0; rowIndex < pLength; rowIndex ++){
|
|
259
|
-
let row = this.state.data[rowIndex];
|
|
260
|
-
if(!isObj(row)) continue;
|
|
261
|
-
rowCounterIndex++;
|
|
262
|
-
datagridBody.push(<DatagridTableRow
|
|
263
|
-
key={this.getRowKey(row,rowIndex)}
|
|
264
|
-
row = {row}
|
|
265
|
-
cell = {cell}
|
|
266
|
-
rowCounterIndex = {rowCounterIndex}
|
|
267
|
-
context = {this}
|
|
268
|
-
selectable = {this.props.selectable}
|
|
269
|
-
rowIndex = {rowIndex}
|
|
270
|
-
filterArgs = {this.getActionsArgs()}
|
|
271
|
-
/>)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
let datagridHeaderContent = [null]
|
|
275
|
-
Object.mapToArray(this.state.columns,(header,headerIndex) => {
|
|
276
|
-
let {
|
|
277
|
-
field,
|
|
278
|
-
render,
|
|
279
|
-
readOnly,
|
|
280
|
-
disabled,
|
|
281
|
-
visible,
|
|
282
|
-
defaultValue,
|
|
283
|
-
className,
|
|
284
|
-
id,
|
|
285
|
-
colIndex,
|
|
286
|
-
key,
|
|
287
|
-
...restCol
|
|
288
|
-
} = header;
|
|
289
|
-
restCol = defaultObj(restCol);
|
|
290
|
-
let colFilter = defaultVal(restCol.filter,true);
|
|
291
|
-
delete restCol.filter;
|
|
292
|
-
let colProps = {id,key}
|
|
293
|
-
colProps.key = isNonNullString(key)?key : (header.field||("datagrid-column-header-"+headerIndex))
|
|
294
|
-
colProps.className = classNames(visible?'':'hidden',className,"datagrid-cell datagrid-column datagrid-column-cell");
|
|
295
|
-
this.visibleColsMenu.push(
|
|
296
|
-
<CheckboxListItem
|
|
297
|
-
name = {uniqid("checkbox-name-l")}
|
|
298
|
-
id = {uniqid("checked-l-boxed")}
|
|
299
|
-
key={header.field}
|
|
300
|
-
onClick = {()=>{this.toggleColumnVisibility(header.field)}}
|
|
301
|
-
primaryText = {header.text||header.title||header.field}
|
|
302
|
-
checked = {visible}
|
|
303
|
-
uncheckedIcon = {null}
|
|
304
|
-
/>
|
|
305
|
-
);
|
|
306
|
-
let headerFilter = null;
|
|
307
|
-
restCol.field = header.field;
|
|
308
|
-
restCol.label = defaultStr(header.text,header.label) ;
|
|
309
|
-
restCol.orOperator = defaultBool(restCol.orOperator,filterOrOperator,true);
|
|
310
|
-
restCol.andOperator = defaultBool(restCol.andOperator,filterAndOperator,true)
|
|
311
|
-
delete restCol.sortable;
|
|
312
|
-
let hasFilterClassName = "has-not-filter";
|
|
313
|
-
if(colFilter && filters !== false){
|
|
314
|
-
hasFilterClassName = "has-filter";
|
|
315
|
-
this.filters[header.field] = {...defaultObj(this.filters[header.field])}
|
|
316
|
-
headerFilter = <Filter
|
|
317
|
-
{...restCol}
|
|
318
|
-
searchIconTooltip = 'Filtre'
|
|
319
|
-
searchIcon = 'filter_list'
|
|
320
|
-
name = {header.field}
|
|
321
|
-
defaultValue = {defaultVal(this.filters[header.field].originalValue,this.filters[header.field].originValue)}
|
|
322
|
-
key = {header.field}
|
|
323
|
-
onClearFilter = {this.onClearFilter.bind(this)}
|
|
324
|
-
onChange = {this.onFilterChange.bind(this)}
|
|
325
|
-
operator = {this.filters[header.field].operator}
|
|
326
|
-
action = {defaultStr(this.filters[header.field].originAction,this.filters[header.field].action)}
|
|
327
|
-
/>
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
headerFilters.push(
|
|
332
|
-
<TableColumn
|
|
333
|
-
key = {header.field}
|
|
334
|
-
className={classNames("tableexport-ignore",hasFilterClassName,'datagrid-column',visible?'':'hidden',"datagrid-filter datagrid-filter-column filter-column-"+header.field,'column-'+header.field)}
|
|
335
|
-
>
|
|
336
|
-
{headerFilter}
|
|
337
|
-
</TableColumn>
|
|
338
|
-
)
|
|
339
|
-
colProps.sorted = undefined;
|
|
340
|
-
colProps.sortIcon = <Icon name={"arrow_upward"} className="tableexport-ignore"></Icon>
|
|
341
|
-
let canSort = sortable && header.sortable !== false
|
|
342
|
-
if(canSort){
|
|
343
|
-
colProps.role = "button";
|
|
344
|
-
if(this.state.sort.column ==field){
|
|
345
|
-
colProps.sorted = this.state.sort.dir == 'asc'? true : false;
|
|
346
|
-
}
|
|
347
|
-
colProps.onClick = (event) =>{React.stopEventPropagation(event);this.sort(header.field,null,header);}
|
|
348
|
-
}
|
|
349
|
-
datagridHeaderContent.push(
|
|
350
|
-
<TableColumn
|
|
351
|
-
{ ...colProps}
|
|
352
|
-
className = {classNames(colProps.className,canSort?"datagrid-column-header-sortable cursor-pointer":"datagrid-column-header-not-sortable cursor-not-allowed")}
|
|
353
|
-
>
|
|
354
|
-
<span className={("no-padding no-margin")} onMouseOver={()=>{}} onMouseLeave={()=>{}}>
|
|
355
|
-
{header.text||header.title||header.field}
|
|
356
|
-
</span>
|
|
357
|
-
</TableColumn>
|
|
358
|
-
)
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
let datagridHeader = <React.Fragment>
|
|
362
|
-
<TableRow className="datagrid-table-header-row">
|
|
363
|
-
{datagridHeaderContent}
|
|
364
|
-
</TableRow>
|
|
365
|
-
{
|
|
366
|
-
showFilters && filters !== false && (
|
|
367
|
-
<TableRow className="filters-row datagrid-filters-row tableexport-ignore">
|
|
368
|
-
{selectable?
|
|
369
|
-
<TableColumn className="header-filter-wrap select-rows tableexport-ignore"/>
|
|
370
|
-
:null}
|
|
371
|
-
{headerFilters}
|
|
372
|
-
</TableRow>
|
|
373
|
-
)
|
|
374
|
-
}
|
|
375
|
-
</React.Fragment>
|
|
376
|
-
let selectAllRowsToggleTitle = isAllRowsSelected?"Tout Déselec":"Tout Select"
|
|
377
|
-
let restItems = [];
|
|
378
|
-
let max = this.getMaxSelectableRows();
|
|
379
|
-
if(selectableMultiple && max && defaultBool(this.props.selectableMultiple,true)){
|
|
380
|
-
max = max.formatNumber();
|
|
381
|
-
restItems = [
|
|
382
|
-
{
|
|
383
|
-
primaryText : "Sélect "+max,
|
|
384
|
-
leftIcon : <Icon name="select-all"></Icon>,
|
|
385
|
-
onClick : (x,event)=>{
|
|
386
|
-
this.__isAllRowsSelected = false;
|
|
387
|
-
this.handleAllRowsToggle();
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
primaryText : "Tout désélec",
|
|
392
|
-
onClick : (x,event)=>{
|
|
393
|
-
this.__isAllRowsSelected = true;
|
|
394
|
-
this.handleAllRowsToggle();
|
|
395
|
-
},
|
|
396
|
-
leftIcon : <Icon name="select"></Icon>
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
}
|
|
400
|
-
if(selectable){
|
|
401
|
-
datagridHeaderContent[0] = <TableColumn key="toggle-rows-selection" className="tableexport-ignore toggle-rows-selection datagrid-column">
|
|
402
|
-
<Tooltip Component = {Checkbox}
|
|
403
|
-
aria-label = {selectAllRowsToggleTitle}
|
|
404
|
-
name = {uniqid("checkbox-name")}
|
|
405
|
-
id = {uniqid("checked-boxed")}
|
|
406
|
-
title = {selectAllRowsToggleTitle}
|
|
407
|
-
checkedIcon = {<Icon name="check_box"></Icon>}
|
|
408
|
-
checked = {isAllRowsSelected}
|
|
409
|
-
uncheckedIcon = {<Icon name="check_box_outline_blank"></Icon>}
|
|
410
|
-
onChange = {(x,event)=>{
|
|
411
|
-
this.handleAllRowsToggle();
|
|
412
|
-
}}
|
|
413
|
-
/>
|
|
414
|
-
</TableColumn>
|
|
415
|
-
}
|
|
416
|
-
let Pagination = null;
|
|
417
|
-
this.searchPassIconId = this._datagridId+"-options-icon"
|
|
418
|
-
if(showPagination) Pagination = <div className="pagination-table-wrapper"><table className={classNames("pagination-wrapper no-padding no-marging datagrid-toolbar",pPos)}>
|
|
419
|
-
<tbody className="toolbar pagination-toolbar">
|
|
420
|
-
<tr>
|
|
421
|
-
{!isMobile && (
|
|
422
|
-
<React.Fragment>
|
|
423
|
-
<td className="refresh-td">
|
|
424
|
-
<Button
|
|
425
|
-
raised
|
|
426
|
-
iconEl = {<Icon name="refresh"/>}
|
|
427
|
-
onClick = {this.refresh.bind(this)}
|
|
428
|
-
>
|
|
429
|
-
Rafraichir
|
|
430
|
-
</Button>
|
|
431
|
-
</td>
|
|
432
|
-
{filters !== false && (<td className="">
|
|
433
|
-
<Button
|
|
434
|
-
raised
|
|
435
|
-
className={"toggle-filters-visibility"}
|
|
436
|
-
onClick = {()=>{showFilters?this.hideFilters():this.showFilters()} }
|
|
437
|
-
iconEl = {
|
|
438
|
-
<Icon name ={showFilters?'visibility_off':'visibility'}></Icon>}
|
|
439
|
-
>
|
|
440
|
-
{showFilters?'Masquer/Filtres':'Afficher/Filtres'}
|
|
441
|
-
</Button>
|
|
442
|
-
</td>)}
|
|
443
|
-
<td className="">
|
|
444
|
-
<Button
|
|
445
|
-
raised
|
|
446
|
-
className={"toggle-footer-visibility"}
|
|
447
|
-
onClick = {()=>{showFooter?this.hideFooter():this.showFooter()} }
|
|
448
|
-
iconEl = {
|
|
449
|
-
<Icon name ={showFooter?'view_column':'view_module'}></Icon>}
|
|
450
|
-
>
|
|
451
|
-
{showFooter?'Masquer/Pied de page':'Afficher/Pied de page'}
|
|
452
|
-
</Button>
|
|
453
|
-
</td>
|
|
454
|
-
{selectableMultiple && (
|
|
455
|
-
<td>
|
|
456
|
-
{restItems.map((item,index)=>{
|
|
457
|
-
return <Button
|
|
458
|
-
raised
|
|
459
|
-
key = {index}
|
|
460
|
-
iconEl = {item.leftIcon}
|
|
461
|
-
onClick = {item.onClick}
|
|
462
|
-
>
|
|
463
|
-
{item.primaryText}
|
|
464
|
-
</Button>
|
|
465
|
-
})}
|
|
466
|
-
</td>
|
|
467
|
-
)}
|
|
468
|
-
</React.Fragment>
|
|
469
|
-
)}
|
|
470
|
-
{exportable && (
|
|
471
|
-
<td className={classNames('datagrid-export-buttons')}>
|
|
472
|
-
<ExportTable
|
|
473
|
-
{...exportTableProps}
|
|
474
|
-
selector = {this.datagridDomId}
|
|
475
|
-
ref = {(el)=>{
|
|
476
|
-
if(el){
|
|
477
|
-
this.exportDataInstance = el;
|
|
478
|
-
}
|
|
479
|
-
}}
|
|
480
|
-
getAllData = {()=>{
|
|
481
|
-
return this.INITIAL_STATE.data;
|
|
482
|
-
}}
|
|
483
|
-
/>
|
|
484
|
-
</td>
|
|
485
|
-
)
|
|
486
|
-
}
|
|
487
|
-
<td className={"toggle-column-visibility"}>
|
|
488
|
-
<DocumentMenu id={uniqid("doc-menu-datagrid")} text={<Icon title={isMobile?"Actions":"Colonnes"} name={isMobile?"menu":'view_column'}></Icon>} menuItems={
|
|
489
|
-
isMobile ? [
|
|
490
|
-
isMobile?
|
|
491
|
-
{
|
|
492
|
-
primaryText : 'Rafraichir',
|
|
493
|
-
leftIcon : <Icon name="refresh"></Icon>,
|
|
494
|
-
onClick : this.refresh.bind(this)
|
|
495
|
-
} : null,
|
|
496
|
-
{
|
|
497
|
-
primaryText : 'colonnes',
|
|
498
|
-
leftIcon : <Icon name="view_column"></Icon>,
|
|
499
|
-
nestedItems : this.visibleColsMenu
|
|
500
|
-
},
|
|
501
|
-
isMobile && filters !== false?{
|
|
502
|
-
className:"toggle-filters-visibility",
|
|
503
|
-
onClick : ()=>{showFilters?this.hideFilters():this.showFilters()}
|
|
504
|
-
,leftIcon : <Icon name={showFilters?'visibility_off':'visibility'}></Icon>
|
|
505
|
-
,primaryText : (showFilters?'Masquer/Filtres':'Afficher/Filtres')
|
|
506
|
-
} : null,
|
|
507
|
-
isMobile?{
|
|
508
|
-
className:"toggle-footer-visibility",
|
|
509
|
-
onClick : ()=>{showFooter?this.hideFooter():this.showFooter()}
|
|
510
|
-
,leftIcon : <Icon name={showFooter?'view_column':'view_module'}></Icon>
|
|
511
|
-
,primaryText : (showFooter?'Masquer/Pied de page':'Afficher/Pied de page')
|
|
512
|
-
} : null,
|
|
513
|
-
...(isMobile && selectableMultiple ? restItems : [])
|
|
514
|
-
] : this.visibleColsMenu
|
|
515
|
-
} />
|
|
516
|
-
</td>
|
|
517
|
-
{pagin && (
|
|
518
|
-
<React.Fragment>
|
|
519
|
-
<td className={classNames('pagination-item-td')}>
|
|
520
|
-
<span className="pagination-label">
|
|
521
|
-
{rowsPerPageLabel}
|
|
522
|
-
</span>
|
|
523
|
-
</td>
|
|
524
|
-
<td className="pagination-item-td">
|
|
525
|
-
<select
|
|
526
|
-
id={uniqid("pagination-select-field")}
|
|
527
|
-
className={'pagination-select-field md-select-field--pagination pagination-select-field'}
|
|
528
|
-
onChange={this._setRowsPerPage.bind(this)}
|
|
529
|
-
defaultValue = {pagination.limit}
|
|
530
|
-
>
|
|
531
|
-
{
|
|
532
|
-
Object.map(pagination.rowsPerPageItems,(val,i)=>{
|
|
533
|
-
return <option defaultValue={val == pagination.limit ? 'selected' : undefined} key={i}>{val}</option>
|
|
534
|
-
})
|
|
535
|
-
}
|
|
536
|
-
</select>
|
|
537
|
-
</td>
|
|
538
|
-
<td className="pagination-item-td">
|
|
539
|
-
<Button
|
|
540
|
-
flat
|
|
541
|
-
id={uniqid("go-to-first-page-id")}
|
|
542
|
-
onClick={this._goToFirstPage.bind(this)}
|
|
543
|
-
disabled={countPages <=0 || pagination.page == 1}
|
|
544
|
-
iconEl={<Icon name="first_page"></Icon>}
|
|
545
|
-
/>
|
|
546
|
-
</td>
|
|
547
|
-
<td className="pagination-item-td">
|
|
548
|
-
<Button
|
|
549
|
-
id={uniqid("decrement-id")}
|
|
550
|
-
onClick={this._decrement.bind(this)}
|
|
551
|
-
disabled={pagination.start === 0}
|
|
552
|
-
iconEl={<Icon name="keyboard_arrow_left"></Icon>}
|
|
553
|
-
/>
|
|
554
|
-
</td>
|
|
555
|
-
<td className="pagination-item-td">
|
|
556
|
-
{this.renderQueryLimit(<span className="pagination-label">{paginationLabel}</span>)}
|
|
557
|
-
</td>
|
|
558
|
-
<td className="pagination-td">
|
|
559
|
-
<Button
|
|
560
|
-
flat
|
|
561
|
-
id={uniqid('increment-id')}
|
|
562
|
-
onClick={this._increment.bind(this)}
|
|
563
|
-
disabled={(pagination.start + pagination.limit) >= pagination.rows}
|
|
564
|
-
iconEl={<Icon name="keyboard_arrow_right"></Icon>}
|
|
565
|
-
/>
|
|
566
|
-
</td>
|
|
567
|
-
<td className="pagination-item-td">
|
|
568
|
-
<Button
|
|
569
|
-
flat
|
|
570
|
-
id={uniqid("go-to-last-page-id")}
|
|
571
|
-
onClick={this._goToLastPage.bind(this)}
|
|
572
|
-
disabled={countPages <=1 || pagination.page == countPages}
|
|
573
|
-
iconEl={<Icon name="last_page"></Icon>}
|
|
574
|
-
/>
|
|
575
|
-
</td>
|
|
576
|
-
</React.Fragment>
|
|
577
|
-
)}
|
|
578
|
-
{filters !== false && <td className="datagrid-local-filter-wrapper" ><LocalFilter title = {this.props.title} fields ={this.state.columns} onChange={this.onLocalFiltersChange.bind(this)}/></td>}
|
|
579
|
-
<td className="datagrid-render-type"><RenderType key={uniqid("render-type")}/></td>
|
|
580
|
-
</tr>
|
|
581
|
-
</tbody>
|
|
582
|
-
</table>
|
|
583
|
-
</div>
|
|
584
|
-
datagridProps.baseId = defaultStr(datagridProps.baseId,uniqid("datagrid-pros-base-id"))
|
|
585
|
-
let title = this.props.title;
|
|
586
|
-
let clx = title ? "has-title ml1":"has-not-title"
|
|
587
|
-
let _dbSelector = showDBSelector ? <div className={"datagrid-db-selector-wrapper "+clx}>
|
|
588
|
-
<DBSelector
|
|
589
|
-
{...dbSelectorProps}
|
|
590
|
-
onChange = {this.onChangeDatabases.bind(this)}
|
|
591
|
-
/>
|
|
592
|
-
</div> : null;
|
|
593
|
-
if(!title){
|
|
594
|
-
title = _dbSelector;
|
|
595
|
-
_dbSelector = null;
|
|
596
|
-
}
|
|
597
|
-
let footers = this.getFooterValues();
|
|
598
|
-
return <Card tableCard className={classNames("datagrid-wrapper datagrid-table-wrapper",this.state.startLoadingData && !this.state.stopLoadingData?'loading user-select-none':'',isAllRowsSelected ? "all-rows-selected":'all-rows-not-selelected')}>
|
|
599
|
-
<DatagridActions
|
|
600
|
-
title = {title}
|
|
601
|
-
context = {this}
|
|
602
|
-
selectedRows = {this.selectedRows}
|
|
603
|
-
contextualTitleId = {this._datagridId+"contextual-id"}
|
|
604
|
-
childrenActions = {actions}
|
|
605
|
-
/>
|
|
606
|
-
{_dbSelector}
|
|
607
|
-
{showPaginationOnTop ?Pagination:null}
|
|
608
|
-
{_progressBar}
|
|
609
|
-
{
|
|
610
|
-
!_progressBar && (
|
|
611
|
-
<React.Fragment>
|
|
612
|
-
<div id={this.datagridDomId+"-scrollable-content-wrapper"} className={classNames("scrollable-top-content-wrapper",showPagination?'pagination-visible':'pagination-hidden')} onScroll={this.onScrollDom.bind(this)}>
|
|
613
|
-
<div id={this.datagridDomId+"-scrollable-content"} className="scrollable-top-content"></div>
|
|
614
|
-
</div>
|
|
615
|
-
<DataTable {...datagridProps}>
|
|
616
|
-
<TableHeader {..._headerProps}>
|
|
617
|
-
{datagridHeader}
|
|
618
|
-
</TableHeader>
|
|
619
|
-
<TableBody {..._bodyProps}>
|
|
620
|
-
{datagridBody}
|
|
621
|
-
</TableBody>
|
|
622
|
-
<tfoot className="md-table-footer">
|
|
623
|
-
{!showPaginationOnTop? <tr className="pagination-on-bottom-tr w100">
|
|
624
|
-
<td className={classNames("pagination-on-bottom-td")} colSpan={colSpan}>
|
|
625
|
-
{Pagination}
|
|
626
|
-
</td>
|
|
627
|
-
</tr>:null}
|
|
628
|
-
{showFooter && (
|
|
629
|
-
<tr className="datagrid-footer-wrapper">
|
|
630
|
-
<td className="footer-toggle-row-selection tableexport-ignore"></td>
|
|
631
|
-
{
|
|
632
|
-
Object.mapToArray(this.state.columns,(column,field,_index)=>{
|
|
633
|
-
if(!isObj(column) || !column.visible) return null;
|
|
634
|
-
if(!isObj(footers[field])) return <td key={field}></td>
|
|
635
|
-
let footer = footers[field];
|
|
636
|
-
return <td key={field} className={classNames("datagrid-footer-col md-table-column",footer.visible === false ? 'hidden':'')}>
|
|
637
|
-
<Footer
|
|
638
|
-
{...footer}
|
|
639
|
-
displayLabel = {false}
|
|
640
|
-
className = "footer-toggle-row-selection tableexport-ignore"
|
|
641
|
-
/>
|
|
642
|
-
</td>
|
|
643
|
-
})
|
|
644
|
-
}
|
|
645
|
-
</tr>
|
|
646
|
-
)}
|
|
647
|
-
</tfoot>
|
|
648
|
-
</DataTable>
|
|
649
|
-
</React.Fragment>
|
|
650
|
-
)
|
|
651
|
-
}
|
|
652
|
-
</Card>
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
///cette fonction permet de retourner le nom de la base de données à utiliser pour la récupération des données
|
|
658
|
-
DGridTableRendering.getDBName = DGrid.getDBName;
|
|
659
|
-
|
|
660
|
-
DGridTableRendering.propTypes = {
|
|
661
|
-
...DGrid.propTypes,
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
export default DGridTableRendering;
|