ywana-core8 0.0.569 → 0.0.572
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/dist/index.cjs +1226 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +50 -1
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +1225 -107
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1226 -106
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +12 -1
- package/src/domain/TablePage.js +2 -1
- package/src/domain/TablePage2.js +680 -0
- package/src/domain/index.js +1 -0
- package/src/html/accordion.css +36 -0
- package/src/html/accordion.js +58 -0
- package/src/html/accordion.test.js +37 -0
- package/src/html/index.js +1 -0
- package/src/html/section.css +1 -1
- package/src/html/section.js +1 -1
- package/src/html/table.test.js +2 -2
- package/src/html/textfield.js +4 -4
- package/src/html/textfield.test.js +1 -0
- package/src/html/tokenfield.js +1 -2
- package/src/site/site.css +13 -0
- package/src/site/site.js +1 -1
- package/src/site/site.test.js +7 -6
package/dist/index.modern.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import 'material-design-icons-iconfont/dist/material-design-icons.css';
|
2
|
-
import React, {
|
2
|
+
import React, { useState, useContext, useEffect, Fragment, useMemo, useRef, Children } from 'react';
|
3
3
|
import RSwitch from 'react-switch';
|
4
4
|
import moment$1 from 'moment';
|
5
5
|
import { extendMoment } from 'moment-range';
|
@@ -9,7 +9,7 @@ import { ReactNotifications, Store } from 'react-notifications-component';
|
|
9
9
|
import 'react-notifications-component/dist/theme.css';
|
10
10
|
import equal from 'deep-equal';
|
11
11
|
|
12
|
-
function _catch$
|
12
|
+
function _catch$4(body, recover) {
|
13
13
|
try {
|
14
14
|
var result = body();
|
15
15
|
} catch (e) {
|
@@ -41,7 +41,7 @@ var fetchAsync = function fetchAsync(method, URL, body, token, headers) {
|
|
41
41
|
body: body
|
42
42
|
};
|
43
43
|
if (headers) request.headers = request.headers;
|
44
|
-
return Promise.resolve(_catch$
|
44
|
+
return Promise.resolve(_catch$4(function () {
|
45
45
|
return Promise.resolve(fetch(URL, request)).then(function (response) {
|
46
46
|
var _exit;
|
47
47
|
|
@@ -142,6 +142,24 @@ var Session = {
|
|
142
142
|
}
|
143
143
|
};
|
144
144
|
|
145
|
+
function _extends() {
|
146
|
+
_extends = Object.assign || function (target) {
|
147
|
+
for (var i = 1; i < arguments.length; i++) {
|
148
|
+
var source = arguments[i];
|
149
|
+
|
150
|
+
for (var key in source) {
|
151
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
152
|
+
target[key] = source[key];
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
return target;
|
158
|
+
};
|
159
|
+
|
160
|
+
return _extends.apply(this, arguments);
|
161
|
+
}
|
162
|
+
|
145
163
|
/**
|
146
164
|
* Icon
|
147
165
|
*/
|
@@ -174,6 +192,99 @@ var Icon = function Icon(_ref) {
|
|
174
192
|
}, icon);
|
175
193
|
};
|
176
194
|
|
195
|
+
var Accordion = function Accordion(props) {
|
196
|
+
var className = props.className,
|
197
|
+
_props$sections = props.sections,
|
198
|
+
sections = _props$sections === void 0 ? [] : _props$sections,
|
199
|
+
onCheck = props.onCheck;
|
200
|
+
|
201
|
+
var _useState = useState(sections.map(function (section) {
|
202
|
+
return section.open;
|
203
|
+
})),
|
204
|
+
openSections = _useState[0],
|
205
|
+
setOpenSections = _useState[1];
|
206
|
+
|
207
|
+
var _useState2 = useState(sections.map(function (section) {
|
208
|
+
return section.checked;
|
209
|
+
})),
|
210
|
+
checkedSections = _useState2[0],
|
211
|
+
setCheckedSections = _useState2[1];
|
212
|
+
|
213
|
+
function toggle(index) {
|
214
|
+
var next = openSections.map(function (open, i) {
|
215
|
+
return i === index ? !open : open;
|
216
|
+
});
|
217
|
+
setOpenSections(next);
|
218
|
+
}
|
219
|
+
|
220
|
+
function check(index) {
|
221
|
+
var next = checkedSections.map(function (checked, i) {
|
222
|
+
return i === index ? !checked : checked;
|
223
|
+
});
|
224
|
+
setCheckedSections(next);
|
225
|
+
if (onCheck) onCheck(index, next[index], sections[index].id);
|
226
|
+
}
|
227
|
+
|
228
|
+
return /*#__PURE__*/React.createElement("div", {
|
229
|
+
className: "accordion " + className
|
230
|
+
}, sections.map(function (section, index) {
|
231
|
+
var isOpen = openSections[index];
|
232
|
+
var isChecked = checkedSections[index];
|
233
|
+
return /*#__PURE__*/React.createElement(AccordionSection, _extends({
|
234
|
+
key: index
|
235
|
+
}, section, {
|
236
|
+
open: isOpen,
|
237
|
+
checked: isChecked,
|
238
|
+
onToggle: function onToggle() {
|
239
|
+
return toggle(index);
|
240
|
+
},
|
241
|
+
onCheck: function onCheck() {
|
242
|
+
return check(index);
|
243
|
+
}
|
244
|
+
}), section.children);
|
245
|
+
}));
|
246
|
+
};
|
247
|
+
|
248
|
+
var AccordionSection = function AccordionSection(props) {
|
249
|
+
var checked = props.checked,
|
250
|
+
icon = props.icon,
|
251
|
+
title = props.title,
|
252
|
+
subtitle = props.subtitle,
|
253
|
+
_props$open = props.open,
|
254
|
+
open = _props$open === void 0 ? false : _props$open,
|
255
|
+
onToggle = props.onToggle,
|
256
|
+
onCheck = props.onCheck,
|
257
|
+
toolbar = props.toolbar,
|
258
|
+
info = props.info,
|
259
|
+
children = props.children;
|
260
|
+
var togglerIcon = open ? "expand_less" : "expand_more";
|
261
|
+
var checkedIcon = checked === undefined || checked === null ? null : checked === false ? "check_box_outline_blank" : "check_box";
|
262
|
+
return /*#__PURE__*/React.createElement("section", {
|
263
|
+
className: "accordion-section"
|
264
|
+
}, /*#__PURE__*/React.createElement("header", null, checkedIcon ? /*#__PURE__*/React.createElement(Icon, {
|
265
|
+
className: "accordion-section-checker",
|
266
|
+
icon: checkedIcon,
|
267
|
+
clickable: true,
|
268
|
+
action: onCheck
|
269
|
+
}) : '', icon ? /*#__PURE__*/React.createElement(Icon, {
|
270
|
+
className: "accordion-section-icon",
|
271
|
+
icon: icon
|
272
|
+
}) : '', title ? /*#__PURE__*/React.createElement("div", {
|
273
|
+
className: "accordion-section--title"
|
274
|
+
}, title) : '', subtitle ? /*#__PURE__*/React.createElement("div", {
|
275
|
+
className: "accordion-section--subtitle"
|
276
|
+
}, subtitle) : '', info ? /*#__PURE__*/React.createElement("div", {
|
277
|
+
className: "accordion-section--info"
|
278
|
+
}, info) : '', toolbar ? /*#__PURE__*/React.createElement("div", {
|
279
|
+
className: "accordion-section--toolbar"
|
280
|
+
}, toolbar) : '', /*#__PURE__*/React.createElement(Icon, {
|
281
|
+
className: "accordion-section-toggler",
|
282
|
+
icon: togglerIcon,
|
283
|
+
clickable: true,
|
284
|
+
action: onToggle
|
285
|
+
})), open ? /*#__PURE__*/React.createElement("main", null, children) : '');
|
286
|
+
};
|
287
|
+
|
177
288
|
/**
|
178
289
|
* HTML Button
|
179
290
|
*/
|
@@ -493,24 +604,6 @@ var Header = function Header(props) {
|
|
493
604
|
}, props.children));
|
494
605
|
};
|
495
606
|
|
496
|
-
function _extends() {
|
497
|
-
_extends = Object.assign || function (target) {
|
498
|
-
for (var i = 1; i < arguments.length; i++) {
|
499
|
-
var source = arguments[i];
|
500
|
-
|
501
|
-
for (var key in source) {
|
502
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
503
|
-
target[key] = source[key];
|
504
|
-
}
|
505
|
-
}
|
506
|
-
}
|
507
|
-
|
508
|
-
return target;
|
509
|
-
};
|
510
|
-
|
511
|
-
return _extends.apply(this, arguments);
|
512
|
-
}
|
513
|
-
|
514
607
|
/**
|
515
608
|
* List
|
516
609
|
*/
|
@@ -851,7 +944,7 @@ var Section = function Section(props) {
|
|
851
944
|
};
|
852
945
|
|
853
946
|
return /*#__PURE__*/React.createElement("section", {
|
854
|
-
className: "
|
947
|
+
className: "section " + className
|
855
948
|
}, /*#__PURE__*/React.createElement(Header, {
|
856
949
|
icon: icon,
|
857
950
|
title: title
|
@@ -1374,8 +1467,8 @@ var DropDown = function DropDown(props) {
|
|
1374
1467
|
if (!readOnly) setOpen(!open);
|
1375
1468
|
}
|
1376
1469
|
|
1377
|
-
function select(
|
1378
|
-
var next =
|
1470
|
+
function select(value) {
|
1471
|
+
var next = value;
|
1379
1472
|
var option = options.find(function (option) {
|
1380
1473
|
return option.value === next;
|
1381
1474
|
});
|
@@ -1400,12 +1493,13 @@ var DropDown = function DropDown(props) {
|
|
1400
1493
|
var lis = items.map(function (option) {
|
1401
1494
|
return /*#__PURE__*/React.createElement("li", {
|
1402
1495
|
key: option.value,
|
1403
|
-
value: option.value
|
1496
|
+
value: option.value,
|
1497
|
+
onClick: function onClick() {
|
1498
|
+
return select(option.value);
|
1499
|
+
}
|
1404
1500
|
}, /*#__PURE__*/React.createElement(Text, null, option.label));
|
1405
1501
|
});
|
1406
|
-
return /*#__PURE__*/React.createElement("menu", null, /*#__PURE__*/React.createElement("ul",
|
1407
|
-
onMouseDown: select
|
1408
|
-
}, lis));
|
1502
|
+
return /*#__PURE__*/React.createElement("menu", null, /*#__PURE__*/React.createElement("ul", null, lis));
|
1409
1503
|
} else {
|
1410
1504
|
return null;
|
1411
1505
|
}
|
@@ -3618,7 +3712,9 @@ var SiteMenu = function SiteMenu(_ref6) {
|
|
3618
3712
|
return _goto(id);
|
3619
3713
|
}
|
3620
3714
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
3621
|
-
text: title
|
3715
|
+
text: title,
|
3716
|
+
top: ".5rem",
|
3717
|
+
left: "2rem"
|
3622
3718
|
}, /*#__PURE__*/React.createElement(Icon, {
|
3623
3719
|
key: id,
|
3624
3720
|
icon: icon,
|
@@ -4189,13 +4285,13 @@ var ContentEditor = function ContentEditor(_ref) {
|
|
4189
4285
|
* Tabbed Content Editor
|
4190
4286
|
*/
|
4191
4287
|
|
4192
|
-
var TabbedContentEditor = function TabbedContentEditor(
|
4193
|
-
var content =
|
4194
|
-
filter =
|
4195
|
-
|
4196
|
-
grouped =
|
4197
|
-
onChange =
|
4198
|
-
onReload =
|
4288
|
+
var TabbedContentEditor = function TabbedContentEditor(_ref3) {
|
4289
|
+
var content = _ref3.content,
|
4290
|
+
filter = _ref3.filter,
|
4291
|
+
_ref3$grouped = _ref3.grouped,
|
4292
|
+
grouped = _ref3$grouped === void 0 ? false : _ref3$grouped,
|
4293
|
+
onChange = _ref3.onChange,
|
4294
|
+
onReload = _ref3.onReload;
|
4199
4295
|
|
4200
4296
|
var _useState = useState(0),
|
4201
4297
|
tab = _useState[0],
|
@@ -4280,9 +4376,9 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4280
4376
|
* TreededContentEditor
|
4281
4377
|
*/
|
4282
4378
|
|
4283
|
-
var TreededContentEditor = function TreededContentEditor(
|
4284
|
-
var content =
|
4285
|
-
onChange =
|
4379
|
+
var TreededContentEditor = function TreededContentEditor(_ref4) {
|
4380
|
+
var content = _ref4.content,
|
4381
|
+
onChange = _ref4.onChange;
|
4286
4382
|
var value = content.value();
|
4287
4383
|
var nodes = Object.values(content.type).filter(function (field) {
|
4288
4384
|
return field.type === TYPES.ARRAY;
|
@@ -4347,13 +4443,13 @@ var TreededContentEditor = function TreededContentEditor(_ref3) {
|
|
4347
4443
|
* FieldEditor
|
4348
4444
|
*/
|
4349
4445
|
|
4350
|
-
var FieldEditor = function FieldEditor(
|
4351
|
-
var field =
|
4352
|
-
onChange =
|
4353
|
-
content =
|
4354
|
-
|
4355
|
-
outlined =
|
4356
|
-
onReload =
|
4446
|
+
var FieldEditor = function FieldEditor(_ref5) {
|
4447
|
+
var field = _ref5.field,
|
4448
|
+
onChange = _ref5.onChange,
|
4449
|
+
content = _ref5.content,
|
4450
|
+
_ref5$outlined = _ref5.outlined,
|
4451
|
+
outlined = _ref5$outlined === void 0 ? false : _ref5$outlined,
|
4452
|
+
onReload = _ref5.onReload;
|
4357
4453
|
var id = field.id,
|
4358
4454
|
type = field.type,
|
4359
4455
|
item = field.item,
|
@@ -4440,11 +4536,11 @@ var FieldEditor = function FieldEditor(_ref4) {
|
|
4440
4536
|
* Entity Editor
|
4441
4537
|
*/
|
4442
4538
|
|
4443
|
-
var EntityEditor = function EntityEditor(
|
4444
|
-
var field =
|
4445
|
-
|
4446
|
-
value =
|
4447
|
-
onChange =
|
4539
|
+
var EntityEditor = function EntityEditor(_ref6) {
|
4540
|
+
var field = _ref6.field,
|
4541
|
+
_ref6$value = _ref6.value,
|
4542
|
+
value = _ref6$value === void 0 ? {} : _ref6$value,
|
4543
|
+
onChange = _ref6.onChange;
|
4448
4544
|
var id = field.id,
|
4449
4545
|
item = field.item,
|
4450
4546
|
label = field.label;
|
@@ -4504,13 +4600,13 @@ var EntityEditor = function EntityEditor(_ref5) {
|
|
4504
4600
|
*/
|
4505
4601
|
|
4506
4602
|
|
4507
|
-
var StringEditor = function StringEditor(
|
4508
|
-
var field =
|
4509
|
-
|
4510
|
-
value =
|
4511
|
-
onChange =
|
4512
|
-
content =
|
4513
|
-
outlined =
|
4603
|
+
var StringEditor = function StringEditor(_ref7) {
|
4604
|
+
var field = _ref7.field,
|
4605
|
+
_ref7$value = _ref7.value,
|
4606
|
+
value = _ref7$value === void 0 ? '' : _ref7$value,
|
4607
|
+
onChange = _ref7.onChange,
|
4608
|
+
content = _ref7.content,
|
4609
|
+
outlined = _ref7.outlined;
|
4514
4610
|
var id = field.id,
|
4515
4611
|
format = field.format,
|
4516
4612
|
label = field.label,
|
@@ -4626,12 +4722,12 @@ var StringEditor = function StringEditor(_ref6) {
|
|
4626
4722
|
* Number Editor
|
4627
4723
|
*/
|
4628
4724
|
|
4629
|
-
var NumberEditor = function NumberEditor(
|
4630
|
-
var field =
|
4631
|
-
value =
|
4632
|
-
onChange =
|
4633
|
-
|
4634
|
-
outlined =
|
4725
|
+
var NumberEditor = function NumberEditor(_ref8) {
|
4726
|
+
var field = _ref8.field,
|
4727
|
+
value = _ref8.value,
|
4728
|
+
onChange = _ref8.onChange,
|
4729
|
+
_ref8$outlined = _ref8.outlined,
|
4730
|
+
outlined = _ref8$outlined === void 0 ? false : _ref8$outlined;
|
4635
4731
|
var id = field.id,
|
4636
4732
|
label = field.label,
|
4637
4733
|
_field$editable2 = field.editable,
|
@@ -4664,11 +4760,11 @@ var NumberEditor = function NumberEditor(_ref7) {
|
|
4664
4760
|
*/
|
4665
4761
|
|
4666
4762
|
|
4667
|
-
var ListEditor = function ListEditor(
|
4668
|
-
var field =
|
4669
|
-
|
4670
|
-
value =
|
4671
|
-
onChange =
|
4763
|
+
var ListEditor = function ListEditor(_ref9) {
|
4764
|
+
var field = _ref9.field,
|
4765
|
+
_ref9$value = _ref9.value,
|
4766
|
+
value = _ref9$value === void 0 ? [] : _ref9$value,
|
4767
|
+
onChange = _ref9.onChange;
|
4672
4768
|
var label = field.label;
|
4673
4769
|
|
4674
4770
|
function change(id, value) {
|
@@ -4688,12 +4784,12 @@ var ListEditor = function ListEditor(_ref8) {
|
|
4688
4784
|
* Multi Selection Editor
|
4689
4785
|
*/
|
4690
4786
|
|
4691
|
-
var MultiSelectionEditor = function MultiSelectionEditor(
|
4692
|
-
var field =
|
4693
|
-
|
4694
|
-
value =
|
4695
|
-
content =
|
4696
|
-
onChange =
|
4787
|
+
var MultiSelectionEditor = function MultiSelectionEditor(_ref10) {
|
4788
|
+
var field = _ref10.field,
|
4789
|
+
_ref10$value = _ref10.value,
|
4790
|
+
value = _ref10$value === void 0 ? [] : _ref10$value,
|
4791
|
+
content = _ref10.content,
|
4792
|
+
onChange = _ref10.onChange;
|
4697
4793
|
var id = field.id,
|
4698
4794
|
label = field.label,
|
4699
4795
|
options = field.options;
|
@@ -4732,12 +4828,12 @@ var MultiSelectionEditor = function MultiSelectionEditor(_ref9) {
|
|
4732
4828
|
* Collection Editor
|
4733
4829
|
*/
|
4734
4830
|
|
4735
|
-
var CollectionEditor$1 = function CollectionEditor(
|
4736
|
-
var field =
|
4737
|
-
|
4738
|
-
value =
|
4739
|
-
onChange =
|
4740
|
-
onReload =
|
4831
|
+
var CollectionEditor$1 = function CollectionEditor(_ref11) {
|
4832
|
+
var field = _ref11.field,
|
4833
|
+
_ref11$value = _ref11.value,
|
4834
|
+
value = _ref11$value === void 0 ? [] : _ref11$value,
|
4835
|
+
onChange = _ref11.onChange,
|
4836
|
+
onReload = _ref11.onReload;
|
4741
4837
|
var id = field.id,
|
4742
4838
|
item = field.item,
|
4743
4839
|
label = field.label,
|
@@ -4807,7 +4903,7 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4807
4903
|
onChange: onChange,
|
4808
4904
|
onReload: reload
|
4809
4905
|
}) // : <DataTable {...table} editable={editable} />
|
4810
|
-
: /*#__PURE__*/React.createElement(TableEditor$
|
4906
|
+
: /*#__PURE__*/React.createElement(TableEditor$3, {
|
4811
4907
|
icon: "info",
|
4812
4908
|
title: label,
|
4813
4909
|
data: value,
|
@@ -4827,9 +4923,9 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4827
4923
|
* Collection Adder
|
4828
4924
|
*/
|
4829
4925
|
|
4830
|
-
var CollectionAdder = function CollectionAdder(
|
4831
|
-
var item =
|
4832
|
-
onAdd =
|
4926
|
+
var CollectionAdder = function CollectionAdder(_ref12) {
|
4927
|
+
var item = _ref12.item,
|
4928
|
+
onAdd = _ref12.onAdd;
|
4833
4929
|
|
4834
4930
|
var _useState3 = useState(false),
|
4835
4931
|
edit = _useState3[0],
|
@@ -4898,7 +4994,7 @@ var CollectionAdder = function CollectionAdder(_ref11) {
|
|
4898
4994
|
*/
|
4899
4995
|
|
4900
4996
|
|
4901
|
-
var TableEditor$
|
4997
|
+
var TableEditor$3 = function TableEditor(props) {
|
4902
4998
|
var select = function select(row) {
|
4903
4999
|
try {
|
4904
5000
|
if (onSelect) onSelect(row.id);
|
@@ -5242,7 +5338,7 @@ var EditContentDialog = function EditContentDialog(_ref) {
|
|
5242
5338
|
* Collection Page
|
5243
5339
|
*/
|
5244
5340
|
|
5245
|
-
function _catch$
|
5341
|
+
function _catch$3(body, recover) {
|
5246
5342
|
try {
|
5247
5343
|
var result = body();
|
5248
5344
|
} catch (e) {
|
@@ -5819,7 +5915,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5819
5915
|
try {
|
5820
5916
|
var _this2 = this;
|
5821
5917
|
|
5822
|
-
var _temp2 = _catch$
|
5918
|
+
var _temp2 = _catch$3(function () {
|
5823
5919
|
return Promise.resolve(API.all(null, page)).then(function (data) {
|
5824
5920
|
_this2.all = field ? data[field] : data;
|
5825
5921
|
});
|
@@ -5868,7 +5964,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5868
5964
|
},
|
5869
5965
|
fetch: function fetch(id) {
|
5870
5966
|
try {
|
5871
|
-
return Promise.resolve(_catch$
|
5967
|
+
return Promise.resolve(_catch$3(function () {
|
5872
5968
|
return Promise.resolve(API.find(id));
|
5873
5969
|
}, function (error) {
|
5874
5970
|
console.log(error);
|
@@ -5884,7 +5980,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5884
5980
|
try {
|
5885
5981
|
var _this8 = this;
|
5886
5982
|
|
5887
|
-
var _temp6 = _catch$
|
5983
|
+
var _temp6 = _catch$3(function () {
|
5888
5984
|
return Promise.resolve(API.create(form)).then(function () {
|
5889
5985
|
return Promise.resolve(_this8.load()).then(function () {});
|
5890
5986
|
});
|
@@ -5901,7 +5997,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5901
5997
|
try {
|
5902
5998
|
var _this10 = this;
|
5903
5999
|
|
5904
|
-
var _temp8 = _catch$
|
6000
|
+
var _temp8 = _catch$3(function () {
|
5905
6001
|
return Promise.resolve(API.update(form)).then(function () {
|
5906
6002
|
return Promise.resolve(_this10.load()).then(function () {});
|
5907
6003
|
});
|
@@ -5918,7 +6014,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5918
6014
|
try {
|
5919
6015
|
var _this12 = this;
|
5920
6016
|
|
5921
|
-
var _temp10 = _catch$
|
6017
|
+
var _temp10 = _catch$3(function () {
|
5922
6018
|
return Promise.resolve(API.patch(id, form)).then(function () {
|
5923
6019
|
return Promise.resolve(_this12.load()).then(function () {});
|
5924
6020
|
});
|
@@ -5935,7 +6031,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5935
6031
|
try {
|
5936
6032
|
var _this14 = this;
|
5937
6033
|
|
5938
|
-
var _temp12 = _catch$
|
6034
|
+
var _temp12 = _catch$3(function () {
|
5939
6035
|
return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
|
5940
6036
|
return Promise.resolve(_this14.load()).then(function () {});
|
5941
6037
|
});
|
@@ -5952,7 +6048,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5952
6048
|
try {
|
5953
6049
|
var _this16 = this;
|
5954
6050
|
|
5955
|
-
var _temp14 = _catch$
|
6051
|
+
var _temp14 = _catch$3(function () {
|
5956
6052
|
return Promise.resolve(API.remove(id)).then(function () {
|
5957
6053
|
return Promise.resolve(_this16.load()).then(function () {});
|
5958
6054
|
});
|
@@ -6165,7 +6261,7 @@ var QUERY = {
|
|
6165
6261
|
* Table Page
|
6166
6262
|
*/
|
6167
6263
|
|
6168
|
-
function _catch$
|
6264
|
+
function _catch$2(body, recover) {
|
6169
6265
|
try {
|
6170
6266
|
var result = body();
|
6171
6267
|
} catch (e) {
|
@@ -6292,7 +6388,7 @@ var TablePage = function TablePage(props) {
|
|
6292
6388
|
pageContext = _useContext[0],
|
6293
6389
|
setPageContext = _useContext[1];
|
6294
6390
|
|
6295
|
-
var context = TableContext$
|
6391
|
+
var context = TableContext$2(url, field, host, urlQuery, params);
|
6296
6392
|
var selected = pageContext.selected;
|
6297
6393
|
var timer = useRef(null);
|
6298
6394
|
|
@@ -6392,13 +6488,13 @@ var TablePage = function TablePage(props) {
|
|
6392
6488
|
if (rowSelected || rowChecked) {
|
6393
6489
|
return /*#__PURE__*/React.createElement("aside", {
|
6394
6490
|
className: "table-page"
|
6395
|
-
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$
|
6491
|
+
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$2, {
|
6396
6492
|
content: new Content(schema, form),
|
6397
6493
|
filter: editorFilter,
|
6398
6494
|
onChange: change,
|
6399
6495
|
onClose: closeAside,
|
6400
6496
|
editable: canEdit
|
6401
|
-
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$
|
6497
|
+
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$2, {
|
6402
6498
|
schema: schema,
|
6403
6499
|
actions: selectionActions
|
6404
6500
|
}) : null);
|
@@ -6439,17 +6535,17 @@ var TablePage = function TablePage(props) {
|
|
6439
6535
|
onSelect: playScenario
|
6440
6536
|
})) : null, renderActions()), canQuery || canFilter ? /*#__PURE__*/React.createElement("menu", {
|
6441
6537
|
className: "table-page"
|
6442
|
-
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$
|
6538
|
+
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$2, {
|
6443
6539
|
schema: schema,
|
6444
6540
|
url: url,
|
6445
6541
|
user: user
|
6446
|
-
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$
|
6542
|
+
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$2, {
|
6447
6543
|
schema: schema,
|
6448
6544
|
onSave: canQuery ? saveQuery : null
|
6449
6545
|
}) : null) : null, /*#__PURE__*/React.createElement("main", {
|
6450
6546
|
key: id,
|
6451
6547
|
className: "table-page"
|
6452
|
-
}, /*#__PURE__*/React.createElement(TableEditor$
|
6548
|
+
}, /*#__PURE__*/React.createElement(TableEditor$2, {
|
6453
6549
|
icon: icon,
|
6454
6550
|
title: name,
|
6455
6551
|
schema: schema,
|
@@ -6463,7 +6559,7 @@ var TablePage = function TablePage(props) {
|
|
6463
6559
|
}), children ? /*#__PURE__*/React.createElement("article", null, children) : null), renderAside());
|
6464
6560
|
};
|
6465
6561
|
|
6466
|
-
var TableRowEditor$
|
6562
|
+
var TableRowEditor$2 = function TableRowEditor(props) {
|
6467
6563
|
var name = props.name,
|
6468
6564
|
content = props.content,
|
6469
6565
|
filter = props.filter,
|
@@ -6492,7 +6588,7 @@ var TableRowEditor$1 = function TableRowEditor(props) {
|
|
6492
6588
|
*/
|
6493
6589
|
|
6494
6590
|
|
6495
|
-
var TableSelector$
|
6591
|
+
var TableSelector$2 = function TableSelector(props) {
|
6496
6592
|
var schema = props.schema,
|
6497
6593
|
_props$actions2 = props.actions,
|
6498
6594
|
actions = _props$actions2 === void 0 ? [] : _props$actions2;
|
@@ -6555,7 +6651,7 @@ var TableSelector$1 = function TableSelector(props) {
|
|
6555
6651
|
*/
|
6556
6652
|
|
6557
6653
|
|
6558
|
-
var TableQueries$
|
6654
|
+
var TableQueries$2 = function TableQueries(props) {
|
6559
6655
|
var remove = function remove(id) {
|
6560
6656
|
try {
|
6561
6657
|
return Promise.resolve(pageContext.removeQuery(id, user)).then(function () {
|
@@ -6617,7 +6713,7 @@ var TableQueries$1 = function TableQueries(props) {
|
|
6617
6713
|
*/
|
6618
6714
|
|
6619
6715
|
|
6620
|
-
var TableFilters$
|
6716
|
+
var TableFilters$2 = function TableFilters(props) {
|
6621
6717
|
var reload = function reload() {
|
6622
6718
|
try {
|
6623
6719
|
return Promise.resolve(pageContext.load(form)).then(function () {
|
@@ -6713,7 +6809,7 @@ var TableFilters$1 = function TableFilters(props) {
|
|
6713
6809
|
*/
|
6714
6810
|
|
6715
6811
|
|
6716
|
-
var TableEditor$
|
6812
|
+
var TableEditor$2 = function TableEditor(props) {
|
6717
6813
|
var checkOne = function checkOne(id, field, value) {
|
6718
6814
|
check([id], value);
|
6719
6815
|
return Promise.resolve();
|
@@ -6945,6 +7041,1028 @@ var TableEditor$1 = function TableEditor(props) {
|
|
6945
7041
|
* Table Context
|
6946
7042
|
*/
|
6947
7043
|
|
7044
|
+
var TableContext$2 = function TableContext(url, field, host, urlQuery, params) {
|
7045
|
+
var API = TableAPI$2(url, host, params);
|
7046
|
+
return {
|
7047
|
+
all: [],
|
7048
|
+
checked: new Set([]),
|
7049
|
+
selected: null,
|
7050
|
+
filters: {},
|
7051
|
+
queries: [],
|
7052
|
+
load: function load(filter) {
|
7053
|
+
try {
|
7054
|
+
var _this2 = this;
|
7055
|
+
|
7056
|
+
var _temp5 = _catch$2(function () {
|
7057
|
+
var filters = filter ? Object.keys(filter).reduce(function (filters, key) {
|
7058
|
+
var field = filter[key];
|
7059
|
+
|
7060
|
+
if (field) {
|
7061
|
+
if (CHECK['isObject'](field)) {
|
7062
|
+
Object.keys(field).forEach(function (key2) {
|
7063
|
+
var subfield = field[key2];
|
7064
|
+
if (subfield) filters[key + "." + key2] = subfield;
|
7065
|
+
});
|
7066
|
+
} else {
|
7067
|
+
filters[key] = field;
|
7068
|
+
}
|
7069
|
+
}
|
7070
|
+
|
7071
|
+
return filters;
|
7072
|
+
}, {}) : [];
|
7073
|
+
return Promise.resolve(API.all(filters)).then(function (data) {
|
7074
|
+
_this2.all = field ? data[field] : data;
|
7075
|
+
});
|
7076
|
+
}, function (error) {
|
7077
|
+
console.log(error);
|
7078
|
+
});
|
7079
|
+
|
7080
|
+
return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(function () {}) : void 0);
|
7081
|
+
} catch (e) {
|
7082
|
+
return Promise.reject(e);
|
7083
|
+
}
|
7084
|
+
},
|
7085
|
+
check: function check(ids, isChecked) {
|
7086
|
+
var _this3 = this;
|
7087
|
+
|
7088
|
+
if (isChecked === void 0) {
|
7089
|
+
isChecked = true;
|
7090
|
+
}
|
7091
|
+
|
7092
|
+
if (isChecked) {
|
7093
|
+
ids.forEach(function (id) {
|
7094
|
+
return _this3.checked.add(id);
|
7095
|
+
});
|
7096
|
+
} else {
|
7097
|
+
ids.forEach(function (id) {
|
7098
|
+
return _this3.checked["delete"](id);
|
7099
|
+
});
|
7100
|
+
}
|
7101
|
+
},
|
7102
|
+
select: function select(id) {
|
7103
|
+
var result = this.all.find(function (item) {
|
7104
|
+
return item.id === id;
|
7105
|
+
});
|
7106
|
+
this.selected = result;
|
7107
|
+
},
|
7108
|
+
clear: function clear() {
|
7109
|
+
this.selected = null;
|
7110
|
+
},
|
7111
|
+
create: function create(form) {
|
7112
|
+
try {
|
7113
|
+
var _this5 = this;
|
7114
|
+
|
7115
|
+
var _temp7 = _catch$2(function () {
|
7116
|
+
return Promise.resolve(API.create(form)).then(function () {
|
7117
|
+
return Promise.resolve(_this5.load()).then(function () {});
|
7118
|
+
});
|
7119
|
+
}, function (error) {
|
7120
|
+
console.log(error);
|
7121
|
+
});
|
7122
|
+
|
7123
|
+
return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
|
7124
|
+
} catch (e) {
|
7125
|
+
return Promise.reject(e);
|
7126
|
+
}
|
7127
|
+
},
|
7128
|
+
update: function update(form) {
|
7129
|
+
try {
|
7130
|
+
var _this7 = this;
|
7131
|
+
|
7132
|
+
var _temp9 = _catch$2(function () {
|
7133
|
+
return Promise.resolve(API.update(form)).then(function () {
|
7134
|
+
return Promise.resolve(_this7.load()).then(function () {});
|
7135
|
+
});
|
7136
|
+
}, function (error) {
|
7137
|
+
console.log(error);
|
7138
|
+
});
|
7139
|
+
|
7140
|
+
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
|
7141
|
+
} catch (e) {
|
7142
|
+
return Promise.reject(e);
|
7143
|
+
}
|
7144
|
+
},
|
7145
|
+
remove: function remove(id) {
|
7146
|
+
try {
|
7147
|
+
var _this9 = this;
|
7148
|
+
|
7149
|
+
var _temp11 = _catch$2(function () {
|
7150
|
+
return Promise.resolve(API.remove(id)).then(function () {
|
7151
|
+
return Promise.resolve(_this9.load()).then(function () {});
|
7152
|
+
});
|
7153
|
+
}, function (error) {
|
7154
|
+
console.log(error);
|
7155
|
+
});
|
7156
|
+
|
7157
|
+
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
|
7158
|
+
} catch (e) {
|
7159
|
+
return Promise.reject(e);
|
7160
|
+
}
|
7161
|
+
},
|
7162
|
+
changeFilters: function changeFilters(filters) {
|
7163
|
+
this.filters = filters;
|
7164
|
+
},
|
7165
|
+
loadQueries: function loadQueries(user) {
|
7166
|
+
try {
|
7167
|
+
var _this11 = this;
|
7168
|
+
|
7169
|
+
var _temp13 = _catch$2(function () {
|
7170
|
+
return Promise.resolve(API.queries(user, urlQuery)).then(function (_API$queries) {
|
7171
|
+
_this11.queries = _API$queries;
|
7172
|
+
});
|
7173
|
+
}, function (error) {
|
7174
|
+
console.log(error);
|
7175
|
+
});
|
7176
|
+
|
7177
|
+
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
|
7178
|
+
} catch (e) {
|
7179
|
+
return Promise.reject(e);
|
7180
|
+
}
|
7181
|
+
},
|
7182
|
+
createQuery: function createQuery(query, user) {
|
7183
|
+
try {
|
7184
|
+
var _this13 = this;
|
7185
|
+
|
7186
|
+
var _temp15 = _catch$2(function () {
|
7187
|
+
return Promise.resolve(API.createQuery(query, urlQuery)).then(function () {
|
7188
|
+
return Promise.resolve(_this13.loadQueries(user)).then(function () {});
|
7189
|
+
});
|
7190
|
+
}, function (error) {
|
7191
|
+
console.log(error);
|
7192
|
+
});
|
7193
|
+
|
7194
|
+
return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
|
7195
|
+
} catch (e) {
|
7196
|
+
return Promise.reject(e);
|
7197
|
+
}
|
7198
|
+
},
|
7199
|
+
removeQuery: function removeQuery(id, user) {
|
7200
|
+
try {
|
7201
|
+
var _this15 = this;
|
7202
|
+
|
7203
|
+
var _temp17 = _catch$2(function () {
|
7204
|
+
return Promise.resolve(API.removeQuery(id, urlQuery)).then(function () {
|
7205
|
+
return Promise.resolve(_this15.loadQueries(user)).then(function () {});
|
7206
|
+
});
|
7207
|
+
}, function (error) {
|
7208
|
+
console.log(error);
|
7209
|
+
});
|
7210
|
+
|
7211
|
+
return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(function () {}) : void 0);
|
7212
|
+
} catch (e) {
|
7213
|
+
return Promise.reject(e);
|
7214
|
+
}
|
7215
|
+
}
|
7216
|
+
};
|
7217
|
+
};
|
7218
|
+
/**
|
7219
|
+
* table API
|
7220
|
+
*/
|
7221
|
+
|
7222
|
+
|
7223
|
+
var TableAPI$2 = function TableAPI(url, host, params) {
|
7224
|
+
if (params === void 0) {
|
7225
|
+
params = "";
|
7226
|
+
}
|
7227
|
+
|
7228
|
+
var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
7229
|
+
return {
|
7230
|
+
all: function all(filters) {
|
7231
|
+
var queryParams = "?" + params;
|
7232
|
+
|
7233
|
+
if (filters) {
|
7234
|
+
var filterQuery = Object.keys(filters).reduce(function (query, key) {
|
7235
|
+
var value = filters[key];
|
7236
|
+
|
7237
|
+
if (typeof value === 'boolean') {
|
7238
|
+
return query.concat(key + "=" + value + "&");
|
7239
|
+
} else if (Array.isArray(value)) {
|
7240
|
+
var param = value.length === 0 ? '' : value.reduce(function (param, item) {
|
7241
|
+
param = param.concat(key + "=" + item + "&");
|
7242
|
+
return param;
|
7243
|
+
}, "");
|
7244
|
+
return query.concat(param);
|
7245
|
+
} else {
|
7246
|
+
return query.concat(key + "=%" + filters[key] + "%&");
|
7247
|
+
}
|
7248
|
+
}, "");
|
7249
|
+
queryParams = queryParams.concat(filterQuery);
|
7250
|
+
}
|
7251
|
+
|
7252
|
+
return http.GET(url + queryParams);
|
7253
|
+
},
|
7254
|
+
find: function find(id) {
|
7255
|
+
return http.GET(url + "/" + id);
|
7256
|
+
},
|
7257
|
+
create: function create(form) {
|
7258
|
+
var body = JSON.stringify(form);
|
7259
|
+
return http.POST(url, body);
|
7260
|
+
},
|
7261
|
+
update: function update(form) {
|
7262
|
+
var body = JSON.stringify(form);
|
7263
|
+
return http.PUT(url + "/" + form.id, body);
|
7264
|
+
},
|
7265
|
+
remove: function remove(id) {
|
7266
|
+
return http.DELETE(url + "/" + id);
|
7267
|
+
},
|
7268
|
+
queries: function queries(user, url2) {
|
7269
|
+
var url3 = url2 ? url2 : url;
|
7270
|
+
url3 = url3 + "queries";
|
7271
|
+
if (user) url3 = url3 + ("?user=" + user);
|
7272
|
+
return http.GET(url3);
|
7273
|
+
},
|
7274
|
+
createQuery: function createQuery(form, url2) {
|
7275
|
+
var url3 = url2 ? url2 : url;
|
7276
|
+
var body = JSON.stringify(form);
|
7277
|
+
return http.POST(url3 + "queries", body);
|
7278
|
+
},
|
7279
|
+
removeQuery: function removeQuery(id, url2) {
|
7280
|
+
var url3 = url2 ? url2 : url;
|
7281
|
+
return http.DELETE(url3 + "queries/" + id);
|
7282
|
+
}
|
7283
|
+
};
|
7284
|
+
};
|
7285
|
+
|
7286
|
+
/**
|
7287
|
+
* Table Page
|
7288
|
+
*/
|
7289
|
+
|
7290
|
+
function _catch$1(body, recover) {
|
7291
|
+
try {
|
7292
|
+
var result = body();
|
7293
|
+
} catch (e) {
|
7294
|
+
return recover(e);
|
7295
|
+
}
|
7296
|
+
|
7297
|
+
if (result && result.then) {
|
7298
|
+
return result.then(void 0, recover);
|
7299
|
+
}
|
7300
|
+
|
7301
|
+
return result;
|
7302
|
+
}
|
7303
|
+
/**
|
7304
|
+
* TableRowEditor
|
7305
|
+
*/
|
7306
|
+
|
7307
|
+
|
7308
|
+
var TablePage2 = function TablePage2(props) {
|
7309
|
+
var playScenario = function playScenario() {
|
7310
|
+
try {
|
7311
|
+
var promises1 = pageContext.all.map(function (item) {
|
7312
|
+
try {
|
7313
|
+
return Promise.resolve(pageContext.remove(item.id));
|
7314
|
+
} catch (e) {
|
7315
|
+
return Promise.reject(e);
|
7316
|
+
}
|
7317
|
+
});
|
7318
|
+
Promise.all(promises1).then(function () {
|
7319
|
+
try {
|
7320
|
+
var promises2 = scenario.map(function (item) {
|
7321
|
+
try {
|
7322
|
+
return Promise.resolve(pageContext.create(item));
|
7323
|
+
} catch (e) {
|
7324
|
+
return Promise.reject(e);
|
7325
|
+
}
|
7326
|
+
});
|
7327
|
+
Promise.all(promises2).then(function () {
|
7328
|
+
try {
|
7329
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7330
|
+
setPageContext(Object.assign({}, pageContext));
|
7331
|
+
});
|
7332
|
+
} catch (e) {
|
7333
|
+
return Promise.reject(e);
|
7334
|
+
}
|
7335
|
+
});
|
7336
|
+
return Promise.resolve();
|
7337
|
+
} catch (e) {
|
7338
|
+
return Promise.reject(e);
|
7339
|
+
}
|
7340
|
+
});
|
7341
|
+
return Promise.resolve();
|
7342
|
+
} catch (e) {
|
7343
|
+
return Promise.reject(e);
|
7344
|
+
}
|
7345
|
+
};
|
7346
|
+
|
7347
|
+
var save = function save() {
|
7348
|
+
try {
|
7349
|
+
return Promise.resolve(pageContext.update(form)).then(function () {
|
7350
|
+
setPageContext(Object.assign({}, pageContext));
|
7351
|
+
});
|
7352
|
+
} catch (e) {
|
7353
|
+
return Promise.reject(e);
|
7354
|
+
}
|
7355
|
+
};
|
7356
|
+
|
7357
|
+
var reload = function reload() {
|
7358
|
+
try {
|
7359
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7360
|
+
setPageContext(Object.assign({}, pageContext));
|
7361
|
+
});
|
7362
|
+
} catch (e) {
|
7363
|
+
return Promise.reject(e);
|
7364
|
+
}
|
7365
|
+
};
|
7366
|
+
|
7367
|
+
var site = useContext(SiteContext);
|
7368
|
+
var _props$id = props.id,
|
7369
|
+
id = _props$id === void 0 ? "table" : _props$id,
|
7370
|
+
icon = props.icon,
|
7371
|
+
title = props.title,
|
7372
|
+
name = props.name,
|
7373
|
+
schema = props.schema,
|
7374
|
+
url = props.url,
|
7375
|
+
field = props.field,
|
7376
|
+
host = props.host,
|
7377
|
+
_props$params = props.params,
|
7378
|
+
params = _props$params === void 0 ? "" : _props$params,
|
7379
|
+
_props$autosave = props.autosave,
|
7380
|
+
autosave = _props$autosave === void 0 ? true : _props$autosave,
|
7381
|
+
_props$delay = props.delay,
|
7382
|
+
delay = _props$delay === void 0 ? 1000 : _props$delay,
|
7383
|
+
editable = props.editable,
|
7384
|
+
_props$actions = props.actions,
|
7385
|
+
actions = _props$actions === void 0 ? [] : _props$actions,
|
7386
|
+
_props$dev = props.dev,
|
7387
|
+
dev = _props$dev === void 0 ? false : _props$dev,
|
7388
|
+
tableActions = props.tableActions,
|
7389
|
+
_props$selectionActio = props.selectionActions,
|
7390
|
+
selectionActions = _props$selectionActio === void 0 ? [] : _props$selectionActio,
|
7391
|
+
_props$canFilter = props.canFilter,
|
7392
|
+
canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
|
7393
|
+
_props$canAdd = props.canAdd,
|
7394
|
+
canAdd = _props$canAdd === void 0 ? true : _props$canAdd,
|
7395
|
+
_props$canDelete = props.canDelete,
|
7396
|
+
canDelete = _props$canDelete === void 0 ? true : _props$canDelete,
|
7397
|
+
_props$canEdit = props.canEdit,
|
7398
|
+
canEdit = _props$canEdit === void 0 ? true : _props$canEdit,
|
7399
|
+
_props$canQuery = props.canQuery,
|
7400
|
+
canQuery = _props$canQuery === void 0 ? false : _props$canQuery,
|
7401
|
+
urlQuery = props.urlQuery,
|
7402
|
+
user = props.user,
|
7403
|
+
groupBy = props.groupBy,
|
7404
|
+
validator = props.validator,
|
7405
|
+
scenario = props.scenario,
|
7406
|
+
formFilter = props.formFilter,
|
7407
|
+
tableFilter = props.tableFilter,
|
7408
|
+
_props$editorFilter = props.editorFilter,
|
7409
|
+
editorFilter = _props$editorFilter === void 0 ? false : _props$editorFilter,
|
7410
|
+
tableClassName = props.tableClassName,
|
7411
|
+
children = props.children;
|
7412
|
+
|
7413
|
+
var _useContext = useContext(PageContext),
|
7414
|
+
pageContext = _useContext[0],
|
7415
|
+
setPageContext = _useContext[1];
|
7416
|
+
|
7417
|
+
var context = TableContext$1(url, field, host, urlQuery, params);
|
7418
|
+
var selected = pageContext.selected;
|
7419
|
+
var timer = useRef(null);
|
7420
|
+
|
7421
|
+
var _useState = useState(selected),
|
7422
|
+
form = _useState[0],
|
7423
|
+
setForm = _useState[1];
|
7424
|
+
|
7425
|
+
useEffect(function () {
|
7426
|
+
try {
|
7427
|
+
return Promise.resolve(context.load()).then(function () {
|
7428
|
+
function _temp2() {
|
7429
|
+
setPageContext(context);
|
7430
|
+
}
|
7431
|
+
|
7432
|
+
var _temp = function () {
|
7433
|
+
if (canQuery) return Promise.resolve(context.loadQueries(user)).then(function () {});
|
7434
|
+
}();
|
7435
|
+
|
7436
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
7437
|
+
});
|
7438
|
+
} catch (e) {
|
7439
|
+
return Promise.reject(e);
|
7440
|
+
}
|
7441
|
+
}, []);
|
7442
|
+
useEffect(function () {
|
7443
|
+
setForm(selected);
|
7444
|
+
}, [selected]);
|
7445
|
+
useEffect(function () {
|
7446
|
+
if (autosave) {
|
7447
|
+
clearTimeout(timer.current);
|
7448
|
+
timer.current = setTimeout(function () {
|
7449
|
+
if (canSave()) save();
|
7450
|
+
}, delay);
|
7451
|
+
}
|
7452
|
+
}, [form]);
|
7453
|
+
|
7454
|
+
function add() {
|
7455
|
+
var onOK = function onOK(form) {
|
7456
|
+
try {
|
7457
|
+
return Promise.resolve(pageContext.create(form)).then(function () {
|
7458
|
+
setPageContext(Object.assign({}, pageContext));
|
7459
|
+
});
|
7460
|
+
} catch (e) {
|
7461
|
+
return Promise.reject(e);
|
7462
|
+
}
|
7463
|
+
};
|
7464
|
+
|
7465
|
+
site.openDialog( /*#__PURE__*/React.createElement(CreateContentDialog, {
|
7466
|
+
label: "Crear " + name,
|
7467
|
+
type: schema,
|
7468
|
+
onOK: onOK,
|
7469
|
+
validator: validator,
|
7470
|
+
filter: formFilter
|
7471
|
+
}));
|
7472
|
+
}
|
7473
|
+
|
7474
|
+
function saveQuery(filters) {
|
7475
|
+
var onOK = function onOK(form) {
|
7476
|
+
try {
|
7477
|
+
form.filters = filters;
|
7478
|
+
form.layout = {};
|
7479
|
+
form.user = user;
|
7480
|
+
form.url = url;
|
7481
|
+
return Promise.resolve(pageContext.createQuery(form, user)).then(function () {
|
7482
|
+
setPageContext(Object.assign({}, pageContext));
|
7483
|
+
});
|
7484
|
+
} catch (e) {
|
7485
|
+
return Promise.reject(e);
|
7486
|
+
}
|
7487
|
+
};
|
7488
|
+
|
7489
|
+
site.openDialog( /*#__PURE__*/React.createElement(CreateContentDialog, {
|
7490
|
+
label: "Nueva query",
|
7491
|
+
type: QUERY,
|
7492
|
+
onOK: onOK
|
7493
|
+
}));
|
7494
|
+
}
|
7495
|
+
|
7496
|
+
function change(next) {
|
7497
|
+
setForm(next);
|
7498
|
+
}
|
7499
|
+
|
7500
|
+
function canSave() {
|
7501
|
+
var can = !equal(form, selected);
|
7502
|
+
return can;
|
7503
|
+
}
|
7504
|
+
|
7505
|
+
function closeAside() {
|
7506
|
+
pageContext.select(null);
|
7507
|
+
setPageContext(Object.assign({}, pageContext));
|
7508
|
+
}
|
7509
|
+
|
7510
|
+
function renderAside() {
|
7511
|
+
var rowSelected = selected && form;
|
7512
|
+
var rowChecked = pageContext.checked && pageContext.checked.size > 0;
|
7513
|
+
|
7514
|
+
if (rowSelected || rowChecked) {
|
7515
|
+
return /*#__PURE__*/React.createElement("aside", {
|
7516
|
+
className: "table-page"
|
7517
|
+
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$1, {
|
7518
|
+
content: new Content(schema, form),
|
7519
|
+
filter: editorFilter,
|
7520
|
+
onChange: change,
|
7521
|
+
onClose: closeAside,
|
7522
|
+
editable: canEdit
|
7523
|
+
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$1, {
|
7524
|
+
schema: schema,
|
7525
|
+
actions: selectionActions
|
7526
|
+
}) : null);
|
7527
|
+
}
|
7528
|
+
|
7529
|
+
return null;
|
7530
|
+
}
|
7531
|
+
|
7532
|
+
function renderActions() {
|
7533
|
+
return actions.map(function (element) {
|
7534
|
+
var action = function action() {
|
7535
|
+
return element.props.action(pageContext);
|
7536
|
+
};
|
7537
|
+
|
7538
|
+
var clone = React.cloneElement(element, {
|
7539
|
+
action: action
|
7540
|
+
});
|
7541
|
+
return clone;
|
7542
|
+
});
|
7543
|
+
}
|
7544
|
+
|
7545
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7546
|
+
className: "table-page",
|
7547
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
7548
|
+
}, canAdd ? /*#__PURE__*/React.createElement(Button, {
|
7549
|
+
icon: "add",
|
7550
|
+
label: "A\xF1adir",
|
7551
|
+
action: add,
|
7552
|
+
raised: true
|
7553
|
+
}) : null, "\xA0", /*#__PURE__*/React.createElement(Button, {
|
7554
|
+
icon: "refresh",
|
7555
|
+
label: "Reload",
|
7556
|
+
action: reload
|
7557
|
+
}), dev ? /*#__PURE__*/React.createElement(MenuIcon, {
|
7558
|
+
align: "alignRight"
|
7559
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
7560
|
+
label: "Cargar Escenario 1",
|
7561
|
+
onSelect: playScenario
|
7562
|
+
})) : null, renderActions()), canQuery || canFilter ? /*#__PURE__*/React.createElement("menu", {
|
7563
|
+
className: "table-page"
|
7564
|
+
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$1, {
|
7565
|
+
schema: schema,
|
7566
|
+
url: url,
|
7567
|
+
user: user
|
7568
|
+
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$1, {
|
7569
|
+
schema: schema,
|
7570
|
+
onSave: canQuery ? saveQuery : null
|
7571
|
+
}) : null) : null, /*#__PURE__*/React.createElement("main", {
|
7572
|
+
key: id,
|
7573
|
+
className: "table-page"
|
7574
|
+
}, /*#__PURE__*/React.createElement(TableEditor$1, {
|
7575
|
+
icon: icon,
|
7576
|
+
title: name,
|
7577
|
+
schema: schema,
|
7578
|
+
delay: delay,
|
7579
|
+
editable: editable,
|
7580
|
+
groupBy: groupBy,
|
7581
|
+
filter: tableFilter,
|
7582
|
+
actions: tableActions,
|
7583
|
+
canDelete: canDelete,
|
7584
|
+
className: tableClassName
|
7585
|
+
}), children ? /*#__PURE__*/React.createElement("article", null, children) : null), renderAside());
|
7586
|
+
};
|
7587
|
+
|
7588
|
+
var TableRowEditor$1 = function TableRowEditor(props) {
|
7589
|
+
var name = props.name,
|
7590
|
+
content = props.content,
|
7591
|
+
filter = props.filter,
|
7592
|
+
editable = props.editable,
|
7593
|
+
onChange = props.onChange,
|
7594
|
+
onClose = props.onClose;
|
7595
|
+
return /*#__PURE__*/React.createElement("div", {
|
7596
|
+
className: "table-row-editor"
|
7597
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
7598
|
+
icon: "local_offer",
|
7599
|
+
title: name || "Propiedades"
|
7600
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7601
|
+
icon: "close",
|
7602
|
+
clickable: true,
|
7603
|
+
action: onClose
|
7604
|
+
})), /*#__PURE__*/React.createElement("main", null, editable ? /*#__PURE__*/React.createElement(ContentEditor, {
|
7605
|
+
content: content,
|
7606
|
+
onChange: onChange,
|
7607
|
+
filter: filter
|
7608
|
+
}) : /*#__PURE__*/React.createElement(ContentViewer, {
|
7609
|
+
content: content
|
7610
|
+
})));
|
7611
|
+
};
|
7612
|
+
/**
|
7613
|
+
* Table Selector
|
7614
|
+
*/
|
7615
|
+
|
7616
|
+
|
7617
|
+
var TableSelector$1 = function TableSelector(props) {
|
7618
|
+
var schema = props.schema,
|
7619
|
+
_props$actions2 = props.actions,
|
7620
|
+
actions = _props$actions2 === void 0 ? [] : _props$actions2;
|
7621
|
+
|
7622
|
+
var _useContext2 = useContext(PageContext),
|
7623
|
+
pageContext = _useContext2[0],
|
7624
|
+
setPageContext = _useContext2[1];
|
7625
|
+
|
7626
|
+
var all = pageContext.all,
|
7627
|
+
checked = pageContext.checked;
|
7628
|
+
var count = checked.size + "/" + all.length;
|
7629
|
+
var columns = Object.keys(schema).filter(function (key) {
|
7630
|
+
return schema[key].selectorColumn === true;
|
7631
|
+
}).map(function (key) {
|
7632
|
+
var field = schema[key];
|
7633
|
+
return {
|
7634
|
+
id: field.id,
|
7635
|
+
label: field.label
|
7636
|
+
};
|
7637
|
+
});
|
7638
|
+
var rows = all.filter(function (item) {
|
7639
|
+
return checked.has(item.id);
|
7640
|
+
});
|
7641
|
+
var table = {
|
7642
|
+
columns: columns,
|
7643
|
+
rows: rows || []
|
7644
|
+
};
|
7645
|
+
var buttons = actions.map(function (_ref) {
|
7646
|
+
var label = _ref.label,
|
7647
|
+
_action = _ref.action,
|
7648
|
+
validate = _ref.validate;
|
7649
|
+
return /*#__PURE__*/React.createElement(Button, {
|
7650
|
+
label: label,
|
7651
|
+
raised: true,
|
7652
|
+
action: function action() {
|
7653
|
+
return _action(checked, pageContext, function () {
|
7654
|
+
try {
|
7655
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7656
|
+
setPageContext(Object.assign({}, pageContext));
|
7657
|
+
});
|
7658
|
+
} catch (e) {
|
7659
|
+
return Promise.reject(e);
|
7660
|
+
}
|
7661
|
+
}, rows);
|
7662
|
+
},
|
7663
|
+
disabled: !validate(checked, rows)
|
7664
|
+
});
|
7665
|
+
});
|
7666
|
+
return /*#__PURE__*/React.createElement("div", {
|
7667
|
+
className: "table-selector"
|
7668
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
7669
|
+
icon: "checklist_rtl",
|
7670
|
+
title: "Selecci\xF3n"
|
7671
|
+
}, /*#__PURE__*/React.createElement("span", {
|
7672
|
+
className: "size"
|
7673
|
+
}, count)), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(DataTable, table)), /*#__PURE__*/React.createElement("footer", null, buttons));
|
7674
|
+
};
|
7675
|
+
/**
|
7676
|
+
* Table Queries
|
7677
|
+
*/
|
7678
|
+
|
7679
|
+
|
7680
|
+
var TableQueries$1 = function TableQueries(props) {
|
7681
|
+
var remove = function remove(id) {
|
7682
|
+
try {
|
7683
|
+
return Promise.resolve(pageContext.removeQuery(id, user)).then(function () {
|
7684
|
+
setPageContext(Object.assign({}, pageContext));
|
7685
|
+
});
|
7686
|
+
} catch (e) {
|
7687
|
+
return Promise.reject(e);
|
7688
|
+
}
|
7689
|
+
};
|
7690
|
+
|
7691
|
+
var _useContext3 = useContext(PageContext),
|
7692
|
+
pageContext = _useContext3[0],
|
7693
|
+
setPageContext = _useContext3[1];
|
7694
|
+
|
7695
|
+
var url = props.url,
|
7696
|
+
user = props.user;
|
7697
|
+
var _pageContext$queries = pageContext.queries,
|
7698
|
+
queries = _pageContext$queries === void 0 ? [] : _pageContext$queries;
|
7699
|
+
|
7700
|
+
var _useState2 = useState(),
|
7701
|
+
selected = _useState2[0],
|
7702
|
+
setSelected = _useState2[1];
|
7703
|
+
|
7704
|
+
function select(query) {
|
7705
|
+
setSelected(query.id);
|
7706
|
+
pageContext.changeFilters(query.filters);
|
7707
|
+
setPageContext(Object.assign({}, pageContext));
|
7708
|
+
}
|
7709
|
+
|
7710
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7711
|
+
className: "table-queries",
|
7712
|
+
title: /*#__PURE__*/React.createElement(Text, null, "Queries")
|
7713
|
+
}), /*#__PURE__*/React.createElement("main", {
|
7714
|
+
className: "table-queries"
|
7715
|
+
}, queries ? queries.filter(function (query) {
|
7716
|
+
return query.url === url;
|
7717
|
+
}).map(function (query) {
|
7718
|
+
var style = selected === query.id ? "selected" : "";
|
7719
|
+
return /*#__PURE__*/React.createElement("div", {
|
7720
|
+
className: "table-queries-item " + style,
|
7721
|
+
onClick: function onClick() {
|
7722
|
+
return select(query);
|
7723
|
+
}
|
7724
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7725
|
+
icon: "star",
|
7726
|
+
size: "small"
|
7727
|
+
}), /*#__PURE__*/React.createElement("label", null, query.name), /*#__PURE__*/React.createElement(Icon, {
|
7728
|
+
icon: "close",
|
7729
|
+
clickable: true,
|
7730
|
+
size: "small",
|
7731
|
+
action: function action() {
|
7732
|
+
return remove(query.id);
|
7733
|
+
}
|
7734
|
+
}));
|
7735
|
+
}) : /*#__PURE__*/React.createElement("div", null, "...empty...")));
|
7736
|
+
};
|
7737
|
+
/**
|
7738
|
+
* Table Filters
|
7739
|
+
*/
|
7740
|
+
|
7741
|
+
|
7742
|
+
var TableFilters$1 = function TableFilters(props) {
|
7743
|
+
var reload = function reload() {
|
7744
|
+
try {
|
7745
|
+
return Promise.resolve(pageContext.load(form)).then(function () {
|
7746
|
+
setPageContext(Object.assign({}, pageContext));
|
7747
|
+
});
|
7748
|
+
} catch (e) {
|
7749
|
+
return Promise.reject(e);
|
7750
|
+
}
|
7751
|
+
};
|
7752
|
+
|
7753
|
+
var change = function change(next) {
|
7754
|
+
try {
|
7755
|
+
setForm(next);
|
7756
|
+
return Promise.resolve();
|
7757
|
+
} catch (e) {
|
7758
|
+
return Promise.reject(e);
|
7759
|
+
}
|
7760
|
+
};
|
7761
|
+
|
7762
|
+
var _useContext4 = useContext(PageContext),
|
7763
|
+
pageContext = _useContext4[0],
|
7764
|
+
setPageContext = _useContext4[1];
|
7765
|
+
|
7766
|
+
var filters = pageContext.filters;
|
7767
|
+
var schema = props.schema,
|
7768
|
+
onSave = props.onSave;
|
7769
|
+
|
7770
|
+
var _useState3 = useState({}),
|
7771
|
+
form = _useState3[0],
|
7772
|
+
setForm = _useState3[1];
|
7773
|
+
|
7774
|
+
var filterSchema = useMemo(function () {
|
7775
|
+
var filterSchema = Object.assign({}, schema);
|
7776
|
+
|
7777
|
+
for (var key in filterSchema) {
|
7778
|
+
if (filterSchema[key].filter === false) {
|
7779
|
+
delete filterSchema[key];
|
7780
|
+
} else {
|
7781
|
+
if (filterSchema[key].type === TYPES.ENTITY) {
|
7782
|
+
var fs = filterSchema[key].item;
|
7783
|
+
|
7784
|
+
for (var key in fs) {
|
7785
|
+
if (fs[key].filter === false) delete fs[key];
|
7786
|
+
}
|
7787
|
+
}
|
7788
|
+
}
|
7789
|
+
} //Object.values(filterSchema).forEach(field => field.section = null)
|
7790
|
+
|
7791
|
+
|
7792
|
+
delete filterSchema.flows;
|
7793
|
+
return filterSchema;
|
7794
|
+
}, [schema]);
|
7795
|
+
useEffect(function () {
|
7796
|
+
if (filters) setForm(filters);
|
7797
|
+
}, [filters]);
|
7798
|
+
useEffect(function () {
|
7799
|
+
reload();
|
7800
|
+
}, [form]);
|
7801
|
+
|
7802
|
+
function clear() {
|
7803
|
+
change({});
|
7804
|
+
}
|
7805
|
+
|
7806
|
+
function save() {
|
7807
|
+
if (onSave) {
|
7808
|
+
onSave(form);
|
7809
|
+
}
|
7810
|
+
}
|
7811
|
+
|
7812
|
+
var content = new Content(filterSchema, form);
|
7813
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7814
|
+
className: "table-filters",
|
7815
|
+
title: /*#__PURE__*/React.createElement(Text, null, "Filters")
|
7816
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7817
|
+
icon: "filter_list_off",
|
7818
|
+
size: "small",
|
7819
|
+
clickable: true,
|
7820
|
+
action: clear
|
7821
|
+
}), onSave ? /*#__PURE__*/React.createElement(Icon, {
|
7822
|
+
icon: "save",
|
7823
|
+
size: "small",
|
7824
|
+
clickable: true,
|
7825
|
+
action: save
|
7826
|
+
}) : null), /*#__PURE__*/React.createElement("main", {
|
7827
|
+
className: "table-filters"
|
7828
|
+
}, /*#__PURE__*/React.createElement(ContentEditor, {
|
7829
|
+
content: content,
|
7830
|
+
onChange: change
|
7831
|
+
})));
|
7832
|
+
};
|
7833
|
+
/**
|
7834
|
+
* Table Editor
|
7835
|
+
*/
|
7836
|
+
|
7837
|
+
|
7838
|
+
var TableEditor$1 = function TableEditor(props) {
|
7839
|
+
var checkOne = function checkOne(id, field, value) {
|
7840
|
+
check([id], value);
|
7841
|
+
return Promise.resolve();
|
7842
|
+
};
|
7843
|
+
|
7844
|
+
var check = function check(ids, value) {
|
7845
|
+
try {
|
7846
|
+
pageContext.check(ids, value);
|
7847
|
+
setPageContext(Object.assign({}, pageContext));
|
7848
|
+
return Promise.resolve();
|
7849
|
+
} catch (e) {
|
7850
|
+
return Promise.reject(e);
|
7851
|
+
}
|
7852
|
+
};
|
7853
|
+
|
7854
|
+
var select = function select(row, event) {
|
7855
|
+
try {
|
7856
|
+
clear();
|
7857
|
+
return Promise.resolve(pageContext.select(row.id)).then(function () {
|
7858
|
+
setPageContext(Object.assign({}, pageContext));
|
7859
|
+
});
|
7860
|
+
} catch (e) {
|
7861
|
+
return Promise.reject(e);
|
7862
|
+
}
|
7863
|
+
};
|
7864
|
+
|
7865
|
+
var remove = function remove(id) {
|
7866
|
+
try {
|
7867
|
+
return Promise.resolve(site.confirm("Are you sure ?")).then(function (confirm) {
|
7868
|
+
var _temp3 = function () {
|
7869
|
+
if (confirm) {
|
7870
|
+
return Promise.resolve(pageContext.remove(id)).then(function () {
|
7871
|
+
pageContext.clear();
|
7872
|
+
setPageContext(Object.assign({}, pageContext));
|
7873
|
+
});
|
7874
|
+
}
|
7875
|
+
}();
|
7876
|
+
|
7877
|
+
if (_temp3 && _temp3.then) return _temp3.then(function () {});
|
7878
|
+
});
|
7879
|
+
} catch (e) {
|
7880
|
+
return Promise.reject(e);
|
7881
|
+
}
|
7882
|
+
};
|
7883
|
+
|
7884
|
+
var site = useContext(SiteContext);
|
7885
|
+
|
7886
|
+
var _useContext5 = useContext(PageContext),
|
7887
|
+
pageContext = _useContext5[0],
|
7888
|
+
setPageContext = _useContext5[1];
|
7889
|
+
|
7890
|
+
var _pageContext$all = pageContext.all,
|
7891
|
+
all = _pageContext$all === void 0 ? [] : _pageContext$all;
|
7892
|
+
var icon = props.icon,
|
7893
|
+
title = props.title,
|
7894
|
+
schema = props.schema,
|
7895
|
+
editable = props.editable,
|
7896
|
+
canDelete = props.canDelete,
|
7897
|
+
filter = props.filter,
|
7898
|
+
actions = props.actions,
|
7899
|
+
className = props.className;
|
7900
|
+
|
7901
|
+
var _useState4 = useState(props.groupBy),
|
7902
|
+
groupBy = _useState4[0],
|
7903
|
+
setGroupBy = _useState4[1];
|
7904
|
+
|
7905
|
+
function changeGroup(id, value) {
|
7906
|
+
setGroupBy(value);
|
7907
|
+
}
|
7908
|
+
|
7909
|
+
function change(rowID, cellID, value) {
|
7910
|
+
var _Object$assign;
|
7911
|
+
|
7912
|
+
var row = all.find(function (r) {
|
7913
|
+
return r.id === rowID;
|
7914
|
+
});
|
7915
|
+
var next = Object.assign({}, row, (_Object$assign = {}, _Object$assign[cellID] = value, _Object$assign));
|
7916
|
+
delete next.actions;
|
7917
|
+
pageContext.update(next);
|
7918
|
+
setPageContext(Object.assign({}, pageContext));
|
7919
|
+
}
|
7920
|
+
|
7921
|
+
function clear() {
|
7922
|
+
pageContext.clear();
|
7923
|
+
setPageContext(Object.assign({}, pageContext));
|
7924
|
+
}
|
7925
|
+
|
7926
|
+
function run(action, item) {
|
7927
|
+
action.action(item.id, pageContext, function () {
|
7928
|
+
try {
|
7929
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7930
|
+
setPageContext(Object.assign({}, pageContext));
|
7931
|
+
});
|
7932
|
+
} catch (e) {
|
7933
|
+
return Promise.reject(e);
|
7934
|
+
}
|
7935
|
+
});
|
7936
|
+
}
|
7937
|
+
|
7938
|
+
function buildGroupOptions(schema) {
|
7939
|
+
return Object.values(schema).filter(function (field) {
|
7940
|
+
return field.grouper === true;
|
7941
|
+
}).map(function (field) {
|
7942
|
+
return {
|
7943
|
+
label: field.label,
|
7944
|
+
value: field.id
|
7945
|
+
};
|
7946
|
+
});
|
7947
|
+
}
|
7948
|
+
|
7949
|
+
function renderGroupLabel(groupName) {
|
7950
|
+
var grouper = schema[groupBy];
|
7951
|
+
if (!groupName || !grouper) return "";
|
7952
|
+
|
7953
|
+
if (grouper.options) {
|
7954
|
+
var options = CHECK['isFunction'](grouper.options) ? grouper.options() : grouper.options;
|
7955
|
+
var option = options.find(function (option) {
|
7956
|
+
return option.value === groupName;
|
7957
|
+
});
|
7958
|
+
return option ? option.label : groupName;
|
7959
|
+
} else {
|
7960
|
+
return groupName;
|
7961
|
+
}
|
7962
|
+
}
|
7963
|
+
|
7964
|
+
var table = useMemo(function () {
|
7965
|
+
return {
|
7966
|
+
columns: Object.values(schema).filter(function (field) {
|
7967
|
+
return field.column === true;
|
7968
|
+
}).map(function (field) {
|
7969
|
+
var options = field.options;
|
7970
|
+
|
7971
|
+
if (options && typeof options == 'function') {
|
7972
|
+
options = options();
|
7973
|
+
}
|
7974
|
+
|
7975
|
+
return {
|
7976
|
+
id: field.id,
|
7977
|
+
label: field.label,
|
7978
|
+
type: field.type,
|
7979
|
+
format: field.format,
|
7980
|
+
item: field.item ? field.item : [],
|
7981
|
+
onChange: field.id === "checked" ? checkOne : field.editable ? change : null,
|
7982
|
+
|
7983
|
+
/* checked has it´s own handler */
|
7984
|
+
options: options
|
7985
|
+
};
|
7986
|
+
}),
|
7987
|
+
rows: []
|
7988
|
+
};
|
7989
|
+
}, [schema]);
|
7990
|
+
var items = filter ? filter(all) : all;
|
7991
|
+
if (items.length === 0) return /*#__PURE__*/React.createElement("div", {
|
7992
|
+
className: "empty-message"
|
7993
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7994
|
+
icon: "search_off"
|
7995
|
+
}), /*#__PURE__*/React.createElement(Text, null, "No Result Found"));
|
7996
|
+
var groups = items.reduce(function (groups, item) {
|
7997
|
+
var groupName = item[groupBy];
|
7998
|
+
if (!groups[groupName]) groups[groupName] = [];
|
7999
|
+
groups[groupName].push(item);
|
8000
|
+
return groups;
|
8001
|
+
}, {});
|
8002
|
+
var sections = Object.keys(groups).map(function (groupName) {
|
8003
|
+
var rows = groups[groupName].map(function (item) {
|
8004
|
+
item.checked = pageContext.checked ? pageContext.checked.has(item.id) : false;
|
8005
|
+
item.actions = actions ? actions.map(function (_action2) {
|
8006
|
+
return _action2.filter ? _action2.filter(item) ? /*#__PURE__*/React.createElement(Icon, {
|
8007
|
+
icon: _action2.icon,
|
8008
|
+
clickable: true,
|
8009
|
+
size: "small",
|
8010
|
+
action: function action() {
|
8011
|
+
return run(_action2, item);
|
8012
|
+
}
|
8013
|
+
}) : null : /*#__PURE__*/React.createElement(Icon, {
|
8014
|
+
icon: _action2.icon,
|
8015
|
+
clickable: true,
|
8016
|
+
size: "small",
|
8017
|
+
action: function action() {
|
8018
|
+
return run(_action2, item);
|
8019
|
+
}
|
8020
|
+
});
|
8021
|
+
}) : [];
|
8022
|
+
if (canDelete) item.actions.push( /*#__PURE__*/React.createElement(Icon, {
|
8023
|
+
icon: "delete",
|
8024
|
+
size: "small",
|
8025
|
+
clickable: true,
|
8026
|
+
action: function action() {
|
8027
|
+
return remove(item.id);
|
8028
|
+
}
|
8029
|
+
}));
|
8030
|
+
return item;
|
8031
|
+
});
|
8032
|
+
table.rows = rows;
|
8033
|
+
return {
|
8034
|
+
id: groupName,
|
8035
|
+
checked: false,
|
8036
|
+
title: renderGroupLabel(groupName),
|
8037
|
+
info: groups[groupName].length,
|
8038
|
+
open: true,
|
8039
|
+
children: /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
|
8040
|
+
onRowSelection: select,
|
8041
|
+
editable: editable,
|
8042
|
+
onCheckAll: check,
|
8043
|
+
className: className
|
8044
|
+
}))
|
8045
|
+
};
|
8046
|
+
});
|
8047
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
8048
|
+
icon: icon,
|
8049
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
8050
|
+
}, groupBy ? /*#__PURE__*/React.createElement(DropDown, {
|
8051
|
+
id: "groupBy",
|
8052
|
+
label: "Agrupar Por",
|
8053
|
+
value: groupBy,
|
8054
|
+
options: buildGroupOptions(schema),
|
8055
|
+
onChange: changeGroup
|
8056
|
+
}) : null), /*#__PURE__*/React.createElement("main", {
|
8057
|
+
className: "table-editor"
|
8058
|
+
}, /*#__PURE__*/React.createElement(Accordion, {
|
8059
|
+
sections: sections
|
8060
|
+
})));
|
8061
|
+
};
|
8062
|
+
/**
|
8063
|
+
* Table Context
|
8064
|
+
*/
|
8065
|
+
|
6948
8066
|
var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
6949
8067
|
var API = TableAPI$1(url, host, params);
|
6950
8068
|
return {
|
@@ -8289,5 +9407,5 @@ var isFunction = function isFunction(value) {
|
|
8289
9407
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
8290
9408
|
};
|
8291
9409
|
|
8292
|
-
export { Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionFilters, CollectionPage, CollectionTree, Content, ContentEditor, ContentForm, CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FORMATS, FieldEditor, FileExplorer, FileIconsView, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$
|
9410
|
+
export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionFilters, CollectionPage, CollectionTree, Content, ContentEditor, ContentForm, CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FORMATS, FieldEditor, FileExplorer, FileIconsView, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, Text, TextArea, TextField, Thumbnail, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, isFunction };
|
8293
9411
|
//# sourceMappingURL=index.modern.js.map
|