@guillotinaweb/react-gmi 0.29.2 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/actions/copy_item.d.ts +2 -2
- package/dist/actions/move_item.d.ts +2 -2
- package/dist/actions/remove_item.d.ts +2 -2
- package/dist/components/behaviors/iattachment.d.ts +4 -2
- package/dist/components/behaviors/imultiimageorderedattachment.d.ts +3 -1
- package/dist/components/behaviors/iworkflow.d.ts +1 -1
- package/dist/components/context_toolbar.d.ts +1 -1
- package/dist/components/fields/editComponent.d.ts +5 -4
- package/dist/components/fields/editableField.d.ts +4 -2
- package/dist/components/fields/renderField.d.ts +8 -5
- package/dist/components/flash.d.ts +1 -1
- package/dist/components/input/email.d.ts +1 -1
- package/dist/components/input/form_builder.d.ts +2 -2
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/search_input.d.ts +1 -1
- package/dist/components/input/search_input_list.d.ts +2 -2
- package/dist/components/input/select_vocabulary.d.ts +2 -2
- package/dist/components/input/upload.d.ts +1 -2
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/panel/permissions.d.ts +1 -1
- package/dist/components/panel/permissions_prinperm.d.ts +2 -2
- package/dist/components/panel/permissions_prinrole.d.ts +1 -1
- package/dist/components/panel/permissions_roleperm.d.ts +1 -1
- package/dist/components/path.d.ts +1 -1
- package/dist/components/properties_view.d.ts +2 -2
- package/dist/components/search_labels.d.ts +1 -1
- package/dist/components/search_options_labels.d.ts +1 -1
- package/dist/components/search_vocabulary_labels.d.ts +2 -2
- package/dist/components/selected_items_actions.d.ts +14 -0
- package/dist/components/tabs.d.ts +4 -2
- package/dist/components/widgets/tags.d.ts +4 -1
- package/dist/contexts/index.d.ts +21 -19
- package/dist/forms/required_fields.d.ts +2 -3
- package/dist/forms/users.d.ts +1 -1
- package/dist/hooks/useClickAway.d.ts +2 -1
- package/dist/hooks/useConfig.d.ts +4 -2
- package/dist/hooks/useCrudContext.d.ts +11 -10
- package/dist/hooks/useInput.d.ts +4 -3
- package/dist/hooks/useRegistry.d.ts +29 -29
- package/dist/hooks/useSetState.d.ts +6 -1
- package/dist/hooks/useVocabulary.d.ts +1 -1
- package/dist/lib/auth.d.ts +14 -19
- package/dist/lib/client.d.ts +49 -36
- package/dist/lib/helpers.d.ts +10 -18
- package/dist/lib/processResponse.d.ts +9 -0
- package/dist/lib/rest.d.ts +9 -16
- package/dist/lib/utils.d.ts +3 -2
- package/dist/lib/validators.d.ts +1 -1
- package/dist/locales/generic_messages.d.ts +248 -370
- package/dist/models/index.d.ts +5 -5
- package/dist/models/sharing.d.ts +5 -5
- package/dist/react-gmi.esm.js +1181 -904
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +1180 -904
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +1154 -851
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +1180 -904
- package/dist/react-gmi.umd.js.map +1 -1
- package/dist/reducers/guillotina.d.ts +22 -8
- package/dist/types/global.d.ts +9 -0
- package/dist/types/guillotina.d.ts +192 -44
- package/dist/views/folder.d.ts +1 -1
- package/dist/views/groups.d.ts +1 -1
- package/dist/views/item.d.ts +1 -1
- package/dist/views/users.d.ts +1 -1
- package/package.json +3 -2
- package/dist/lib/search.test.d.ts +0 -1
- package/dist/setupTests.d.ts +0 -1
package/dist/react-gmi.umd.js
CHANGED
|
@@ -107,6 +107,97 @@
|
|
|
107
107
|
return it.next.bind(it);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
var initialState = {
|
|
111
|
+
path: '',
|
|
112
|
+
loading: false,
|
|
113
|
+
context: undefined,
|
|
114
|
+
flash: {
|
|
115
|
+
message: undefined,
|
|
116
|
+
type: undefined
|
|
117
|
+
},
|
|
118
|
+
action: {
|
|
119
|
+
action: undefined,
|
|
120
|
+
params: undefined
|
|
121
|
+
},
|
|
122
|
+
permissions: [],
|
|
123
|
+
errorStatus: undefined,
|
|
124
|
+
registry: {},
|
|
125
|
+
refresh: undefined
|
|
126
|
+
};
|
|
127
|
+
var GuillotinaReducerActionTypes;
|
|
128
|
+
|
|
129
|
+
(function (GuillotinaReducerActionTypes) {
|
|
130
|
+
GuillotinaReducerActionTypes["SET_PATH"] = "SET_PATH";
|
|
131
|
+
GuillotinaReducerActionTypes["SET_CONTEXT"] = "SET_CONTEXT";
|
|
132
|
+
GuillotinaReducerActionTypes["SET_ERROR"] = "SET_ERROR";
|
|
133
|
+
GuillotinaReducerActionTypes["SET_FLASH"] = "SET_FLASH";
|
|
134
|
+
GuillotinaReducerActionTypes["CLEAR_FLASH"] = "CLEAR_FLASH";
|
|
135
|
+
GuillotinaReducerActionTypes["SET_ACTION"] = "SET_ACTION";
|
|
136
|
+
GuillotinaReducerActionTypes["CLEAR_ACTION"] = "CLEAR_ACTION";
|
|
137
|
+
GuillotinaReducerActionTypes["REFRESH"] = "REFRESH";
|
|
138
|
+
GuillotinaReducerActionTypes["APPLY"] = "APPLY";
|
|
139
|
+
})(GuillotinaReducerActionTypes || (GuillotinaReducerActionTypes = {}));
|
|
140
|
+
|
|
141
|
+
function guillotinaReducer(state, action) {
|
|
142
|
+
switch (action.type) {
|
|
143
|
+
case GuillotinaReducerActionTypes.SET_PATH:
|
|
144
|
+
return _extends({}, state, {
|
|
145
|
+
path: action.payload.path,
|
|
146
|
+
loading: true
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
case GuillotinaReducerActionTypes.SET_CONTEXT:
|
|
150
|
+
return _extends({}, state, action.payload, {
|
|
151
|
+
errorStatus: undefined,
|
|
152
|
+
loading: false
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
case GuillotinaReducerActionTypes.SET_ERROR:
|
|
156
|
+
return _extends({}, state, {
|
|
157
|
+
errorStatus: action.payload.errorStatus,
|
|
158
|
+
loading: false
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
case GuillotinaReducerActionTypes.SET_FLASH:
|
|
162
|
+
return _extends({}, state, action.payload);
|
|
163
|
+
|
|
164
|
+
case GuillotinaReducerActionTypes.CLEAR_FLASH:
|
|
165
|
+
return _extends({}, state, {
|
|
166
|
+
flash: {
|
|
167
|
+
message: undefined,
|
|
168
|
+
type: undefined
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
case GuillotinaReducerActionTypes.SET_ACTION:
|
|
173
|
+
return _extends({}, state, {
|
|
174
|
+
action: action.payload
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
case GuillotinaReducerActionTypes.CLEAR_ACTION:
|
|
178
|
+
return _extends({}, state, {
|
|
179
|
+
action: {
|
|
180
|
+
action: undefined,
|
|
181
|
+
params: undefined
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
case GuillotinaReducerActionTypes.REFRESH:
|
|
186
|
+
return _extends({}, state, {
|
|
187
|
+
refresh: Date.now(),
|
|
188
|
+
loading: !action.payload.transparent
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
case GuillotinaReducerActionTypes.APPLY:
|
|
192
|
+
return _extends({}, state, {
|
|
193
|
+
context: _extends({}, state.context, action.payload.context)
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
default:
|
|
197
|
+
return state;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
110
201
|
var AuthContext = React.createContext({});
|
|
111
202
|
var ClientContext = React.createContext(null);
|
|
112
203
|
var Traversal = /*#__PURE__*/function () {
|
|
@@ -137,7 +228,7 @@
|
|
|
137
228
|
transparent = _ref2$transparent === void 0 ? false : _ref2$transparent;
|
|
138
229
|
|
|
139
230
|
this.dispatch({
|
|
140
|
-
type:
|
|
231
|
+
type: GuillotinaReducerActionTypes.REFRESH,
|
|
141
232
|
payload: {
|
|
142
233
|
transparent: transparent
|
|
143
234
|
}
|
|
@@ -145,15 +236,18 @@
|
|
|
145
236
|
};
|
|
146
237
|
|
|
147
238
|
_proto.apply = function apply(data) {
|
|
239
|
+
// apply a optimistic update to context
|
|
148
240
|
this.dispatch({
|
|
149
|
-
type:
|
|
150
|
-
payload:
|
|
241
|
+
type: GuillotinaReducerActionTypes.APPLY,
|
|
242
|
+
payload: {
|
|
243
|
+
context: data
|
|
244
|
+
}
|
|
151
245
|
});
|
|
152
246
|
};
|
|
153
247
|
|
|
154
248
|
_proto.flash = function flash(message, type) {
|
|
155
249
|
this.dispatch({
|
|
156
|
-
type:
|
|
250
|
+
type: GuillotinaReducerActionTypes.SET_FLASH,
|
|
157
251
|
payload: {
|
|
158
252
|
flash: {
|
|
159
253
|
message: message,
|
|
@@ -170,7 +264,8 @@
|
|
|
170
264
|
|
|
171
265
|
_proto.clearFlash = function clearFlash() {
|
|
172
266
|
this.dispatch({
|
|
173
|
-
type:
|
|
267
|
+
type: GuillotinaReducerActionTypes.CLEAR_FLASH,
|
|
268
|
+
payload: {}
|
|
174
269
|
});
|
|
175
270
|
};
|
|
176
271
|
|
|
@@ -180,7 +275,7 @@
|
|
|
180
275
|
}
|
|
181
276
|
|
|
182
277
|
this.dispatch({
|
|
183
|
-
type:
|
|
278
|
+
type: GuillotinaReducerActionTypes.SET_ACTION,
|
|
184
279
|
payload: {
|
|
185
280
|
action: action,
|
|
186
281
|
params: params
|
|
@@ -190,7 +285,8 @@
|
|
|
190
285
|
|
|
191
286
|
_proto.cancelAction = function cancelAction() {
|
|
192
287
|
this.dispatch({
|
|
193
|
-
type:
|
|
288
|
+
type: GuillotinaReducerActionTypes.CLEAR_ACTION,
|
|
289
|
+
payload: {}
|
|
194
290
|
});
|
|
195
291
|
};
|
|
196
292
|
|
|
@@ -227,6 +323,10 @@
|
|
|
227
323
|
}, {
|
|
228
324
|
key: "context",
|
|
229
325
|
get: function get() {
|
|
326
|
+
if (this.state.context === undefined) {
|
|
327
|
+
throw new Error('Context is not loaded');
|
|
328
|
+
}
|
|
329
|
+
|
|
230
330
|
return this.state.context;
|
|
231
331
|
}
|
|
232
332
|
}, {
|
|
@@ -249,7 +349,13 @@
|
|
|
249
349
|
});
|
|
250
350
|
}
|
|
251
351
|
function useTraversal() {
|
|
252
|
-
|
|
352
|
+
var traversal = React.useContext(TraversalContext);
|
|
353
|
+
|
|
354
|
+
if (!traversal) {
|
|
355
|
+
throw new Error('useTraversal must be used within a TraversalProvider');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return traversal;
|
|
253
359
|
}
|
|
254
360
|
function ClientProvider(_ref4) {
|
|
255
361
|
var children = _ref4.children,
|
|
@@ -260,7 +366,13 @@
|
|
|
260
366
|
});
|
|
261
367
|
}
|
|
262
368
|
function useGuillotinaClient() {
|
|
263
|
-
|
|
369
|
+
var client = React.useContext(ClientContext);
|
|
370
|
+
|
|
371
|
+
if (!client) {
|
|
372
|
+
throw new Error('useGuillotinaClient must be used within a ClientProvider');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return client;
|
|
264
376
|
}
|
|
265
377
|
|
|
266
378
|
var genericMessages = reactIntl.defineMessages({
|
|
@@ -767,8 +879,10 @@
|
|
|
767
879
|
return bytes;
|
|
768
880
|
}
|
|
769
881
|
function stringToSlug(str) {
|
|
770
|
-
str = str.replace(/^\s+|\s+$/g, '');
|
|
771
|
-
|
|
882
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
883
|
+
|
|
884
|
+
str = str.toLowerCase(); // remove accents, swap ñ for n, etc
|
|
885
|
+
|
|
772
886
|
var from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
|
|
773
887
|
var to = 'aaaaeeeeiiiioooouuuunc------';
|
|
774
888
|
|
|
@@ -776,13 +890,16 @@
|
|
|
776
890
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
777
891
|
}
|
|
778
892
|
|
|
779
|
-
str = str.replace(/[^a-z0-9 -]/g, '')
|
|
893
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
894
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
895
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
896
|
+
|
|
780
897
|
return str;
|
|
781
898
|
}
|
|
782
899
|
function sleep(ms) {
|
|
783
900
|
return new Promise(function (resolve) {
|
|
784
901
|
setTimeout(function () {
|
|
785
|
-
resolve(
|
|
902
|
+
resolve();
|
|
786
903
|
}, ms);
|
|
787
904
|
});
|
|
788
905
|
}
|
|
@@ -811,8 +928,6 @@
|
|
|
811
928
|
};
|
|
812
929
|
|
|
813
930
|
var Button = function Button(_ref) {
|
|
814
|
-
var _ref2;
|
|
815
|
-
|
|
816
931
|
var children = _ref.children,
|
|
817
932
|
_ref$className = _ref.className,
|
|
818
933
|
className = _ref$className === void 0 ? 'is-primary' : _ref$className,
|
|
@@ -824,9 +939,7 @@
|
|
|
824
939
|
_ref$disabled = _ref.disabled,
|
|
825
940
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
826
941
|
dataTest = _ref.dataTest;
|
|
827
|
-
|
|
828
|
-
var css = (_ref2 = []).concat.apply(_ref2, ['button'].concat(className.split(' ')));
|
|
829
|
-
|
|
942
|
+
var css = [].concat(className.split(' '), ['button']);
|
|
830
943
|
if (loading) css = css.concat('is-loading');
|
|
831
944
|
return jsxRuntime.jsx("p", {
|
|
832
945
|
className: "control",
|
|
@@ -841,6 +954,50 @@
|
|
|
841
954
|
});
|
|
842
955
|
};
|
|
843
956
|
|
|
957
|
+
var formatDate = function formatDate(str) {
|
|
958
|
+
var d = new Date(str);
|
|
959
|
+
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
960
|
+
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
961
|
+
};
|
|
962
|
+
var get = function get(obj, path, defValue) {
|
|
963
|
+
var _pathArray$reduce;
|
|
964
|
+
|
|
965
|
+
// If path is not defined or it has false value
|
|
966
|
+
if (!path) return defValue; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
|
|
967
|
+
// Regex explained: https://regexr.com/58j0k
|
|
968
|
+
|
|
969
|
+
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
|
|
970
|
+
|
|
971
|
+
if (pathArray === null) return defValue;
|
|
972
|
+
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
973
|
+
return prevObj && prevObj[key];
|
|
974
|
+
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
975
|
+
};
|
|
976
|
+
function getNewId(id) {
|
|
977
|
+
if (id === void 0) {
|
|
978
|
+
id = '';
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
var suffix = '-copy-';
|
|
982
|
+
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
983
|
+
return stringToSlug(id).replace(rgx, function (r) {
|
|
984
|
+
var num = parseInt(r.replace(suffix, '') || '0');
|
|
985
|
+
return "" + suffix + (num + 1);
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function debounce(callback, wait) {
|
|
989
|
+
var timer;
|
|
990
|
+
return function () {
|
|
991
|
+
var _arguments = arguments;
|
|
992
|
+
clearTimeout(timer);
|
|
993
|
+
return new Promise(function (resolve) {
|
|
994
|
+
timer = setTimeout(function () {
|
|
995
|
+
return resolve(callback.apply(void 0, [].slice.call(_arguments)));
|
|
996
|
+
}, wait);
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
844
1001
|
function Modal(props) {
|
|
845
1002
|
var isActive = props.isActive,
|
|
846
1003
|
setActive = props.setActive,
|
|
@@ -920,7 +1077,8 @@
|
|
|
920
1077
|
})]
|
|
921
1078
|
})]
|
|
922
1079
|
});
|
|
923
|
-
}
|
|
1080
|
+
} // @todo Improve it... Replacing the inputText to a tree
|
|
1081
|
+
|
|
924
1082
|
function PathTree(_ref2) {
|
|
925
1083
|
var title = _ref2.title,
|
|
926
1084
|
defaultPath = _ref2.defaultPath,
|
|
@@ -936,7 +1094,7 @@
|
|
|
936
1094
|
}), jsxRuntime.jsxs("form", {
|
|
937
1095
|
onSubmit: function onSubmit(e) {
|
|
938
1096
|
e.preventDefault();
|
|
939
|
-
onConfirm(e.
|
|
1097
|
+
onConfirm(get(e, 'target.0.value', ''), e.target);
|
|
940
1098
|
},
|
|
941
1099
|
children: [jsxRuntime.jsx("small", {
|
|
942
1100
|
style: {
|
|
@@ -968,51 +1126,6 @@
|
|
|
968
1126
|
});
|
|
969
1127
|
}
|
|
970
1128
|
|
|
971
|
-
function useSetState(initialState) {
|
|
972
|
-
var _useState = React.useState(initialState),
|
|
973
|
-
state = _useState[0],
|
|
974
|
-
set = _useState[1];
|
|
975
|
-
|
|
976
|
-
var setState = React.useCallback(function (patch) {
|
|
977
|
-
set(function (prevState) {
|
|
978
|
-
return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
|
|
979
|
-
});
|
|
980
|
-
}, [set]);
|
|
981
|
-
return [state, setState];
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
function _catch(body, recover) {
|
|
985
|
-
try {
|
|
986
|
-
var result = body();
|
|
987
|
-
} catch (e) {
|
|
988
|
-
return recover(e);
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
if (result && result.then) {
|
|
992
|
-
return result.then(void 0, recover);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
return result;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
var initial = {
|
|
999
|
-
loading: undefined,
|
|
1000
|
-
isError: false,
|
|
1001
|
-
errorMessage: undefined,
|
|
1002
|
-
result: undefined,
|
|
1003
|
-
response: undefined
|
|
1004
|
-
};
|
|
1005
|
-
|
|
1006
|
-
var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
|
|
1007
|
-
if (dataError && dataError.details) {
|
|
1008
|
-
return dataError.details;
|
|
1009
|
-
} else if (dataError && dataError.reason) {
|
|
1010
|
-
return dataError.reason;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
return defaultValue;
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
1129
|
var processResponse = function processResponse(res, ready_body) {
|
|
1017
1130
|
if (ready_body === void 0) {
|
|
1018
1131
|
ready_body = true;
|
|
@@ -1032,7 +1145,7 @@
|
|
|
1032
1145
|
return {
|
|
1033
1146
|
isError: true,
|
|
1034
1147
|
loading: false,
|
|
1035
|
-
errorMessage: getErrorMessage(_res$json2, res.status),
|
|
1148
|
+
errorMessage: getErrorMessage(_res$json2, res.status).toString(),
|
|
1036
1149
|
response: res
|
|
1037
1150
|
};
|
|
1038
1151
|
});
|
|
@@ -1041,10 +1154,66 @@
|
|
|
1041
1154
|
}
|
|
1042
1155
|
};
|
|
1043
1156
|
|
|
1044
|
-
var
|
|
1157
|
+
var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
|
|
1158
|
+
if (dataError && dataError.details) {
|
|
1159
|
+
return dataError.details;
|
|
1160
|
+
} else if (dataError && dataError.reason) {
|
|
1161
|
+
return dataError.reason;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
return defaultValue;
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Do setState like react class component.
|
|
1169
|
+
*/
|
|
1170
|
+
|
|
1171
|
+
function useSetState(initialState) {
|
|
1172
|
+
var _useState = React.useState(initialState),
|
|
1173
|
+
state = _useState[0],
|
|
1174
|
+
setState = _useState[1]; // Function which accepts a partial state to merge
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
var setCustomState = React.useCallback(function (newPartialState) {
|
|
1178
|
+
try {
|
|
1179
|
+
setState(function (prevState) {
|
|
1180
|
+
return _extends({}, prevState, newPartialState);
|
|
1181
|
+
});
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
// eslint-disable-next-line no-console
|
|
1184
|
+
console.error(error);
|
|
1185
|
+
}
|
|
1186
|
+
}, []); // Return
|
|
1187
|
+
|
|
1188
|
+
return [state, setCustomState];
|
|
1189
|
+
} // **** Export Default **** //
|
|
1190
|
+
|
|
1191
|
+
function _catch(body, recover) {
|
|
1192
|
+
try {
|
|
1193
|
+
var result = body();
|
|
1194
|
+
} catch (e) {
|
|
1195
|
+
return recover(e);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
if (result && result.then) {
|
|
1199
|
+
return result.then(void 0, recover);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
return result;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
var initial = {
|
|
1206
|
+
loading: undefined,
|
|
1207
|
+
isError: false,
|
|
1208
|
+
errorMessage: undefined,
|
|
1209
|
+
result: undefined,
|
|
1210
|
+
response: undefined
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
function patch(setState, Ctx) {
|
|
1045
1214
|
return function (data, endpoint, body) {
|
|
1046
|
-
if (
|
|
1047
|
-
|
|
1215
|
+
if (data === void 0) {
|
|
1216
|
+
data = {};
|
|
1048
1217
|
}
|
|
1049
1218
|
|
|
1050
1219
|
if (body === void 0) {
|
|
@@ -1052,7 +1221,7 @@
|
|
|
1052
1221
|
}
|
|
1053
1222
|
|
|
1054
1223
|
try {
|
|
1055
|
-
function
|
|
1224
|
+
function _temp3() {
|
|
1056
1225
|
setState(newState);
|
|
1057
1226
|
return newState;
|
|
1058
1227
|
}
|
|
@@ -1062,7 +1231,7 @@
|
|
|
1062
1231
|
});
|
|
1063
1232
|
var newState = {};
|
|
1064
1233
|
|
|
1065
|
-
var
|
|
1234
|
+
var _temp4 = _catch(function () {
|
|
1066
1235
|
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1067
1236
|
return Promise.resolve(Ctx.client.patch(path, data)).then(function (res) {
|
|
1068
1237
|
return Promise.resolve(processResponse(res, body)).then(function (_processResponse) {
|
|
@@ -1077,29 +1246,25 @@
|
|
|
1077
1246
|
};
|
|
1078
1247
|
});
|
|
1079
1248
|
|
|
1080
|
-
return Promise.resolve(
|
|
1249
|
+
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
|
|
1081
1250
|
} catch (e) {
|
|
1082
1251
|
return Promise.reject(e);
|
|
1083
1252
|
}
|
|
1084
1253
|
};
|
|
1085
|
-
}
|
|
1254
|
+
}
|
|
1086
1255
|
|
|
1087
|
-
|
|
1256
|
+
function del(setState, Ctx) {
|
|
1088
1257
|
return function (data, endpoint, body) {
|
|
1089
1258
|
if (data === void 0) {
|
|
1090
1259
|
data = {};
|
|
1091
1260
|
}
|
|
1092
1261
|
|
|
1093
|
-
if (endpoint === void 0) {
|
|
1094
|
-
endpoint = undefined;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
1262
|
if (body === void 0) {
|
|
1098
1263
|
body = false;
|
|
1099
1264
|
}
|
|
1100
1265
|
|
|
1101
1266
|
try {
|
|
1102
|
-
function
|
|
1267
|
+
function _temp7() {
|
|
1103
1268
|
setState(newState);
|
|
1104
1269
|
return newState;
|
|
1105
1270
|
}
|
|
@@ -1109,7 +1274,7 @@
|
|
|
1109
1274
|
});
|
|
1110
1275
|
var newState = {};
|
|
1111
1276
|
|
|
1112
|
-
var
|
|
1277
|
+
var _temp8 = _catch(function () {
|
|
1113
1278
|
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1114
1279
|
return Promise.resolve(Ctx.client.delete(path, data)).then(function (res) {
|
|
1115
1280
|
return Promise.resolve(processResponse(res, body)).then(function (_processResponse2) {
|
|
@@ -1124,17 +1289,17 @@
|
|
|
1124
1289
|
};
|
|
1125
1290
|
});
|
|
1126
1291
|
|
|
1127
|
-
return Promise.resolve(
|
|
1292
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
|
|
1128
1293
|
} catch (e) {
|
|
1129
1294
|
return Promise.reject(e);
|
|
1130
1295
|
}
|
|
1131
1296
|
};
|
|
1132
|
-
}
|
|
1297
|
+
}
|
|
1133
1298
|
|
|
1134
|
-
|
|
1299
|
+
function post(setState, Ctx) {
|
|
1135
1300
|
return function (data, endpoint, body) {
|
|
1136
|
-
if (
|
|
1137
|
-
|
|
1301
|
+
if (data === void 0) {
|
|
1302
|
+
data = {};
|
|
1138
1303
|
}
|
|
1139
1304
|
|
|
1140
1305
|
if (body === void 0) {
|
|
@@ -1142,7 +1307,7 @@
|
|
|
1142
1307
|
}
|
|
1143
1308
|
|
|
1144
1309
|
try {
|
|
1145
|
-
function
|
|
1310
|
+
function _temp11() {
|
|
1146
1311
|
setState(newState);
|
|
1147
1312
|
return newState;
|
|
1148
1313
|
}
|
|
@@ -1152,7 +1317,7 @@
|
|
|
1152
1317
|
});
|
|
1153
1318
|
var newState = {};
|
|
1154
1319
|
|
|
1155
|
-
var
|
|
1320
|
+
var _temp12 = _catch(function () {
|
|
1156
1321
|
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1157
1322
|
return Promise.resolve(Ctx.client.post(path, data)).then(function (res) {
|
|
1158
1323
|
return Promise.resolve(processResponse(res, body)).then(function (_processResponse3) {
|
|
@@ -1167,21 +1332,17 @@
|
|
|
1167
1332
|
};
|
|
1168
1333
|
});
|
|
1169
1334
|
|
|
1170
|
-
return Promise.resolve(
|
|
1335
|
+
return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12));
|
|
1171
1336
|
} catch (e) {
|
|
1172
1337
|
return Promise.reject(e);
|
|
1173
1338
|
}
|
|
1174
1339
|
};
|
|
1175
|
-
}
|
|
1340
|
+
}
|
|
1176
1341
|
|
|
1177
|
-
|
|
1342
|
+
function get$1(setState, Ctx) {
|
|
1178
1343
|
return function (endpoint) {
|
|
1179
|
-
if (endpoint === void 0) {
|
|
1180
|
-
endpoint = undefined;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
1344
|
try {
|
|
1184
|
-
function
|
|
1345
|
+
function _temp15() {
|
|
1185
1346
|
setState(newState);
|
|
1186
1347
|
return newState;
|
|
1187
1348
|
}
|
|
@@ -1191,7 +1352,7 @@
|
|
|
1191
1352
|
});
|
|
1192
1353
|
var newState = {};
|
|
1193
1354
|
|
|
1194
|
-
var
|
|
1355
|
+
var _temp16 = _catch(function () {
|
|
1195
1356
|
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1196
1357
|
return Promise.resolve(Ctx.client.get(path)).then(function (res) {
|
|
1197
1358
|
return Promise.resolve(processResponse(res, true)).then(function (_processResponse4) {
|
|
@@ -1206,12 +1367,16 @@
|
|
|
1206
1367
|
};
|
|
1207
1368
|
});
|
|
1208
1369
|
|
|
1209
|
-
return Promise.resolve(
|
|
1370
|
+
return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(_temp15) : _temp15(_temp16));
|
|
1210
1371
|
} catch (e) {
|
|
1211
1372
|
return Promise.reject(e);
|
|
1212
1373
|
}
|
|
1213
1374
|
};
|
|
1214
|
-
}
|
|
1375
|
+
} // const get = (
|
|
1376
|
+
// setState: (value: Partial<State>) => void,
|
|
1377
|
+
// Ctx: Traversal
|
|
1378
|
+
// ) =>
|
|
1379
|
+
|
|
1215
1380
|
|
|
1216
1381
|
function useCrudContext() {
|
|
1217
1382
|
var Ctx = useTraversal();
|
|
@@ -1225,7 +1390,7 @@
|
|
|
1225
1390
|
patch: patch(setState, Ctx),
|
|
1226
1391
|
del: del(setState, Ctx),
|
|
1227
1392
|
post: post(setState, Ctx),
|
|
1228
|
-
get: get(setState, Ctx)
|
|
1393
|
+
get: get$1(setState, Ctx)
|
|
1229
1394
|
});
|
|
1230
1395
|
}
|
|
1231
1396
|
|
|
@@ -1273,9 +1438,6 @@
|
|
|
1273
1438
|
children: jsxRuntime.jsx(Form, {
|
|
1274
1439
|
loading: loading,
|
|
1275
1440
|
onSubmit: doSubmit,
|
|
1276
|
-
onError: function onError(err) {
|
|
1277
|
-
return console.log(err);
|
|
1278
|
-
},
|
|
1279
1441
|
actionName: 'Add ' + type,
|
|
1280
1442
|
title: 'Add ' + type,
|
|
1281
1443
|
type: type,
|
|
@@ -1285,31 +1447,52 @@
|
|
|
1285
1447
|
}
|
|
1286
1448
|
|
|
1287
1449
|
var Permissions = ['guillotina.AddContent', 'guillotina.ModifyContent', 'guillotina.ViewContent', 'guillotina.DeleteContent', 'guillotina.AccessContent', 'guillotina.SeePermissions', 'guillotina.ChangePermissions', 'guillotina.MoveContent', 'guillotina.DuplicateContent', 'guillotina.ReadConfiguration', 'guillotina.RegisterConfigurations', 'guillotina.WriteConfiguration', 'guillotina.ManageAddons', 'guillotina.swagger.View'];
|
|
1288
|
-
var
|
|
1450
|
+
var defaultConfig = {
|
|
1289
1451
|
DisabledTypes: ['UserManager', 'GroupManager'],
|
|
1290
1452
|
PageSize: 10,
|
|
1291
1453
|
DelayActions: 200,
|
|
1292
1454
|
Permissions: Permissions,
|
|
1293
1455
|
SearchEngine: 'PostreSQL',
|
|
1456
|
+
// Elasticsearch
|
|
1294
1457
|
fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
|
|
1295
1458
|
return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
1296
1459
|
}
|
|
1297
1460
|
};
|
|
1298
|
-
var calculated = Object.assign({},
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
var
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1461
|
+
var calculated = Object.assign({}, defaultConfig);
|
|
1462
|
+
|
|
1463
|
+
function addConfig(updates, currentConfig) {
|
|
1464
|
+
var updatedConfig = _extends({}, currentConfig);
|
|
1465
|
+
|
|
1466
|
+
Object.entries(updates).forEach(function (_ref) {
|
|
1467
|
+
var key = _ref[0],
|
|
1468
|
+
value = _ref[1];
|
|
1469
|
+
var currentKey = key;
|
|
1470
|
+
var currentValue = currentConfig[currentKey];
|
|
1471
|
+
|
|
1472
|
+
if (Array.isArray(value) && Array.isArray(currentValue)) {
|
|
1473
|
+
var _extends2;
|
|
1474
|
+
|
|
1475
|
+
// Correctly type the array concatenation
|
|
1476
|
+
updatedConfig = _extends({}, updatedConfig, (_extends2 = {}, _extends2[currentKey] = [].concat(currentValue, value), _extends2));
|
|
1477
|
+
} else if (isPlainObject(value) && isPlainObject(currentValue)) {
|
|
1478
|
+
var _extends3;
|
|
1479
|
+
|
|
1480
|
+
// Correctly type the object merging
|
|
1481
|
+
updatedConfig = _extends({}, updatedConfig, (_extends3 = {}, _extends3[currentKey] = _extends({}, currentValue, value), _extends3));
|
|
1307
1482
|
} else {
|
|
1308
|
-
|
|
1483
|
+
var _extends4;
|
|
1484
|
+
|
|
1485
|
+
// Directly assign all other types
|
|
1486
|
+
updatedConfig = _extends({}, updatedConfig, (_extends4 = {}, _extends4[currentKey] = value, _extends4));
|
|
1309
1487
|
}
|
|
1310
1488
|
});
|
|
1311
|
-
return
|
|
1312
|
-
}
|
|
1489
|
+
return updatedConfig;
|
|
1490
|
+
} // Helper function to check if a value is a plain object (and not a React node, etc.)
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
function isPlainObject(value) {
|
|
1494
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
1495
|
+
}
|
|
1313
1496
|
|
|
1314
1497
|
function useConfig(cfg) {
|
|
1315
1498
|
if (cfg === void 0) {
|
|
@@ -1333,7 +1516,7 @@
|
|
|
1333
1516
|
setLoading(true);
|
|
1334
1517
|
var actions = items.map(function (item) {
|
|
1335
1518
|
try {
|
|
1336
|
-
return Promise.resolve(Ctx.client.delete("" + Ctx.path + item
|
|
1519
|
+
return Promise.resolve(Ctx.client.delete("" + Ctx.path + item.id, {})).then(function (res) {
|
|
1337
1520
|
var _temp = function () {
|
|
1338
1521
|
if (!res.ok) {
|
|
1339
1522
|
return Promise.resolve(res.json()).then(function (err) {
|
|
@@ -1347,7 +1530,9 @@
|
|
|
1347
1530
|
} catch (e) {
|
|
1348
1531
|
return Promise.reject(e);
|
|
1349
1532
|
}
|
|
1350
|
-
});
|
|
1533
|
+
}); // this sleep is here, to let elasticsearch, wait for
|
|
1534
|
+
// index our operations... (will work 99% of use cases)
|
|
1535
|
+
|
|
1351
1536
|
actions.push(sleep(cfg.DelayActions));
|
|
1352
1537
|
return Promise.resolve(Promise.all(actions)).then(function () {
|
|
1353
1538
|
if (errors.length === 0) {
|
|
@@ -1377,9 +1562,9 @@
|
|
|
1377
1562
|
|
|
1378
1563
|
var _props$items = props.items,
|
|
1379
1564
|
items = _props$items === void 0 ? [] : _props$items;
|
|
1380
|
-
var last = items[items.length - 1]
|
|
1565
|
+
var last = items[items.length - 1].id;
|
|
1381
1566
|
var itemsNames = items.map(function (item) {
|
|
1382
|
-
return item
|
|
1567
|
+
return item.id;
|
|
1383
1568
|
}).join(', ').replace(", " + last, " and " + last);
|
|
1384
1569
|
return jsxRuntime.jsx(Confirm, {
|
|
1385
1570
|
loading: loading,
|
|
@@ -1406,7 +1591,7 @@
|
|
|
1406
1591
|
dataTest = _ref.dataTest;
|
|
1407
1592
|
var inputRef = React.useRef(null);
|
|
1408
1593
|
|
|
1409
|
-
var _useState = React.useState(checked),
|
|
1594
|
+
var _useState = React.useState(!!checked),
|
|
1410
1595
|
state = _useState[0],
|
|
1411
1596
|
setState = _useState[1];
|
|
1412
1597
|
|
|
@@ -1425,13 +1610,13 @@
|
|
|
1425
1610
|
className: "field",
|
|
1426
1611
|
children: jsxRuntime.jsxs("label", {
|
|
1427
1612
|
htmlFor: id,
|
|
1428
|
-
className: classnames(['checkbox', className]),
|
|
1613
|
+
className: classnames(['checkbox', className != null ? className : '']),
|
|
1429
1614
|
children: [jsxRuntime.jsx("input", {
|
|
1430
1615
|
ref: inputRef,
|
|
1431
1616
|
disabled: disabled || loading,
|
|
1432
1617
|
id: id,
|
|
1433
1618
|
type: "checkbox",
|
|
1434
|
-
className: classnames(['checkbox', classNameInput]),
|
|
1619
|
+
className: classnames(['checkbox', classNameInput != null ? classNameInput : '']),
|
|
1435
1620
|
checked: state,
|
|
1436
1621
|
onChange: updateState,
|
|
1437
1622
|
"data-test": dataTest
|
|
@@ -1469,7 +1654,7 @@
|
|
|
1469
1654
|
return result;
|
|
1470
1655
|
};
|
|
1471
1656
|
|
|
1472
|
-
var useInput = function useInput(onChange, value,
|
|
1657
|
+
var useInput = function useInput(onChange, value, validators) {
|
|
1473
1658
|
var _useState = React.useState({
|
|
1474
1659
|
hasError: false,
|
|
1475
1660
|
value: value
|
|
@@ -1478,7 +1663,7 @@
|
|
|
1478
1663
|
setState = _useState[1];
|
|
1479
1664
|
|
|
1480
1665
|
var onUpdate = function onUpdate(ev) {
|
|
1481
|
-
var value = ev && ev.target ? ev.target.value :
|
|
1666
|
+
var value = ev && ev.target ? ev.target.value : '';
|
|
1482
1667
|
setState({
|
|
1483
1668
|
value: value,
|
|
1484
1669
|
hasError: false
|
|
@@ -1487,7 +1672,7 @@
|
|
|
1487
1672
|
};
|
|
1488
1673
|
|
|
1489
1674
|
var onBlur = function onBlur() {
|
|
1490
|
-
var hasError = applyValidators(state.value,
|
|
1675
|
+
var hasError = applyValidators(state.value, validators) === false;
|
|
1491
1676
|
if (hasError) setState({
|
|
1492
1677
|
value: state.value,
|
|
1493
1678
|
hasError: hasError
|
|
@@ -1517,6 +1702,9 @@
|
|
|
1517
1702
|
};
|
|
1518
1703
|
};
|
|
1519
1704
|
|
|
1705
|
+
// From github.com/protonmail/proton-shared
|
|
1706
|
+
|
|
1707
|
+
/* eslint-disable no-useless-escape */
|
|
1520
1708
|
var REGEX_EMAIL = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/i;
|
|
1521
1709
|
var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
|
1522
1710
|
var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
|
|
@@ -1617,10 +1805,10 @@
|
|
|
1617
1805
|
dataTest = _ref$dataTest === void 0 ? 'testInput' : _ref$dataTest,
|
|
1618
1806
|
disabled = _ref.disabled,
|
|
1619
1807
|
onKeyUp = _ref.onKeyUp;
|
|
1620
|
-
var validatorFn =
|
|
1808
|
+
var validatorFn = [];
|
|
1621
1809
|
|
|
1622
1810
|
if (required) {
|
|
1623
|
-
validatorFn = Array.isArray(validator) ?
|
|
1811
|
+
validatorFn = Array.isArray(validator) ? [].concat(validator, [notEmpty]) : [validator, notEmpty];
|
|
1624
1812
|
}
|
|
1625
1813
|
|
|
1626
1814
|
var _useInput = useInput(onChange, value != null ? value : '', validatorFn),
|
|
@@ -1632,17 +1820,18 @@
|
|
|
1632
1820
|
|
|
1633
1821
|
var _useState2 = React.useState(false),
|
|
1634
1822
|
mounted = _useState2[0],
|
|
1635
|
-
setMounted = _useState2[1];
|
|
1823
|
+
setMounted = _useState2[1]; // eslint-disable-next-line
|
|
1824
|
+
|
|
1636
1825
|
|
|
1637
|
-
|
|
1826
|
+
var newRef = ref || React.useRef();
|
|
1638
1827
|
React.useEffect(function () {
|
|
1639
1828
|
setMounted(true);
|
|
1640
1829
|
}, []);
|
|
1641
1830
|
React.useEffect(function () {
|
|
1642
|
-
if (autofocus && !error &&
|
|
1643
|
-
|
|
1831
|
+
if (autofocus && !error && newRef != null && typeof newRef !== 'function' && newRef.current) {
|
|
1832
|
+
newRef.current.focus();
|
|
1644
1833
|
}
|
|
1645
|
-
}, [mounted, autofocus,
|
|
1834
|
+
}, [mounted, autofocus, newRef, error]);
|
|
1646
1835
|
var theError = state.hasError ? errorMessage || 'invalid field' : '';
|
|
1647
1836
|
var statusClasses = state.hasError ? 'is-danger' : '';
|
|
1648
1837
|
|
|
@@ -1683,7 +1872,8 @@
|
|
|
1683
1872
|
|
|
1684
1873
|
var Icon = function Icon(_ref) {
|
|
1685
1874
|
var icon = _ref.icon,
|
|
1686
|
-
className = _ref.className,
|
|
1875
|
+
_ref$className = _ref.className,
|
|
1876
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1687
1877
|
align = _ref.align;
|
|
1688
1878
|
var addClass = className ? className.split(' ') : [className];
|
|
1689
1879
|
align = align || 'is-right';
|
|
@@ -1794,24 +1984,26 @@
|
|
|
1794
1984
|
remotes = _ref$remotes === void 0 ? {} : _ref$remotes,
|
|
1795
1985
|
_ref$submitButton = _ref.submitButton,
|
|
1796
1986
|
submitButton = _ref$submitButton === void 0 ? true : _ref$submitButton;
|
|
1797
|
-
var ref = React.useRef();
|
|
1987
|
+
var ref = React.useRef(null);
|
|
1798
1988
|
var properties = schema.properties,
|
|
1799
1989
|
required = schema.required;
|
|
1800
|
-
var values = Object.assign({}, formData || {});
|
|
1990
|
+
var values = Object.assign({}, formData || {}); // build initial state
|
|
1991
|
+
|
|
1801
1992
|
var initialState = {};
|
|
1802
1993
|
var fields = Object.keys(properties).filter(function (x) {
|
|
1803
1994
|
return !exclude.includes(x);
|
|
1804
1995
|
});
|
|
1805
1996
|
fields.forEach(function (element) {
|
|
1806
1997
|
initialState[element] = values[element] || undefined;
|
|
1807
|
-
});
|
|
1998
|
+
}); // Register remotes
|
|
1808
1999
|
|
|
1809
|
-
if (
|
|
2000
|
+
if (ref.current === null) {
|
|
1810
2001
|
ref.current = {};
|
|
1811
2002
|
Object.keys(remotes).forEach(function (item) {
|
|
1812
2003
|
return ref.current[item] = remotes[item];
|
|
1813
2004
|
});
|
|
1814
2005
|
} else {
|
|
2006
|
+
// apply remote changes
|
|
1815
2007
|
Object.keys(remotes).forEach(function (key) {
|
|
1816
2008
|
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
1817
2009
|
ref.current[key] = remotes[key];
|
|
@@ -1822,15 +2014,16 @@
|
|
|
1822
2014
|
ref.current = ref.current || {};
|
|
1823
2015
|
|
|
1824
2016
|
var onUpdate = function onUpdate(field) {
|
|
1825
|
-
return function (
|
|
1826
|
-
ref.current[field] =
|
|
2017
|
+
return function (value) {
|
|
2018
|
+
ref.current[field] = value;
|
|
1827
2019
|
};
|
|
1828
2020
|
};
|
|
1829
2021
|
|
|
1830
2022
|
var GetTag = function GetTag(_ref2) {
|
|
1831
2023
|
var field = _ref2.field;
|
|
1832
2024
|
var property = properties[field];
|
|
1833
|
-
var
|
|
2025
|
+
var key = property.widget || property.type;
|
|
2026
|
+
var Tag = formComponents[key];
|
|
1834
2027
|
var props = {
|
|
1835
2028
|
value: initialState[field],
|
|
1836
2029
|
onChange: onUpdate(field),
|
|
@@ -1845,7 +2038,6 @@
|
|
|
1845
2038
|
props.placeholder += ' *';
|
|
1846
2039
|
}
|
|
1847
2040
|
|
|
1848
|
-
Tag.displayName = field + "Field";
|
|
1849
2041
|
return jsxRuntime.jsx(Tag, _extends({}, props));
|
|
1850
2042
|
};
|
|
1851
2043
|
|
|
@@ -1914,9 +2106,13 @@
|
|
|
1914
2106
|
selectValue = selectValue.concat([ev.target.selectedOptions[i].value]);
|
|
1915
2107
|
}
|
|
1916
2108
|
|
|
1917
|
-
onChange
|
|
2109
|
+
if (onChange) {
|
|
2110
|
+
onChange(selectValue);
|
|
2111
|
+
}
|
|
1918
2112
|
} else {
|
|
1919
|
-
onChange
|
|
2113
|
+
if (onChange) {
|
|
2114
|
+
onChange(ev.target.value);
|
|
2115
|
+
}
|
|
1920
2116
|
}
|
|
1921
2117
|
};
|
|
1922
2118
|
|
|
@@ -1965,39 +2161,12 @@
|
|
|
1965
2161
|
});
|
|
1966
2162
|
Select.displayName = 'Select';
|
|
1967
2163
|
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
var _pathArray$reduce;
|
|
1975
|
-
|
|
1976
|
-
if (!path) return undefined;
|
|
1977
|
-
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
1978
|
-
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
1979
|
-
return prevObj && prevObj[key];
|
|
1980
|
-
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
1981
|
-
};
|
|
1982
|
-
function getNewId(id) {
|
|
1983
|
-
if (id === void 0) {
|
|
1984
|
-
id = '';
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
var suffix = '-copy-';
|
|
1988
|
-
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
1989
|
-
return stringToSlug(id).replace(rgx, function (r) {
|
|
1990
|
-
var num = parseInt(r.replace(suffix, '') || '0');
|
|
1991
|
-
return "" + suffix + (num + 1);
|
|
1992
|
-
});
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
function _catch$1(body, recover) {
|
|
1996
|
-
try {
|
|
1997
|
-
var result = body();
|
|
1998
|
-
} catch (e) {
|
|
1999
|
-
return recover(e);
|
|
2000
|
-
}
|
|
2164
|
+
function _catch$1(body, recover) {
|
|
2165
|
+
try {
|
|
2166
|
+
var result = body();
|
|
2167
|
+
} catch (e) {
|
|
2168
|
+
return recover(e);
|
|
2169
|
+
}
|
|
2001
2170
|
|
|
2002
2171
|
if (result && result.then) {
|
|
2003
2172
|
return result.then(void 0, recover);
|
|
@@ -2007,10 +2176,6 @@
|
|
|
2007
2176
|
}
|
|
2008
2177
|
|
|
2009
2178
|
function useVocabulary(vocabularyName, path) {
|
|
2010
|
-
if (path === void 0) {
|
|
2011
|
-
path = null;
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
2179
|
var traversal = useTraversal();
|
|
2015
2180
|
|
|
2016
2181
|
var _useSetState = useSetState({
|
|
@@ -2079,8 +2244,10 @@
|
|
|
2079
2244
|
var vocabulary = useVocabulary(vocabularyName);
|
|
2080
2245
|
|
|
2081
2246
|
var getOptions = function getOptions() {
|
|
2082
|
-
if (get
|
|
2083
|
-
var
|
|
2247
|
+
if (get(vocabulary, 'data.items', null)) {
|
|
2248
|
+
var _vocabulary$data$item, _vocabulary$data;
|
|
2249
|
+
|
|
2250
|
+
var vocData = ((_vocabulary$data$item = vocabulary == null ? void 0 : (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).map(function (item) {
|
|
2084
2251
|
return {
|
|
2085
2252
|
text: item.title,
|
|
2086
2253
|
value: item.token
|
|
@@ -2126,6 +2293,8 @@
|
|
|
2126
2293
|
});
|
|
2127
2294
|
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
2128
2295
|
|
|
2296
|
+
// https://github.com/molefrog/wouter
|
|
2297
|
+
|
|
2129
2298
|
var setURLParams = function setURLParams(p) {
|
|
2130
2299
|
return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
|
|
2131
2300
|
};
|
|
@@ -2145,7 +2314,10 @@
|
|
|
2145
2314
|
|
|
2146
2315
|
var prevPath = React.useRef(path);
|
|
2147
2316
|
React.useEffect(function () {
|
|
2148
|
-
patchHistoryEvents();
|
|
2317
|
+
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
2318
|
+
// last render and updates the state only when needed.
|
|
2319
|
+
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
2320
|
+
// that's why we store the last pathname in a ref.
|
|
2149
2321
|
|
|
2150
2322
|
var checkForUpdates = function checkForUpdates() {
|
|
2151
2323
|
var pathname = currentSearchParams();
|
|
@@ -2155,14 +2327,22 @@
|
|
|
2155
2327
|
var events = ['popstate', 'pushState', 'replaceState'];
|
|
2156
2328
|
events.map(function (e) {
|
|
2157
2329
|
return window.addEventListener(e, checkForUpdates);
|
|
2158
|
-
});
|
|
2330
|
+
}); // it's possible that an update has occurred between render and the effect handler,
|
|
2331
|
+
// so we run additional check on mount to catch these updates. Based on:
|
|
2332
|
+
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
2333
|
+
|
|
2159
2334
|
checkForUpdates();
|
|
2160
2335
|
return function () {
|
|
2161
2336
|
events.map(function (e) {
|
|
2162
2337
|
return window.removeEventListener(e, checkForUpdates);
|
|
2163
2338
|
});
|
|
2164
2339
|
};
|
|
2165
|
-
}, []);
|
|
2340
|
+
}, []); // the 2nd argument of the `useLocation` return value is a function
|
|
2341
|
+
// that allows to perform a navigation.
|
|
2342
|
+
//
|
|
2343
|
+
// the function reference should stay the same between re-renders, so that
|
|
2344
|
+
// it can be passed down as an element prop without any performance concerns.
|
|
2345
|
+
|
|
2166
2346
|
var navigate = React.useCallback(function (to, replace) {
|
|
2167
2347
|
if (replace) {
|
|
2168
2348
|
clean(to);
|
|
@@ -2181,23 +2361,40 @@
|
|
|
2181
2361
|
setURLParams(current);
|
|
2182
2362
|
}, [path]);
|
|
2183
2363
|
return [path, navigate, remove];
|
|
2184
|
-
};
|
|
2364
|
+
}; // While History API does have `popstate` event, the only
|
|
2365
|
+
// proper way to listen to changes via `push/replaceState`
|
|
2366
|
+
// is to monkey-patch these methods.
|
|
2367
|
+
//
|
|
2368
|
+
// See https://stackoverflow.com/a/4585031
|
|
2369
|
+
|
|
2185
2370
|
var patched = 0;
|
|
2186
2371
|
|
|
2187
2372
|
var patchHistoryEvents = function patchHistoryEvents() {
|
|
2188
2373
|
if (patched) return;
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2374
|
+
var originalPushState = window.history.pushState;
|
|
2375
|
+
|
|
2376
|
+
window.history.pushState = function () {
|
|
2377
|
+
var args = [].slice.call(arguments);
|
|
2378
|
+
var result = originalPushState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2379
|
+
|
|
2380
|
+
var event = new Event('pushState');
|
|
2381
|
+
event.arguments = args;
|
|
2382
|
+
dispatchEvent(event);
|
|
2383
|
+
return result;
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
var originalReplaceState = window.history.replaceState;
|
|
2387
|
+
|
|
2388
|
+
window.history.replaceState = function () {
|
|
2389
|
+
var args = [].slice.call(arguments);
|
|
2390
|
+
var result = originalReplaceState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2391
|
+
|
|
2392
|
+
var event = new Event('replaceState');
|
|
2393
|
+
event.arguments = args;
|
|
2394
|
+
dispatchEvent(event);
|
|
2395
|
+
return result;
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2201
2398
|
return patched = 1;
|
|
2202
2399
|
};
|
|
2203
2400
|
|
|
@@ -2252,7 +2449,7 @@
|
|
|
2252
2449
|
children = _ref.children,
|
|
2253
2450
|
_ref$style = _ref.style,
|
|
2254
2451
|
style = _ref$style === void 0 ? {} : _ref$style;
|
|
2255
|
-
var link = React.useRef();
|
|
2452
|
+
var link = React.useRef(null);
|
|
2256
2453
|
|
|
2257
2454
|
function onClick() {
|
|
2258
2455
|
if (link && link.current) {
|
|
@@ -2359,15 +2556,7 @@
|
|
|
2359
2556
|
|
|
2360
2557
|
var _proto = RestClient.prototype;
|
|
2361
2558
|
|
|
2362
|
-
_proto.request = function request(path, data, headers) {
|
|
2363
|
-
if (data === void 0) {
|
|
2364
|
-
data = undefined;
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2367
|
-
if (headers === void 0) {
|
|
2368
|
-
headers = undefined;
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2559
|
+
_proto.request = function request(path, data, headers, signal) {
|
|
2371
2560
|
try {
|
|
2372
2561
|
var _this2 = this;
|
|
2373
2562
|
|
|
@@ -2383,9 +2572,18 @@
|
|
|
2383
2572
|
path = "/" + path;
|
|
2384
2573
|
}
|
|
2385
2574
|
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2575
|
+
var dataRequest = data || {};
|
|
2576
|
+
dataRequest.headers = _this2.getHeaders();
|
|
2577
|
+
|
|
2578
|
+
if (headers) {
|
|
2579
|
+
dataRequest.headers = _extends({}, dataRequest.headers, headers);
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
if (signal) {
|
|
2583
|
+
dataRequest.signal = signal;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
return Promise.resolve(fetch("" + _this2.url + path, dataRequest));
|
|
2389
2587
|
} catch (e) {
|
|
2390
2588
|
return Promise.reject(e);
|
|
2391
2589
|
}
|
|
@@ -2393,12 +2591,12 @@
|
|
|
2393
2591
|
|
|
2394
2592
|
_proto.getHeaders = function getHeaders() {
|
|
2395
2593
|
var authToken = this.auth.getToken();
|
|
2396
|
-
|
|
2397
|
-
return
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2594
|
+
var headersInit = {};
|
|
2595
|
+
if (!authToken) return headersInit;
|
|
2596
|
+
headersInit.Accept = 'application/json';
|
|
2597
|
+
headersInit['Content-Type'] = 'application/json';
|
|
2598
|
+
headersInit.Authorization = 'Bearer ' + authToken;
|
|
2599
|
+
return headersInit;
|
|
2402
2600
|
};
|
|
2403
2601
|
|
|
2404
2602
|
_proto.post = function post(path, data) {
|
|
@@ -2414,11 +2612,11 @@
|
|
|
2414
2612
|
}
|
|
2415
2613
|
};
|
|
2416
2614
|
|
|
2417
|
-
_proto.get = function get(path) {
|
|
2615
|
+
_proto.get = function get(path, signal) {
|
|
2418
2616
|
try {
|
|
2419
2617
|
var _this6 = this;
|
|
2420
2618
|
|
|
2421
|
-
return Promise.resolve(_this6.request(path));
|
|
2619
|
+
return Promise.resolve(_this6.request(path, undefined, undefined, signal));
|
|
2422
2620
|
} catch (e) {
|
|
2423
2621
|
return Promise.reject(e);
|
|
2424
2622
|
}
|
|
@@ -2456,24 +2654,20 @@
|
|
|
2456
2654
|
|
|
2457
2655
|
var headers = _this12.getHeaders();
|
|
2458
2656
|
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2657
|
+
var newHeaders = {};
|
|
2658
|
+
newHeaders['Content-Type'] = data['content-type'];
|
|
2659
|
+
newHeaders['X-UPLOAD-FILENAME'] = data.filename;
|
|
2660
|
+
newHeaders['Content-Encoding'] = 'base64';
|
|
2463
2661
|
return Promise.resolve(_this12.request(path, {
|
|
2464
2662
|
method: 'PATCH',
|
|
2465
2663
|
body: data.data
|
|
2466
|
-
}, headers));
|
|
2664
|
+
}, _extends({}, headers, newHeaders)));
|
|
2467
2665
|
} catch (e) {
|
|
2468
2666
|
return Promise.reject(e);
|
|
2469
2667
|
}
|
|
2470
2668
|
};
|
|
2471
2669
|
|
|
2472
2670
|
_proto.delete = function _delete(path, data) {
|
|
2473
|
-
if (data === void 0) {
|
|
2474
|
-
data = undefined;
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
2671
|
try {
|
|
2478
2672
|
var _this14 = this;
|
|
2479
2673
|
|
|
@@ -2614,6 +2808,14 @@
|
|
|
2614
2808
|
}
|
|
2615
2809
|
};
|
|
2616
2810
|
|
|
2811
|
+
_proto.getQueryParamsSearchFunction = function getQueryParamsSearchFunction(name) {
|
|
2812
|
+
if (name === 'getQueryParamsElasticsearch') {
|
|
2813
|
+
return this.getQueryParamsElasticsearch;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
return this.getQueryParamsPostresql;
|
|
2817
|
+
};
|
|
2818
|
+
|
|
2617
2819
|
_proto.getQueryParamsPostresql = function getQueryParamsPostresql(_ref) {
|
|
2618
2820
|
var _ref$start = _ref.start,
|
|
2619
2821
|
start = _ref$start === void 0 ? 0 : _ref$start,
|
|
@@ -2705,7 +2907,7 @@
|
|
|
2705
2907
|
label: 'id/name',
|
|
2706
2908
|
key: 'title',
|
|
2707
2909
|
isSortable: true,
|
|
2708
|
-
child: function child(m,
|
|
2910
|
+
child: function child(m, _navigate, search) {
|
|
2709
2911
|
return jsxRuntime.jsxs(TdLink, {
|
|
2710
2912
|
model: m,
|
|
2711
2913
|
children: [m.name, search && jsxRuntime.jsxs(React__default['default'].Fragment, {
|
|
@@ -2739,15 +2941,19 @@
|
|
|
2739
2941
|
});
|
|
2740
2942
|
}
|
|
2741
2943
|
}];
|
|
2742
|
-
}
|
|
2944
|
+
} // BBB API changes. Compat G5 and G6
|
|
2945
|
+
;
|
|
2743
2946
|
|
|
2744
2947
|
_proto.applyCompat = function applyCompat(data) {
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2948
|
+
var result = _extends({}, data, {
|
|
2949
|
+
member: data.items,
|
|
2950
|
+
items_count: data.items_total
|
|
2951
|
+
});
|
|
2952
|
+
|
|
2953
|
+
return result;
|
|
2748
2954
|
};
|
|
2749
2955
|
|
|
2750
|
-
_proto.search = function search(path, params, container, prepare) {
|
|
2956
|
+
_proto.search = function search(path, params, container, prepare, signal) {
|
|
2751
2957
|
if (container === void 0) {
|
|
2752
2958
|
container = false;
|
|
2753
2959
|
}
|
|
@@ -2769,7 +2975,7 @@
|
|
|
2769
2975
|
|
|
2770
2976
|
var query = prepare ? toQueryString(params) : params;
|
|
2771
2977
|
var url = path + "@search?" + query;
|
|
2772
|
-
return Promise.resolve(_this7.rest.get(url)).then(function (res) {
|
|
2978
|
+
return Promise.resolve(_this7.rest.get(url, signal)).then(function (res) {
|
|
2773
2979
|
return Promise.resolve(res.json()).then(function (data) {
|
|
2774
2980
|
return _this7.applyCompat(data);
|
|
2775
2981
|
});
|
|
@@ -2899,7 +3105,8 @@
|
|
|
2899
3105
|
|
|
2900
3106
|
var _temp4 = function () {
|
|
2901
3107
|
if (!cacheSchemas[name]) {
|
|
2902
|
-
var url = _this25.getContainerFromPath(path);
|
|
3108
|
+
var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
|
|
3109
|
+
|
|
2903
3110
|
|
|
2904
3111
|
return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
|
|
2905
3112
|
return Promise.resolve(res.json()).then(function (_res$json) {
|
|
@@ -2980,23 +3187,53 @@
|
|
|
2980
3187
|
var users = _this37.getUsers(path);
|
|
2981
3188
|
|
|
2982
3189
|
return Promise.resolve(Promise.all([groups, users])).then(function (_ref3) {
|
|
2983
|
-
var
|
|
2984
|
-
|
|
3190
|
+
var responseGroups = _ref3[0],
|
|
3191
|
+
responseUsers = _ref3[1];
|
|
2985
3192
|
|
|
2986
|
-
function
|
|
2987
|
-
function
|
|
3193
|
+
function _temp8() {
|
|
3194
|
+
function _temp6() {
|
|
2988
3195
|
return {
|
|
2989
|
-
groups:
|
|
2990
|
-
users:
|
|
3196
|
+
groups: groupsData,
|
|
3197
|
+
users: usersData
|
|
2991
3198
|
};
|
|
2992
3199
|
}
|
|
2993
3200
|
|
|
2994
|
-
var
|
|
2995
|
-
|
|
3201
|
+
var _temp5 = function () {
|
|
3202
|
+
if (responseUsers) {
|
|
3203
|
+
return Promise.resolve(responseUsers.json()).then(function (usersDataResponse) {
|
|
3204
|
+
usersData = usersDataResponse.map(function (user) {
|
|
3205
|
+
return {
|
|
3206
|
+
'@name': user.id,
|
|
3207
|
+
user_roles: user.roles,
|
|
3208
|
+
fullname: user.fullname,
|
|
3209
|
+
email: user.email
|
|
3210
|
+
};
|
|
3211
|
+
});
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
}();
|
|
3215
|
+
|
|
3216
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
2996
3217
|
}
|
|
2997
3218
|
|
|
2998
|
-
var
|
|
2999
|
-
|
|
3219
|
+
var groupsData = [];
|
|
3220
|
+
var usersData = [];
|
|
3221
|
+
|
|
3222
|
+
var _temp7 = function () {
|
|
3223
|
+
if (responseGroups.ok) {
|
|
3224
|
+
return Promise.resolve(responseGroups.json()).then(function (groupsDataResponse) {
|
|
3225
|
+
groupsData = groupsDataResponse.map(function (group) {
|
|
3226
|
+
return {
|
|
3227
|
+
'@name': group.id,
|
|
3228
|
+
user_roles: group.roles,
|
|
3229
|
+
users: group.users
|
|
3230
|
+
};
|
|
3231
|
+
});
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
}();
|
|
3235
|
+
|
|
3236
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
3000
3237
|
});
|
|
3001
3238
|
} catch (e) {
|
|
3002
3239
|
return Promise.reject(e);
|
|
@@ -3018,6 +3255,7 @@
|
|
|
3018
3255
|
try {
|
|
3019
3256
|
var _this41 = this;
|
|
3020
3257
|
|
|
3258
|
+
// paths used to query the API always has to start without a "/"
|
|
3021
3259
|
if (path.startsWith('/')) {
|
|
3022
3260
|
path = path.slice(1);
|
|
3023
3261
|
}
|
|
@@ -3037,7 +3275,7 @@
|
|
|
3037
3275
|
try {
|
|
3038
3276
|
var _this43 = this;
|
|
3039
3277
|
|
|
3040
|
-
function
|
|
3278
|
+
function _temp12() {
|
|
3041
3279
|
return cacheTypes[path];
|
|
3042
3280
|
}
|
|
3043
3281
|
|
|
@@ -3045,10 +3283,10 @@
|
|
|
3045
3283
|
path = path.slice(1);
|
|
3046
3284
|
}
|
|
3047
3285
|
|
|
3048
|
-
var
|
|
3286
|
+
var _temp13 = function () {
|
|
3049
3287
|
if (!cacheTypes[path]) {
|
|
3050
3288
|
return Promise.resolve(_this43.rest.get(path + '@addable-types')).then(function (types) {
|
|
3051
|
-
var
|
|
3289
|
+
var _temp9 = function () {
|
|
3052
3290
|
if (types.status === 401 || types.status === 404) {
|
|
3053
3291
|
cacheTypes[path] = [];
|
|
3054
3292
|
} else {
|
|
@@ -3058,12 +3296,12 @@
|
|
|
3058
3296
|
}
|
|
3059
3297
|
}();
|
|
3060
3298
|
|
|
3061
|
-
if (
|
|
3299
|
+
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
3062
3300
|
});
|
|
3063
3301
|
}
|
|
3064
3302
|
}();
|
|
3065
3303
|
|
|
3066
|
-
return Promise.resolve(
|
|
3304
|
+
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
|
|
3067
3305
|
} catch (e) {
|
|
3068
3306
|
return Promise.reject(e);
|
|
3069
3307
|
}
|
|
@@ -3075,17 +3313,24 @@
|
|
|
3075
3313
|
return new GuillotinaClient(new RestClient(url, container, auth), container === '/');
|
|
3076
3314
|
}
|
|
3077
3315
|
var lightFileReader = function lightFileReader(file) {
|
|
3078
|
-
return new Promise(function (resolve) {
|
|
3316
|
+
return new Promise(function (resolve, reject) {
|
|
3079
3317
|
var reader = new FileReader();
|
|
3080
3318
|
reader.readAsArrayBuffer(file);
|
|
3081
3319
|
|
|
3082
3320
|
reader.onloadend = function (e) {
|
|
3083
|
-
var
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3321
|
+
var _e$target;
|
|
3322
|
+
|
|
3323
|
+
var fileData = e == null ? void 0 : (_e$target = e.target) == null ? void 0 : _e$target.result;
|
|
3324
|
+
|
|
3325
|
+
if (fileData) {
|
|
3326
|
+
resolve({
|
|
3327
|
+
filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
|
|
3328
|
+
data: fileData,
|
|
3329
|
+
'content-type': file.type
|
|
3330
|
+
});
|
|
3331
|
+
} else {
|
|
3332
|
+
reject('Error reading file');
|
|
3333
|
+
}
|
|
3089
3334
|
};
|
|
3090
3335
|
});
|
|
3091
3336
|
};
|
|
@@ -3116,9 +3361,15 @@
|
|
|
3116
3361
|
|
|
3117
3362
|
var changed = function changed(event) {
|
|
3118
3363
|
try {
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3364
|
+
var _temp2 = function () {
|
|
3365
|
+
if (event.target.files) {
|
|
3366
|
+
return Promise.resolve(lightFileReader(event.target.files[0])).then(function (fileToUpload) {
|
|
3367
|
+
onChange(fileToUpload);
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
}();
|
|
3371
|
+
|
|
3372
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
3122
3373
|
} catch (e) {
|
|
3123
3374
|
return Promise.reject(e);
|
|
3124
3375
|
}
|
|
@@ -3209,12 +3460,12 @@
|
|
|
3209
3460
|
|
|
3210
3461
|
var defaultEvents = ['mousedown', 'touchstart'];
|
|
3211
3462
|
|
|
3212
|
-
var on = function on(obj) {
|
|
3213
|
-
return obj.addEventListener
|
|
3463
|
+
var on = function on(obj, type, handler) {
|
|
3464
|
+
return obj.addEventListener(type, handler);
|
|
3214
3465
|
};
|
|
3215
3466
|
|
|
3216
|
-
var off = function off(obj) {
|
|
3217
|
-
return obj.removeEventListener
|
|
3467
|
+
var off = function off(obj, type, handler) {
|
|
3468
|
+
return obj.removeEventListener(type, handler);
|
|
3218
3469
|
};
|
|
3219
3470
|
|
|
3220
3471
|
function useClickAway(ref, onClickAway, events) {
|
|
@@ -3246,23 +3497,7 @@
|
|
|
3246
3497
|
}, [events, ref]);
|
|
3247
3498
|
}
|
|
3248
3499
|
|
|
3249
|
-
|
|
3250
|
-
var timeout;
|
|
3251
|
-
return function () {
|
|
3252
|
-
var context = this;
|
|
3253
|
-
var args = arguments;
|
|
3254
|
-
|
|
3255
|
-
var later = function later() {
|
|
3256
|
-
timeout = null;
|
|
3257
|
-
func.apply(context, args);
|
|
3258
|
-
};
|
|
3259
|
-
|
|
3260
|
-
clearTimeout(timeout);
|
|
3261
|
-
timeout = setTimeout(later, wait);
|
|
3262
|
-
};
|
|
3263
|
-
}
|
|
3264
|
-
|
|
3265
|
-
var initialState = {
|
|
3500
|
+
var initialState$1 = {
|
|
3266
3501
|
page: 0,
|
|
3267
3502
|
items: undefined,
|
|
3268
3503
|
loading: false,
|
|
@@ -3272,10 +3507,9 @@
|
|
|
3272
3507
|
var onChange = _ref.onChange,
|
|
3273
3508
|
error = _ref.error,
|
|
3274
3509
|
errorZoneClassName = _ref.errorZoneClassName,
|
|
3275
|
-
|
|
3276
|
-
traversal = _ref$traversal === void 0 ? null : _ref$traversal,
|
|
3510
|
+
traversal = _ref.traversal,
|
|
3277
3511
|
_ref$path = _ref.path,
|
|
3278
|
-
path = _ref$path === void 0 ?
|
|
3512
|
+
path = _ref$path === void 0 ? undefined : _ref$path,
|
|
3279
3513
|
_ref$qs = _ref.qs,
|
|
3280
3514
|
qs = _ref$qs === void 0 ? [] : _ref$qs,
|
|
3281
3515
|
_ref$queryCondition = _ref.queryCondition,
|
|
@@ -3290,14 +3524,14 @@
|
|
|
3290
3524
|
_ref$dataTestItem = _ref.dataTestItem,
|
|
3291
3525
|
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
3292
3526
|
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
3293
|
-
renderTextItemOption = _ref$renderTextItemOp === void 0 ?
|
|
3527
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
|
|
3294
3528
|
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
3295
|
-
typeNameQuery = _ref$typeNameQuery === void 0 ?
|
|
3529
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
|
|
3296
3530
|
_ref$labelProperty = _ref.labelProperty,
|
|
3297
3531
|
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
3298
3532
|
var intl = reactIntl.useIntl();
|
|
3299
3533
|
|
|
3300
|
-
var _useSetState = useSetState(initialState),
|
|
3534
|
+
var _useSetState = useSetState(initialState$1),
|
|
3301
3535
|
options = _useSetState[0],
|
|
3302
3536
|
setOptions = _useSetState[1];
|
|
3303
3537
|
|
|
@@ -3351,7 +3585,7 @@
|
|
|
3351
3585
|
var searchTermParsed = ["id", value];
|
|
3352
3586
|
var getSearch = traversal.registry.get;
|
|
3353
3587
|
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3354
|
-
var qsParsed = traversal.client
|
|
3588
|
+
var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
|
|
3355
3589
|
path: traversal.path,
|
|
3356
3590
|
start: 0,
|
|
3357
3591
|
pageSize: PageSize,
|
|
@@ -3369,7 +3603,7 @@
|
|
|
3369
3603
|
|
|
3370
3604
|
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3371
3605
|
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
3372
|
-
result[item.id] = get
|
|
3606
|
+
result[item.id] = get(item, labelProperty, item.id);
|
|
3373
3607
|
return result;
|
|
3374
3608
|
}, {});
|
|
3375
3609
|
setValueLabel(newValuesLabel);
|
|
@@ -3397,6 +3631,7 @@
|
|
|
3397
3631
|
}
|
|
3398
3632
|
|
|
3399
3633
|
try {
|
|
3634
|
+
console.log('handle search input');
|
|
3400
3635
|
setOptions({
|
|
3401
3636
|
loading: true
|
|
3402
3637
|
});
|
|
@@ -3411,7 +3646,7 @@
|
|
|
3411
3646
|
|
|
3412
3647
|
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3413
3648
|
|
|
3414
|
-
var qsParsed = traversal.client
|
|
3649
|
+
var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
|
|
3415
3650
|
path: traversal.path,
|
|
3416
3651
|
start: page * PageSize,
|
|
3417
3652
|
pageSize: PageSize,
|
|
@@ -3424,7 +3659,7 @@
|
|
|
3424
3659
|
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
3425
3660
|
}
|
|
3426
3661
|
|
|
3427
|
-
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3662
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0 || sortParsed.length > 0) {
|
|
3428
3663
|
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
|
|
3429
3664
|
}
|
|
3430
3665
|
|
|
@@ -3449,7 +3684,7 @@
|
|
|
3449
3684
|
return renderTextItemOption(item);
|
|
3450
3685
|
}
|
|
3451
3686
|
|
|
3452
|
-
return get
|
|
3687
|
+
return get(item, labelProperty, item.title) || item['@name'];
|
|
3453
3688
|
};
|
|
3454
3689
|
|
|
3455
3690
|
React.useEffect(function () {
|
|
@@ -3475,7 +3710,7 @@
|
|
|
3475
3710
|
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3476
3711
|
if (searchTerm !== '') {
|
|
3477
3712
|
setSearchTerm('');
|
|
3478
|
-
setOptions(initialState);
|
|
3713
|
+
setOptions(initialState$1);
|
|
3479
3714
|
}
|
|
3480
3715
|
|
|
3481
3716
|
setIsOpen(false);
|
|
@@ -3493,6 +3728,7 @@
|
|
|
3493
3728
|
}
|
|
3494
3729
|
|
|
3495
3730
|
setIsOpen(!isOpen);
|
|
3731
|
+
console.log('on clic btn', options);
|
|
3496
3732
|
|
|
3497
3733
|
if (!options.loading && !options.items) {
|
|
3498
3734
|
handleSearch(options.page);
|
|
@@ -3501,7 +3737,7 @@
|
|
|
3501
3737
|
"aria-haspopup": "true",
|
|
3502
3738
|
"aria-controls": "dropdown-menu",
|
|
3503
3739
|
children: [jsxRuntime.jsx("span", {
|
|
3504
|
-
children: value ? get
|
|
3740
|
+
children: value ? get(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)
|
|
3505
3741
|
}), jsxRuntime.jsx("span", {
|
|
3506
3742
|
className: "icon",
|
|
3507
3743
|
children: jsxRuntime.jsx("i", {
|
|
@@ -3575,23 +3811,7 @@
|
|
|
3575
3811
|
});
|
|
3576
3812
|
};
|
|
3577
3813
|
|
|
3578
|
-
|
|
3579
|
-
var timeout;
|
|
3580
|
-
return function () {
|
|
3581
|
-
var context = this;
|
|
3582
|
-
var args = arguments;
|
|
3583
|
-
|
|
3584
|
-
var later = function later() {
|
|
3585
|
-
timeout = null;
|
|
3586
|
-
func.apply(context, args);
|
|
3587
|
-
};
|
|
3588
|
-
|
|
3589
|
-
clearTimeout(timeout);
|
|
3590
|
-
timeout = setTimeout(later, wait);
|
|
3591
|
-
};
|
|
3592
|
-
}
|
|
3593
|
-
|
|
3594
|
-
var initialState$1 = {
|
|
3814
|
+
var initialState$2 = {
|
|
3595
3815
|
page: 0,
|
|
3596
3816
|
items: undefined,
|
|
3597
3817
|
loading: false,
|
|
@@ -3601,10 +3821,9 @@
|
|
|
3601
3821
|
var onChange = _ref.onChange,
|
|
3602
3822
|
error = _ref.error,
|
|
3603
3823
|
errorZoneClassName = _ref.errorZoneClassName,
|
|
3604
|
-
|
|
3605
|
-
traversal = _ref$traversal === void 0 ? null : _ref$traversal,
|
|
3824
|
+
traversal = _ref.traversal,
|
|
3606
3825
|
_ref$path = _ref.path,
|
|
3607
|
-
path = _ref$path === void 0 ?
|
|
3826
|
+
path = _ref$path === void 0 ? undefined : _ref$path,
|
|
3608
3827
|
_ref$qs = _ref.qs,
|
|
3609
3828
|
qs = _ref$qs === void 0 ? [] : _ref$qs,
|
|
3610
3829
|
_ref$queryCondition = _ref.queryCondition,
|
|
@@ -3619,14 +3838,14 @@
|
|
|
3619
3838
|
_ref$dataTestItem = _ref.dataTestItem,
|
|
3620
3839
|
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
3621
3840
|
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
3622
|
-
renderTextItemOption = _ref$renderTextItemOp === void 0 ?
|
|
3841
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
|
|
3623
3842
|
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
3624
|
-
typeNameQuery = _ref$typeNameQuery === void 0 ?
|
|
3843
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
|
|
3625
3844
|
_ref$labelProperty = _ref.labelProperty,
|
|
3626
3845
|
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
3627
3846
|
var intl = reactIntl.useIntl();
|
|
3628
3847
|
|
|
3629
|
-
var _useSetState = useSetState(initialState$
|
|
3848
|
+
var _useSetState = useSetState(initialState$2),
|
|
3630
3849
|
options = _useSetState[0],
|
|
3631
3850
|
setOptions = _useSetState[1];
|
|
3632
3851
|
|
|
@@ -3672,7 +3891,7 @@
|
|
|
3672
3891
|
};
|
|
3673
3892
|
};
|
|
3674
3893
|
|
|
3675
|
-
var delayedQuery = React.useCallback(debounce
|
|
3894
|
+
var delayedQuery = React.useCallback(debounce(function (value) {
|
|
3676
3895
|
return handleSearch(0, false, value);
|
|
3677
3896
|
}, 500), []);
|
|
3678
3897
|
|
|
@@ -3704,7 +3923,7 @@
|
|
|
3704
3923
|
|
|
3705
3924
|
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3706
3925
|
|
|
3707
|
-
var qsParsed = traversal.client
|
|
3926
|
+
var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
|
|
3708
3927
|
path: traversal.path,
|
|
3709
3928
|
start: page * PageSize,
|
|
3710
3929
|
pageSize: PageSize,
|
|
@@ -3746,7 +3965,7 @@
|
|
|
3746
3965
|
var searchTermParsed = ['__or', "id=" + value.join('%26id=')];
|
|
3747
3966
|
var getSearch = traversal.registry.get;
|
|
3748
3967
|
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3749
|
-
var qsParsed = traversal.client
|
|
3968
|
+
var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
|
|
3750
3969
|
path: traversal.path,
|
|
3751
3970
|
start: 0,
|
|
3752
3971
|
pageSize: 100,
|
|
@@ -3762,9 +3981,9 @@
|
|
|
3762
3981
|
searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
|
|
3763
3982
|
}
|
|
3764
3983
|
|
|
3765
|
-
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false
|
|
3984
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3766
3985
|
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
3767
|
-
result[item.id] = get
|
|
3986
|
+
result[item.id] = get(item, labelProperty, item.id);
|
|
3768
3987
|
return result;
|
|
3769
3988
|
}, {});
|
|
3770
3989
|
setValuesLabels(newValuesLabel);
|
|
@@ -3784,7 +4003,7 @@
|
|
|
3784
4003
|
return renderTextItemOption(item);
|
|
3785
4004
|
}
|
|
3786
4005
|
|
|
3787
|
-
return get
|
|
4006
|
+
return get(item, labelProperty, item.title) || item['@name'];
|
|
3788
4007
|
};
|
|
3789
4008
|
|
|
3790
4009
|
React.useEffect(function () {
|
|
@@ -3807,7 +4026,7 @@
|
|
|
3807
4026
|
children: value.map(function (tag, index) {
|
|
3808
4027
|
return jsxRuntime.jsxs("div", {
|
|
3809
4028
|
className: "tag is-info is-medium",
|
|
3810
|
-
children: [get
|
|
4029
|
+
children: [get(valuesLabel, tag, tag), jsxRuntime.jsx("button", {
|
|
3811
4030
|
className: "delete is-small",
|
|
3812
4031
|
onClick: function onClick(ev) {
|
|
3813
4032
|
ev.stopPropagation();
|
|
@@ -3827,7 +4046,7 @@
|
|
|
3827
4046
|
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3828
4047
|
if (searchTerm !== '') {
|
|
3829
4048
|
setSearchTerm('');
|
|
3830
|
-
setOptions(initialState$
|
|
4049
|
+
setOptions(initialState$2);
|
|
3831
4050
|
}
|
|
3832
4051
|
|
|
3833
4052
|
setIsOpen(false);
|
|
@@ -3891,7 +4110,7 @@
|
|
|
3891
4110
|
if (onChange && !value.includes(item.id)) {
|
|
3892
4111
|
var _extends2;
|
|
3893
4112
|
|
|
3894
|
-
setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get
|
|
4113
|
+
setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get(item, labelProperty, item.id), _extends2)));
|
|
3895
4114
|
onChange([].concat(value, [item.id]));
|
|
3896
4115
|
}
|
|
3897
4116
|
},
|
|
@@ -4079,7 +4298,7 @@
|
|
|
4079
4298
|
ref.current.focus();
|
|
4080
4299
|
}
|
|
4081
4300
|
});
|
|
4082
|
-
var canModified = modifyContent && !get
|
|
4301
|
+
var canModified = schema !== undefined && modifyContent && !get(schema, 'readonly', false);
|
|
4083
4302
|
|
|
4084
4303
|
var saveField = function saveField(ev) {
|
|
4085
4304
|
try {
|
|
@@ -4145,7 +4364,7 @@
|
|
|
4145
4364
|
var deleteField = function deleteField(ev) {
|
|
4146
4365
|
try {
|
|
4147
4366
|
if (ev) ev.preventDefault();
|
|
4148
|
-
return Promise.resolve(function () {
|
|
4367
|
+
return Promise.resolve(function (_schema$items) {
|
|
4149
4368
|
if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
4150
4369
|
var _ns2, _ref4, _ref5;
|
|
4151
4370
|
|
|
@@ -4173,7 +4392,7 @@
|
|
|
4173
4392
|
});
|
|
4174
4393
|
} else if ((schema == null ? void 0 : schema.type) === 'string' && schema != null && schema.enum) {
|
|
4175
4394
|
setValue(null);
|
|
4176
|
-
} else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : schema.items.type) === 'string') {
|
|
4395
|
+
} else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.type) === 'string') {
|
|
4177
4396
|
setValue([]);
|
|
4178
4397
|
}
|
|
4179
4398
|
}());
|
|
@@ -4230,7 +4449,7 @@
|
|
|
4230
4449
|
dataTest: "editableFieldBtnCancelTest",
|
|
4231
4450
|
children: intl.formatMessage(genericMessages.cancel)
|
|
4232
4451
|
})
|
|
4233
|
-
}), !required && fieldHaveDeleteButton(schema) && jsxRuntime.jsx("div", {
|
|
4452
|
+
}), !required && schema && fieldHaveDeleteButton(schema) && jsxRuntime.jsx("div", {
|
|
4234
4453
|
className: "control",
|
|
4235
4454
|
children: jsxRuntime.jsx(Button, {
|
|
4236
4455
|
className: "is-small is-danger",
|
|
@@ -4259,7 +4478,8 @@
|
|
|
4259
4478
|
var blob = new Blob([text], {
|
|
4260
4479
|
type: data.content_type
|
|
4261
4480
|
});
|
|
4262
|
-
var url = window.URL.createObjectURL(blob);
|
|
4481
|
+
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
4482
|
+
|
|
4263
4483
|
var link = document.createElement('a');
|
|
4264
4484
|
link.href = url;
|
|
4265
4485
|
|
|
@@ -4274,6 +4494,7 @@
|
|
|
4274
4494
|
setTimeout(function () {
|
|
4275
4495
|
var _link$parentNode;
|
|
4276
4496
|
|
|
4497
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
4277
4498
|
window.URL.revokeObjectURL(url);
|
|
4278
4499
|
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
4279
4500
|
}, 100);
|
|
@@ -4349,23 +4570,27 @@
|
|
|
4349
4570
|
}
|
|
4350
4571
|
|
|
4351
4572
|
if (type === 'object') {
|
|
4573
|
+
var _schema$properties;
|
|
4574
|
+
|
|
4352
4575
|
if (Array.isArray(value)) {
|
|
4353
|
-
return value.map(function (item) {
|
|
4576
|
+
return value.map(function (item, index) {
|
|
4354
4577
|
return jsxRuntime.jsx("div", {
|
|
4355
4578
|
children: jsxRuntime.jsx(RenderField, {
|
|
4356
4579
|
value: item
|
|
4357
4580
|
})
|
|
4358
|
-
},
|
|
4581
|
+
}, "renderField_" + index + "_" + (schema == null ? void 0 : schema.title));
|
|
4359
4582
|
});
|
|
4360
4583
|
}
|
|
4361
4584
|
|
|
4362
|
-
|
|
4363
|
-
return
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4585
|
+
if ((schema == null ? void 0 : (_schema$properties = schema.properties) == null ? void 0 : _schema$properties.key) !== undefined) {
|
|
4586
|
+
return Object.keys(value).map(function (key) {
|
|
4587
|
+
return jsxRuntime.jsx(FieldValue, {
|
|
4588
|
+
field: get(schema, "properties." + key + ".title", key),
|
|
4589
|
+
schema: schema.properties.key,
|
|
4590
|
+
value: get(value, key, {})
|
|
4591
|
+
}, key);
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4369
4594
|
}
|
|
4370
4595
|
|
|
4371
4596
|
return jsxRuntime.jsxs("p", {
|
|
@@ -4409,6 +4634,7 @@
|
|
|
4409
4634
|
var schema = _ref3.schema,
|
|
4410
4635
|
value = _ref3.value,
|
|
4411
4636
|
modifyContent = _ref3.modifyContent;
|
|
4637
|
+
console.log('search render fields');
|
|
4412
4638
|
var intl = reactIntl.useIntl();
|
|
4413
4639
|
|
|
4414
4640
|
var _useState = React.useState([]),
|
|
@@ -4433,7 +4659,7 @@
|
|
|
4433
4659
|
var searchTermParsed = ['__or', "id=" + valuesToSearch.join('%26id=')];
|
|
4434
4660
|
var getSearch = traversal.registry.get;
|
|
4435
4661
|
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
4436
|
-
var qsParsed = traversal.client
|
|
4662
|
+
var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
|
|
4437
4663
|
path: traversal.path,
|
|
4438
4664
|
start: 0,
|
|
4439
4665
|
pageSize: 100,
|
|
@@ -4444,11 +4670,11 @@
|
|
|
4444
4670
|
searchTermQs = buildQs([searchTermParsed].concat(qsParsed));
|
|
4445
4671
|
}
|
|
4446
4672
|
|
|
4447
|
-
return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false
|
|
4673
|
+
return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
4448
4674
|
var newValuesLabel = data.items.map(function (item) {
|
|
4449
4675
|
var _schema$labelProperty;
|
|
4450
4676
|
|
|
4451
|
-
return get
|
|
4677
|
+
return get(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
|
|
4452
4678
|
});
|
|
4453
4679
|
setValuesLabels(newValuesLabel);
|
|
4454
4680
|
setIsLoadingData(false);
|
|
@@ -4458,13 +4684,15 @@
|
|
|
4458
4684
|
}
|
|
4459
4685
|
};
|
|
4460
4686
|
|
|
4461
|
-
var valuesToSearch =
|
|
4687
|
+
var valuesToSearch = [];
|
|
4462
4688
|
|
|
4463
|
-
if (typeof
|
|
4464
|
-
valuesToSearch = [
|
|
4689
|
+
if (typeof value === 'string' && value) {
|
|
4690
|
+
valuesToSearch = [value];
|
|
4691
|
+
} else if (Array.isArray(value)) {
|
|
4692
|
+
valuesToSearch = value;
|
|
4465
4693
|
}
|
|
4466
4694
|
|
|
4467
|
-
if (valuesToSearch
|
|
4695
|
+
if (valuesToSearch.length > 0) {
|
|
4468
4696
|
fetchData(valuesToSearch);
|
|
4469
4697
|
} else {
|
|
4470
4698
|
setValuesLabels([]);
|
|
@@ -4499,7 +4727,7 @@
|
|
|
4499
4727
|
modifyContent = _ref4.modifyContent;
|
|
4500
4728
|
var intl = reactIntl.useIntl();
|
|
4501
4729
|
var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
4502
|
-
var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
4730
|
+
var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName) || '';
|
|
4503
4731
|
var vocabulary = useVocabulary(vocabularyName);
|
|
4504
4732
|
|
|
4505
4733
|
var getRenderProps = function getRenderProps() {
|
|
@@ -4510,7 +4738,7 @@
|
|
|
4510
4738
|
if (schema != null && schema.vocabularyName) {
|
|
4511
4739
|
var _vocabularyValue$titl;
|
|
4512
4740
|
|
|
4513
|
-
var vocabularyValue = get
|
|
4741
|
+
var vocabularyValue = get(vocabulary, 'data.items', []).find(function (item) {
|
|
4514
4742
|
return item.token === value;
|
|
4515
4743
|
});
|
|
4516
4744
|
renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
|
|
@@ -4520,7 +4748,7 @@
|
|
|
4520
4748
|
renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(function (value) {
|
|
4521
4749
|
var _get$find$title, _get$find;
|
|
4522
4750
|
|
|
4523
|
-
return (_get$find$title = (_get$find = get
|
|
4751
|
+
return (_get$find$title = (_get$find = get(vocabulary, 'data.items', []).find(function (item) {
|
|
4524
4752
|
return item.token === value;
|
|
4525
4753
|
})) == null ? void 0 : _get$find.title) != null ? _get$find$title : '';
|
|
4526
4754
|
});
|
|
@@ -4597,7 +4825,7 @@
|
|
|
4597
4825
|
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4598
4826
|
path: schema.queryPath,
|
|
4599
4827
|
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4600
|
-
typeNameQuery: schema
|
|
4828
|
+
typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
|
|
4601
4829
|
})]
|
|
4602
4830
|
});
|
|
4603
4831
|
} else if ((schema == null ? void 0 : schema.widget) === 'search') {
|
|
@@ -4614,7 +4842,7 @@
|
|
|
4614
4842
|
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4615
4843
|
path: schema.queryPath,
|
|
4616
4844
|
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4617
|
-
typeNameQuery: schema
|
|
4845
|
+
typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
|
|
4618
4846
|
})]
|
|
4619
4847
|
});
|
|
4620
4848
|
} else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
@@ -4644,7 +4872,7 @@
|
|
|
4644
4872
|
|
|
4645
4873
|
if (schema.items.vocabularyName) {
|
|
4646
4874
|
return jsxRuntime.jsx(SelectVocabulary, {
|
|
4647
|
-
vocabularyName: get
|
|
4875
|
+
vocabularyName: get(schema, 'items.vocabularyName', ''),
|
|
4648
4876
|
val: val || [],
|
|
4649
4877
|
className: className,
|
|
4650
4878
|
classWrap: "is-fullwidth",
|
|
@@ -4681,22 +4909,25 @@
|
|
|
4681
4909
|
}), jsxRuntime.jsx(InputList, {
|
|
4682
4910
|
value: val || [],
|
|
4683
4911
|
className: className,
|
|
4684
|
-
onChange: function onChange(
|
|
4685
|
-
return _setValue(
|
|
4912
|
+
onChange: function onChange(val) {
|
|
4913
|
+
return _setValue(val);
|
|
4686
4914
|
},
|
|
4687
4915
|
ref: ref,
|
|
4688
4916
|
dataTest: dataTest
|
|
4689
4917
|
})]
|
|
4690
4918
|
});
|
|
4691
4919
|
} else if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
4920
|
+
var value = val;
|
|
4692
4921
|
return jsxRuntime.jsx(FileUpload, {
|
|
4693
4922
|
onChange: function onChange(ev) {
|
|
4694
4923
|
return _setValue(ev);
|
|
4695
4924
|
},
|
|
4696
|
-
label: get
|
|
4925
|
+
label: get(value, 'filename', undefined),
|
|
4697
4926
|
dataTest: dataTest
|
|
4698
4927
|
});
|
|
4699
4928
|
} else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
|
|
4929
|
+
var _schema$vocabulary;
|
|
4930
|
+
|
|
4700
4931
|
if (schema != null && schema.vocabularyName) {
|
|
4701
4932
|
return jsxRuntime.jsx(SelectVocabulary, {
|
|
4702
4933
|
val: val || '',
|
|
@@ -4705,7 +4936,7 @@
|
|
|
4705
4936
|
classWrap: "is-fullwidth",
|
|
4706
4937
|
dataTest: dataTest,
|
|
4707
4938
|
onChange: _setValue,
|
|
4708
|
-
vocabularyName: get
|
|
4939
|
+
vocabularyName: get(schema, 'vocabularyName', ''),
|
|
4709
4940
|
placeholder: placeholder,
|
|
4710
4941
|
id: id
|
|
4711
4942
|
});
|
|
@@ -4717,7 +4948,7 @@
|
|
|
4717
4948
|
appendDefault: true,
|
|
4718
4949
|
classWrap: "is-fullwidth",
|
|
4719
4950
|
dataTest: dataTest,
|
|
4720
|
-
options: schema == null ? void 0 : schema.vocabulary.map(function (item) {
|
|
4951
|
+
options: ((_schema$vocabulary = schema == null ? void 0 : schema.vocabulary) != null ? _schema$vocabulary : []).map(function (item) {
|
|
4721
4952
|
return {
|
|
4722
4953
|
text: item,
|
|
4723
4954
|
value: item
|
|
@@ -4728,26 +4959,27 @@
|
|
|
4728
4959
|
id: id
|
|
4729
4960
|
});
|
|
4730
4961
|
} else if ((schema == null ? void 0 : schema.type) === 'object' && schema.widget !== 'file') {
|
|
4731
|
-
var
|
|
4962
|
+
var _value = val;
|
|
4732
4963
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4733
4964
|
children: [schema.title && jsxRuntime.jsx("h4", {
|
|
4734
4965
|
className: "subtitle mt-2",
|
|
4735
4966
|
children: schema.title
|
|
4736
|
-
}), Object.keys(get
|
|
4967
|
+
}), Object.keys(get(schema, 'properties', {})).map(function (key) {
|
|
4737
4968
|
var _subSchema$title;
|
|
4738
4969
|
|
|
4739
|
-
var subSchema = get
|
|
4740
|
-
var requiredFields = get
|
|
4970
|
+
var subSchema = get(schema, "properties." + key, null);
|
|
4971
|
+
var requiredFields = get(schema, 'required', []);
|
|
4972
|
+
if (!subSchema) return null;
|
|
4741
4973
|
return jsxRuntime.jsx(EditComponent, {
|
|
4742
4974
|
id: id + "[" + key + "]",
|
|
4743
4975
|
schema: subSchema,
|
|
4744
|
-
val:
|
|
4976
|
+
val: _value && key in _value ? _value[key] : '',
|
|
4745
4977
|
placeholder: (_subSchema$title = subSchema == null ? void 0 : subSchema.title) != null ? _subSchema$title : '',
|
|
4746
4978
|
required: requiredFields.includes(key),
|
|
4747
4979
|
setValue: function setValue(ev) {
|
|
4748
4980
|
var _extends2;
|
|
4749
4981
|
|
|
4750
|
-
_setValue(_extends({},
|
|
4982
|
+
_setValue(_extends({}, _value, (_extends2 = {}, _extends2[key] = ev, _extends2)));
|
|
4751
4983
|
},
|
|
4752
4984
|
dataTest: key + "TestInput"
|
|
4753
4985
|
}, id + "[" + key + "]");
|
|
@@ -4809,9 +5041,9 @@
|
|
|
4809
5041
|
}, 1), jsxRuntime.jsx("td", {
|
|
4810
5042
|
children: jsxRuntime.jsx(EditableField, {
|
|
4811
5043
|
field: key,
|
|
4812
|
-
value: values
|
|
5044
|
+
value: values.file,
|
|
4813
5045
|
ns: "guillotina.behaviors.attachment.IAttachment",
|
|
4814
|
-
schema: properties
|
|
5046
|
+
schema: properties.file,
|
|
4815
5047
|
modifyContent: modifyContent && ['file'].includes(key)
|
|
4816
5048
|
})
|
|
4817
5049
|
}, 2)]
|
|
@@ -4861,6 +5093,11 @@
|
|
|
4861
5093
|
|
|
4862
5094
|
setLoading(true);
|
|
4863
5095
|
setError(undefined);
|
|
5096
|
+
|
|
5097
|
+
if (!file) {
|
|
5098
|
+
return Promise.resolve();
|
|
5099
|
+
}
|
|
5100
|
+
|
|
4864
5101
|
var endpoint = Ctx.path + "@upload/files/" + fileKey;
|
|
4865
5102
|
return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
|
|
4866
5103
|
if (req.status !== 200) {
|
|
@@ -4929,7 +5166,7 @@
|
|
|
4929
5166
|
field: "files/" + key,
|
|
4930
5167
|
value: values['files'][key],
|
|
4931
5168
|
ns: "guillotina.behaviors.attachment.IMultiAttachment.files",
|
|
4932
|
-
schema: properties
|
|
5169
|
+
schema: get(properties, 'files.additionalProperties', {}),
|
|
4933
5170
|
modifyContent: false
|
|
4934
5171
|
}), jsxRuntime.jsx("div", {
|
|
4935
5172
|
className: "ml-5",
|
|
@@ -5153,13 +5390,18 @@
|
|
|
5153
5390
|
ev.preventDefault();
|
|
5154
5391
|
setLoading(true);
|
|
5155
5392
|
setError(undefined);
|
|
5393
|
+
|
|
5394
|
+
if (!file) {
|
|
5395
|
+
return Promise.resolve();
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5156
5398
|
var endpoint = Ctx.path + "@upload/image";
|
|
5157
5399
|
return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
|
|
5158
5400
|
var _exit;
|
|
5159
5401
|
|
|
5160
5402
|
function _temp4(_result) {
|
|
5161
5403
|
if (_exit) return _result;
|
|
5162
|
-
setFile(
|
|
5404
|
+
setFile(null);
|
|
5163
5405
|
setLoading(false);
|
|
5164
5406
|
Ctx.flash(intl.formatMessage(genericFileMessages.image_uploaded), 'success');
|
|
5165
5407
|
Ctx.refresh();
|
|
@@ -5440,7 +5682,7 @@
|
|
|
5440
5682
|
fileKey = _useState[0],
|
|
5441
5683
|
setFileKey = _useState[1];
|
|
5442
5684
|
|
|
5443
|
-
var _useState2 = React.useState(
|
|
5685
|
+
var _useState2 = React.useState(undefined),
|
|
5444
5686
|
file = _useState2[0],
|
|
5445
5687
|
setFile = _useState2[1];
|
|
5446
5688
|
|
|
@@ -5473,6 +5715,11 @@
|
|
|
5473
5715
|
|
|
5474
5716
|
setLoading(true);
|
|
5475
5717
|
setError(undefined);
|
|
5718
|
+
|
|
5719
|
+
if (!file) {
|
|
5720
|
+
return Promise.resolve();
|
|
5721
|
+
}
|
|
5722
|
+
|
|
5476
5723
|
var endpoint = Ctx.path + "@upload/images/" + fileKey;
|
|
5477
5724
|
return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
|
|
5478
5725
|
var _exit;
|
|
@@ -5575,7 +5822,7 @@
|
|
|
5575
5822
|
field: "images/" + key,
|
|
5576
5823
|
value: values['images'][key],
|
|
5577
5824
|
ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
|
|
5578
|
-
schema: properties
|
|
5825
|
+
schema: get(properties, 'images.additionalProperties', {}),
|
|
5579
5826
|
modifyContent: false,
|
|
5580
5827
|
required: false
|
|
5581
5828
|
}), jsxRuntime.jsx("div", {
|
|
@@ -5865,7 +6112,7 @@
|
|
|
5865
6112
|
sortedList = _useState2[0],
|
|
5866
6113
|
setSortedList = _useState2[1];
|
|
5867
6114
|
|
|
5868
|
-
var _useState3 = React.useState(
|
|
6115
|
+
var _useState3 = React.useState(undefined),
|
|
5869
6116
|
file = _useState3[0],
|
|
5870
6117
|
setFile = _useState3[1];
|
|
5871
6118
|
|
|
@@ -6009,7 +6256,7 @@
|
|
|
6009
6256
|
field: "images/" + key,
|
|
6010
6257
|
value: values['images'][key],
|
|
6011
6258
|
ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
|
|
6012
|
-
schema: properties
|
|
6259
|
+
schema: get(properties, 'images.additionalProperties', {}),
|
|
6013
6260
|
modifyContent: false,
|
|
6014
6261
|
required: false
|
|
6015
6262
|
}), jsxRuntime.jsx("div", {
|
|
@@ -6064,163 +6311,6 @@
|
|
|
6064
6311
|
});
|
|
6065
6312
|
}
|
|
6066
6313
|
|
|
6067
|
-
var base = {
|
|
6068
|
-
local: {
|
|
6069
|
-
roleperm: {},
|
|
6070
|
-
prinperm: {},
|
|
6071
|
-
prinrole: {}
|
|
6072
|
-
},
|
|
6073
|
-
inherit: []
|
|
6074
|
-
};
|
|
6075
|
-
var Sharing = /*#__PURE__*/function () {
|
|
6076
|
-
function Sharing(element) {
|
|
6077
|
-
this.local = void 0;
|
|
6078
|
-
this.inherit = void 0;
|
|
6079
|
-
Object.assign(this, element || base);
|
|
6080
|
-
}
|
|
6081
|
-
|
|
6082
|
-
var _proto = Sharing.prototype;
|
|
6083
|
-
|
|
6084
|
-
_proto.getRole = function getRole(role) {
|
|
6085
|
-
return this.local.roleperm[role];
|
|
6086
|
-
};
|
|
6087
|
-
|
|
6088
|
-
_proto.getPrincipals = function getPrincipals(principal) {
|
|
6089
|
-
return this.local.prinperm[principal];
|
|
6090
|
-
};
|
|
6091
|
-
|
|
6092
|
-
_proto.getPrinroles = function getPrinroles(role) {
|
|
6093
|
-
return this.local.prinrole[role];
|
|
6094
|
-
};
|
|
6095
|
-
|
|
6096
|
-
_createClass(Sharing, [{
|
|
6097
|
-
key: "roles",
|
|
6098
|
-
get: function get() {
|
|
6099
|
-
return Object.keys(this.local.roleperm);
|
|
6100
|
-
}
|
|
6101
|
-
}, {
|
|
6102
|
-
key: "principals",
|
|
6103
|
-
get: function get() {
|
|
6104
|
-
return Object.keys(this.local.prinperm);
|
|
6105
|
-
}
|
|
6106
|
-
}, {
|
|
6107
|
-
key: "prinrole",
|
|
6108
|
-
get: function get() {
|
|
6109
|
-
return Object.keys(this.local.prinrole);
|
|
6110
|
-
}
|
|
6111
|
-
}]);
|
|
6112
|
-
|
|
6113
|
-
return Sharing;
|
|
6114
|
-
}();
|
|
6115
|
-
|
|
6116
|
-
var ItemModel = /*#__PURE__*/function () {
|
|
6117
|
-
function ItemModel(item, url) {
|
|
6118
|
-
if (url === void 0) {
|
|
6119
|
-
url = '';
|
|
6120
|
-
}
|
|
6121
|
-
|
|
6122
|
-
this.item = void 0;
|
|
6123
|
-
this.url = void 0;
|
|
6124
|
-
this.item = item;
|
|
6125
|
-
this.url = url;
|
|
6126
|
-
}
|
|
6127
|
-
|
|
6128
|
-
_createClass(ItemModel, [{
|
|
6129
|
-
key: "path",
|
|
6130
|
-
get: function get() {
|
|
6131
|
-
var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
|
|
6132
|
-
var path = item.split('//')[1].split('/').splice(1).join('/');
|
|
6133
|
-
path = "/" + path + "/";
|
|
6134
|
-
|
|
6135
|
-
if (this.url.length > 0) {
|
|
6136
|
-
if (this.url.startsWith('/')) {
|
|
6137
|
-
path = path.replace(this.url.substring(1), '');
|
|
6138
|
-
} else {
|
|
6139
|
-
path = path.replace(this.url, '');
|
|
6140
|
-
}
|
|
6141
|
-
}
|
|
6142
|
-
|
|
6143
|
-
return path;
|
|
6144
|
-
}
|
|
6145
|
-
}, {
|
|
6146
|
-
key: "name",
|
|
6147
|
-
get: function get() {
|
|
6148
|
-
return this.item.title || this.item['@name'];
|
|
6149
|
-
}
|
|
6150
|
-
}, {
|
|
6151
|
-
key: "icon",
|
|
6152
|
-
get: function get() {
|
|
6153
|
-
var cfg = useConfig();
|
|
6154
|
-
|
|
6155
|
-
if (cfg.icons && cfg.icons[this.type]) {
|
|
6156
|
-
return cfg.icons[this.type];
|
|
6157
|
-
}
|
|
6158
|
-
|
|
6159
|
-
switch (this.type) {
|
|
6160
|
-
case 'GroupManager':
|
|
6161
|
-
return 'fas fa-users-cog';
|
|
6162
|
-
|
|
6163
|
-
case 'UserManager':
|
|
6164
|
-
return 'fas fa-user-cog';
|
|
6165
|
-
|
|
6166
|
-
case 'User':
|
|
6167
|
-
return 'fas fa-user';
|
|
6168
|
-
|
|
6169
|
-
case 'Group':
|
|
6170
|
-
return 'fas fa-users';
|
|
6171
|
-
|
|
6172
|
-
case 'Folder':
|
|
6173
|
-
return 'fas fa-folder';
|
|
6174
|
-
|
|
6175
|
-
default:
|
|
6176
|
-
return 'fas fa-file';
|
|
6177
|
-
}
|
|
6178
|
-
}
|
|
6179
|
-
}, {
|
|
6180
|
-
key: "fullPath",
|
|
6181
|
-
get: function get() {
|
|
6182
|
-
return this.url + this.item.id;
|
|
6183
|
-
}
|
|
6184
|
-
}, {
|
|
6185
|
-
key: "id",
|
|
6186
|
-
get: function get() {
|
|
6187
|
-
if (this.item.id) {
|
|
6188
|
-
return this.item.id;
|
|
6189
|
-
}
|
|
6190
|
-
|
|
6191
|
-
var id = this.item['@id'].split('&')[0].split('/');
|
|
6192
|
-
return id[id.length - 1];
|
|
6193
|
-
}
|
|
6194
|
-
}, {
|
|
6195
|
-
key: "uid",
|
|
6196
|
-
get: function get() {
|
|
6197
|
-
return this.item['@uid'];
|
|
6198
|
-
}
|
|
6199
|
-
}, {
|
|
6200
|
-
key: "type",
|
|
6201
|
-
get: function get() {
|
|
6202
|
-
return this.item['@type'] || this.item.type_name;
|
|
6203
|
-
}
|
|
6204
|
-
}, {
|
|
6205
|
-
key: "title",
|
|
6206
|
-
get: function get() {
|
|
6207
|
-
return this.item.title;
|
|
6208
|
-
}
|
|
6209
|
-
}, {
|
|
6210
|
-
key: "created",
|
|
6211
|
-
get: function get() {
|
|
6212
|
-
return this.item.creation_date ? formatDate(this.item.creation_date) : '';
|
|
6213
|
-
}
|
|
6214
|
-
}, {
|
|
6215
|
-
key: "updated",
|
|
6216
|
-
get: function get() {
|
|
6217
|
-
return this.item.modification_date ? formatDate(this.item.modification_date) : '';
|
|
6218
|
-
}
|
|
6219
|
-
}]);
|
|
6220
|
-
|
|
6221
|
-
return ItemModel;
|
|
6222
|
-
}();
|
|
6223
|
-
|
|
6224
6314
|
var messages$1 = reactIntl.defineMessages({
|
|
6225
6315
|
status_changed_ok: {
|
|
6226
6316
|
id: "status_changed_ok",
|
|
@@ -6296,13 +6386,12 @@
|
|
|
6296
6386
|
definition = _useState[0],
|
|
6297
6387
|
setDefinition = _useState[1];
|
|
6298
6388
|
|
|
6299
|
-
var _useState2 = React.useState(
|
|
6389
|
+
var _useState2 = React.useState(undefined),
|
|
6300
6390
|
workflowAction = _useState2[0],
|
|
6301
6391
|
setWorkflowAction = _useState2[1];
|
|
6302
6392
|
|
|
6303
|
-
var model = new ItemModel(Ctx.context);
|
|
6304
6393
|
var vocabulary = useVocabulary('workflow_states');
|
|
6305
|
-
var currentState =
|
|
6394
|
+
var currentState = Ctx.context['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
|
|
6306
6395
|
React.useEffect(function () {
|
|
6307
6396
|
loadDefinition();
|
|
6308
6397
|
}, [Ctx.path]);
|
|
@@ -6322,7 +6411,7 @@
|
|
|
6322
6411
|
}
|
|
6323
6412
|
|
|
6324
6413
|
Ctx.refresh();
|
|
6325
|
-
setWorkflowAction(
|
|
6414
|
+
setWorkflowAction(undefined);
|
|
6326
6415
|
});
|
|
6327
6416
|
});
|
|
6328
6417
|
} catch (e) {
|
|
@@ -6331,21 +6420,23 @@
|
|
|
6331
6420
|
};
|
|
6332
6421
|
|
|
6333
6422
|
var getStateTitle = function getStateTitle() {
|
|
6334
|
-
var _vocabulary$data, _vocabulary$data
|
|
6423
|
+
var _vocabulary$data$item, _vocabulary$data;
|
|
6424
|
+
|
|
6425
|
+
if (((_vocabulary$data$item = (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
|
|
6426
|
+
var _vocabulary$data2;
|
|
6335
6427
|
|
|
6336
|
-
|
|
6337
|
-
var vocabularyValue = vocabulary.data.items.find(function (item) {
|
|
6428
|
+
var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
|
|
6338
6429
|
return item.token === currentState;
|
|
6339
6430
|
});
|
|
6340
6431
|
|
|
6341
6432
|
if (vocabularyValue) {
|
|
6342
|
-
var translatedValue = get
|
|
6433
|
+
var translatedValue = get(vocabularyValue, "title.translated_title." + intl.locale, null);
|
|
6343
6434
|
|
|
6344
6435
|
if (translatedValue !== null) {
|
|
6345
6436
|
return translatedValue;
|
|
6346
6437
|
}
|
|
6347
6438
|
|
|
6348
|
-
var titleValue = get
|
|
6439
|
+
var titleValue = get(vocabularyValue, "title.title." + intl.locale, null);
|
|
6349
6440
|
|
|
6350
6441
|
if (titleValue !== null) {
|
|
6351
6442
|
return titleValue;
|
|
@@ -6361,7 +6452,7 @@
|
|
|
6361
6452
|
children: [workflowAction && jsxRuntime.jsx(Confirm, {
|
|
6362
6453
|
loading: loading,
|
|
6363
6454
|
onCancel: function onCancel() {
|
|
6364
|
-
return setWorkflowAction(
|
|
6455
|
+
return setWorkflowAction(undefined);
|
|
6365
6456
|
},
|
|
6366
6457
|
onConfirm: doWorkflowAction,
|
|
6367
6458
|
message: intl.formatMessage(messages$1.confirm_message, {
|
|
@@ -6387,7 +6478,7 @@
|
|
|
6387
6478
|
onClick: function onClick() {
|
|
6388
6479
|
return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
|
|
6389
6480
|
},
|
|
6390
|
-
children: get
|
|
6481
|
+
children: get(transition, "metadata.translated_title." + intl.locale, transition.title)
|
|
6391
6482
|
}, transition['@id']);
|
|
6392
6483
|
})]
|
|
6393
6484
|
})]
|
|
@@ -6413,14 +6504,17 @@
|
|
|
6413
6504
|
|
|
6414
6505
|
return jsxRuntime.jsx(React.Fragment, {
|
|
6415
6506
|
children: Object.keys(ACTIONS_OBJECT).map(function (actionKey) {
|
|
6416
|
-
|
|
6507
|
+
var actionKeyTyped = actionKey;
|
|
6508
|
+
var actionObject = ACTIONS_OBJECT[actionKeyTyped];
|
|
6509
|
+
|
|
6510
|
+
if (hasPerm(actionObject.perms)) {
|
|
6417
6511
|
return jsxRuntime.jsx("button", {
|
|
6418
6512
|
className: "button mr-4",
|
|
6419
6513
|
onClick: function onClick() {
|
|
6420
|
-
onAction(
|
|
6514
|
+
onAction(actionKeyTyped);
|
|
6421
6515
|
},
|
|
6422
|
-
children:
|
|
6423
|
-
}, "panel_action_" +
|
|
6516
|
+
children: actionObject.text
|
|
6517
|
+
}, "panel_action_" + actionObject.text);
|
|
6424
6518
|
}
|
|
6425
6519
|
})
|
|
6426
6520
|
});
|
|
@@ -6462,7 +6556,8 @@
|
|
|
6462
6556
|
"value": "Installed Addons"
|
|
6463
6557
|
}]
|
|
6464
6558
|
}
|
|
6465
|
-
});
|
|
6559
|
+
}); // TODO: Refactor without useAsync... just crudContext
|
|
6560
|
+
|
|
6466
6561
|
function PanelAddons() {
|
|
6467
6562
|
var _state$data$available, _state$data, _state$data$available2, _state$data2, _state$data$installed, _state$data3, _state$data$installed2, _state$data4;
|
|
6468
6563
|
|
|
@@ -6617,8 +6712,9 @@
|
|
|
6617
6712
|
|
|
6618
6713
|
var arrayToObject = function arrayToObject(array) {
|
|
6619
6714
|
return array.reduce(function (obj, item) {
|
|
6620
|
-
|
|
6621
|
-
|
|
6715
|
+
var _extends2;
|
|
6716
|
+
|
|
6717
|
+
return _extends({}, obj, (_extends2 = {}, _extends2[item.id] = item, _extends2));
|
|
6622
6718
|
}, {});
|
|
6623
6719
|
};
|
|
6624
6720
|
|
|
@@ -6780,8 +6876,9 @@
|
|
|
6780
6876
|
|
|
6781
6877
|
function onSelectAllItems(checked) {
|
|
6782
6878
|
setSelected(items.reduce(function (obj, item) {
|
|
6783
|
-
|
|
6784
|
-
|
|
6879
|
+
var _extends2;
|
|
6880
|
+
|
|
6881
|
+
return _extends({}, obj, (_extends2 = {}, _extends2[item.path + "/" + item.id] = checked, _extends2));
|
|
6785
6882
|
}, {
|
|
6786
6883
|
all: checked
|
|
6787
6884
|
}));
|
|
@@ -6789,11 +6886,11 @@
|
|
|
6789
6886
|
|
|
6790
6887
|
function onSelectOneItem(item) {
|
|
6791
6888
|
setSelected(function (state) {
|
|
6792
|
-
var
|
|
6889
|
+
var _extends3;
|
|
6793
6890
|
|
|
6794
|
-
return _extends({}, state, (
|
|
6891
|
+
return _extends({}, state, (_extends3 = {
|
|
6795
6892
|
all: false
|
|
6796
|
-
},
|
|
6893
|
+
}, _extends3[item.path + "/" + item.id] = !state[item.path + "/" + item.id], _extends3));
|
|
6797
6894
|
});
|
|
6798
6895
|
}
|
|
6799
6896
|
|
|
@@ -6815,13 +6912,38 @@
|
|
|
6815
6912
|
children: children
|
|
6816
6913
|
});
|
|
6817
6914
|
}
|
|
6818
|
-
function AllItemsCheckbox(_ref2) {
|
|
6819
|
-
var dataTest = _ref2.dataTest;
|
|
6820
6915
|
|
|
6916
|
+
var useItemsActions = function useItemsActions() {
|
|
6821
6917
|
var _useContext = React.useContext(ItemsActionsCtx),
|
|
6918
|
+
onAction = _useContext.onAction,
|
|
6919
|
+
onSelectOneItem = _useContext.onSelectOneItem,
|
|
6822
6920
|
onSelectAllItems = _useContext.onSelectAllItems,
|
|
6823
6921
|
selected = _useContext.selected;
|
|
6824
6922
|
|
|
6923
|
+
if (!onAction || !onSelectOneItem || !onSelectAllItems || !selected) {
|
|
6924
|
+
throw new Error('useItemsActions must be used inside ItemsActionsProvider');
|
|
6925
|
+
}
|
|
6926
|
+
|
|
6927
|
+
return {
|
|
6928
|
+
onAction: onAction,
|
|
6929
|
+
onSelectOneItem: onSelectOneItem,
|
|
6930
|
+
onSelectAllItems: onSelectAllItems,
|
|
6931
|
+
selected: selected
|
|
6932
|
+
};
|
|
6933
|
+
};
|
|
6934
|
+
/**
|
|
6935
|
+
* Checkbox component without props that consume the ItemsActionsContext
|
|
6936
|
+
* and it select/unselect all items of the page.
|
|
6937
|
+
*/
|
|
6938
|
+
|
|
6939
|
+
|
|
6940
|
+
function AllItemsCheckbox(_ref2) {
|
|
6941
|
+
var dataTest = _ref2.dataTest;
|
|
6942
|
+
|
|
6943
|
+
var _useItemsActions = useItemsActions(),
|
|
6944
|
+
onSelectAllItems = _useItemsActions.onSelectAllItems,
|
|
6945
|
+
selected = _useItemsActions.selected;
|
|
6946
|
+
|
|
6825
6947
|
return jsxRuntime.jsx(Checkbox, {
|
|
6826
6948
|
onChange: onSelectAllItems,
|
|
6827
6949
|
checked: selected.all,
|
|
@@ -6832,9 +6954,9 @@
|
|
|
6832
6954
|
var item = _ref3.item,
|
|
6833
6955
|
dataTest = _ref3.dataTest;
|
|
6834
6956
|
|
|
6835
|
-
var
|
|
6836
|
-
selected =
|
|
6837
|
-
onSelectOneItem =
|
|
6957
|
+
var _useItemsActions2 = useItemsActions(),
|
|
6958
|
+
selected = _useItemsActions2.selected,
|
|
6959
|
+
onSelectOneItem = _useItemsActions2.onSelectOneItem;
|
|
6838
6960
|
|
|
6839
6961
|
var absId = item.path + "/" + item.id;
|
|
6840
6962
|
var value = selected[absId];
|
|
@@ -6846,14 +6968,18 @@
|
|
|
6846
6968
|
dataTest: dataTest
|
|
6847
6969
|
});
|
|
6848
6970
|
}
|
|
6971
|
+
/**
|
|
6972
|
+
* Dropdown to choose some action to apply to the selected items.
|
|
6973
|
+
*/
|
|
6974
|
+
|
|
6849
6975
|
function ItemsActionsDropdown() {
|
|
6850
6976
|
var intl = reactIntl.useIntl();
|
|
6851
6977
|
var ACTIONS_OBJECT = getActionsObject(intl, true);
|
|
6852
6978
|
var traversal = useTraversal();
|
|
6853
6979
|
|
|
6854
|
-
var
|
|
6855
|
-
selected =
|
|
6856
|
-
onAction =
|
|
6980
|
+
var _useItemsActions3 = useItemsActions(),
|
|
6981
|
+
selected = _useItemsActions3.selected,
|
|
6982
|
+
onAction = _useItemsActions3.onAction;
|
|
6857
6983
|
|
|
6858
6984
|
var disabled = Object.values(selected).every(function (v) {
|
|
6859
6985
|
return !v;
|
|
@@ -6937,6 +7063,7 @@
|
|
|
6937
7063
|
"aria-label": "pagination",
|
|
6938
7064
|
children: [jsxRuntime.jsx("a", {
|
|
6939
7065
|
className: "pagination-previous is-small",
|
|
7066
|
+
// disabled={current === 0}
|
|
6940
7067
|
onClick: function onClick() {
|
|
6941
7068
|
return current > 0 ? doPaginate(current - 1) : null;
|
|
6942
7069
|
},
|
|
@@ -6948,6 +7075,7 @@
|
|
|
6948
7075
|
})
|
|
6949
7076
|
}), jsxRuntime.jsx("a", {
|
|
6950
7077
|
className: "pagination-next is-small",
|
|
7078
|
+
// disabled={current >= maxPages - 1}
|
|
6951
7079
|
onClick: function onClick() {
|
|
6952
7080
|
return doPaginate(current + 1);
|
|
6953
7081
|
},
|
|
@@ -6962,6 +7090,170 @@
|
|
|
6962
7090
|
});
|
|
6963
7091
|
}
|
|
6964
7092
|
|
|
7093
|
+
var base = {
|
|
7094
|
+
local: {
|
|
7095
|
+
roleperm: {},
|
|
7096
|
+
prinperm: {},
|
|
7097
|
+
prinrole: {}
|
|
7098
|
+
},
|
|
7099
|
+
inherit: []
|
|
7100
|
+
};
|
|
7101
|
+
var Sharing = /*#__PURE__*/function () {
|
|
7102
|
+
function Sharing(element) {
|
|
7103
|
+
this.local = void 0;
|
|
7104
|
+
this.inherit = void 0;
|
|
7105
|
+
|
|
7106
|
+
if (element === undefined) {
|
|
7107
|
+
throw new Error('Sharing element is undefined');
|
|
7108
|
+
}
|
|
7109
|
+
|
|
7110
|
+
this.local = element.local || base.local;
|
|
7111
|
+
this.inherit = element.inherit || base.inherit;
|
|
7112
|
+
}
|
|
7113
|
+
|
|
7114
|
+
var _proto = Sharing.prototype;
|
|
7115
|
+
|
|
7116
|
+
_proto.getRole = function getRole(role) {
|
|
7117
|
+
return this.local.roleperm[role];
|
|
7118
|
+
};
|
|
7119
|
+
|
|
7120
|
+
_proto.getPrincipals = function getPrincipals(principal) {
|
|
7121
|
+
return this.local.prinperm[principal];
|
|
7122
|
+
};
|
|
7123
|
+
|
|
7124
|
+
_proto.getPrinroles = function getPrinroles(role) {
|
|
7125
|
+
return this.local.prinrole[role];
|
|
7126
|
+
};
|
|
7127
|
+
|
|
7128
|
+
_createClass(Sharing, [{
|
|
7129
|
+
key: "roles",
|
|
7130
|
+
get: function get() {
|
|
7131
|
+
return Object.keys(this.local.roleperm);
|
|
7132
|
+
}
|
|
7133
|
+
}, {
|
|
7134
|
+
key: "principals",
|
|
7135
|
+
get: function get() {
|
|
7136
|
+
return Object.keys(this.local.prinperm);
|
|
7137
|
+
}
|
|
7138
|
+
}, {
|
|
7139
|
+
key: "prinrole",
|
|
7140
|
+
get: function get() {
|
|
7141
|
+
return Object.keys(this.local.prinrole);
|
|
7142
|
+
}
|
|
7143
|
+
}]);
|
|
7144
|
+
|
|
7145
|
+
return Sharing;
|
|
7146
|
+
}();
|
|
7147
|
+
|
|
7148
|
+
var ItemModel = /*#__PURE__*/function () {
|
|
7149
|
+
function ItemModel(item, url) {
|
|
7150
|
+
if (url === void 0) {
|
|
7151
|
+
url = '';
|
|
7152
|
+
}
|
|
7153
|
+
|
|
7154
|
+
this.item = void 0;
|
|
7155
|
+
this.url = void 0;
|
|
7156
|
+
this.item = item;
|
|
7157
|
+
this.url = url;
|
|
7158
|
+
}
|
|
7159
|
+
|
|
7160
|
+
_createClass(ItemModel, [{
|
|
7161
|
+
key: "path",
|
|
7162
|
+
get: function get() {
|
|
7163
|
+
// Compat
|
|
7164
|
+
var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
|
|
7165
|
+
var path = item.split('//')[1].split('/').splice(1).join('/');
|
|
7166
|
+
path = "/" + path + "/";
|
|
7167
|
+
|
|
7168
|
+
if (this.url.length > 0) {
|
|
7169
|
+
if (this.url.startsWith('/')) {
|
|
7170
|
+
path = path.replace(this.url.substring(1), '');
|
|
7171
|
+
} else {
|
|
7172
|
+
path = path.replace(this.url, '');
|
|
7173
|
+
}
|
|
7174
|
+
}
|
|
7175
|
+
|
|
7176
|
+
return path;
|
|
7177
|
+
}
|
|
7178
|
+
}, {
|
|
7179
|
+
key: "name",
|
|
7180
|
+
get: function get() {
|
|
7181
|
+
return this.item.title || this.item['@name'];
|
|
7182
|
+
}
|
|
7183
|
+
}, {
|
|
7184
|
+
key: "icon",
|
|
7185
|
+
get: function get() {
|
|
7186
|
+
var cfg = useConfig();
|
|
7187
|
+
|
|
7188
|
+
if (cfg.icons && cfg.icons[this.type]) {
|
|
7189
|
+
return cfg.icons[this.type];
|
|
7190
|
+
}
|
|
7191
|
+
|
|
7192
|
+
switch (this.type) {
|
|
7193
|
+
case 'GroupManager':
|
|
7194
|
+
return 'fas fa-users-cog';
|
|
7195
|
+
|
|
7196
|
+
case 'UserManager':
|
|
7197
|
+
return 'fas fa-user-cog';
|
|
7198
|
+
|
|
7199
|
+
case 'User':
|
|
7200
|
+
return 'fas fa-user';
|
|
7201
|
+
|
|
7202
|
+
case 'Group':
|
|
7203
|
+
return 'fas fa-users';
|
|
7204
|
+
|
|
7205
|
+
case 'Folder':
|
|
7206
|
+
return 'fas fa-folder';
|
|
7207
|
+
|
|
7208
|
+
default:
|
|
7209
|
+
return 'fas fa-file';
|
|
7210
|
+
}
|
|
7211
|
+
}
|
|
7212
|
+
}, {
|
|
7213
|
+
key: "fullPath",
|
|
7214
|
+
get: function get() {
|
|
7215
|
+
return this.url + this.id;
|
|
7216
|
+
}
|
|
7217
|
+
}, {
|
|
7218
|
+
key: "id",
|
|
7219
|
+
get: function get() {
|
|
7220
|
+
if ('id' in this.item) {
|
|
7221
|
+
return this.item.id;
|
|
7222
|
+
}
|
|
7223
|
+
|
|
7224
|
+
var id = this.item['@id'].split('&')[0].split('/');
|
|
7225
|
+
return id[id.length - 1];
|
|
7226
|
+
}
|
|
7227
|
+
}, {
|
|
7228
|
+
key: "uid",
|
|
7229
|
+
get: function get() {
|
|
7230
|
+
return this.item['@uid'];
|
|
7231
|
+
}
|
|
7232
|
+
}, {
|
|
7233
|
+
key: "type",
|
|
7234
|
+
get: function get() {
|
|
7235
|
+
return this.item['@type'] || this.item.type_name;
|
|
7236
|
+
}
|
|
7237
|
+
}, {
|
|
7238
|
+
key: "title",
|
|
7239
|
+
get: function get() {
|
|
7240
|
+
return this.item.title;
|
|
7241
|
+
}
|
|
7242
|
+
}, {
|
|
7243
|
+
key: "created",
|
|
7244
|
+
get: function get() {
|
|
7245
|
+
return this.item.creation_date ? formatDate(this.item.creation_date) : '';
|
|
7246
|
+
}
|
|
7247
|
+
}, {
|
|
7248
|
+
key: "updated",
|
|
7249
|
+
get: function get() {
|
|
7250
|
+
return this.item.modification_date ? formatDate(this.item.modification_date) : '';
|
|
7251
|
+
}
|
|
7252
|
+
}]);
|
|
7253
|
+
|
|
7254
|
+
return ItemModel;
|
|
7255
|
+
}();
|
|
7256
|
+
|
|
6965
7257
|
function Item(_ref) {
|
|
6966
7258
|
var item = _ref.item,
|
|
6967
7259
|
icon = _ref.icon;
|
|
@@ -7102,11 +7394,11 @@
|
|
|
7102
7394
|
renderValue = _useState[0],
|
|
7103
7395
|
setRenderValue = _useState[1];
|
|
7104
7396
|
|
|
7105
|
-
var defaultRenderValue = location.get(query);
|
|
7397
|
+
var defaultRenderValue = location.get(query) || '';
|
|
7106
7398
|
React.useEffect(function () {
|
|
7107
7399
|
var value = defaultRenderValue;
|
|
7108
7400
|
|
|
7109
|
-
if ((options != null ? options : []).length > 0) {
|
|
7401
|
+
if (options && (options != null ? options : []).length > 0) {
|
|
7110
7402
|
var option = options.find(function (item) {
|
|
7111
7403
|
return item.value === value;
|
|
7112
7404
|
});
|
|
@@ -7155,14 +7447,16 @@
|
|
|
7155
7447
|
setRenderValue = _useState[1];
|
|
7156
7448
|
|
|
7157
7449
|
var vocabulary = useVocabulary(vocabularyName);
|
|
7158
|
-
var defaultRenderValue = location.get(query);
|
|
7450
|
+
var defaultRenderValue = location.get(query) || '';
|
|
7159
7451
|
React.useEffect(function () {
|
|
7160
7452
|
var _vocabulary$data$item, _vocabulary$data;
|
|
7161
7453
|
|
|
7162
7454
|
var value = defaultRenderValue;
|
|
7163
7455
|
|
|
7164
7456
|
if (((_vocabulary$data$item = vocabulary == null ? void 0 : (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
|
|
7165
|
-
var
|
|
7457
|
+
var _vocabulary$data2;
|
|
7458
|
+
|
|
7459
|
+
var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
|
|
7166
7460
|
return item.token === value;
|
|
7167
7461
|
});
|
|
7168
7462
|
|
|
@@ -7196,7 +7490,7 @@
|
|
|
7196
7490
|
return null;
|
|
7197
7491
|
}
|
|
7198
7492
|
|
|
7199
|
-
var initialState$
|
|
7493
|
+
var initialState$3 = {
|
|
7200
7494
|
page: 0,
|
|
7201
7495
|
items: [],
|
|
7202
7496
|
loading: true,
|
|
@@ -7215,7 +7509,7 @@
|
|
|
7215
7509
|
var intl = reactIntl.useIntl();
|
|
7216
7510
|
var Ctx = useTraversal();
|
|
7217
7511
|
|
|
7218
|
-
var _useSetState = useSetState(initialState$
|
|
7512
|
+
var _useSetState = useSetState(initialState$3),
|
|
7219
7513
|
state = _useSetState[0],
|
|
7220
7514
|
setState = _useSetState[1];
|
|
7221
7515
|
|
|
@@ -7231,7 +7525,7 @@
|
|
|
7231
7525
|
var page;
|
|
7232
7526
|
|
|
7233
7527
|
try {
|
|
7234
|
-
page = parseInt(location.get('page')
|
|
7528
|
+
page = parseInt(location.get('page') || '0');
|
|
7235
7529
|
} catch (_unused) {
|
|
7236
7530
|
page = 0;
|
|
7237
7531
|
}
|
|
@@ -7278,7 +7572,7 @@
|
|
|
7278
7572
|
var resultQueryParams = [];
|
|
7279
7573
|
var resultDynamicLocation = [];
|
|
7280
7574
|
filterSchema.forEach(function (filter) {
|
|
7281
|
-
var itemParam = location.get(filter.attribute_key);
|
|
7575
|
+
var itemParam = location.get(filter.attribute_key) || '';
|
|
7282
7576
|
resultDynamicLocation.push(itemParam);
|
|
7283
7577
|
|
|
7284
7578
|
if (itemParam) {
|
|
@@ -7290,53 +7584,51 @@
|
|
|
7290
7584
|
var controller = new AbortController();
|
|
7291
7585
|
if (Ctx.state.loading) return;
|
|
7292
7586
|
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
var get = Ctx.registry.get;
|
|
7299
|
-
var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
7300
|
-
|
|
7301
|
-
if (sortParsed === undefined) {
|
|
7302
|
-
var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type'], {
|
|
7303
|
-
key: 'id',
|
|
7304
|
-
direction: 'des'
|
|
7587
|
+
var getData = function getData() {
|
|
7588
|
+
try {
|
|
7589
|
+
setState({
|
|
7590
|
+
loading: true,
|
|
7591
|
+
total: Ctx.context.length
|
|
7305
7592
|
});
|
|
7306
|
-
|
|
7307
|
-
|
|
7593
|
+
var get = Ctx.registry.get;
|
|
7594
|
+
var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
7308
7595
|
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
});
|
|
7314
|
-
var qs = '';
|
|
7596
|
+
if (sortParsed === undefined) {
|
|
7597
|
+
var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type']);
|
|
7598
|
+
sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
|
|
7599
|
+
}
|
|
7315
7600
|
|
|
7316
|
-
|
|
7317
|
-
|
|
7601
|
+
var qsParsed = Ctx.client.getQueryParamsSearchFunction(fnName)({
|
|
7602
|
+
path: Ctx.path,
|
|
7603
|
+
start: page * PageSize,
|
|
7604
|
+
pageSize: PageSize
|
|
7605
|
+
});
|
|
7606
|
+
var qs = '';
|
|
7318
7607
|
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
var _sortParsed2;
|
|
7608
|
+
if (search || type || resultQueryParams.length > 0) {
|
|
7609
|
+
var _searchParsed, _typeParsed, _sortParsed;
|
|
7322
7610
|
|
|
7323
|
-
|
|
7324
|
-
|
|
7611
|
+
qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
|
|
7612
|
+
} else {
|
|
7613
|
+
var _sortParsed2;
|
|
7325
7614
|
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7615
|
+
qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
|
|
7616
|
+
}
|
|
7617
|
+
|
|
7618
|
+
var signal = controller.signal;
|
|
7619
|
+
return Promise.resolve(Ctx.client.search(Ctx.path, qs, false, false, signal)).then(function (data) {
|
|
7620
|
+
setState({
|
|
7621
|
+
items: data.items,
|
|
7622
|
+
loading: false,
|
|
7623
|
+
total: data.items_count
|
|
7624
|
+
});
|
|
7334
7625
|
});
|
|
7335
|
-
})
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
}
|
|
7626
|
+
} catch (e) {
|
|
7627
|
+
return Promise.reject(e);
|
|
7628
|
+
}
|
|
7629
|
+
};
|
|
7339
7630
|
|
|
7631
|
+
getData();
|
|
7340
7632
|
return function () {
|
|
7341
7633
|
controller.abort();
|
|
7342
7634
|
};
|
|
@@ -7381,12 +7673,14 @@
|
|
|
7381
7673
|
var _filter$values;
|
|
7382
7674
|
|
|
7383
7675
|
if (filter.type === 'select' && ((_filter$values = filter.values) != null ? _filter$values : []).length > 0) {
|
|
7676
|
+
var _filter$values2;
|
|
7677
|
+
|
|
7384
7678
|
return jsxRuntime.jsx(Select, {
|
|
7385
7679
|
id: filter.attribute_key,
|
|
7386
7680
|
placeholder: filter.label,
|
|
7387
7681
|
appendDefault: true,
|
|
7388
7682
|
classWrap: "is-size-7 is-fullwidth",
|
|
7389
|
-
options: filter.values,
|
|
7683
|
+
options: (_filter$values2 = filter.values) != null ? _filter$values2 : [],
|
|
7390
7684
|
value: location.get(filter.attribute_key) || '',
|
|
7391
7685
|
dataTest: "filterInput" + filter.attribute_key,
|
|
7392
7686
|
onChange: function onChange(value) {
|
|
@@ -7453,7 +7747,7 @@
|
|
|
7453
7747
|
var filterData = location.get(filter.attribute_key);
|
|
7454
7748
|
|
|
7455
7749
|
if (filterData) {
|
|
7456
|
-
var _filter$
|
|
7750
|
+
var _filter$values3;
|
|
7457
7751
|
|
|
7458
7752
|
if (filter.type === 'select' && filter.vocabulary) {
|
|
7459
7753
|
return jsxRuntime.jsx("div", {
|
|
@@ -7462,7 +7756,7 @@
|
|
|
7462
7756
|
vocabularyName: filter == null ? void 0 : filter.vocabulary
|
|
7463
7757
|
})
|
|
7464
7758
|
}, filter.attribute_key);
|
|
7465
|
-
} else if (filter.type === 'select' && ((_filter$
|
|
7759
|
+
} else if (filter.type === 'select' && ((_filter$values3 = filter.values) != null ? _filter$values3 : []).length > 0) {
|
|
7466
7760
|
return jsxRuntime.jsx("div", {
|
|
7467
7761
|
children: jsxRuntime.jsx(SearchOptionsLabels, {
|
|
7468
7762
|
query: filter.attribute_key,
|
|
@@ -7508,7 +7802,7 @@
|
|
|
7508
7802
|
className: "has-text-info is-flex is-align-items-center",
|
|
7509
7803
|
children: [jsxRuntime.jsx("span", {
|
|
7510
7804
|
children: column.label
|
|
7511
|
-
}), getIcon(column.key, column.isSortable)]
|
|
7805
|
+
}), getIcon(column.key, !!column.isSortable)]
|
|
7512
7806
|
})
|
|
7513
7807
|
}, "table-col-" + column.label);
|
|
7514
7808
|
}), jsxRuntime.jsx("th", {
|
|
@@ -7519,7 +7813,7 @@
|
|
|
7519
7813
|
children: [items && items.map(function (item) {
|
|
7520
7814
|
return jsxRuntime.jsx(RItem, {
|
|
7521
7815
|
item: item,
|
|
7522
|
-
search: search,
|
|
7816
|
+
search: search != null ? search : '',
|
|
7523
7817
|
columns: columns
|
|
7524
7818
|
}, item['@uid']);
|
|
7525
7819
|
}), items && items.length === 0 && jsxRuntime.jsx("tr", {
|
|
@@ -7543,17 +7837,19 @@
|
|
|
7543
7837
|
}
|
|
7544
7838
|
|
|
7545
7839
|
function BehaviorsView(_ref) {
|
|
7840
|
+
var _context$__behaviors_;
|
|
7841
|
+
|
|
7546
7842
|
var context = _ref.context,
|
|
7547
7843
|
schema = _ref.schema;
|
|
7548
7844
|
var Ctx = useTraversal();
|
|
7549
7845
|
var getBehavior = Ctx.registry.getBehavior;
|
|
7550
|
-
var behaviors = [].concat(context.__behaviors__, context['@static_behaviors']);
|
|
7846
|
+
var behaviors = [].concat((_context$__behaviors_ = context.__behaviors__) != null ? _context$__behaviors_ : [], Object(context['@static_behaviors']));
|
|
7551
7847
|
|
|
7552
|
-
var GetBehavior = function GetBehavior(
|
|
7553
|
-
var Cls = getBehavior(
|
|
7848
|
+
var GetBehavior = function GetBehavior(behaviorName) {
|
|
7849
|
+
var Cls = getBehavior(behaviorName, BehaviorNotImplemented);
|
|
7554
7850
|
return jsxRuntime.jsx(Cls, {
|
|
7555
|
-
values: context[
|
|
7556
|
-
properties: get
|
|
7851
|
+
values: context[behaviorName],
|
|
7852
|
+
properties: get(schema, ['definitions', behaviorName, 'properties'], {})
|
|
7557
7853
|
});
|
|
7558
7854
|
};
|
|
7559
7855
|
|
|
@@ -7649,9 +7945,11 @@
|
|
|
7649
7945
|
var properties = Object.keys((schema == null ? void 0 : (_schema$data = schema.data) == null ? void 0 : _schema$data.properties) || []).filter(function (key) {
|
|
7650
7946
|
return !ignoreFields.includes(key);
|
|
7651
7947
|
}).map(function (key) {
|
|
7948
|
+
var _schema$data2;
|
|
7949
|
+
|
|
7652
7950
|
return {
|
|
7653
7951
|
key: key,
|
|
7654
|
-
value: schema.data.properties[key]
|
|
7952
|
+
value: schema == null ? void 0 : (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key]
|
|
7655
7953
|
};
|
|
7656
7954
|
});
|
|
7657
7955
|
React.useEffect(function () {
|
|
@@ -7663,7 +7961,7 @@
|
|
|
7663
7961
|
setSchema({
|
|
7664
7962
|
loading: true
|
|
7665
7963
|
});
|
|
7666
|
-
return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path,
|
|
7964
|
+
return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path, Ctx.context.type_name)).then(function (dataJson) {
|
|
7667
7965
|
setSchema({
|
|
7668
7966
|
loading: false,
|
|
7669
7967
|
data: dataJson
|
|
@@ -7738,7 +8036,7 @@
|
|
|
7738
8036
|
}), jsxRuntime.jsx("td", {
|
|
7739
8037
|
children: jsxRuntime.jsx(EditableField, {
|
|
7740
8038
|
field: prop,
|
|
7741
|
-
value: Ctx.context
|
|
8039
|
+
value: get(Ctx.context, prop, ''),
|
|
7742
8040
|
modifyContent: false
|
|
7743
8041
|
})
|
|
7744
8042
|
})]
|
|
@@ -7762,7 +8060,7 @@
|
|
|
7762
8060
|
})
|
|
7763
8061
|
}), jsxRuntime.jsx("tbody", {
|
|
7764
8062
|
children: properties.map(function (_ref) {
|
|
7765
|
-
var _schema$data$required, _schema$
|
|
8063
|
+
var _schema$data$required, _schema$data3;
|
|
7766
8064
|
|
|
7767
8065
|
var key = _ref.key,
|
|
7768
8066
|
value = _ref.value;
|
|
@@ -7775,10 +8073,10 @@
|
|
|
7775
8073
|
}), jsxRuntime.jsx("td", {
|
|
7776
8074
|
children: jsxRuntime.jsx(EditableField, {
|
|
7777
8075
|
field: key,
|
|
7778
|
-
value: Ctx.context
|
|
8076
|
+
value: get(Ctx.context, key, ''),
|
|
7779
8077
|
schema: value,
|
|
7780
8078
|
modifyContent: modifyContent,
|
|
7781
|
-
required: ((_schema$data$required = (_schema$
|
|
8079
|
+
required: ((_schema$data$required = (_schema$data3 = schema.data) == null ? void 0 : _schema$data3.required) != null ? _schema$data$required : []).includes(key)
|
|
7782
8080
|
})
|
|
7783
8081
|
})]
|
|
7784
8082
|
}, 'prop' + key);
|
|
@@ -7814,14 +8112,6 @@
|
|
|
7814
8112
|
state = _useSetState[0],
|
|
7815
8113
|
setState = _useSetState[1];
|
|
7816
8114
|
|
|
7817
|
-
var getMultiples = function getMultiples(field, setter) {
|
|
7818
|
-
return function (values) {
|
|
7819
|
-
var _setter;
|
|
7820
|
-
|
|
7821
|
-
setter((_setter = {}, _setter[field] = values, _setter));
|
|
7822
|
-
};
|
|
7823
|
-
};
|
|
7824
|
-
|
|
7825
8115
|
var savePermission = function savePermission() {
|
|
7826
8116
|
try {
|
|
7827
8117
|
if (!state.principal || !state.setting || state.permission.length === 0) {
|
|
@@ -7871,7 +8161,7 @@
|
|
|
7871
8161
|
children: intl.formatMessage(genericMessages.select_principal)
|
|
7872
8162
|
}), jsxRuntime.jsx(Select, {
|
|
7873
8163
|
appendDefault: true,
|
|
7874
|
-
options: principals,
|
|
8164
|
+
options: principals != null ? principals : [],
|
|
7875
8165
|
onChange: function onChange(value) {
|
|
7876
8166
|
return setState({
|
|
7877
8167
|
principal: value
|
|
@@ -7885,8 +8175,12 @@
|
|
|
7885
8175
|
className: "label",
|
|
7886
8176
|
children: intl.formatMessage(genericMessages.select_permissions)
|
|
7887
8177
|
}), jsxRuntime.jsx(Select, {
|
|
7888
|
-
options: permissions,
|
|
7889
|
-
onChange:
|
|
8178
|
+
options: permissions != null ? permissions : [],
|
|
8179
|
+
onChange: function onChange(values) {
|
|
8180
|
+
setState({
|
|
8181
|
+
permission: values
|
|
8182
|
+
});
|
|
8183
|
+
},
|
|
7890
8184
|
size: 5,
|
|
7891
8185
|
multiple: true,
|
|
7892
8186
|
dataTest: "selectPermissionsTest"
|
|
@@ -7937,14 +8231,6 @@
|
|
|
7937
8231
|
state = _useSetState[0],
|
|
7938
8232
|
setState = _useSetState[1];
|
|
7939
8233
|
|
|
7940
|
-
var getMultiples = function getMultiples(field, setter) {
|
|
7941
|
-
return function (values) {
|
|
7942
|
-
var _setter;
|
|
7943
|
-
|
|
7944
|
-
setter((_setter = {}, _setter[field] = values, _setter));
|
|
7945
|
-
};
|
|
7946
|
-
};
|
|
7947
|
-
|
|
7948
8234
|
var savePermission = function savePermission() {
|
|
7949
8235
|
try {
|
|
7950
8236
|
if (!state.principal || !state.setting || state.roles.length === 0) {
|
|
@@ -7994,7 +8280,7 @@
|
|
|
7994
8280
|
children: intl.formatMessage(genericMessages.select_principal)
|
|
7995
8281
|
}), jsxRuntime.jsx(Select, {
|
|
7996
8282
|
appendDefault: true,
|
|
7997
|
-
options: principals,
|
|
8283
|
+
options: principals != null ? principals : [],
|
|
7998
8284
|
onChange: function onChange(value) {
|
|
7999
8285
|
return setState({
|
|
8000
8286
|
principal: value
|
|
@@ -8009,7 +8295,11 @@
|
|
|
8009
8295
|
children: intl.formatMessage(genericMessages.select_role)
|
|
8010
8296
|
}), jsxRuntime.jsx(Select, {
|
|
8011
8297
|
options: roles,
|
|
8012
|
-
onChange:
|
|
8298
|
+
onChange: function onChange(values) {
|
|
8299
|
+
setState({
|
|
8300
|
+
roles: values
|
|
8301
|
+
});
|
|
8302
|
+
},
|
|
8013
8303
|
size: 5,
|
|
8014
8304
|
multiple: true,
|
|
8015
8305
|
dataTest: "selectRoleTest"
|
|
@@ -8060,14 +8350,6 @@
|
|
|
8060
8350
|
state = _useSetState[0],
|
|
8061
8351
|
setState = _useSetState[1];
|
|
8062
8352
|
|
|
8063
|
-
var getMultiples = function getMultiples(field, setter) {
|
|
8064
|
-
return function (values) {
|
|
8065
|
-
var _setter;
|
|
8066
|
-
|
|
8067
|
-
setter((_setter = {}, _setter[field] = values, _setter));
|
|
8068
|
-
};
|
|
8069
|
-
};
|
|
8070
|
-
|
|
8071
8353
|
var savePermission = function savePermission() {
|
|
8072
8354
|
try {
|
|
8073
8355
|
if (!state.role || !state.setting || state.permission.length === 0) {
|
|
@@ -8131,8 +8413,12 @@
|
|
|
8131
8413
|
className: "label",
|
|
8132
8414
|
children: intl.formatMessage(genericMessages.select_permissions)
|
|
8133
8415
|
}), jsxRuntime.jsx(Select, {
|
|
8134
|
-
options: permissions,
|
|
8135
|
-
onChange:
|
|
8416
|
+
options: permissions != null ? permissions : [],
|
|
8417
|
+
onChange: function onChange(values) {
|
|
8418
|
+
setState({
|
|
8419
|
+
permission: values
|
|
8420
|
+
});
|
|
8421
|
+
},
|
|
8136
8422
|
dataTest: "selectPermissionsTest",
|
|
8137
8423
|
size: 5,
|
|
8138
8424
|
multiple: true
|
|
@@ -8265,7 +8551,18 @@
|
|
|
8265
8551
|
React.useEffect(function () {
|
|
8266
8552
|
get('@sharing');
|
|
8267
8553
|
}, [reset]);
|
|
8268
|
-
var perms =
|
|
8554
|
+
var perms = React.useMemo(function () {
|
|
8555
|
+
if (result) {
|
|
8556
|
+
return new Sharing(result);
|
|
8557
|
+
}
|
|
8558
|
+
|
|
8559
|
+
return null;
|
|
8560
|
+
}, [result]);
|
|
8561
|
+
|
|
8562
|
+
if (perms === null) {
|
|
8563
|
+
return null;
|
|
8564
|
+
}
|
|
8565
|
+
|
|
8269
8566
|
return jsxRuntime.jsxs("div", {
|
|
8270
8567
|
className: "columns",
|
|
8271
8568
|
children: [!loading && jsxRuntime.jsxs("div", {
|
|
@@ -8423,14 +8720,14 @@
|
|
|
8423
8720
|
return Promise.resolve(Ctx.client.getPrincipals(Ctx.path)).then(function (principalsData) {
|
|
8424
8721
|
var groups = principalsData.groups.map(function (group) {
|
|
8425
8722
|
return {
|
|
8426
|
-
text: group
|
|
8427
|
-
value: group
|
|
8723
|
+
text: group['@name'],
|
|
8724
|
+
value: group['@name']
|
|
8428
8725
|
};
|
|
8429
8726
|
});
|
|
8430
8727
|
var users = principalsData.users.map(function (user) {
|
|
8431
8728
|
return {
|
|
8432
|
-
text: user.fullname || user
|
|
8433
|
-
value: user
|
|
8729
|
+
text: user.fullname || user['@name'],
|
|
8730
|
+
value: user['@name']
|
|
8434
8731
|
};
|
|
8435
8732
|
});
|
|
8436
8733
|
principals = [].concat(groups, users);
|
|
@@ -8501,18 +8798,6 @@
|
|
|
8501
8798
|
text: "Add " + title
|
|
8502
8799
|
};
|
|
8503
8800
|
if (items.length === 0) return [];
|
|
8504
|
-
|
|
8505
|
-
if (items[0] && typeof items[0] === 'string') {
|
|
8506
|
-
return [def].concat(items.map(function (x) {
|
|
8507
|
-
return {
|
|
8508
|
-
value: x,
|
|
8509
|
-
text: x
|
|
8510
|
-
};
|
|
8511
|
-
})).filter(function (item) {
|
|
8512
|
-
return !already.includes(item.value);
|
|
8513
|
-
});
|
|
8514
|
-
}
|
|
8515
|
-
|
|
8516
8801
|
return [def].concat(items).filter(function (item) {
|
|
8517
8802
|
return !already.includes(item.value);
|
|
8518
8803
|
});
|
|
@@ -8525,7 +8810,7 @@
|
|
|
8525
8810
|
noData = _ref.noData,
|
|
8526
8811
|
onChange = _ref.onChange,
|
|
8527
8812
|
loading = _ref.loading;
|
|
8528
|
-
var selectRef = React.useRef();
|
|
8813
|
+
var selectRef = React.useRef(null);
|
|
8529
8814
|
|
|
8530
8815
|
var _useState = React.useState(items),
|
|
8531
8816
|
result = _useState[0],
|
|
@@ -8573,7 +8858,7 @@
|
|
|
8573
8858
|
marginBottom: '20px'
|
|
8574
8859
|
},
|
|
8575
8860
|
children: noData
|
|
8576
|
-
}), available.length > 1 && jsxRuntime.jsx("li", {
|
|
8861
|
+
}), (available != null ? available : []).length > 1 && jsxRuntime.jsx("li", {
|
|
8577
8862
|
className: "widget-list-add select is-small",
|
|
8578
8863
|
children: jsxRuntime.jsx(Select, {
|
|
8579
8864
|
options: availableData,
|
|
@@ -8591,13 +8876,13 @@
|
|
|
8591
8876
|
});
|
|
8592
8877
|
}
|
|
8593
8878
|
|
|
8594
|
-
var initialState$
|
|
8595
|
-
types:
|
|
8879
|
+
var initialState$4 = {
|
|
8880
|
+
types: []
|
|
8596
8881
|
};
|
|
8597
8882
|
function CreateButton() {
|
|
8598
8883
|
var intl = reactIntl.useIntl();
|
|
8599
8884
|
|
|
8600
|
-
var _useSetState = useSetState(initialState$
|
|
8885
|
+
var _useSetState = useSetState(initialState$4),
|
|
8601
8886
|
state = _useSetState[0],
|
|
8602
8887
|
setState = _useSetState[1];
|
|
8603
8888
|
|
|
@@ -8645,7 +8930,8 @@
|
|
|
8645
8930
|
|
|
8646
8931
|
if (state.types && state.types.length === 0) {
|
|
8647
8932
|
return null;
|
|
8648
|
-
}
|
|
8933
|
+
} // Implement some kind of filtering
|
|
8934
|
+
|
|
8649
8935
|
|
|
8650
8936
|
return jsxRuntime.jsx(Dropdown, {
|
|
8651
8937
|
id: "dropdown-menu",
|
|
@@ -8684,7 +8970,7 @@
|
|
|
8684
8970
|
var AddButton = _ref.AddButton;
|
|
8685
8971
|
var intl = reactIntl.useIntl();
|
|
8686
8972
|
|
|
8687
|
-
var _useSetState2 = useSetState(initialState$
|
|
8973
|
+
var _useSetState2 = useSetState(initialState$4),
|
|
8688
8974
|
state = _useSetState2[0],
|
|
8689
8975
|
setState = _useSetState2[1];
|
|
8690
8976
|
|
|
@@ -8695,7 +8981,7 @@
|
|
|
8695
8981
|
|
|
8696
8982
|
var traversal = useTraversal();
|
|
8697
8983
|
var Config = useConfig();
|
|
8698
|
-
var searchText = location.get('q');
|
|
8984
|
+
var searchText = location.get('q') || '';
|
|
8699
8985
|
|
|
8700
8986
|
var _useState = React.useState(searchText || ''),
|
|
8701
8987
|
searchValue = _useState[0],
|
|
@@ -8708,14 +8994,13 @@
|
|
|
8708
8994
|
setSearchValue(searchText);
|
|
8709
8995
|
}, [searchText]);
|
|
8710
8996
|
|
|
8711
|
-
var onSearchQuery = function onSearchQuery(
|
|
8712
|
-
|
|
8997
|
+
var onSearchQuery = function onSearchQuery(event) {
|
|
8998
|
+
event.preventDefault();
|
|
8713
8999
|
setLocation({
|
|
8714
|
-
q:
|
|
9000
|
+
q: event.currentTarget.elements.filterInput.value,
|
|
8715
9001
|
tab: 'Items',
|
|
8716
9002
|
page: 0
|
|
8717
9003
|
});
|
|
8718
|
-
ev.preventDefault();
|
|
8719
9004
|
};
|
|
8720
9005
|
|
|
8721
9006
|
var onSearchByType = function onSearchByType(typeText) {
|
|
@@ -8749,7 +9034,8 @@
|
|
|
8749
9034
|
type: "text",
|
|
8750
9035
|
className: "input is-size-7",
|
|
8751
9036
|
placeholder: intl.formatMessage(genericMessages.search),
|
|
8752
|
-
"data-test": "inputFilterTest"
|
|
9037
|
+
"data-test": "inputFilterTest",
|
|
9038
|
+
id: "filterInput"
|
|
8753
9039
|
})
|
|
8754
9040
|
}), jsxRuntime.jsx("div", {
|
|
8755
9041
|
className: "control",
|
|
@@ -8776,7 +9062,9 @@
|
|
|
8776
9062
|
value: item
|
|
8777
9063
|
};
|
|
8778
9064
|
}),
|
|
8779
|
-
onChange:
|
|
9065
|
+
onChange: function onChange(value) {
|
|
9066
|
+
return onSearchByType(value);
|
|
9067
|
+
}
|
|
8780
9068
|
})
|
|
8781
9069
|
}), traversal.hasPerm('guillotina.AddContent') && jsxRuntime.jsx("div", {
|
|
8782
9070
|
className: "level-item",
|
|
@@ -8817,11 +9105,11 @@
|
|
|
8817
9105
|
location = _useLocation[0],
|
|
8818
9106
|
setLocation = _useLocation[1];
|
|
8819
9107
|
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
currentTab =
|
|
8824
|
-
}
|
|
9108
|
+
currentTab = location.get('tab') || Object.keys(tabs)[0];
|
|
9109
|
+
/*if (!Object.keys(tabs).includes(currentTab)) {
|
|
9110
|
+
setLocation(defaultTab)
|
|
9111
|
+
currentTab = defaultTab
|
|
9112
|
+
}*/
|
|
8825
9113
|
|
|
8826
9114
|
var _useState = React.useState(currentTab),
|
|
8827
9115
|
current = _useState[0],
|
|
@@ -8830,7 +9118,7 @@
|
|
|
8830
9118
|
var CurrentComp = tabs[current] || fallback;
|
|
8831
9119
|
React__default['default'].useEffect(function () {
|
|
8832
9120
|
if (Object.keys(tabs).includes(currentTab)) {
|
|
8833
|
-
setTab(currentTab);
|
|
9121
|
+
setTab(currentTab); // setLocation({tab: currentTab})
|
|
8834
9122
|
}
|
|
8835
9123
|
}, [currentTab, tabs]);
|
|
8836
9124
|
|
|
@@ -8889,14 +9177,14 @@
|
|
|
8889
9177
|
Behaviors: 'guillotina.ModifyContent',
|
|
8890
9178
|
Permissions: 'guillotina.SeePermissions'
|
|
8891
9179
|
};
|
|
8892
|
-
function FolderCtx(
|
|
9180
|
+
function FolderCtx() {
|
|
8893
9181
|
var ctx = useTraversal();
|
|
8894
9182
|
var calculated = ctx.filterTabs(tabs, tabsPermissions);
|
|
8895
|
-
return jsxRuntime.jsx(TabsPanel,
|
|
9183
|
+
return jsxRuntime.jsx(TabsPanel, {
|
|
8896
9184
|
tabs: calculated,
|
|
8897
9185
|
currentTab: "Items",
|
|
8898
|
-
rightToolbar: jsxRuntime.jsx(ContextToolbar,
|
|
8899
|
-
}
|
|
9186
|
+
rightToolbar: jsxRuntime.jsx(ContextToolbar, {})
|
|
9187
|
+
});
|
|
8900
9188
|
}
|
|
8901
9189
|
|
|
8902
9190
|
var tabs$1 = {
|
|
@@ -8910,13 +9198,13 @@
|
|
|
8910
9198
|
Behaviors: 'guillotina.ModifyContent',
|
|
8911
9199
|
Permissions: 'guillotina.SeePermissions'
|
|
8912
9200
|
};
|
|
8913
|
-
function ItemCtx(
|
|
9201
|
+
function ItemCtx() {
|
|
8914
9202
|
var ctx = useTraversal();
|
|
8915
9203
|
var calculated = ctx.filterTabs(tabs$1, tabsPermissions$1);
|
|
8916
|
-
return jsxRuntime.jsx(TabsPanel,
|
|
9204
|
+
return jsxRuntime.jsx(TabsPanel, {
|
|
8917
9205
|
tabs: calculated,
|
|
8918
9206
|
currentTab: "Properties"
|
|
8919
|
-
}
|
|
9207
|
+
});
|
|
8920
9208
|
}
|
|
8921
9209
|
|
|
8922
9210
|
function _catch$7(body, recover) {
|
|
@@ -8935,8 +9223,9 @@
|
|
|
8935
9223
|
|
|
8936
9224
|
function ApplicationCtx() {
|
|
8937
9225
|
var intl = reactIntl.useIntl();
|
|
8938
|
-
var
|
|
8939
|
-
var
|
|
9226
|
+
var traversal = useTraversal();
|
|
9227
|
+
var appContext = traversal.state.context;
|
|
9228
|
+
var databases = appContext.databases;
|
|
8940
9229
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
8941
9230
|
children: [jsxRuntime.jsx("h3", {
|
|
8942
9231
|
children: intl.formatMessage({
|
|
@@ -8950,22 +9239,26 @@
|
|
|
8950
9239
|
className: "container",
|
|
8951
9240
|
children: [jsxRuntime.jsx(ItemTitle, {
|
|
8952
9241
|
title: "Objects"
|
|
8953
|
-
}),
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
9242
|
+
}), jsxRuntime.jsx("table", {
|
|
9243
|
+
children: jsxRuntime.jsx("tbody", {
|
|
9244
|
+
children: databases.map(function (db) {
|
|
9245
|
+
return jsxRuntime.jsx(Item, {
|
|
9246
|
+
item: {
|
|
9247
|
+
id: db,
|
|
9248
|
+
path: "/" + db + "/"
|
|
9249
|
+
},
|
|
9250
|
+
icon: 'fas fa-database'
|
|
9251
|
+
}, db);
|
|
9252
|
+
})
|
|
9253
|
+
})
|
|
8961
9254
|
})]
|
|
8962
9255
|
})]
|
|
8963
9256
|
});
|
|
8964
9257
|
}
|
|
8965
9258
|
function DatabaseCtx() {
|
|
8966
|
-
var
|
|
8967
|
-
var containers =
|
|
8968
|
-
var path =
|
|
9259
|
+
var traversal = useTraversal();
|
|
9260
|
+
var containers = traversal.state.context.containers;
|
|
9261
|
+
var path = traversal.state.path;
|
|
8969
9262
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
8970
9263
|
children: jsxRuntime.jsxs("div", {
|
|
8971
9264
|
className: "container",
|
|
@@ -9253,17 +9546,17 @@
|
|
|
9253
9546
|
|
|
9254
9547
|
var searchText = location.get('q');
|
|
9255
9548
|
|
|
9256
|
-
var onSearchQuery = function onSearchQuery(
|
|
9257
|
-
|
|
9549
|
+
var onSearchQuery = function onSearchQuery(event) {
|
|
9550
|
+
event.preventDefault();
|
|
9258
9551
|
setLocation({
|
|
9259
|
-
q:
|
|
9552
|
+
q: event.currentTarget.elements.filterInput.value,
|
|
9260
9553
|
page: 0
|
|
9261
9554
|
});
|
|
9262
|
-
|
|
9263
|
-
|
|
9555
|
+
}; // cleanup form on state.search change
|
|
9556
|
+
|
|
9264
9557
|
|
|
9265
9558
|
React.useEffect(function () {
|
|
9266
|
-
if (!searchText || searchText === '') {
|
|
9559
|
+
if (ref.current && (!searchText || searchText === '')) {
|
|
9267
9560
|
ref.current.value = '';
|
|
9268
9561
|
}
|
|
9269
9562
|
}, [searchText]);
|
|
@@ -9283,7 +9576,8 @@
|
|
|
9283
9576
|
type: "text",
|
|
9284
9577
|
className: "input is-size-7",
|
|
9285
9578
|
placeholder: intl.formatMessage(genericMessages.search),
|
|
9286
|
-
"data-test": "inputFilterTest"
|
|
9579
|
+
"data-test": "inputFilterTest",
|
|
9580
|
+
id: "filterInput"
|
|
9287
9581
|
})
|
|
9288
9582
|
}), jsxRuntime.jsx("div", {
|
|
9289
9583
|
className: "control",
|
|
@@ -9315,12 +9609,12 @@
|
|
|
9315
9609
|
})]
|
|
9316
9610
|
});
|
|
9317
9611
|
}
|
|
9318
|
-
function UsersCtx(
|
|
9319
|
-
return jsxRuntime.jsx(TabsPanel,
|
|
9612
|
+
function UsersCtx() {
|
|
9613
|
+
return jsxRuntime.jsx(TabsPanel, {
|
|
9320
9614
|
tabs: tabs$3,
|
|
9321
9615
|
currentTab: "Users",
|
|
9322
9616
|
rightToolbar: jsxRuntime.jsx(UsersToolbar, {})
|
|
9323
|
-
}
|
|
9617
|
+
});
|
|
9324
9618
|
}
|
|
9325
9619
|
function UserCtx() {
|
|
9326
9620
|
var intl = reactIntl.useIntl();
|
|
@@ -9337,9 +9631,10 @@
|
|
|
9337
9631
|
state = _useState[0],
|
|
9338
9632
|
setState = _useState[1];
|
|
9339
9633
|
|
|
9634
|
+
var userDataContext = Ctx.context;
|
|
9340
9635
|
var fields = {
|
|
9341
9636
|
user_groups: [],
|
|
9342
|
-
user_roles:
|
|
9637
|
+
user_roles: userDataContext.user_roles
|
|
9343
9638
|
};
|
|
9344
9639
|
|
|
9345
9640
|
var _useRemoteField = useRemoteField(fields),
|
|
@@ -9443,7 +9738,7 @@
|
|
|
9443
9738
|
"value": "Username"
|
|
9444
9739
|
}]
|
|
9445
9740
|
}), ":", ' ']
|
|
9446
|
-
}), ' ',
|
|
9741
|
+
}), ' ', userDataContext.username, " (", userDataContext.email, ")"]
|
|
9447
9742
|
}), jsxRuntime.jsxs("p", {
|
|
9448
9743
|
children: [jsxRuntime.jsxs("label", {
|
|
9449
9744
|
children: [' ', intl.formatMessage({
|
|
@@ -9453,7 +9748,7 @@
|
|
|
9453
9748
|
"value": "Creation Date"
|
|
9454
9749
|
}]
|
|
9455
9750
|
}), ":", ' ']
|
|
9456
|
-
}), ' ', formatDate(
|
|
9751
|
+
}), ' ', formatDate(userDataContext.creation_date)]
|
|
9457
9752
|
}), jsxRuntime.jsxs("p", {
|
|
9458
9753
|
children: [jsxRuntime.jsxs("label", {
|
|
9459
9754
|
children: [' ', intl.formatMessage({
|
|
@@ -9463,7 +9758,7 @@
|
|
|
9463
9758
|
"value": "Modification Date"
|
|
9464
9759
|
}]
|
|
9465
9760
|
}), ":", ' ']
|
|
9466
|
-
}), ' ', formatDate(
|
|
9761
|
+
}), ' ', formatDate(userDataContext.modification_date)]
|
|
9467
9762
|
}), jsxRuntime.jsx(Button, {
|
|
9468
9763
|
className: "is-size-7 is-info",
|
|
9469
9764
|
onClick: function onClick() {
|
|
@@ -9482,7 +9777,7 @@
|
|
|
9482
9777
|
onSubmit: function onSubmit(ev) {
|
|
9483
9778
|
return updateObject(ev);
|
|
9484
9779
|
},
|
|
9485
|
-
formData:
|
|
9780
|
+
formData: userDataContext,
|
|
9486
9781
|
exclude: ['password'],
|
|
9487
9782
|
remotes: remotes,
|
|
9488
9783
|
submitButton: false,
|
|
@@ -9496,7 +9791,7 @@
|
|
|
9496
9791
|
className: "column",
|
|
9497
9792
|
children: [jsxRuntime.jsx(TagsWidget, {
|
|
9498
9793
|
onChange: updateRemote('user_groups'),
|
|
9499
|
-
items:
|
|
9794
|
+
items: userDataContext.user_groups,
|
|
9500
9795
|
title: "Groups",
|
|
9501
9796
|
noData: intl.formatMessage({
|
|
9502
9797
|
id: "there_is_no_groups_for_this_user",
|
|
@@ -9517,7 +9812,12 @@
|
|
|
9517
9812
|
"value": "The user doesn't have any role"
|
|
9518
9813
|
}]
|
|
9519
9814
|
}),
|
|
9520
|
-
available: state.roles
|
|
9815
|
+
available: state.roles.map(function (x) {
|
|
9816
|
+
return {
|
|
9817
|
+
value: x,
|
|
9818
|
+
text: x
|
|
9819
|
+
};
|
|
9820
|
+
})
|
|
9521
9821
|
})]
|
|
9522
9822
|
})]
|
|
9523
9823
|
})]
|
|
@@ -9533,7 +9833,7 @@
|
|
|
9533
9833
|
try {
|
|
9534
9834
|
return Promise.resolve(Promise.all(items.map(function (item, i) {
|
|
9535
9835
|
var input = form[i + 1] || {};
|
|
9536
|
-
return Ctx.client.post("" + Ctx.path + item
|
|
9836
|
+
return Ctx.client.post("" + Ctx.path + item.id + "/@duplicate", {
|
|
9537
9837
|
destination: path,
|
|
9538
9838
|
new_id: input.value || getNewId(item.id)
|
|
9539
9839
|
});
|
|
@@ -9579,7 +9879,7 @@
|
|
|
9579
9879
|
}), jsxRuntime.jsx("input", {
|
|
9580
9880
|
type: "text",
|
|
9581
9881
|
className: "input",
|
|
9582
|
-
"data-test": "inputCopyIdTest-" + item
|
|
9882
|
+
"data-test": "inputCopyIdTest-" + item.id,
|
|
9583
9883
|
defaultValue: getNewId(item.id)
|
|
9584
9884
|
})]
|
|
9585
9885
|
}, item.id);
|
|
@@ -9652,9 +9952,9 @@
|
|
|
9652
9952
|
var moveItems = function moveItems(path) {
|
|
9653
9953
|
try {
|
|
9654
9954
|
return Promise.resolve(Promise.all(items.map(function (item) {
|
|
9655
|
-
return Ctx.client.post("" + Ctx.path + item
|
|
9955
|
+
return Ctx.client.post("" + Ctx.path + item.id + "/@move", {
|
|
9656
9956
|
destination: path,
|
|
9657
|
-
new_id: item
|
|
9957
|
+
new_id: item.id
|
|
9658
9958
|
});
|
|
9659
9959
|
}))).then(function (responses) {
|
|
9660
9960
|
Ctx.refresh();
|
|
@@ -9991,17 +10291,17 @@
|
|
|
9991
10291
|
|
|
9992
10292
|
var searchText = location.get('q');
|
|
9993
10293
|
|
|
9994
|
-
var onSearchQuery = function onSearchQuery(
|
|
9995
|
-
|
|
10294
|
+
var onSearchQuery = function onSearchQuery(event) {
|
|
10295
|
+
event.preventDefault();
|
|
9996
10296
|
setLocation({
|
|
9997
|
-
q:
|
|
10297
|
+
q: event.currentTarget.elements.filterInput.value,
|
|
9998
10298
|
page: 0
|
|
9999
10299
|
});
|
|
10000
|
-
|
|
10001
|
-
|
|
10300
|
+
}; // cleanup form on state.search change
|
|
10301
|
+
|
|
10002
10302
|
|
|
10003
10303
|
React.useEffect(function () {
|
|
10004
|
-
if (!searchText || searchText === '') {
|
|
10304
|
+
if (ref.current && (!searchText || searchText === '')) {
|
|
10005
10305
|
ref.current.value = '';
|
|
10006
10306
|
}
|
|
10007
10307
|
}, [searchText]);
|
|
@@ -10021,7 +10321,8 @@
|
|
|
10021
10321
|
type: "text",
|
|
10022
10322
|
className: "input is-size-7",
|
|
10023
10323
|
placeholder: intl.formatMessage(genericMessages.search),
|
|
10024
|
-
"data-test": "inputFilterTest"
|
|
10324
|
+
"data-test": "inputFilterTest",
|
|
10325
|
+
id: "filterInput"
|
|
10025
10326
|
})
|
|
10026
10327
|
}), jsxRuntime.jsx("div", {
|
|
10027
10328
|
className: "control",
|
|
@@ -10059,12 +10360,12 @@
|
|
|
10059
10360
|
})]
|
|
10060
10361
|
});
|
|
10061
10362
|
}
|
|
10062
|
-
function GroupsCtx(
|
|
10063
|
-
return jsxRuntime.jsx(TabsPanel,
|
|
10363
|
+
function GroupsCtx() {
|
|
10364
|
+
return jsxRuntime.jsx(TabsPanel, {
|
|
10064
10365
|
tabs: tabs$4,
|
|
10065
10366
|
currentTab: "Groups",
|
|
10066
10367
|
rightToolbar: jsxRuntime.jsx(GroupToolbar, {})
|
|
10067
|
-
}
|
|
10368
|
+
});
|
|
10068
10369
|
}
|
|
10069
10370
|
var sortParsed = parser("_sort_asc=id");
|
|
10070
10371
|
var searchParsed = parser('type_name=User');
|
|
@@ -10079,6 +10380,7 @@
|
|
|
10079
10380
|
roles = _useState[0],
|
|
10080
10381
|
setRoles = _useState[1];
|
|
10081
10382
|
|
|
10383
|
+
var groupDataContext = Ctx.context;
|
|
10082
10384
|
React.useEffect(function () {
|
|
10083
10385
|
var getRoles = function getRoles() {
|
|
10084
10386
|
try {
|
|
@@ -10132,11 +10434,11 @@
|
|
|
10132
10434
|
var addRole = function addRole(role) {
|
|
10133
10435
|
try {
|
|
10134
10436
|
return Promise.resolve(patch({
|
|
10135
|
-
user_roles:
|
|
10437
|
+
user_roles: groupDataContext.user_roles.concat(role)
|
|
10136
10438
|
})).then(function (_ref) {
|
|
10137
10439
|
var isError = _ref.isError,
|
|
10138
10440
|
errorMessage = _ref.errorMessage;
|
|
10139
|
-
handleResponse(isError, intl.formatMessage({
|
|
10441
|
+
handleResponse(!!isError, intl.formatMessage({
|
|
10140
10442
|
id: "role_added_to_group",
|
|
10141
10443
|
defaultMessage: [{
|
|
10142
10444
|
"type": 0,
|
|
@@ -10150,7 +10452,7 @@
|
|
|
10150
10452
|
}]
|
|
10151
10453
|
}, {
|
|
10152
10454
|
role: role
|
|
10153
|
-
}), errorMessage);
|
|
10455
|
+
}), errorMessage != null ? errorMessage : '');
|
|
10154
10456
|
});
|
|
10155
10457
|
} catch (e) {
|
|
10156
10458
|
return Promise.reject(e);
|
|
@@ -10160,13 +10462,13 @@
|
|
|
10160
10462
|
var removeRole = function removeRole(role) {
|
|
10161
10463
|
try {
|
|
10162
10464
|
return Promise.resolve(patch({
|
|
10163
|
-
user_roles:
|
|
10465
|
+
user_roles: groupDataContext.user_roles.filter(function (r) {
|
|
10164
10466
|
return r !== role;
|
|
10165
10467
|
})
|
|
10166
10468
|
})).then(function (_ref2) {
|
|
10167
10469
|
var isError = _ref2.isError,
|
|
10168
10470
|
errorMessage = _ref2.errorMessage;
|
|
10169
|
-
handleResponse(isError, intl.formatMessage({
|
|
10471
|
+
handleResponse(!!isError, intl.formatMessage({
|
|
10170
10472
|
id: "role_removed_from_group",
|
|
10171
10473
|
defaultMessage: [{
|
|
10172
10474
|
"type": 0,
|
|
@@ -10180,7 +10482,7 @@
|
|
|
10180
10482
|
}]
|
|
10181
10483
|
}, {
|
|
10182
10484
|
role: role
|
|
10183
|
-
}), errorMessage);
|
|
10485
|
+
}), errorMessage != null ? errorMessage : '');
|
|
10184
10486
|
});
|
|
10185
10487
|
} catch (e) {
|
|
10186
10488
|
return Promise.reject(e);
|
|
@@ -10190,30 +10492,32 @@
|
|
|
10190
10492
|
var addUser = function addUser(newUserId) {
|
|
10191
10493
|
try {
|
|
10192
10494
|
var data = {};
|
|
10193
|
-
|
|
10495
|
+
groupDataContext.users.forEach(function (user) {
|
|
10194
10496
|
data[user] = true;
|
|
10195
10497
|
});
|
|
10196
10498
|
data[newUserId] = true;
|
|
10197
10499
|
return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
|
|
10198
10500
|
users: data
|
|
10199
|
-
})).then(function (
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
|
|
10501
|
+
})).then(function (response) {
|
|
10502
|
+
return Promise.resolve(processResponse(response)).then(function (_ref3) {
|
|
10503
|
+
var isError = _ref3.isError,
|
|
10504
|
+
errorMessage = _ref3.errorMessage;
|
|
10505
|
+
handleResponse(isError, intl.formatMessage({
|
|
10506
|
+
id: "user_added_to_group",
|
|
10507
|
+
defaultMessage: [{
|
|
10508
|
+
"type": 0,
|
|
10509
|
+
"value": "User "
|
|
10510
|
+
}, {
|
|
10511
|
+
"type": 1,
|
|
10512
|
+
"value": "user"
|
|
10513
|
+
}, {
|
|
10514
|
+
"type": 0,
|
|
10515
|
+
"value": " added to group"
|
|
10516
|
+
}]
|
|
10210
10517
|
}, {
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
}, {
|
|
10215
|
-
user: newUserId
|
|
10216
|
-
}), errorMessage);
|
|
10518
|
+
user: newUserId
|
|
10519
|
+
}), errorMessage != null ? errorMessage : '');
|
|
10520
|
+
});
|
|
10217
10521
|
});
|
|
10218
10522
|
} catch (e) {
|
|
10219
10523
|
return Promise.reject(e);
|
|
@@ -10223,29 +10527,31 @@
|
|
|
10223
10527
|
var removeUser = function removeUser(userToRemove) {
|
|
10224
10528
|
try {
|
|
10225
10529
|
var data = {};
|
|
10226
|
-
|
|
10530
|
+
groupDataContext.users.forEach(function (user) {
|
|
10227
10531
|
data[user] = userToRemove !== user;
|
|
10228
10532
|
});
|
|
10229
10533
|
return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
|
|
10230
10534
|
users: data
|
|
10231
|
-
})).then(function (
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10535
|
+
})).then(function (response) {
|
|
10536
|
+
return Promise.resolve(processResponse(response)).then(function (_ref4) {
|
|
10537
|
+
var isError = _ref4.isError,
|
|
10538
|
+
errorMessage = _ref4.errorMessage;
|
|
10539
|
+
handleResponse(isError, intl.formatMessage({
|
|
10540
|
+
id: "user_removed_from_group",
|
|
10541
|
+
defaultMessage: [{
|
|
10542
|
+
"type": 0,
|
|
10543
|
+
"value": "User "
|
|
10544
|
+
}, {
|
|
10545
|
+
"type": 1,
|
|
10546
|
+
"value": "user"
|
|
10547
|
+
}, {
|
|
10548
|
+
"type": 0,
|
|
10549
|
+
"value": " removed from group"
|
|
10550
|
+
}]
|
|
10242
10551
|
}, {
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
}, {
|
|
10247
|
-
user: userToRemove
|
|
10248
|
-
}), errorMessage);
|
|
10552
|
+
user: userToRemove
|
|
10553
|
+
}), errorMessage != null ? errorMessage : '');
|
|
10554
|
+
});
|
|
10249
10555
|
});
|
|
10250
10556
|
} catch (e) {
|
|
10251
10557
|
return Promise.reject(e);
|
|
@@ -10300,11 +10606,13 @@
|
|
|
10300
10606
|
})
|
|
10301
10607
|
}), jsxRuntime.jsx(Select, {
|
|
10302
10608
|
options: roles.filter(function (role) {
|
|
10303
|
-
return !
|
|
10609
|
+
return !groupDataContext.user_roles.includes(role.value);
|
|
10304
10610
|
}),
|
|
10305
10611
|
appendDefault: true,
|
|
10306
|
-
onChange:
|
|
10307
|
-
|
|
10612
|
+
onChange: function onChange(value) {
|
|
10613
|
+
return addRole(value);
|
|
10614
|
+
}
|
|
10615
|
+
}), jsxRuntime.jsx("hr", {}), groupDataContext.user_roles.map(function (urole) {
|
|
10308
10616
|
return jsxRuntime.jsx("p", {
|
|
10309
10617
|
className: "control",
|
|
10310
10618
|
children: jsxRuntime.jsx(Tag, {
|
|
@@ -10336,7 +10644,7 @@
|
|
|
10336
10644
|
traversal: Ctx,
|
|
10337
10645
|
onChange: addUser,
|
|
10338
10646
|
btnClass: "is-small"
|
|
10339
|
-
}), jsxRuntime.jsx("hr", {}),
|
|
10647
|
+
}), jsxRuntime.jsx("hr", {}), groupDataContext.users.map(function (user) {
|
|
10340
10648
|
return jsxRuntime.jsx("p", {
|
|
10341
10649
|
className: "control",
|
|
10342
10650
|
children: jsxRuntime.jsx(Tag, {
|
|
@@ -10485,7 +10793,7 @@
|
|
|
10485
10793
|
var links = buildPaths(segments);
|
|
10486
10794
|
|
|
10487
10795
|
if (segments.length === 1) {
|
|
10488
|
-
return
|
|
10796
|
+
return null;
|
|
10489
10797
|
}
|
|
10490
10798
|
|
|
10491
10799
|
return jsxRuntime.jsx("nav", {
|
|
@@ -10619,11 +10927,13 @@
|
|
|
10619
10927
|
fallback = undefined;
|
|
10620
10928
|
}
|
|
10621
10929
|
|
|
10622
|
-
if (!context) return;
|
|
10930
|
+
if (!context) return; // console.log("Component for path", path)
|
|
10931
|
+
// lookup by path
|
|
10623
10932
|
|
|
10624
10933
|
if (registry.paths[path]) {
|
|
10625
10934
|
return registry.paths[path];
|
|
10626
|
-
}
|
|
10935
|
+
} // by type
|
|
10936
|
+
|
|
10627
10937
|
|
|
10628
10938
|
if (registry.views[context['@type']]) {
|
|
10629
10939
|
return registry.views[context['@type']];
|
|
@@ -10646,19 +10956,15 @@
|
|
|
10646
10956
|
return undefined;
|
|
10647
10957
|
};
|
|
10648
10958
|
|
|
10649
|
-
var
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
}
|
|
10959
|
+
var getView = function getView(name) {
|
|
10960
|
+
return registry.views[name];
|
|
10961
|
+
};
|
|
10653
10962
|
|
|
10654
|
-
|
|
10963
|
+
var getForm = function getForm(type, fallback) {
|
|
10964
|
+
return registry.forms[type] || fallback || BaseForm;
|
|
10655
10965
|
};
|
|
10656
10966
|
|
|
10657
10967
|
var getAction = function getAction(type, fallback) {
|
|
10658
|
-
if (fallback === void 0) {
|
|
10659
|
-
fallback = undefined;
|
|
10660
|
-
}
|
|
10661
|
-
|
|
10662
10968
|
return registry.actions[type] || fallback;
|
|
10663
10969
|
};
|
|
10664
10970
|
|
|
@@ -10675,10 +10981,21 @@
|
|
|
10675
10981
|
};
|
|
10676
10982
|
|
|
10677
10983
|
var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
|
|
10984
|
+
if (fallback === void 0) {
|
|
10985
|
+
fallback = ['title'];
|
|
10986
|
+
}
|
|
10987
|
+
|
|
10678
10988
|
return registry.fieldsToFilter[type] || fallback;
|
|
10679
10989
|
};
|
|
10680
10990
|
|
|
10681
10991
|
var getDefaultSortValue = function getDefaultSortValue(type, fallback) {
|
|
10992
|
+
if (fallback === void 0) {
|
|
10993
|
+
fallback = {
|
|
10994
|
+
key: 'id',
|
|
10995
|
+
direction: 'des'
|
|
10996
|
+
};
|
|
10997
|
+
}
|
|
10998
|
+
|
|
10682
10999
|
return registry.defaultSortValue[type] || fallback;
|
|
10683
11000
|
};
|
|
10684
11001
|
|
|
@@ -10686,12 +11003,14 @@
|
|
|
10686
11003
|
return context.is_folderish ? FolderCtx : ItemCtx;
|
|
10687
11004
|
};
|
|
10688
11005
|
function useRegistry(data) {
|
|
11006
|
+
// if data is provided we need to merge it into actual registry
|
|
10689
11007
|
var ref = React__default['default'].useRef();
|
|
10690
11008
|
|
|
10691
11009
|
if (data && !ref.current) {
|
|
10692
11010
|
ref.current = true;
|
|
10693
11011
|
Object.keys(data).map(function (key) {
|
|
10694
|
-
|
|
11012
|
+
var registryKey = key;
|
|
11013
|
+
registry[registryKey] = _extends({}, registry[registryKey], data[registryKey]);
|
|
10695
11014
|
});
|
|
10696
11015
|
}
|
|
10697
11016
|
|
|
@@ -10706,86 +11025,26 @@
|
|
|
10706
11025
|
getItemsColumn: getItemsColumn,
|
|
10707
11026
|
getFieldsToFilter: getFieldsToFilter,
|
|
10708
11027
|
getDefaultSortValue: getDefaultSortValue,
|
|
10709
|
-
getSchemas: getSchemas
|
|
11028
|
+
getSchemas: getSchemas,
|
|
11029
|
+
getView: getView
|
|
10710
11030
|
};
|
|
10711
11031
|
}
|
|
11032
|
+
/*
|
|
10712
11033
|
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
context: undefined,
|
|
10717
|
-
flash: {
|
|
10718
|
-
message: undefined,
|
|
10719
|
-
type: undefined
|
|
10720
|
-
},
|
|
10721
|
-
action: {
|
|
10722
|
-
action: undefined,
|
|
10723
|
-
params: undefined
|
|
11034
|
+
const registry = {
|
|
11035
|
+
paths: {
|
|
11036
|
+
"/db/guillotina/tags/": TagsContext
|
|
10724
11037
|
},
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
};
|
|
10730
|
-
function guillotinaReducer(state, action) {
|
|
10731
|
-
switch (action.type) {
|
|
10732
|
-
case 'SET_PATH':
|
|
10733
|
-
return _extends({}, state, {
|
|
10734
|
-
path: action.payload,
|
|
10735
|
-
loading: true
|
|
10736
|
-
});
|
|
10737
|
-
|
|
10738
|
-
case 'SET_CONTEXT':
|
|
10739
|
-
return _extends({}, state, action.payload, {
|
|
10740
|
-
errorStatus: undefined,
|
|
10741
|
-
loading: false
|
|
10742
|
-
});
|
|
10743
|
-
|
|
10744
|
-
case 'SET_ERROR':
|
|
10745
|
-
return _extends({}, state, {
|
|
10746
|
-
errorStatus: action.payload,
|
|
10747
|
-
loading: false
|
|
10748
|
-
});
|
|
10749
|
-
|
|
10750
|
-
case 'SET_FLASH':
|
|
10751
|
-
return _extends({}, state, action.payload);
|
|
10752
|
-
|
|
10753
|
-
case 'CLEAR_FLASH':
|
|
10754
|
-
return _extends({}, state, {
|
|
10755
|
-
flash: {
|
|
10756
|
-
message: undefined,
|
|
10757
|
-
type: undefined
|
|
10758
|
-
}
|
|
10759
|
-
});
|
|
10760
|
-
|
|
10761
|
-
case 'SET_ACTION':
|
|
10762
|
-
return _extends({}, state, {
|
|
10763
|
-
action: action.payload
|
|
10764
|
-
});
|
|
11038
|
+
forms: {
|
|
11039
|
+
Tag: AddTagForm
|
|
11040
|
+
}
|
|
11041
|
+
}
|
|
10765
11042
|
|
|
10766
|
-
case 'CLEAR_ACTION':
|
|
10767
|
-
return _extends({}, state, {
|
|
10768
|
-
action: {
|
|
10769
|
-
action: undefined,
|
|
10770
|
-
params: undefined
|
|
10771
|
-
}
|
|
10772
|
-
});
|
|
10773
11043
|
|
|
10774
|
-
|
|
10775
|
-
return _extends({}, state, {
|
|
10776
|
-
refresh: Date.now(),
|
|
10777
|
-
loading: !action.payload.transparent
|
|
10778
|
-
});
|
|
11044
|
+
<guillotina registry={registry} />
|
|
10779
11045
|
|
|
10780
|
-
case 'APPLY':
|
|
10781
|
-
return _extends({}, state, {
|
|
10782
|
-
context: _extends({}, state.context, action.payload)
|
|
10783
|
-
});
|
|
10784
11046
|
|
|
10785
|
-
|
|
10786
|
-
return state;
|
|
10787
|
-
}
|
|
10788
|
-
}
|
|
11047
|
+
*/
|
|
10789
11048
|
|
|
10790
11049
|
var actions = [
|
|
10791
11050
|
{
|
|
@@ -13596,25 +13855,27 @@
|
|
|
13596
13855
|
props = _objectWithoutPropertiesLoose(_ref, ["auth", "locale"]);
|
|
13597
13856
|
|
|
13598
13857
|
var messages = loadLocaleData(locale);
|
|
13599
|
-
var url = props.url || 'http://localhost:8080';
|
|
13858
|
+
var url = props.url || 'http://localhost:8080'; // without trailing slash
|
|
13859
|
+
|
|
13600
13860
|
var config = props.config || {};
|
|
13601
13861
|
var client = useGuillotinaClient();
|
|
13602
13862
|
|
|
13603
13863
|
var _useConfig = useConfig(config),
|
|
13604
13864
|
Permissions = _useConfig.Permissions;
|
|
13605
13865
|
|
|
13606
|
-
var registry = useRegistry(props.registry
|
|
13866
|
+
var registry = useRegistry(props.registry); // Location is cooked routing solution (only uses search params)
|
|
13607
13867
|
|
|
13608
13868
|
var _useLocation = useLocation(),
|
|
13609
|
-
location = _useLocation[0];
|
|
13869
|
+
location = _useLocation[0]; // if there is no path provided just go to root
|
|
13870
|
+
|
|
13610
13871
|
|
|
13611
13872
|
var searchPath = location.get('path') || '/';
|
|
13612
13873
|
|
|
13613
13874
|
if (searchPath && searchPath !== '') {
|
|
13614
|
-
initialState
|
|
13875
|
+
initialState.path = searchPath;
|
|
13615
13876
|
}
|
|
13616
13877
|
|
|
13617
|
-
var _useReducer = React.useReducer(guillotinaReducer, initialState
|
|
13878
|
+
var _useReducer = React.useReducer(guillotinaReducer, initialState),
|
|
13618
13879
|
state = _useReducer[0],
|
|
13619
13880
|
dispatch = _useReducer[1];
|
|
13620
13881
|
|
|
@@ -13622,8 +13883,10 @@
|
|
|
13622
13883
|
refresh = state.refresh;
|
|
13623
13884
|
React.useEffect(function () {
|
|
13624
13885
|
dispatch({
|
|
13625
|
-
type:
|
|
13626
|
-
payload:
|
|
13886
|
+
type: GuillotinaReducerActionTypes.SET_PATH,
|
|
13887
|
+
payload: {
|
|
13888
|
+
path: searchPath
|
|
13889
|
+
}
|
|
13627
13890
|
});
|
|
13628
13891
|
}, [searchPath]);
|
|
13629
13892
|
React.useEffect(function () {
|
|
@@ -13632,14 +13895,18 @@
|
|
|
13632
13895
|
return Promise.resolve(client.getContext(path)).then(function (data) {
|
|
13633
13896
|
if (data.status === 401) {
|
|
13634
13897
|
dispatch({
|
|
13635
|
-
type:
|
|
13636
|
-
payload:
|
|
13898
|
+
type: GuillotinaReducerActionTypes.SET_ERROR,
|
|
13899
|
+
payload: {
|
|
13900
|
+
errorStatus: 'notallowed'
|
|
13901
|
+
}
|
|
13637
13902
|
});
|
|
13638
13903
|
return;
|
|
13639
13904
|
} else if (data.status === 404) {
|
|
13640
13905
|
dispatch({
|
|
13641
|
-
type:
|
|
13642
|
-
payload:
|
|
13906
|
+
type: GuillotinaReducerActionTypes.SET_ERROR,
|
|
13907
|
+
payload: {
|
|
13908
|
+
errorStatus: 'notallowed'
|
|
13909
|
+
}
|
|
13643
13910
|
});
|
|
13644
13911
|
return;
|
|
13645
13912
|
}
|
|
@@ -13648,7 +13915,7 @@
|
|
|
13648
13915
|
return Promise.resolve(client.canido(path, Permissions)).then(function (pr) {
|
|
13649
13916
|
return Promise.resolve(pr.json()).then(function (permissions) {
|
|
13650
13917
|
dispatch({
|
|
13651
|
-
type:
|
|
13918
|
+
type: GuillotinaReducerActionTypes.SET_CONTEXT,
|
|
13652
13919
|
payload: {
|
|
13653
13920
|
context: context,
|
|
13654
13921
|
permissions: permissions
|
|
@@ -13665,9 +13932,9 @@
|
|
|
13665
13932
|
|
|
13666
13933
|
initContext();
|
|
13667
13934
|
}, [path, refresh, client]);
|
|
13668
|
-
var ErrorBoundary = registry.
|
|
13669
|
-
var NotAllowed = registry.
|
|
13670
|
-
var NotFound = registry.
|
|
13935
|
+
var ErrorBoundary = registry.getView('ErrorBoundary');
|
|
13936
|
+
var NotAllowed = registry.getView('NotAllowed');
|
|
13937
|
+
var NotFound = registry.getView('NotFound');
|
|
13671
13938
|
var Path = registry.get('components', 'Path');
|
|
13672
13939
|
var contextData = {
|
|
13673
13940
|
url: url,
|
|
@@ -13690,7 +13957,7 @@
|
|
|
13690
13957
|
children: jsxRuntime.jsxs(ErrorBoundary, {
|
|
13691
13958
|
children: [!errorStatus && jsxRuntime.jsx(TraversalProvider, _extends({}, contextData, {
|
|
13692
13959
|
children: permissions && jsxRuntime.jsxs(React__default['default'].Fragment, {
|
|
13693
|
-
children: [action.action && jsxRuntime.jsx(Action, _extends({}, action.params)), jsxRuntime.jsx("div", {
|
|
13960
|
+
children: [action.action && Action !== null && jsxRuntime.jsx(Action, _extends({}, action.params)), jsxRuntime.jsx("div", {
|
|
13694
13961
|
className: "level",
|
|
13695
13962
|
children: jsxRuntime.jsx("div", {
|
|
13696
13963
|
className: "level-left",
|
|
@@ -13699,7 +13966,7 @@
|
|
|
13699
13966
|
children: jsxRuntime.jsx(Path, {})
|
|
13700
13967
|
})
|
|
13701
13968
|
})
|
|
13702
|
-
}), jsxRuntime.jsx(Flash, {}), Main && jsxRuntime.jsx(ErrorBoundary, {
|
|
13969
|
+
}), jsxRuntime.jsx(Flash, {}), Main !== undefined && jsxRuntime.jsx(ErrorBoundary, {
|
|
13703
13970
|
children: jsxRuntime.jsxs("div", {
|
|
13704
13971
|
className: "box main-panel",
|
|
13705
13972
|
children: [state.loading && jsxRuntime.jsx(Loading, {}), !state.loading && jsxRuntime.jsx(Main, {
|
|
@@ -13809,7 +14076,7 @@
|
|
|
13809
14076
|
var initialState$5 = {
|
|
13810
14077
|
username: '',
|
|
13811
14078
|
password: '',
|
|
13812
|
-
loading:
|
|
14079
|
+
loading: false,
|
|
13813
14080
|
errors: undefined
|
|
13814
14081
|
};
|
|
13815
14082
|
var Login = function Login(_ref) {
|
|
@@ -13825,7 +14092,7 @@
|
|
|
13825
14092
|
|
|
13826
14093
|
var inputRef = React.useRef(null);
|
|
13827
14094
|
React.useEffect(function () {
|
|
13828
|
-
if (inputRef) {
|
|
14095
|
+
if (inputRef && inputRef.current) {
|
|
13829
14096
|
inputRef.current.focus();
|
|
13830
14097
|
}
|
|
13831
14098
|
}, [inputRef]);
|
|
@@ -14046,30 +14313,30 @@
|
|
|
14046
14313
|
dataTest: dataTest,
|
|
14047
14314
|
children: [schema && schema.data && !schema.loading && schema.formFields.map(function (key) {
|
|
14048
14315
|
if (!ignoreFiels.includes(key)) {
|
|
14049
|
-
var _value$title;
|
|
14316
|
+
var _schema$data, _value$title, _schema$data2;
|
|
14050
14317
|
|
|
14051
|
-
var value = schema.data.properties[key];
|
|
14318
|
+
var value = (_schema$data = schema.data) == null ? void 0 : _schema$data.properties[key];
|
|
14052
14319
|
return jsxRuntime.jsx(EditComponent, {
|
|
14053
14320
|
id: key,
|
|
14054
14321
|
placeholder: (_value$title = value == null ? void 0 : value.title) != null ? _value$title : '',
|
|
14055
14322
|
className: "",
|
|
14056
14323
|
required: true,
|
|
14057
|
-
schema: schema.data.properties[key],
|
|
14058
|
-
setValue: function setValue(
|
|
14324
|
+
schema: (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key],
|
|
14325
|
+
setValue: function setValue(value) {
|
|
14059
14326
|
if (key === 'title') {
|
|
14060
14327
|
var _extends2;
|
|
14061
14328
|
|
|
14062
14329
|
setFormData(_extends({}, formData, (_extends2 = {
|
|
14063
|
-
uuid: stringToSlug(
|
|
14064
|
-
}, _extends2[key] =
|
|
14330
|
+
uuid: stringToSlug(value)
|
|
14331
|
+
}, _extends2[key] = value, _extends2)));
|
|
14065
14332
|
} else if (key === 'uuid') {
|
|
14066
14333
|
setFormData(_extends({}, formData, {
|
|
14067
|
-
uuid: stringToSlug(
|
|
14334
|
+
uuid: stringToSlug(value)
|
|
14068
14335
|
}));
|
|
14069
14336
|
} else {
|
|
14070
14337
|
var _extends3;
|
|
14071
14338
|
|
|
14072
|
-
setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] =
|
|
14339
|
+
setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] = value, _extends3)));
|
|
14073
14340
|
}
|
|
14074
14341
|
},
|
|
14075
14342
|
error: errors[key],
|
|
@@ -14200,6 +14467,7 @@
|
|
|
14200
14467
|
method: 'post'
|
|
14201
14468
|
})).then(function (data) {
|
|
14202
14469
|
if (data.status === 401) {
|
|
14470
|
+
// invalid token
|
|
14203
14471
|
_this4.cleanAuth();
|
|
14204
14472
|
|
|
14205
14473
|
_this4.logout();
|
|
@@ -14262,7 +14530,7 @@
|
|
|
14262
14530
|
|
|
14263
14531
|
if (!authToken) return {};
|
|
14264
14532
|
|
|
14265
|
-
if (this.willExpire(expires) && this.retryRefresh < this.maxRetry) {
|
|
14533
|
+
if (this.willExpire(expires != null ? expires : '') && this.retryRefresh < this.maxRetry) {
|
|
14266
14534
|
|
|
14267
14535
|
(function () {
|
|
14268
14536
|
try {
|
|
@@ -14320,6 +14588,13 @@
|
|
|
14320
14588
|
return Auth;
|
|
14321
14589
|
}();
|
|
14322
14590
|
|
|
14591
|
+
(function (Setting) {
|
|
14592
|
+
Setting["Allow"] = "Allow";
|
|
14593
|
+
Setting["AllowSingle"] = "AllowSingle";
|
|
14594
|
+
Setting["Deny"] = "Deny";
|
|
14595
|
+
Setting["Unset"] = "Unset";
|
|
14596
|
+
})(exports.Setting || (exports.Setting = {}));
|
|
14597
|
+
|
|
14323
14598
|
exports.AddItem = AddItem;
|
|
14324
14599
|
exports.AddPermission = AddPermission;
|
|
14325
14600
|
exports.AllItemsCheckbox = AllItemsCheckbox;
|
|
@@ -14333,7 +14608,6 @@
|
|
|
14333
14608
|
exports.Checkbox = Checkbox;
|
|
14334
14609
|
exports.ClientContext = ClientContext;
|
|
14335
14610
|
exports.ClientProvider = ClientProvider;
|
|
14336
|
-
exports.Config = Config;
|
|
14337
14611
|
exports.Confirm = Confirm;
|
|
14338
14612
|
exports.ContainerCtx = ContainerCtx;
|
|
14339
14613
|
exports.ContextToolbar = ContextToolbar;
|
|
@@ -14431,12 +14705,14 @@
|
|
|
14431
14705
|
exports.base64ToArrayBuffer = base64ToArrayBuffer;
|
|
14432
14706
|
exports.buildQs = buildQs;
|
|
14433
14707
|
exports.classnames = classnames;
|
|
14708
|
+
exports.debounce = debounce;
|
|
14434
14709
|
exports.defaultComponent = defaultComponent;
|
|
14710
|
+
exports.defaultConfig = defaultConfig;
|
|
14435
14711
|
exports.formatDate = formatDate;
|
|
14436
14712
|
exports.generateUID = generateUID;
|
|
14437
14713
|
exports.genericFileMessages = genericFileMessages;
|
|
14438
14714
|
exports.genericMessages = genericMessages;
|
|
14439
|
-
exports.get = get
|
|
14715
|
+
exports.get = get;
|
|
14440
14716
|
exports.getActionsObject = getActionsObject;
|
|
14441
14717
|
exports.getClient = getClient;
|
|
14442
14718
|
exports.getNewId = getNewId;
|