ywana-core8 0.0.571 → 0.0.574
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 +1261 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +38 -1
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +1260 -150
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1261 -149
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.css +1 -0
- package/src/domain/ContentEditor.js +16 -4
- package/src/domain/TablePage.js +8 -1
- package/src/domain/TablePage2.js +679 -0
- package/src/domain/index.js +1 -0
- package/src/domain2/Content.js +33 -0
- package/src/domain2/ContentFilters.js +74 -0
- package/src/domain2/ContentPage.js +96 -0
- package/src/domain2/FORMATS.js +15 -0
- package/src/domain2/TYPES.js +11 -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/site/site.test.js +16 -16
- package/src/widgets/planner/Planner.js +16 -17
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, useRef, useMemo, 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
|
@@ -2797,9 +2890,14 @@ var Planner = function Planner(_ref) {
|
|
2797
2890
|
to = _useState3[0],
|
2798
2891
|
setTo = _useState3[1];
|
2799
2892
|
|
2893
|
+
var thisMondayElement = useRef(null);
|
2800
2894
|
useEffect(function () {
|
2801
|
-
|
2802
|
-
|
2895
|
+
console.log(thisMondayElement.current);
|
2896
|
+
|
2897
|
+
if (thisMondayElement.current) {
|
2898
|
+
showThisWeek();
|
2899
|
+
}
|
2900
|
+
});
|
2803
2901
|
useEffect(function () {
|
2804
2902
|
var element = document.getElementById(focusEvent);
|
2805
2903
|
if (element) element.scrollIntoView({
|
@@ -2953,7 +3051,8 @@ var Planner = function Planner(_ref) {
|
|
2953
3051
|
events: events,
|
2954
3052
|
period: period,
|
2955
3053
|
onSelectCell: selectCell,
|
2956
|
-
onChange: onChange
|
3054
|
+
onChange: onChange,
|
3055
|
+
thisMondayRef: thisMondayElement
|
2957
3056
|
});
|
2958
3057
|
}))));
|
2959
3058
|
};
|
@@ -2967,7 +3066,8 @@ var PlannerRow = function PlannerRow(props) {
|
|
2967
3066
|
events = _props$events === void 0 ? [] : _props$events,
|
2968
3067
|
period = props.period,
|
2969
3068
|
onSelectCell = props.onSelectCell,
|
2970
|
-
onChange = props.onChange
|
3069
|
+
onChange = props.onChange,
|
3070
|
+
thisMondayRef = props.thisMondayRef;
|
2971
3071
|
var rowEvents = events.filter(function (event) {
|
2972
3072
|
return event.lane === lane.id;
|
2973
3073
|
});
|
@@ -2992,7 +3092,8 @@ var PlannerRow = function PlannerRow(props) {
|
|
2992
3092
|
date: date,
|
2993
3093
|
events: cellEvents,
|
2994
3094
|
onSelect: onSelectCell,
|
2995
|
-
onDrop: change
|
3095
|
+
onDrop: change,
|
3096
|
+
thisMondayRef: thisMondayRef
|
2996
3097
|
});
|
2997
3098
|
}));
|
2998
3099
|
};
|
@@ -3006,7 +3107,8 @@ var PlannerCell = function PlannerCell(_ref2) {
|
|
3006
3107
|
events = _ref2.events,
|
3007
3108
|
date = _ref2.date,
|
3008
3109
|
onSelect = _ref2.onSelect,
|
3009
|
-
onDrop = _ref2.onDrop
|
3110
|
+
onDrop = _ref2.onDrop,
|
3111
|
+
thisMondayRef = _ref2.thisMondayRef;
|
3010
3112
|
|
3011
3113
|
var _useState4 = useState(false),
|
3012
3114
|
dragOver = _useState4[0],
|
@@ -3044,10 +3146,12 @@ var PlannerCell = function PlannerCell(_ref2) {
|
|
3044
3146
|
var weekend = isWekend ? "weekend" : "";
|
3045
3147
|
var today = moment$1();
|
3046
3148
|
var weekStart = today.clone().startOf('week');
|
3149
|
+
var isThisMonday = date.moment.isSame(weekStart);
|
3047
3150
|
var thisMonday = date.moment.isSame(weekStart) ? "thisMonday" : "";
|
3048
3151
|
var dragOverStyle = dragOver ? "drag-over" : "";
|
3049
3152
|
return /*#__PURE__*/React.createElement("div", {
|
3050
3153
|
className: "cell " + thisMonday + " " + weekend + " " + dragOverStyle,
|
3154
|
+
ref: isThisMonday ? thisMondayRef : null,
|
3051
3155
|
onDragOver: onDragOver,
|
3052
3156
|
onDragLeave: onDragLeave,
|
3053
3157
|
onDrop: drop,
|
@@ -4192,13 +4296,13 @@ var ContentEditor = function ContentEditor(_ref) {
|
|
4192
4296
|
* Tabbed Content Editor
|
4193
4297
|
*/
|
4194
4298
|
|
4195
|
-
var TabbedContentEditor = function TabbedContentEditor(
|
4196
|
-
var content =
|
4197
|
-
filter =
|
4198
|
-
|
4199
|
-
grouped =
|
4200
|
-
onChange =
|
4201
|
-
onReload =
|
4299
|
+
var TabbedContentEditor = function TabbedContentEditor(_ref3) {
|
4300
|
+
var content = _ref3.content,
|
4301
|
+
filter = _ref3.filter,
|
4302
|
+
_ref3$grouped = _ref3.grouped,
|
4303
|
+
grouped = _ref3$grouped === void 0 ? false : _ref3$grouped,
|
4304
|
+
onChange = _ref3.onChange,
|
4305
|
+
onReload = _ref3.onReload;
|
4202
4306
|
|
4203
4307
|
var _useState = useState(0),
|
4204
4308
|
tab = _useState[0],
|
@@ -4283,9 +4387,9 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4283
4387
|
* TreededContentEditor
|
4284
4388
|
*/
|
4285
4389
|
|
4286
|
-
var TreededContentEditor = function TreededContentEditor(
|
4287
|
-
var content =
|
4288
|
-
onChange =
|
4390
|
+
var TreededContentEditor = function TreededContentEditor(_ref4) {
|
4391
|
+
var content = _ref4.content,
|
4392
|
+
onChange = _ref4.onChange;
|
4289
4393
|
var value = content.value();
|
4290
4394
|
var nodes = Object.values(content.type).filter(function (field) {
|
4291
4395
|
return field.type === TYPES.ARRAY;
|
@@ -4350,13 +4454,13 @@ var TreededContentEditor = function TreededContentEditor(_ref3) {
|
|
4350
4454
|
* FieldEditor
|
4351
4455
|
*/
|
4352
4456
|
|
4353
|
-
var FieldEditor = function FieldEditor(
|
4354
|
-
var field =
|
4355
|
-
onChange =
|
4356
|
-
content =
|
4357
|
-
|
4358
|
-
outlined =
|
4359
|
-
onReload =
|
4457
|
+
var FieldEditor = function FieldEditor(_ref5) {
|
4458
|
+
var field = _ref5.field,
|
4459
|
+
onChange = _ref5.onChange,
|
4460
|
+
content = _ref5.content,
|
4461
|
+
_ref5$outlined = _ref5.outlined,
|
4462
|
+
outlined = _ref5$outlined === void 0 ? false : _ref5$outlined,
|
4463
|
+
onReload = _ref5.onReload;
|
4360
4464
|
var id = field.id,
|
4361
4465
|
type = field.type,
|
4362
4466
|
item = field.item,
|
@@ -4443,11 +4547,11 @@ var FieldEditor = function FieldEditor(_ref4) {
|
|
4443
4547
|
* Entity Editor
|
4444
4548
|
*/
|
4445
4549
|
|
4446
|
-
var EntityEditor = function EntityEditor(
|
4447
|
-
var field =
|
4448
|
-
|
4449
|
-
value =
|
4450
|
-
onChange =
|
4550
|
+
var EntityEditor = function EntityEditor(_ref6) {
|
4551
|
+
var field = _ref6.field,
|
4552
|
+
_ref6$value = _ref6.value,
|
4553
|
+
value = _ref6$value === void 0 ? {} : _ref6$value,
|
4554
|
+
onChange = _ref6.onChange;
|
4451
4555
|
var id = field.id,
|
4452
4556
|
item = field.item,
|
4453
4557
|
label = field.label;
|
@@ -4507,13 +4611,13 @@ var EntityEditor = function EntityEditor(_ref5) {
|
|
4507
4611
|
*/
|
4508
4612
|
|
4509
4613
|
|
4510
|
-
var StringEditor = function StringEditor(
|
4511
|
-
var field =
|
4512
|
-
|
4513
|
-
value =
|
4514
|
-
onChange =
|
4515
|
-
content =
|
4516
|
-
outlined =
|
4614
|
+
var StringEditor = function StringEditor(_ref7) {
|
4615
|
+
var field = _ref7.field,
|
4616
|
+
_ref7$value = _ref7.value,
|
4617
|
+
value = _ref7$value === void 0 ? '' : _ref7$value,
|
4618
|
+
onChange = _ref7.onChange,
|
4619
|
+
content = _ref7.content,
|
4620
|
+
outlined = _ref7.outlined;
|
4517
4621
|
var id = field.id,
|
4518
4622
|
format = field.format,
|
4519
4623
|
label = field.label,
|
@@ -4629,12 +4733,12 @@ var StringEditor = function StringEditor(_ref6) {
|
|
4629
4733
|
* Number Editor
|
4630
4734
|
*/
|
4631
4735
|
|
4632
|
-
var NumberEditor = function NumberEditor(
|
4633
|
-
var field =
|
4634
|
-
value =
|
4635
|
-
onChange =
|
4636
|
-
|
4637
|
-
outlined =
|
4736
|
+
var NumberEditor = function NumberEditor(_ref8) {
|
4737
|
+
var field = _ref8.field,
|
4738
|
+
value = _ref8.value,
|
4739
|
+
onChange = _ref8.onChange,
|
4740
|
+
_ref8$outlined = _ref8.outlined,
|
4741
|
+
outlined = _ref8$outlined === void 0 ? false : _ref8$outlined;
|
4638
4742
|
var id = field.id,
|
4639
4743
|
label = field.label,
|
4640
4744
|
_field$editable2 = field.editable,
|
@@ -4667,11 +4771,11 @@ var NumberEditor = function NumberEditor(_ref7) {
|
|
4667
4771
|
*/
|
4668
4772
|
|
4669
4773
|
|
4670
|
-
var ListEditor = function ListEditor(
|
4671
|
-
var field =
|
4672
|
-
|
4673
|
-
value =
|
4674
|
-
onChange =
|
4774
|
+
var ListEditor = function ListEditor(_ref9) {
|
4775
|
+
var field = _ref9.field,
|
4776
|
+
_ref9$value = _ref9.value,
|
4777
|
+
value = _ref9$value === void 0 ? [] : _ref9$value,
|
4778
|
+
onChange = _ref9.onChange;
|
4675
4779
|
var label = field.label;
|
4676
4780
|
|
4677
4781
|
function change(id, value) {
|
@@ -4691,12 +4795,12 @@ var ListEditor = function ListEditor(_ref8) {
|
|
4691
4795
|
* Multi Selection Editor
|
4692
4796
|
*/
|
4693
4797
|
|
4694
|
-
var MultiSelectionEditor = function MultiSelectionEditor(
|
4695
|
-
var field =
|
4696
|
-
|
4697
|
-
value =
|
4698
|
-
content =
|
4699
|
-
onChange =
|
4798
|
+
var MultiSelectionEditor = function MultiSelectionEditor(_ref10) {
|
4799
|
+
var field = _ref10.field,
|
4800
|
+
_ref10$value = _ref10.value,
|
4801
|
+
value = _ref10$value === void 0 ? [] : _ref10$value,
|
4802
|
+
content = _ref10.content,
|
4803
|
+
onChange = _ref10.onChange;
|
4700
4804
|
var id = field.id,
|
4701
4805
|
label = field.label,
|
4702
4806
|
options = field.options;
|
@@ -4735,15 +4839,17 @@ var MultiSelectionEditor = function MultiSelectionEditor(_ref9) {
|
|
4735
4839
|
* Collection Editor
|
4736
4840
|
*/
|
4737
4841
|
|
4738
|
-
var CollectionEditor$1 = function CollectionEditor(
|
4739
|
-
var field =
|
4740
|
-
|
4741
|
-
value =
|
4742
|
-
onChange =
|
4743
|
-
onReload =
|
4842
|
+
var CollectionEditor$1 = function CollectionEditor(_ref11) {
|
4843
|
+
var field = _ref11.field,
|
4844
|
+
_ref11$value = _ref11.value,
|
4845
|
+
value = _ref11$value === void 0 ? [] : _ref11$value,
|
4846
|
+
onChange = _ref11.onChange,
|
4847
|
+
onReload = _ref11.onReload;
|
4744
4848
|
var id = field.id,
|
4745
4849
|
item = field.item,
|
4746
4850
|
label = field.label,
|
4851
|
+
_field$groupBy = field.groupBy,
|
4852
|
+
groupBy = _field$groupBy === void 0 ? "field1" : _field$groupBy,
|
4747
4853
|
Feeder = field.Feeder,
|
4748
4854
|
Renderer = field.Renderer,
|
4749
4855
|
_field$Adder = field.Adder,
|
@@ -4765,42 +4871,24 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4765
4871
|
}
|
4766
4872
|
}
|
4767
4873
|
|
4768
|
-
function change(index, cellId, cellValue) {
|
4769
|
-
if (onChange) {
|
4770
|
-
var next = value.slice();
|
4771
|
-
next[index][cellId] = cellValue;
|
4772
|
-
onChange(id, next);
|
4773
|
-
}
|
4774
|
-
}
|
4775
|
-
|
4776
4874
|
function reload() {
|
4777
4875
|
if (onReload) onReload();
|
4778
4876
|
}
|
4877
|
+
/* const columns = Object.values(item)
|
4878
|
+
.filter(field => field.column === true)
|
4879
|
+
.map((item) => ({ ...item, onChange: change }))
|
4880
|
+
columns.push({ id: 'actions', label: 'Actions' })
|
4881
|
+
const rows = value.map((item, index) => ({
|
4882
|
+
...item,
|
4883
|
+
id: index,
|
4884
|
+
actions: [
|
4885
|
+
<Icon icon='delete' clickable action={() => remove(index)} size="small" />
|
4886
|
+
]
|
4887
|
+
}))
|
4888
|
+
const table = { columns, rows }
|
4889
|
+
*/
|
4890
|
+
|
4779
4891
|
|
4780
|
-
var columns = Object.values(item).filter(function (field) {
|
4781
|
-
return field.column === true;
|
4782
|
-
}).map(function (item) {
|
4783
|
-
return _extends({}, item, {
|
4784
|
-
onChange: change
|
4785
|
-
});
|
4786
|
-
});
|
4787
|
-
columns.push({
|
4788
|
-
id: 'actions',
|
4789
|
-
label: 'Actions'
|
4790
|
-
});
|
4791
|
-
value.map(function (item, index) {
|
4792
|
-
return _extends({}, item, {
|
4793
|
-
id: index,
|
4794
|
-
actions: [/*#__PURE__*/React.createElement(Icon, {
|
4795
|
-
icon: "delete",
|
4796
|
-
clickable: true,
|
4797
|
-
action: function action() {
|
4798
|
-
return remove(index);
|
4799
|
-
},
|
4800
|
-
size: "small"
|
4801
|
-
})]
|
4802
|
-
});
|
4803
|
-
});
|
4804
4892
|
return /*#__PURE__*/React.createElement("div", {
|
4805
4893
|
className: "collection-editor"
|
4806
4894
|
}, Renderer ? /*#__PURE__*/React.createElement(Renderer, {
|
@@ -4810,12 +4898,12 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4810
4898
|
onChange: onChange,
|
4811
4899
|
onReload: reload
|
4812
4900
|
}) // : <DataTable {...table} editable={editable} />
|
4813
|
-
: /*#__PURE__*/React.createElement(TableEditor$
|
4901
|
+
: /*#__PURE__*/React.createElement(TableEditor$3, {
|
4814
4902
|
icon: "info",
|
4815
4903
|
title: label,
|
4816
4904
|
data: value,
|
4817
4905
|
schema: item,
|
4818
|
-
groupBy:
|
4906
|
+
groupBy: groupBy,
|
4819
4907
|
canDelete: true,
|
4820
4908
|
remove: remove
|
4821
4909
|
}), /*#__PURE__*/React.createElement("footer", null, Feeder ? /*#__PURE__*/React.createElement(Feeder, {
|
@@ -4830,9 +4918,9 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4830
4918
|
* Collection Adder
|
4831
4919
|
*/
|
4832
4920
|
|
4833
|
-
var CollectionAdder = function CollectionAdder(
|
4834
|
-
var item =
|
4835
|
-
onAdd =
|
4921
|
+
var CollectionAdder = function CollectionAdder(_ref12) {
|
4922
|
+
var item = _ref12.item,
|
4923
|
+
onAdd = _ref12.onAdd;
|
4836
4924
|
|
4837
4925
|
var _useState3 = useState(false),
|
4838
4926
|
edit = _useState3[0],
|
@@ -4901,7 +4989,7 @@ var CollectionAdder = function CollectionAdder(_ref11) {
|
|
4901
4989
|
*/
|
4902
4990
|
|
4903
4991
|
|
4904
|
-
var TableEditor$
|
4992
|
+
var TableEditor$3 = function TableEditor(props) {
|
4905
4993
|
var select = function select(row) {
|
4906
4994
|
try {
|
4907
4995
|
if (onSelect) onSelect(row.id);
|
@@ -5245,7 +5333,7 @@ var EditContentDialog = function EditContentDialog(_ref) {
|
|
5245
5333
|
* Collection Page
|
5246
5334
|
*/
|
5247
5335
|
|
5248
|
-
function _catch$
|
5336
|
+
function _catch$3(body, recover) {
|
5249
5337
|
try {
|
5250
5338
|
var result = body();
|
5251
5339
|
} catch (e) {
|
@@ -5822,7 +5910,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5822
5910
|
try {
|
5823
5911
|
var _this2 = this;
|
5824
5912
|
|
5825
|
-
var _temp2 = _catch$
|
5913
|
+
var _temp2 = _catch$3(function () {
|
5826
5914
|
return Promise.resolve(API.all(null, page)).then(function (data) {
|
5827
5915
|
_this2.all = field ? data[field] : data;
|
5828
5916
|
});
|
@@ -5871,7 +5959,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5871
5959
|
},
|
5872
5960
|
fetch: function fetch(id) {
|
5873
5961
|
try {
|
5874
|
-
return Promise.resolve(_catch$
|
5962
|
+
return Promise.resolve(_catch$3(function () {
|
5875
5963
|
return Promise.resolve(API.find(id));
|
5876
5964
|
}, function (error) {
|
5877
5965
|
console.log(error);
|
@@ -5887,7 +5975,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5887
5975
|
try {
|
5888
5976
|
var _this8 = this;
|
5889
5977
|
|
5890
|
-
var _temp6 = _catch$
|
5978
|
+
var _temp6 = _catch$3(function () {
|
5891
5979
|
return Promise.resolve(API.create(form)).then(function () {
|
5892
5980
|
return Promise.resolve(_this8.load()).then(function () {});
|
5893
5981
|
});
|
@@ -5904,7 +5992,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5904
5992
|
try {
|
5905
5993
|
var _this10 = this;
|
5906
5994
|
|
5907
|
-
var _temp8 = _catch$
|
5995
|
+
var _temp8 = _catch$3(function () {
|
5908
5996
|
return Promise.resolve(API.update(form)).then(function () {
|
5909
5997
|
return Promise.resolve(_this10.load()).then(function () {});
|
5910
5998
|
});
|
@@ -5921,7 +6009,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5921
6009
|
try {
|
5922
6010
|
var _this12 = this;
|
5923
6011
|
|
5924
|
-
var _temp10 = _catch$
|
6012
|
+
var _temp10 = _catch$3(function () {
|
5925
6013
|
return Promise.resolve(API.patch(id, form)).then(function () {
|
5926
6014
|
return Promise.resolve(_this12.load()).then(function () {});
|
5927
6015
|
});
|
@@ -5938,7 +6026,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5938
6026
|
try {
|
5939
6027
|
var _this14 = this;
|
5940
6028
|
|
5941
|
-
var _temp12 = _catch$
|
6029
|
+
var _temp12 = _catch$3(function () {
|
5942
6030
|
return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
|
5943
6031
|
return Promise.resolve(_this14.load()).then(function () {});
|
5944
6032
|
});
|
@@ -5955,7 +6043,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
5955
6043
|
try {
|
5956
6044
|
var _this16 = this;
|
5957
6045
|
|
5958
|
-
var _temp14 = _catch$
|
6046
|
+
var _temp14 = _catch$3(function () {
|
5959
6047
|
return Promise.resolve(API.remove(id)).then(function () {
|
5960
6048
|
return Promise.resolve(_this16.load()).then(function () {});
|
5961
6049
|
});
|
@@ -6168,7 +6256,7 @@ var QUERY = {
|
|
6168
6256
|
* Table Page
|
6169
6257
|
*/
|
6170
6258
|
|
6171
|
-
function _catch$
|
6259
|
+
function _catch$2(body, recover) {
|
6172
6260
|
try {
|
6173
6261
|
var result = body();
|
6174
6262
|
} catch (e) {
|
@@ -6295,7 +6383,7 @@ var TablePage = function TablePage(props) {
|
|
6295
6383
|
pageContext = _useContext[0],
|
6296
6384
|
setPageContext = _useContext[1];
|
6297
6385
|
|
6298
|
-
var context = TableContext$
|
6386
|
+
var context = TableContext$2(url, field, host, urlQuery, params);
|
6299
6387
|
var selected = pageContext.selected;
|
6300
6388
|
var timer = useRef(null);
|
6301
6389
|
|
@@ -6395,13 +6483,13 @@ var TablePage = function TablePage(props) {
|
|
6395
6483
|
if (rowSelected || rowChecked) {
|
6396
6484
|
return /*#__PURE__*/React.createElement("aside", {
|
6397
6485
|
className: "table-page"
|
6398
|
-
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$
|
6486
|
+
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$2, {
|
6399
6487
|
content: new Content(schema, form),
|
6400
6488
|
filter: editorFilter,
|
6401
6489
|
onChange: change,
|
6402
6490
|
onClose: closeAside,
|
6403
6491
|
editable: canEdit
|
6404
|
-
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$
|
6492
|
+
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$2, {
|
6405
6493
|
schema: schema,
|
6406
6494
|
actions: selectionActions
|
6407
6495
|
}) : null);
|
@@ -6442,17 +6530,17 @@ var TablePage = function TablePage(props) {
|
|
6442
6530
|
onSelect: playScenario
|
6443
6531
|
})) : null, renderActions()), canQuery || canFilter ? /*#__PURE__*/React.createElement("menu", {
|
6444
6532
|
className: "table-page"
|
6445
|
-
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$
|
6533
|
+
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$2, {
|
6446
6534
|
schema: schema,
|
6447
6535
|
url: url,
|
6448
6536
|
user: user
|
6449
|
-
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$
|
6537
|
+
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$2, {
|
6450
6538
|
schema: schema,
|
6451
6539
|
onSave: canQuery ? saveQuery : null
|
6452
6540
|
}) : null) : null, /*#__PURE__*/React.createElement("main", {
|
6453
6541
|
key: id,
|
6454
6542
|
className: "table-page"
|
6455
|
-
}, /*#__PURE__*/React.createElement(TableEditor$
|
6543
|
+
}, /*#__PURE__*/React.createElement(TableEditor$2, {
|
6456
6544
|
icon: icon,
|
6457
6545
|
title: name,
|
6458
6546
|
schema: schema,
|
@@ -6466,7 +6554,7 @@ var TablePage = function TablePage(props) {
|
|
6466
6554
|
}), children ? /*#__PURE__*/React.createElement("article", null, children) : null), renderAside());
|
6467
6555
|
};
|
6468
6556
|
|
6469
|
-
var TableRowEditor$
|
6557
|
+
var TableRowEditor$2 = function TableRowEditor(props) {
|
6470
6558
|
var name = props.name,
|
6471
6559
|
content = props.content,
|
6472
6560
|
filter = props.filter,
|
@@ -6495,7 +6583,7 @@ var TableRowEditor$1 = function TableRowEditor(props) {
|
|
6495
6583
|
*/
|
6496
6584
|
|
6497
6585
|
|
6498
|
-
var TableSelector$
|
6586
|
+
var TableSelector$2 = function TableSelector(props) {
|
6499
6587
|
var schema = props.schema,
|
6500
6588
|
_props$actions2 = props.actions,
|
6501
6589
|
actions = _props$actions2 === void 0 ? [] : _props$actions2;
|
@@ -6533,8 +6621,10 @@ var TableSelector$1 = function TableSelector(props) {
|
|
6533
6621
|
action: function action() {
|
6534
6622
|
return _action(checked, pageContext, function () {
|
6535
6623
|
try {
|
6536
|
-
return Promise.resolve(pageContext.
|
6537
|
-
|
6624
|
+
return Promise.resolve(pageContext.clearChecks()).then(function () {
|
6625
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
6626
|
+
setPageContext(Object.assign({}, pageContext));
|
6627
|
+
});
|
6538
6628
|
});
|
6539
6629
|
} catch (e) {
|
6540
6630
|
return Promise.reject(e);
|
@@ -6558,7 +6648,7 @@ var TableSelector$1 = function TableSelector(props) {
|
|
6558
6648
|
*/
|
6559
6649
|
|
6560
6650
|
|
6561
|
-
var TableQueries$
|
6651
|
+
var TableQueries$2 = function TableQueries(props) {
|
6562
6652
|
var remove = function remove(id) {
|
6563
6653
|
try {
|
6564
6654
|
return Promise.resolve(pageContext.removeQuery(id, user)).then(function () {
|
@@ -6620,7 +6710,7 @@ var TableQueries$1 = function TableQueries(props) {
|
|
6620
6710
|
*/
|
6621
6711
|
|
6622
6712
|
|
6623
|
-
var TableFilters$
|
6713
|
+
var TableFilters$2 = function TableFilters(props) {
|
6624
6714
|
var reload = function reload() {
|
6625
6715
|
try {
|
6626
6716
|
return Promise.resolve(pageContext.load(form)).then(function () {
|
@@ -6716,7 +6806,7 @@ var TableFilters$1 = function TableFilters(props) {
|
|
6716
6806
|
*/
|
6717
6807
|
|
6718
6808
|
|
6719
|
-
var TableEditor$
|
6809
|
+
var TableEditor$2 = function TableEditor(props) {
|
6720
6810
|
var checkOne = function checkOne(id, field, value) {
|
6721
6811
|
check([id], value);
|
6722
6812
|
return Promise.resolve();
|
@@ -6948,8 +7038,8 @@ var TableEditor$1 = function TableEditor(props) {
|
|
6948
7038
|
* Table Context
|
6949
7039
|
*/
|
6950
7040
|
|
6951
|
-
var TableContext$
|
6952
|
-
var API = TableAPI$
|
7041
|
+
var TableContext$2 = function TableContext(url, field, host, urlQuery, params) {
|
7042
|
+
var API = TableAPI$2(url, host, params);
|
6953
7043
|
return {
|
6954
7044
|
all: [],
|
6955
7045
|
checked: new Set([]),
|
@@ -6960,7 +7050,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
6960
7050
|
try {
|
6961
7051
|
var _this2 = this;
|
6962
7052
|
|
6963
|
-
var _temp5 = _catch$
|
7053
|
+
var _temp5 = _catch$2(function () {
|
6964
7054
|
var filters = filter ? Object.keys(filter).reduce(function (filters, key) {
|
6965
7055
|
var field = filter[key];
|
6966
7056
|
|
@@ -7006,6 +7096,9 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7006
7096
|
});
|
7007
7097
|
}
|
7008
7098
|
},
|
7099
|
+
clearChecks: function clearChecks() {
|
7100
|
+
this.checked = new Set([]);
|
7101
|
+
},
|
7009
7102
|
select: function select(id) {
|
7010
7103
|
var result = this.all.find(function (item) {
|
7011
7104
|
return item.id === id;
|
@@ -7019,7 +7112,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7019
7112
|
try {
|
7020
7113
|
var _this5 = this;
|
7021
7114
|
|
7022
|
-
var _temp7 = _catch$
|
7115
|
+
var _temp7 = _catch$2(function () {
|
7023
7116
|
return Promise.resolve(API.create(form)).then(function () {
|
7024
7117
|
return Promise.resolve(_this5.load()).then(function () {});
|
7025
7118
|
});
|
@@ -7036,7 +7129,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7036
7129
|
try {
|
7037
7130
|
var _this7 = this;
|
7038
7131
|
|
7039
|
-
var _temp9 = _catch$
|
7132
|
+
var _temp9 = _catch$2(function () {
|
7040
7133
|
return Promise.resolve(API.update(form)).then(function () {
|
7041
7134
|
return Promise.resolve(_this7.load()).then(function () {});
|
7042
7135
|
});
|
@@ -7053,7 +7146,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7053
7146
|
try {
|
7054
7147
|
var _this9 = this;
|
7055
7148
|
|
7056
|
-
var _temp11 = _catch$
|
7149
|
+
var _temp11 = _catch$2(function () {
|
7057
7150
|
return Promise.resolve(API.remove(id)).then(function () {
|
7058
7151
|
return Promise.resolve(_this9.load()).then(function () {});
|
7059
7152
|
});
|
@@ -7073,7 +7166,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7073
7166
|
try {
|
7074
7167
|
var _this11 = this;
|
7075
7168
|
|
7076
|
-
var _temp13 = _catch$
|
7169
|
+
var _temp13 = _catch$2(function () {
|
7077
7170
|
return Promise.resolve(API.queries(user, urlQuery)).then(function (_API$queries) {
|
7078
7171
|
_this11.queries = _API$queries;
|
7079
7172
|
});
|
@@ -7090,7 +7183,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7090
7183
|
try {
|
7091
7184
|
var _this13 = this;
|
7092
7185
|
|
7093
|
-
var _temp15 = _catch$
|
7186
|
+
var _temp15 = _catch$2(function () {
|
7094
7187
|
return Promise.resolve(API.createQuery(query, urlQuery)).then(function () {
|
7095
7188
|
return Promise.resolve(_this13.loadQueries(user)).then(function () {});
|
7096
7189
|
});
|
@@ -7107,7 +7200,7 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7107
7200
|
try {
|
7108
7201
|
var _this15 = this;
|
7109
7202
|
|
7110
|
-
var _temp17 = _catch$
|
7203
|
+
var _temp17 = _catch$2(function () {
|
7111
7204
|
return Promise.resolve(API.removeQuery(id, urlQuery)).then(function () {
|
7112
7205
|
return Promise.resolve(_this15.loadQueries(user)).then(function () {});
|
7113
7206
|
});
|
@@ -7127,6 +7220,1023 @@ var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
|
7127
7220
|
*/
|
7128
7221
|
|
7129
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 save = function save() {
|
7310
|
+
try {
|
7311
|
+
return Promise.resolve(pageContext.update(form)).then(function () {
|
7312
|
+
setPageContext(Object.assign({}, pageContext));
|
7313
|
+
});
|
7314
|
+
} catch (e) {
|
7315
|
+
return Promise.reject(e);
|
7316
|
+
}
|
7317
|
+
};
|
7318
|
+
|
7319
|
+
var reload = function reload() {
|
7320
|
+
try {
|
7321
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7322
|
+
setPageContext(Object.assign({}, pageContext));
|
7323
|
+
});
|
7324
|
+
} catch (e) {
|
7325
|
+
return Promise.reject(e);
|
7326
|
+
}
|
7327
|
+
};
|
7328
|
+
|
7329
|
+
var site = useContext(SiteContext);
|
7330
|
+
var _props$id = props.id,
|
7331
|
+
id = _props$id === void 0 ? "table" : _props$id,
|
7332
|
+
icon = props.icon,
|
7333
|
+
title = props.title,
|
7334
|
+
name = props.name,
|
7335
|
+
schema = props.schema,
|
7336
|
+
url = props.url,
|
7337
|
+
field = props.field,
|
7338
|
+
host = props.host,
|
7339
|
+
_props$params = props.params,
|
7340
|
+
params = _props$params === void 0 ? "" : _props$params,
|
7341
|
+
_props$canQuery = props.canQuery,
|
7342
|
+
canQuery = _props$canQuery === void 0 ? false : _props$canQuery,
|
7343
|
+
urlQuery = props.urlQuery,
|
7344
|
+
user = props.user,
|
7345
|
+
editable = props.editable,
|
7346
|
+
_props$autosave = props.autosave,
|
7347
|
+
autosave = _props$autosave === void 0 ? true : _props$autosave,
|
7348
|
+
_props$delay = props.delay,
|
7349
|
+
delay = _props$delay === void 0 ? 1000 : _props$delay,
|
7350
|
+
_props$actions = props.actions,
|
7351
|
+
actions = _props$actions === void 0 ? [] : _props$actions,
|
7352
|
+
tableActions = props.tableActions,
|
7353
|
+
_props$selectionActio = props.selectionActions,
|
7354
|
+
selectionActions = _props$selectionActio === void 0 ? [] : _props$selectionActio,
|
7355
|
+
_props$canFilter = props.canFilter,
|
7356
|
+
canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
|
7357
|
+
_props$canAdd = props.canAdd,
|
7358
|
+
canAdd = _props$canAdd === void 0 ? true : _props$canAdd,
|
7359
|
+
_props$canDelete = props.canDelete,
|
7360
|
+
canDelete = _props$canDelete === void 0 ? true : _props$canDelete,
|
7361
|
+
_props$canEdit = props.canEdit,
|
7362
|
+
canEdit = _props$canEdit === void 0 ? true : _props$canEdit,
|
7363
|
+
groupBy = props.groupBy,
|
7364
|
+
validator = props.validator,
|
7365
|
+
formFilter = props.formFilter,
|
7366
|
+
tableFilter = props.tableFilter,
|
7367
|
+
_props$editorFilter = props.editorFilter,
|
7368
|
+
editorFilter = _props$editorFilter === void 0 ? false : _props$editorFilter,
|
7369
|
+
tabbedBy = props.tabbedBy,
|
7370
|
+
tableClassName = props.tableClassName,
|
7371
|
+
children = props.children;
|
7372
|
+
|
7373
|
+
var _useContext = useContext(PageContext),
|
7374
|
+
setPageContext = _useContext[1];
|
7375
|
+
|
7376
|
+
var context = TableContext$1(url, field, host, urlQuery, params);
|
7377
|
+
var _pageContext = pageContext,
|
7378
|
+
selected = _pageContext.selected;
|
7379
|
+
var timer = useRef(null);
|
7380
|
+
|
7381
|
+
var _useState = useState(selected),
|
7382
|
+
form = _useState[0],
|
7383
|
+
setForm = _useState[1];
|
7384
|
+
|
7385
|
+
useEffect(function () {
|
7386
|
+
try {
|
7387
|
+
return Promise.resolve(context.load()).then(function () {
|
7388
|
+
function _temp2() {
|
7389
|
+
setPageContext(context);
|
7390
|
+
}
|
7391
|
+
|
7392
|
+
var _temp = function () {
|
7393
|
+
if (canQuery) return Promise.resolve(context.loadQueries(user)).then(function () {});
|
7394
|
+
}();
|
7395
|
+
|
7396
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
7397
|
+
});
|
7398
|
+
} catch (e) {
|
7399
|
+
return Promise.reject(e);
|
7400
|
+
}
|
7401
|
+
}, []);
|
7402
|
+
useEffect(function () {
|
7403
|
+
setForm(selected);
|
7404
|
+
}, [selected]);
|
7405
|
+
useEffect(function () {
|
7406
|
+
if (autosave) {
|
7407
|
+
clearTimeout(timer.current);
|
7408
|
+
timer.current = setTimeout(function () {
|
7409
|
+
if (canSave()) save();
|
7410
|
+
}, delay);
|
7411
|
+
}
|
7412
|
+
}, [form]);
|
7413
|
+
|
7414
|
+
function add() {
|
7415
|
+
var onOK = function onOK(form) {
|
7416
|
+
try {
|
7417
|
+
return Promise.resolve(pageContext.create(form)).then(function () {
|
7418
|
+
setPageContext(Object.assign({}, pageContext));
|
7419
|
+
});
|
7420
|
+
} catch (e) {
|
7421
|
+
return Promise.reject(e);
|
7422
|
+
}
|
7423
|
+
};
|
7424
|
+
|
7425
|
+
site.openDialog( /*#__PURE__*/React.createElement(CreateContentDialog, {
|
7426
|
+
label: "Crear " + name,
|
7427
|
+
type: schema,
|
7428
|
+
onOK: onOK,
|
7429
|
+
validator: validator,
|
7430
|
+
filter: formFilter
|
7431
|
+
}));
|
7432
|
+
}
|
7433
|
+
|
7434
|
+
function saveQuery(filters) {
|
7435
|
+
var onOK = function onOK(form) {
|
7436
|
+
try {
|
7437
|
+
form.filters = filters;
|
7438
|
+
form.layout = {};
|
7439
|
+
form.user = user;
|
7440
|
+
form.url = url;
|
7441
|
+
return Promise.resolve(pageContext.createQuery(form, user)).then(function () {
|
7442
|
+
setPageContext(Object.assign({}, pageContext));
|
7443
|
+
});
|
7444
|
+
} catch (e) {
|
7445
|
+
return Promise.reject(e);
|
7446
|
+
}
|
7447
|
+
};
|
7448
|
+
|
7449
|
+
site.openDialog( /*#__PURE__*/React.createElement(CreateContentDialog, {
|
7450
|
+
label: "Nueva query",
|
7451
|
+
type: QUERY,
|
7452
|
+
onOK: onOK
|
7453
|
+
}));
|
7454
|
+
}
|
7455
|
+
|
7456
|
+
function change(next) {
|
7457
|
+
setForm(next);
|
7458
|
+
}
|
7459
|
+
|
7460
|
+
function canSave() {
|
7461
|
+
var can = !equal(form, selected);
|
7462
|
+
return can;
|
7463
|
+
}
|
7464
|
+
|
7465
|
+
function closeAside() {
|
7466
|
+
pageContext.select(null);
|
7467
|
+
setPageContext(Object.assign({}, pageContext));
|
7468
|
+
}
|
7469
|
+
|
7470
|
+
function renderAside() {
|
7471
|
+
var rowSelected = selected && form;
|
7472
|
+
var rowChecked = pageContext.checked && pageContext.checked.size > 0;
|
7473
|
+
|
7474
|
+
if (rowSelected || rowChecked) {
|
7475
|
+
return /*#__PURE__*/React.createElement("aside", {
|
7476
|
+
className: "table-page"
|
7477
|
+
}, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor$1, {
|
7478
|
+
content: new Content(schema, form),
|
7479
|
+
filter: editorFilter,
|
7480
|
+
onChange: change,
|
7481
|
+
onClose: closeAside,
|
7482
|
+
editable: canEdit
|
7483
|
+
}) : null, rowChecked ? /*#__PURE__*/React.createElement(TableSelector$1, {
|
7484
|
+
schema: schema,
|
7485
|
+
actions: selectionActions
|
7486
|
+
}) : null);
|
7487
|
+
}
|
7488
|
+
|
7489
|
+
return null;
|
7490
|
+
}
|
7491
|
+
|
7492
|
+
function renderActions() {
|
7493
|
+
return actions.map(function (element) {
|
7494
|
+
var action = function action() {
|
7495
|
+
return element.props.action(pageContext);
|
7496
|
+
};
|
7497
|
+
|
7498
|
+
var clone = React.cloneElement(element, {
|
7499
|
+
action: action
|
7500
|
+
});
|
7501
|
+
return clone;
|
7502
|
+
});
|
7503
|
+
}
|
7504
|
+
|
7505
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7506
|
+
className: "table-page",
|
7507
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
7508
|
+
}, canAdd ? /*#__PURE__*/React.createElement(Button, {
|
7509
|
+
icon: "add",
|
7510
|
+
label: "A\xF1adir",
|
7511
|
+
action: add,
|
7512
|
+
raised: true
|
7513
|
+
}) : null, "\xA0", /*#__PURE__*/React.createElement(Button, {
|
7514
|
+
icon: "refresh",
|
7515
|
+
label: "Reload",
|
7516
|
+
action: reload
|
7517
|
+
}), renderActions()), canQuery || canFilter ? /*#__PURE__*/React.createElement("menu", {
|
7518
|
+
className: "table-page"
|
7519
|
+
}, canQuery ? /*#__PURE__*/React.createElement(TableQueries$1, {
|
7520
|
+
schema: schema,
|
7521
|
+
url: url,
|
7522
|
+
user: user
|
7523
|
+
}) : null, canFilter ? /*#__PURE__*/React.createElement(TableFilters$1, {
|
7524
|
+
schema: schema,
|
7525
|
+
onSave: canQuery ? saveQuery : null
|
7526
|
+
}) : null) : null, /*#__PURE__*/React.createElement("main", {
|
7527
|
+
key: id,
|
7528
|
+
className: "table-page"
|
7529
|
+
}, /*#__PURE__*/React.createElement(TableEditor$1, {
|
7530
|
+
icon: icon,
|
7531
|
+
title: name,
|
7532
|
+
schema: schema,
|
7533
|
+
delay: delay,
|
7534
|
+
editable: editable,
|
7535
|
+
tabbedBy: tabbedBy,
|
7536
|
+
groupBy: groupBy,
|
7537
|
+
filter: tableFilter,
|
7538
|
+
actions: tableActions,
|
7539
|
+
canDelete: canDelete,
|
7540
|
+
className: tableClassName
|
7541
|
+
}), children ? /*#__PURE__*/React.createElement("article", null, children) : null), renderAside());
|
7542
|
+
};
|
7543
|
+
|
7544
|
+
var TableRowEditor$1 = function TableRowEditor(props) {
|
7545
|
+
var name = props.name,
|
7546
|
+
content = props.content,
|
7547
|
+
filter = props.filter,
|
7548
|
+
editable = props.editable,
|
7549
|
+
onChange = props.onChange,
|
7550
|
+
onClose = props.onClose;
|
7551
|
+
return /*#__PURE__*/React.createElement("div", {
|
7552
|
+
className: "table-row-editor"
|
7553
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
7554
|
+
icon: "local_offer",
|
7555
|
+
title: name || "Propiedades"
|
7556
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7557
|
+
icon: "close",
|
7558
|
+
clickable: true,
|
7559
|
+
action: onClose
|
7560
|
+
})), /*#__PURE__*/React.createElement("main", null, editable ? /*#__PURE__*/React.createElement(ContentEditor, {
|
7561
|
+
content: content,
|
7562
|
+
onChange: onChange,
|
7563
|
+
filter: filter
|
7564
|
+
}) : /*#__PURE__*/React.createElement(ContentViewer, {
|
7565
|
+
content: content
|
7566
|
+
})));
|
7567
|
+
};
|
7568
|
+
/**
|
7569
|
+
* Table Selector
|
7570
|
+
*/
|
7571
|
+
|
7572
|
+
|
7573
|
+
var TableSelector$1 = function TableSelector(props) {
|
7574
|
+
var schema = props.schema,
|
7575
|
+
_props$actions2 = props.actions,
|
7576
|
+
actions = _props$actions2 === void 0 ? [] : _props$actions2;
|
7577
|
+
|
7578
|
+
var _useContext2 = useContext(PageContext),
|
7579
|
+
pageContext = _useContext2[0],
|
7580
|
+
setPageContext = _useContext2[1];
|
7581
|
+
|
7582
|
+
var all = pageContext.all,
|
7583
|
+
checked = pageContext.checked;
|
7584
|
+
var count = checked.size + "/" + all.length;
|
7585
|
+
var columns = Object.keys(schema).filter(function (key) {
|
7586
|
+
return schema[key].selectorColumn === true;
|
7587
|
+
}).map(function (key) {
|
7588
|
+
var field = schema[key];
|
7589
|
+
return {
|
7590
|
+
id: field.id,
|
7591
|
+
label: field.label
|
7592
|
+
};
|
7593
|
+
});
|
7594
|
+
var rows = all.filter(function (item) {
|
7595
|
+
return checked.has(item.id);
|
7596
|
+
});
|
7597
|
+
var table = {
|
7598
|
+
columns: columns,
|
7599
|
+
rows: rows || []
|
7600
|
+
};
|
7601
|
+
var buttons = actions.map(function (_ref) {
|
7602
|
+
var label = _ref.label,
|
7603
|
+
_action = _ref.action,
|
7604
|
+
validate = _ref.validate;
|
7605
|
+
return /*#__PURE__*/React.createElement(Button, {
|
7606
|
+
label: label,
|
7607
|
+
raised: true,
|
7608
|
+
action: function action() {
|
7609
|
+
return _action(checked, pageContext, function () {
|
7610
|
+
try {
|
7611
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7612
|
+
setPageContext(Object.assign({}, pageContext));
|
7613
|
+
});
|
7614
|
+
} catch (e) {
|
7615
|
+
return Promise.reject(e);
|
7616
|
+
}
|
7617
|
+
}, rows);
|
7618
|
+
},
|
7619
|
+
disabled: !validate(checked, rows)
|
7620
|
+
});
|
7621
|
+
});
|
7622
|
+
return /*#__PURE__*/React.createElement("div", {
|
7623
|
+
className: "table-selector"
|
7624
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
7625
|
+
icon: "checklist_rtl",
|
7626
|
+
title: "Selecci\xF3n"
|
7627
|
+
}, /*#__PURE__*/React.createElement("span", {
|
7628
|
+
className: "size"
|
7629
|
+
}, count)), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(DataTable, table)), /*#__PURE__*/React.createElement("footer", null, buttons));
|
7630
|
+
};
|
7631
|
+
/**
|
7632
|
+
* Table Queries
|
7633
|
+
*/
|
7634
|
+
|
7635
|
+
|
7636
|
+
var TableQueries$1 = function TableQueries(props) {
|
7637
|
+
var remove = function remove(id) {
|
7638
|
+
try {
|
7639
|
+
return Promise.resolve(pageContext.removeQuery(id, user)).then(function () {
|
7640
|
+
setPageContext(Object.assign({}, pageContext));
|
7641
|
+
});
|
7642
|
+
} catch (e) {
|
7643
|
+
return Promise.reject(e);
|
7644
|
+
}
|
7645
|
+
};
|
7646
|
+
|
7647
|
+
var _useContext3 = useContext(PageContext),
|
7648
|
+
pageContext = _useContext3[0],
|
7649
|
+
setPageContext = _useContext3[1];
|
7650
|
+
|
7651
|
+
var url = props.url,
|
7652
|
+
user = props.user;
|
7653
|
+
var _pageContext$queries = pageContext.queries,
|
7654
|
+
queries = _pageContext$queries === void 0 ? [] : _pageContext$queries;
|
7655
|
+
|
7656
|
+
var _useState2 = useState(),
|
7657
|
+
selected = _useState2[0],
|
7658
|
+
setSelected = _useState2[1];
|
7659
|
+
|
7660
|
+
function select(query) {
|
7661
|
+
setSelected(query.id);
|
7662
|
+
pageContext.changeFilters(query.filters);
|
7663
|
+
setPageContext(Object.assign({}, pageContext));
|
7664
|
+
}
|
7665
|
+
|
7666
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7667
|
+
className: "table-queries",
|
7668
|
+
title: /*#__PURE__*/React.createElement(Text, null, "Queries")
|
7669
|
+
}), /*#__PURE__*/React.createElement("main", {
|
7670
|
+
className: "table-queries"
|
7671
|
+
}, queries ? queries.filter(function (query) {
|
7672
|
+
return query.url === url;
|
7673
|
+
}).map(function (query) {
|
7674
|
+
var style = selected === query.id ? "selected" : "";
|
7675
|
+
return /*#__PURE__*/React.createElement("div", {
|
7676
|
+
className: "table-queries-item " + style,
|
7677
|
+
onClick: function onClick() {
|
7678
|
+
return select(query);
|
7679
|
+
}
|
7680
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7681
|
+
icon: "star",
|
7682
|
+
size: "small"
|
7683
|
+
}), /*#__PURE__*/React.createElement("label", null, query.name), /*#__PURE__*/React.createElement(Icon, {
|
7684
|
+
icon: "close",
|
7685
|
+
clickable: true,
|
7686
|
+
size: "small",
|
7687
|
+
action: function action() {
|
7688
|
+
return remove(query.id);
|
7689
|
+
}
|
7690
|
+
}));
|
7691
|
+
}) : /*#__PURE__*/React.createElement("div", null, "...empty...")));
|
7692
|
+
};
|
7693
|
+
/**
|
7694
|
+
* Table Filters
|
7695
|
+
*/
|
7696
|
+
|
7697
|
+
|
7698
|
+
var TableFilters$1 = function TableFilters(props) {
|
7699
|
+
var reload = function reload() {
|
7700
|
+
try {
|
7701
|
+
return Promise.resolve(pageContext.load(form)).then(function () {
|
7702
|
+
setPageContext(Object.assign({}, pageContext));
|
7703
|
+
});
|
7704
|
+
} catch (e) {
|
7705
|
+
return Promise.reject(e);
|
7706
|
+
}
|
7707
|
+
};
|
7708
|
+
|
7709
|
+
var change = function change(next) {
|
7710
|
+
try {
|
7711
|
+
setForm(next);
|
7712
|
+
return Promise.resolve();
|
7713
|
+
} catch (e) {
|
7714
|
+
return Promise.reject(e);
|
7715
|
+
}
|
7716
|
+
};
|
7717
|
+
|
7718
|
+
var _useContext4 = useContext(PageContext),
|
7719
|
+
pageContext = _useContext4[0],
|
7720
|
+
setPageContext = _useContext4[1];
|
7721
|
+
|
7722
|
+
var filters = pageContext.filters;
|
7723
|
+
var schema = props.schema,
|
7724
|
+
onSave = props.onSave;
|
7725
|
+
|
7726
|
+
var _useState3 = useState({}),
|
7727
|
+
form = _useState3[0],
|
7728
|
+
setForm = _useState3[1];
|
7729
|
+
|
7730
|
+
var filterSchema = useMemo(function () {
|
7731
|
+
var filterSchema = Object.assign({}, schema);
|
7732
|
+
|
7733
|
+
for (var key in filterSchema) {
|
7734
|
+
if (filterSchema[key].filter === false) {
|
7735
|
+
delete filterSchema[key];
|
7736
|
+
} else {
|
7737
|
+
if (filterSchema[key].type === TYPES.ENTITY) {
|
7738
|
+
var fs = filterSchema[key].item;
|
7739
|
+
|
7740
|
+
for (var key in fs) {
|
7741
|
+
if (fs[key].filter === false) delete fs[key];
|
7742
|
+
}
|
7743
|
+
}
|
7744
|
+
}
|
7745
|
+
} //Object.values(filterSchema).forEach(field => field.section = null)
|
7746
|
+
|
7747
|
+
|
7748
|
+
delete filterSchema.flows;
|
7749
|
+
return filterSchema;
|
7750
|
+
}, [schema]);
|
7751
|
+
useEffect(function () {
|
7752
|
+
if (filters) setForm(filters);
|
7753
|
+
}, [filters]);
|
7754
|
+
useEffect(function () {
|
7755
|
+
reload();
|
7756
|
+
}, [form]);
|
7757
|
+
|
7758
|
+
function clear() {
|
7759
|
+
change({});
|
7760
|
+
}
|
7761
|
+
|
7762
|
+
function save() {
|
7763
|
+
if (onSave) {
|
7764
|
+
onSave(form);
|
7765
|
+
}
|
7766
|
+
}
|
7767
|
+
|
7768
|
+
var content = new Content(filterSchema, form);
|
7769
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
7770
|
+
className: "table-filters",
|
7771
|
+
title: /*#__PURE__*/React.createElement(Text, null, "Filters")
|
7772
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7773
|
+
icon: "filter_list_off",
|
7774
|
+
size: "small",
|
7775
|
+
clickable: true,
|
7776
|
+
action: clear
|
7777
|
+
}), onSave ? /*#__PURE__*/React.createElement(Icon, {
|
7778
|
+
icon: "save",
|
7779
|
+
size: "small",
|
7780
|
+
clickable: true,
|
7781
|
+
action: save
|
7782
|
+
}) : null), /*#__PURE__*/React.createElement("main", {
|
7783
|
+
className: "table-filters"
|
7784
|
+
}, /*#__PURE__*/React.createElement(ContentEditor, {
|
7785
|
+
content: content,
|
7786
|
+
onChange: change
|
7787
|
+
})));
|
7788
|
+
};
|
7789
|
+
/**
|
7790
|
+
* Table Editor
|
7791
|
+
*/
|
7792
|
+
|
7793
|
+
|
7794
|
+
var TableEditor$1 = function TableEditor(props) {
|
7795
|
+
var checkOne = function checkOne(id, field, value) {
|
7796
|
+
check([id], value);
|
7797
|
+
return Promise.resolve();
|
7798
|
+
};
|
7799
|
+
|
7800
|
+
var check = function check(ids, value) {
|
7801
|
+
try {
|
7802
|
+
pageContext.check(ids, value);
|
7803
|
+
setPageContext(Object.assign({}, pageContext));
|
7804
|
+
return Promise.resolve();
|
7805
|
+
} catch (e) {
|
7806
|
+
return Promise.reject(e);
|
7807
|
+
}
|
7808
|
+
};
|
7809
|
+
|
7810
|
+
var select = function select(row, event) {
|
7811
|
+
try {
|
7812
|
+
clear();
|
7813
|
+
return Promise.resolve(pageContext.select(row.id)).then(function () {
|
7814
|
+
setPageContext(Object.assign({}, pageContext));
|
7815
|
+
});
|
7816
|
+
} catch (e) {
|
7817
|
+
return Promise.reject(e);
|
7818
|
+
}
|
7819
|
+
};
|
7820
|
+
|
7821
|
+
var remove = function remove(id) {
|
7822
|
+
try {
|
7823
|
+
return Promise.resolve(site.confirm("Are you sure ?")).then(function (confirm) {
|
7824
|
+
var _temp5 = function () {
|
7825
|
+
if (confirm) {
|
7826
|
+
return Promise.resolve(pageContext.remove(id)).then(function () {
|
7827
|
+
pageContext.clear();
|
7828
|
+
setPageContext(Object.assign({}, pageContext));
|
7829
|
+
});
|
7830
|
+
}
|
7831
|
+
}();
|
7832
|
+
|
7833
|
+
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
7834
|
+
});
|
7835
|
+
} catch (e) {
|
7836
|
+
return Promise.reject(e);
|
7837
|
+
}
|
7838
|
+
};
|
7839
|
+
|
7840
|
+
var site = useContext(SiteContext);
|
7841
|
+
|
7842
|
+
var _useContext5 = useContext(PageContext),
|
7843
|
+
pageContext = _useContext5[0],
|
7844
|
+
setPageContext = _useContext5[1];
|
7845
|
+
|
7846
|
+
var _pageContext$all = pageContext.all,
|
7847
|
+
all = _pageContext$all === void 0 ? [] : _pageContext$all;
|
7848
|
+
var icon = props.icon,
|
7849
|
+
title = props.title,
|
7850
|
+
schema = props.schema,
|
7851
|
+
editable = props.editable,
|
7852
|
+
canDelete = props.canDelete,
|
7853
|
+
filter = props.filter,
|
7854
|
+
actions = props.actions,
|
7855
|
+
className = props.className;
|
7856
|
+
|
7857
|
+
var _useState4 = useState(props.groupBy),
|
7858
|
+
groupBy = _useState4[0],
|
7859
|
+
setGroupBy = _useState4[1];
|
7860
|
+
|
7861
|
+
var _useState5 = useState(0),
|
7862
|
+
tab = _useState5[0];
|
7863
|
+
|
7864
|
+
useEffect(function () {
|
7865
|
+
try {
|
7866
|
+
var _temp4 = function () {
|
7867
|
+
if (tab) {
|
7868
|
+
var _filter2;
|
7869
|
+
|
7870
|
+
var _filter = (_filter2 = {}, _filter2[tab.field] = tab.value, _filter2);
|
7871
|
+
|
7872
|
+
return Promise.resolve(pageContext.load(_filter, [])).then(function () {
|
7873
|
+
setPageContext(Object.assign({}, pageContext));
|
7874
|
+
});
|
7875
|
+
}
|
7876
|
+
}();
|
7877
|
+
|
7878
|
+
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
|
7879
|
+
} catch (e) {
|
7880
|
+
return Promise.reject(e);
|
7881
|
+
}
|
7882
|
+
}, [tab]);
|
7883
|
+
|
7884
|
+
function changeGroup(id, value) {
|
7885
|
+
setGroupBy(value);
|
7886
|
+
}
|
7887
|
+
|
7888
|
+
function change(rowID, cellID, value) {
|
7889
|
+
var _Object$assign;
|
7890
|
+
|
7891
|
+
var row = all.find(function (r) {
|
7892
|
+
return r.id === rowID;
|
7893
|
+
});
|
7894
|
+
var next = Object.assign({}, row, (_Object$assign = {}, _Object$assign[cellID] = value, _Object$assign));
|
7895
|
+
delete next.actions;
|
7896
|
+
pageContext.update(next);
|
7897
|
+
setPageContext(Object.assign({}, pageContext));
|
7898
|
+
}
|
7899
|
+
|
7900
|
+
function clear() {
|
7901
|
+
pageContext.clear();
|
7902
|
+
setPageContext(Object.assign({}, pageContext));
|
7903
|
+
}
|
7904
|
+
|
7905
|
+
function run(action, item) {
|
7906
|
+
action.action(item.id, pageContext, function () {
|
7907
|
+
try {
|
7908
|
+
return Promise.resolve(pageContext.load()).then(function () {
|
7909
|
+
setPageContext(Object.assign({}, pageContext));
|
7910
|
+
});
|
7911
|
+
} catch (e) {
|
7912
|
+
return Promise.reject(e);
|
7913
|
+
}
|
7914
|
+
});
|
7915
|
+
}
|
7916
|
+
|
7917
|
+
function buildGroupOptions(schema) {
|
7918
|
+
return Object.values(schema).filter(function (field) {
|
7919
|
+
return field.grouper === true;
|
7920
|
+
}).map(function (field) {
|
7921
|
+
return {
|
7922
|
+
label: field.label,
|
7923
|
+
value: field.id
|
7924
|
+
};
|
7925
|
+
});
|
7926
|
+
}
|
7927
|
+
|
7928
|
+
function renderGroupLabel(groupName) {
|
7929
|
+
var grouper = schema[groupBy];
|
7930
|
+
if (!groupName || !grouper) return "";
|
7931
|
+
|
7932
|
+
if (grouper.options) {
|
7933
|
+
var options = CHECK['isFunction'](grouper.options) ? grouper.options() : grouper.options;
|
7934
|
+
var option = options.find(function (option) {
|
7935
|
+
return option.value === groupName;
|
7936
|
+
});
|
7937
|
+
return option ? option.label : groupName;
|
7938
|
+
} else {
|
7939
|
+
return groupName;
|
7940
|
+
}
|
7941
|
+
}
|
7942
|
+
|
7943
|
+
var tabField = Object.values(schema).find(function (field) {
|
7944
|
+
return field.tab === true;
|
7945
|
+
});
|
7946
|
+
var tabs = tabField ? tabField.options.map(function (option) {
|
7947
|
+
return Object.assign({}, option, {
|
7948
|
+
field: tabField.id
|
7949
|
+
});
|
7950
|
+
}) : [];
|
7951
|
+
var table = useMemo(function () {
|
7952
|
+
return {
|
7953
|
+
columns: Object.values(schema).filter(function (field) {
|
7954
|
+
return field.column === true;
|
7955
|
+
}).map(function (field) {
|
7956
|
+
var options = field.options;
|
7957
|
+
|
7958
|
+
if (options && typeof options == 'function') {
|
7959
|
+
options = options();
|
7960
|
+
}
|
7961
|
+
|
7962
|
+
return {
|
7963
|
+
id: field.id,
|
7964
|
+
label: field.label,
|
7965
|
+
type: field.type,
|
7966
|
+
format: field.format,
|
7967
|
+
item: field.item ? field.item : [],
|
7968
|
+
onChange: field.id === "checked" ? checkOne : field.editable ? change : null,
|
7969
|
+
|
7970
|
+
/* checked has it´s own handler */
|
7971
|
+
options: options
|
7972
|
+
};
|
7973
|
+
}),
|
7974
|
+
rows: []
|
7975
|
+
};
|
7976
|
+
}, [schema]);
|
7977
|
+
var items = filter ? filter(all) : all;
|
7978
|
+
if (items.length === 0) return /*#__PURE__*/React.createElement("div", {
|
7979
|
+
className: "empty-message"
|
7980
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
7981
|
+
icon: "search_off"
|
7982
|
+
}), /*#__PURE__*/React.createElement(Text, null, "No Result Found"));
|
7983
|
+
var groups = items.reduce(function (groups, item) {
|
7984
|
+
var groupName = item[groupBy];
|
7985
|
+
if (!groups[groupName]) groups[groupName] = [];
|
7986
|
+
groups[groupName].push(item);
|
7987
|
+
return groups;
|
7988
|
+
}, {});
|
7989
|
+
var sections = Object.keys(groups).map(function (groupName) {
|
7990
|
+
var rows = groups[groupName].map(function (item) {
|
7991
|
+
item.checked = pageContext.checked ? pageContext.checked.has(item.id) : false;
|
7992
|
+
item.actions = actions ? actions.map(function (_action2) {
|
7993
|
+
return _action2.filter ? _action2.filter(item) ? /*#__PURE__*/React.createElement(Icon, {
|
7994
|
+
icon: _action2.icon,
|
7995
|
+
clickable: true,
|
7996
|
+
size: "small",
|
7997
|
+
action: function action() {
|
7998
|
+
return run(_action2, item);
|
7999
|
+
}
|
8000
|
+
}) : null : /*#__PURE__*/React.createElement(Icon, {
|
8001
|
+
icon: _action2.icon,
|
8002
|
+
clickable: true,
|
8003
|
+
size: "small",
|
8004
|
+
action: function action() {
|
8005
|
+
return run(_action2, item);
|
8006
|
+
}
|
8007
|
+
});
|
8008
|
+
}) : [];
|
8009
|
+
if (canDelete) item.actions.push( /*#__PURE__*/React.createElement(Icon, {
|
8010
|
+
icon: "delete",
|
8011
|
+
size: "small",
|
8012
|
+
clickable: true,
|
8013
|
+
action: function action() {
|
8014
|
+
return remove(item.id);
|
8015
|
+
}
|
8016
|
+
}));
|
8017
|
+
return item;
|
8018
|
+
});
|
8019
|
+
table.rows = rows;
|
8020
|
+
return {
|
8021
|
+
id: groupName,
|
8022
|
+
checked: false,
|
8023
|
+
title: renderGroupLabel(groupName),
|
8024
|
+
info: groups[groupName].length,
|
8025
|
+
open: true,
|
8026
|
+
children: /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
|
8027
|
+
onRowSelection: select,
|
8028
|
+
editable: editable,
|
8029
|
+
onCheckAll: check,
|
8030
|
+
className: className
|
8031
|
+
}))
|
8032
|
+
};
|
8033
|
+
});
|
8034
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
8035
|
+
icon: icon,
|
8036
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
8037
|
+
}, groupBy ? /*#__PURE__*/React.createElement(DropDown, {
|
8038
|
+
id: "groupBy",
|
8039
|
+
label: "Agrupar Por",
|
8040
|
+
value: groupBy,
|
8041
|
+
options: buildGroupOptions(schema),
|
8042
|
+
onChange: changeGroup
|
8043
|
+
}) : null, tabbedBy ? /*#__PURE__*/React.createElement(Tabs, {
|
8044
|
+
fillRight: true,
|
8045
|
+
fillLeft: false
|
8046
|
+
}, tabs.map(function (tab) {
|
8047
|
+
return /*#__PURE__*/React.createElement(Tab, {
|
8048
|
+
id: tab.value,
|
8049
|
+
label: tab.label
|
8050
|
+
});
|
8051
|
+
})) : ''), /*#__PURE__*/React.createElement("main", {
|
8052
|
+
className: "table-editor"
|
8053
|
+
}, /*#__PURE__*/React.createElement(Accordion, {
|
8054
|
+
sections: sections
|
8055
|
+
})));
|
8056
|
+
};
|
8057
|
+
/**
|
8058
|
+
* Table Context
|
8059
|
+
*/
|
8060
|
+
|
8061
|
+
var TableContext$1 = function TableContext(url, field, host, urlQuery, params) {
|
8062
|
+
var API = TableAPI$1(url, host, params);
|
8063
|
+
return {
|
8064
|
+
all: [],
|
8065
|
+
checked: new Set([]),
|
8066
|
+
selected: null,
|
8067
|
+
filters: {},
|
8068
|
+
queries: [],
|
8069
|
+
load: function load(filter) {
|
8070
|
+
try {
|
8071
|
+
var _this2 = this;
|
8072
|
+
|
8073
|
+
var _temp7 = _catch$1(function () {
|
8074
|
+
var filters = filter ? Object.keys(filter).reduce(function (filters, key) {
|
8075
|
+
var field = filter[key];
|
8076
|
+
|
8077
|
+
if (field) {
|
8078
|
+
if (CHECK['isObject'](field)) {
|
8079
|
+
Object.keys(field).forEach(function (key2) {
|
8080
|
+
var subfield = field[key2];
|
8081
|
+
if (subfield) filters[key + "." + key2] = subfield;
|
8082
|
+
});
|
8083
|
+
} else {
|
8084
|
+
filters[key] = field;
|
8085
|
+
}
|
8086
|
+
}
|
8087
|
+
|
8088
|
+
return filters;
|
8089
|
+
}, {}) : [];
|
8090
|
+
return Promise.resolve(API.all(filters)).then(function (data) {
|
8091
|
+
_this2.all = field ? data[field] : data;
|
8092
|
+
});
|
8093
|
+
}, function (error) {
|
8094
|
+
console.log(error);
|
8095
|
+
});
|
8096
|
+
|
8097
|
+
return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
|
8098
|
+
} catch (e) {
|
8099
|
+
return Promise.reject(e);
|
8100
|
+
}
|
8101
|
+
},
|
8102
|
+
check: function check(ids, isChecked) {
|
8103
|
+
var _this3 = this;
|
8104
|
+
|
8105
|
+
if (isChecked === void 0) {
|
8106
|
+
isChecked = true;
|
8107
|
+
}
|
8108
|
+
|
8109
|
+
if (isChecked) {
|
8110
|
+
ids.forEach(function (id) {
|
8111
|
+
return _this3.checked.add(id);
|
8112
|
+
});
|
8113
|
+
} else {
|
8114
|
+
ids.forEach(function (id) {
|
8115
|
+
return _this3.checked["delete"](id);
|
8116
|
+
});
|
8117
|
+
}
|
8118
|
+
},
|
8119
|
+
select: function select(id) {
|
8120
|
+
var result = this.all.find(function (item) {
|
8121
|
+
return item.id === id;
|
8122
|
+
});
|
8123
|
+
this.selected = result;
|
8124
|
+
},
|
8125
|
+
clear: function clear() {
|
8126
|
+
this.selected = null;
|
8127
|
+
},
|
8128
|
+
create: function create(form) {
|
8129
|
+
try {
|
8130
|
+
var _this5 = this;
|
8131
|
+
|
8132
|
+
var _temp9 = _catch$1(function () {
|
8133
|
+
return Promise.resolve(API.create(form)).then(function () {
|
8134
|
+
return Promise.resolve(_this5.load()).then(function () {});
|
8135
|
+
});
|
8136
|
+
}, function (error) {
|
8137
|
+
console.log(error);
|
8138
|
+
});
|
8139
|
+
|
8140
|
+
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
|
8141
|
+
} catch (e) {
|
8142
|
+
return Promise.reject(e);
|
8143
|
+
}
|
8144
|
+
},
|
8145
|
+
update: function update(form) {
|
8146
|
+
try {
|
8147
|
+
var _this7 = this;
|
8148
|
+
|
8149
|
+
var _temp11 = _catch$1(function () {
|
8150
|
+
return Promise.resolve(API.update(form)).then(function () {
|
8151
|
+
return Promise.resolve(_this7.load()).then(function () {});
|
8152
|
+
});
|
8153
|
+
}, function (error) {
|
8154
|
+
console.log(error);
|
8155
|
+
});
|
8156
|
+
|
8157
|
+
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
|
8158
|
+
} catch (e) {
|
8159
|
+
return Promise.reject(e);
|
8160
|
+
}
|
8161
|
+
},
|
8162
|
+
remove: function remove(id) {
|
8163
|
+
try {
|
8164
|
+
var _this9 = this;
|
8165
|
+
|
8166
|
+
var _temp13 = _catch$1(function () {
|
8167
|
+
return Promise.resolve(API.remove(id)).then(function () {
|
8168
|
+
return Promise.resolve(_this9.load()).then(function () {});
|
8169
|
+
});
|
8170
|
+
}, function (error) {
|
8171
|
+
console.log(error);
|
8172
|
+
});
|
8173
|
+
|
8174
|
+
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
|
8175
|
+
} catch (e) {
|
8176
|
+
return Promise.reject(e);
|
8177
|
+
}
|
8178
|
+
},
|
8179
|
+
changeFilters: function changeFilters(filters) {
|
8180
|
+
this.filters = filters;
|
8181
|
+
},
|
8182
|
+
loadQueries: function loadQueries(user) {
|
8183
|
+
try {
|
8184
|
+
var _this11 = this;
|
8185
|
+
|
8186
|
+
var _temp15 = _catch$1(function () {
|
8187
|
+
return Promise.resolve(API.queries(user, urlQuery)).then(function (_API$queries) {
|
8188
|
+
_this11.queries = _API$queries;
|
8189
|
+
});
|
8190
|
+
}, function (error) {
|
8191
|
+
console.log(error);
|
8192
|
+
});
|
8193
|
+
|
8194
|
+
return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
|
8195
|
+
} catch (e) {
|
8196
|
+
return Promise.reject(e);
|
8197
|
+
}
|
8198
|
+
},
|
8199
|
+
createQuery: function createQuery(query, user) {
|
8200
|
+
try {
|
8201
|
+
var _this13 = this;
|
8202
|
+
|
8203
|
+
var _temp17 = _catch$1(function () {
|
8204
|
+
return Promise.resolve(API.createQuery(query, urlQuery)).then(function () {
|
8205
|
+
return Promise.resolve(_this13.loadQueries(user)).then(function () {});
|
8206
|
+
});
|
8207
|
+
}, function (error) {
|
8208
|
+
console.log(error);
|
8209
|
+
});
|
8210
|
+
|
8211
|
+
return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(function () {}) : void 0);
|
8212
|
+
} catch (e) {
|
8213
|
+
return Promise.reject(e);
|
8214
|
+
}
|
8215
|
+
},
|
8216
|
+
removeQuery: function removeQuery(id, user) {
|
8217
|
+
try {
|
8218
|
+
var _this15 = this;
|
8219
|
+
|
8220
|
+
var _temp19 = _catch$1(function () {
|
8221
|
+
return Promise.resolve(API.removeQuery(id, urlQuery)).then(function () {
|
8222
|
+
return Promise.resolve(_this15.loadQueries(user)).then(function () {});
|
8223
|
+
});
|
8224
|
+
}, function (error) {
|
8225
|
+
console.log(error);
|
8226
|
+
});
|
8227
|
+
|
8228
|
+
return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
|
8229
|
+
} catch (e) {
|
8230
|
+
return Promise.reject(e);
|
8231
|
+
}
|
8232
|
+
}
|
8233
|
+
};
|
8234
|
+
};
|
8235
|
+
/**
|
8236
|
+
* Table API
|
8237
|
+
*/
|
8238
|
+
|
8239
|
+
|
7130
8240
|
var TableAPI$1 = function TableAPI(url, host, params) {
|
7131
8241
|
if (params === void 0) {
|
7132
8242
|
params = "";
|
@@ -8292,5 +9402,5 @@ var isFunction = function isFunction(value) {
|
|
8292
9402
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
8293
9403
|
};
|
8294
9404
|
|
8295
|
-
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$
|
9405
|
+
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 };
|
8296
9406
|
//# sourceMappingURL=index.modern.js.map
|