@crystaldesign/diva-backoffice 24.10.0-beta.9 → 24.10.0-rc.1
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/build/esm/index.js +1423 -1317
- package/build/types/backoffice/src/ui/FileUploadBeta/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/FilterBox/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Form/Fields/FormList/index.d.ts +37 -0
- package/build/types/backoffice/src/ui/Form/Fields/FormList/index.d.ts.map +1 -0
- package/build/types/backoffice/src/ui/Form/Presets/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Form/elements.d.ts +7 -0
- package/build/types/backoffice/src/ui/Form/elements.d.ts.map +1 -0
- package/build/types/backoffice/src/ui/Form/index.d.ts +1 -1
- package/build/types/backoffice/src/ui/Form/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Form/types.d.ts +2 -1
- package/build/types/backoffice/src/ui/Form/types.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Form/useFormData.d.ts +2 -0
- package/build/types/backoffice/src/ui/Form/useFormData.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/RichTextEditor/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Select/index.d.ts.map +1 -1
- package/build/types/backoffice/src/ui/Table/BaseTable/cellRenderer/TextCell/index.d.ts.map +1 -1
- package/package.json +3 -3
package/build/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import React, { createElement, createContext, useState, useEffect, useRef, useMemo, useImperativeHandle, useCallback, createRef, useReducer, useContext, memo } from 'react';
|
|
3
3
|
import 'antd/dist/reset.css';
|
|
4
|
-
import {
|
|
4
|
+
import { Form as Form$1, Button, Input, Popover, Typography, Divider, Select as Select$1, Avatar, Spin, Radio, DatePicker, Checkbox, InputNumber, Modal as Modal$2, Space, Cascader, Descriptions, Row, Col, Tooltip as Tooltip$1, Collapse, List as List$1, Skeleton, Alert, Card, Upload, Switch, Table as Table$1, Popconfirm, Tabs, Image, Progress, Slider, Breadcrumb, Result as Result$1, message, Layout, Drawer, ConfigProvider, theme } from 'antd';
|
|
5
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
6
|
import { observer } from 'mobx-react-lite';
|
|
7
7
|
import { getLogger, DivaError, useDivaCore, useTranslation as useTranslation$1, DivaUtils } from '@crystaldesign/diva-core';
|
|
@@ -65,14 +65,14 @@ import FolderOutlined from '@ant-design/icons/FolderOutlined';
|
|
|
65
65
|
import SettingOutlined from '@ant-design/icons/SettingOutlined';
|
|
66
66
|
import PieChartOutlined from '@ant-design/icons/PieChartOutlined';
|
|
67
67
|
import InfoCircleOutlined from '@ant-design/icons/InfoCircleOutlined';
|
|
68
|
-
import debounce from 'lodash/debounce';
|
|
69
|
-
import { isArray } from 'lodash';
|
|
70
68
|
import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
|
|
71
69
|
import JSONEditor from 'jsoneditor';
|
|
72
70
|
import 'jsoneditor/dist/jsoneditor.css';
|
|
73
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
74
71
|
import { MinusCircleOutlined, PlusOutlined, DownloadOutlined as DownloadOutlined$1, PlusSquareOutlined, DeleteOutlined as DeleteOutlined$1, FullscreenOutlined, FileUnknownOutlined, CloseOutlined as CloseOutlined$1, PlusCircleOutlined as PlusCircleOutlined$1, HomeOutlined as HomeOutlined$1, InboxOutlined, PushpinOutlined, PushpinFilled, ReloadOutlined as ReloadOutlined$1 } from '@ant-design/icons';
|
|
72
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
75
73
|
import { Editor } from '@tinymce/tinymce-react';
|
|
74
|
+
import debounce from 'lodash/debounce';
|
|
75
|
+
import { isArray } from 'lodash';
|
|
76
76
|
import { stringify } from 'csv';
|
|
77
77
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
78
78
|
import SearchOutlined from '@ant-design/icons/SearchOutlined';
|
|
@@ -4512,6 +4512,10 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
4512
4512
|
type: 'unixTimeStamp',
|
|
4513
4513
|
sorter: 8,
|
|
4514
4514
|
width: 150
|
|
4515
|
+
}, {
|
|
4516
|
+
title: 'variants',
|
|
4517
|
+
field: 'variants',
|
|
4518
|
+
hidden: true
|
|
4515
4519
|
}],
|
|
4516
4520
|
apiInterface: {
|
|
4517
4521
|
read: {
|
|
@@ -4521,6 +4525,12 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
4521
4525
|
"delete": '${mediaService}/rooms/${id}'
|
|
4522
4526
|
},
|
|
4523
4527
|
rowAction: [{
|
|
4528
|
+
actionType: 'Detail',
|
|
4529
|
+
type: 'Form',
|
|
4530
|
+
id: 'FormRoom',
|
|
4531
|
+
title: t('backoffice.table.rooms.rowAction.editRoom'),
|
|
4532
|
+
label: t('backoffice.table.rooms.rowAction.editRoom')
|
|
4533
|
+
}, {
|
|
4524
4534
|
actionType: 'Detail',
|
|
4525
4535
|
type: 'Form',
|
|
4526
4536
|
id: 'FormMergeRoom',
|
|
@@ -4538,6 +4548,12 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
4538
4548
|
id: 'RoomVariantList',
|
|
4539
4549
|
title: t('backoffice.table.apikeys.rowAction.showRoomVariants'),
|
|
4540
4550
|
label: t('backoffice.table.apikeys.rowAction.showRoomVariants')
|
|
4551
|
+
}, {
|
|
4552
|
+
actionType: 'Detail',
|
|
4553
|
+
type: 'Form',
|
|
4554
|
+
id: 'FormRoomViewpoints',
|
|
4555
|
+
title: t('backoffice.table.rooms.rowAction.viewpoints'),
|
|
4556
|
+
label: t('backoffice.table.rooms.rowAction.viewpoints')
|
|
4541
4557
|
}]
|
|
4542
4558
|
},
|
|
4543
4559
|
TableRenderjobs: {
|
|
@@ -4622,13 +4638,6 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
4622
4638
|
width: 200,
|
|
4623
4639
|
translationPrefix: 'renderjob.state',
|
|
4624
4640
|
type: 'string'
|
|
4625
|
-
}, {
|
|
4626
|
-
title: t('backoffice.table.renderjobs.columns.cachedRefs'),
|
|
4627
|
-
field: 'cachedRefs',
|
|
4628
|
-
type: 'boolean',
|
|
4629
|
-
sorter: 2,
|
|
4630
|
-
width: 100,
|
|
4631
|
-
align: 'center'
|
|
4632
4641
|
}, {
|
|
4633
4642
|
title: t('backoffice.table.renderjobs.columns.priority'),
|
|
4634
4643
|
sorter: 2,
|
|
@@ -4903,46 +4912,6 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
4903
4912
|
setType: 'addToSourceValue'
|
|
4904
4913
|
}]
|
|
4905
4914
|
}
|
|
4906
|
-
}, {
|
|
4907
|
-
actionType: 'Modal',
|
|
4908
|
-
id: 'CacheModal',
|
|
4909
|
-
title: t('backoffice.table.renderjobs.bulkActions.CacheModal.title'),
|
|
4910
|
-
label: t('backoffice.table.renderjobs.bulkActions.CacheModal.title'),
|
|
4911
|
-
rule: [{
|
|
4912
|
-
match: {
|
|
4913
|
-
sourceField: 'state',
|
|
4914
|
-
value: 12
|
|
4915
|
-
}
|
|
4916
|
-
}, {
|
|
4917
|
-
match: {
|
|
4918
|
-
sourceField: 'cachedRefs',
|
|
4919
|
-
value: []
|
|
4920
|
-
}
|
|
4921
|
-
}],
|
|
4922
|
-
errorText: t('backoffice.table.renderjobs.bulkActions.CacheModal.errorText'),
|
|
4923
|
-
apiInterface: {
|
|
4924
|
-
create: '${mediaService}/renderjobs/{_id}/cache'
|
|
4925
|
-
}
|
|
4926
|
-
}, {
|
|
4927
|
-
actionType: 'Modal',
|
|
4928
|
-
id: 'ClearCacheModal',
|
|
4929
|
-
title: t('backoffice.table.renderjobs.bulkActions.ClearCacheModal.title'),
|
|
4930
|
-
label: t('backoffice.table.renderjobs.bulkActions.ClearCacheModal.label'),
|
|
4931
|
-
rule: [{
|
|
4932
|
-
match: {
|
|
4933
|
-
sourceField: 'state',
|
|
4934
|
-
value: 12
|
|
4935
|
-
}
|
|
4936
|
-
}, {
|
|
4937
|
-
match: {
|
|
4938
|
-
sourceField: 'cachedRefs',
|
|
4939
|
-
value: '$length'
|
|
4940
|
-
}
|
|
4941
|
-
}],
|
|
4942
|
-
errorText: t('backoffice.table.renderjobs.bulkActions.ClearCacheModal.errorText'),
|
|
4943
|
-
apiInterface: {
|
|
4944
|
-
"delete": '${mediaService}/renderjobs/${id}/cache'
|
|
4945
|
-
}
|
|
4946
4915
|
}],
|
|
4947
4916
|
deselectOnUpdate: false,
|
|
4948
4917
|
copyAction: {
|
|
@@ -5032,6 +5001,12 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
5032
5001
|
field: '_id',
|
|
5033
5002
|
sorter: 1,
|
|
5034
5003
|
filter: 'advanced'
|
|
5004
|
+
}, {
|
|
5005
|
+
title: t('backoffice.table.renderpackages.columns.position'),
|
|
5006
|
+
field: 'position',
|
|
5007
|
+
sorter: 3,
|
|
5008
|
+
filter: 'advanced',
|
|
5009
|
+
width: 100
|
|
5035
5010
|
}, {
|
|
5036
5011
|
title: t('backoffice.table.renderpackages.columns.name'),
|
|
5037
5012
|
field: 'name',
|
|
@@ -7738,6 +7713,11 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
7738
7713
|
label: t('backoffice.form.createorupdaterenderpackages.items.category'),
|
|
7739
7714
|
type: 'input',
|
|
7740
7715
|
required: true
|
|
7716
|
+
}, {
|
|
7717
|
+
name: 'position',
|
|
7718
|
+
label: t('backoffice.form.createorupdaterenderpackages.items.position'),
|
|
7719
|
+
type: 'number',
|
|
7720
|
+
required: false
|
|
7741
7721
|
}, {
|
|
7742
7722
|
type: 'subTitle',
|
|
7743
7723
|
name: 'Presets'
|
|
@@ -7975,6 +7955,13 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
7975
7955
|
label: t('backoffice.form.renderjob.items.productName'),
|
|
7976
7956
|
type: 'input',
|
|
7977
7957
|
readonly: true
|
|
7958
|
+
}, {
|
|
7959
|
+
name: 'functionType',
|
|
7960
|
+
label: t('backoffice.form.renderjob.items.functionType'),
|
|
7961
|
+
type: 'select',
|
|
7962
|
+
mode: 'single',
|
|
7963
|
+
allowClear: true,
|
|
7964
|
+
values: ['PROD', 'PROD_SEC', 'PROD_CLOSE', 'PROD_MILIEU', 'SHO', 'CONFIG_INFO', 'AR_INFO', 'PROD_DETAIL', 'CAT', 'PLN', 'LOG', 'FUNC', 'COMMERCIAL', 'TPL', 'ASI', 'PLT', 'CAI', 'BAN', 'INF', 'OTH', 'ART', 'OPV']
|
|
7978
7965
|
}, {
|
|
7979
7966
|
name: 'priority',
|
|
7980
7967
|
label: t('backoffice.form.renderjob.items.priority'),
|
|
@@ -8223,6 +8210,13 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
8223
8210
|
label: t('backoffice.form.renderjob.items.productName'),
|
|
8224
8211
|
type: 'input',
|
|
8225
8212
|
readonly: true
|
|
8213
|
+
}, {
|
|
8214
|
+
name: 'functionType',
|
|
8215
|
+
label: t('backoffice.form.renderjob.items.functionType'),
|
|
8216
|
+
type: 'select',
|
|
8217
|
+
mode: 'single',
|
|
8218
|
+
allowClear: true,
|
|
8219
|
+
values: ['PROD', 'PROD_SEC', 'PROD_CLOSE', 'PROD_MILIEU', 'SHO', 'CONFIG_INFO', 'AR_INFO', 'PROD_DETAIL', 'CAT', 'PLN', 'LOG', 'FUNC', 'COMMERCIAL', 'TPL', 'ASI', 'PLT', 'CAI', 'BAN', 'INF', 'OTH', 'ART', 'OPV']
|
|
8226
8220
|
}, {
|
|
8227
8221
|
name: 'priority',
|
|
8228
8222
|
label: t('backoffice.form.renderjob.items.priority'),
|
|
@@ -8375,6 +8369,13 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
8375
8369
|
label: t('backoffice.form.renderjob.items.productName'),
|
|
8376
8370
|
type: 'input',
|
|
8377
8371
|
readonly: true
|
|
8372
|
+
}, {
|
|
8373
|
+
name: 'functionType',
|
|
8374
|
+
label: t('backoffice.form.renderjob.items.functionType'),
|
|
8375
|
+
type: 'select',
|
|
8376
|
+
mode: 'single',
|
|
8377
|
+
allowClear: true,
|
|
8378
|
+
values: ['PROD', 'PROD_SEC', 'PROD_CLOSE', 'PROD_MILIEU', 'SHO', 'CONFIG_INFO', 'AR_INFO', 'PROD_DETAIL', 'CAT', 'PLN', 'LOG', 'FUNC', 'COMMERCIAL', 'TPL', 'ASI', 'PLT', 'CAI', 'BAN', 'INF', 'OTH', 'ART', 'OPV']
|
|
8378
8379
|
}, {
|
|
8379
8380
|
name: 'priority',
|
|
8380
8381
|
label: t('backoffice.form.renderjob.items.priority'),
|
|
@@ -9270,6 +9271,95 @@ function loadConfiguration(t, root, config, lang) {
|
|
|
9270
9271
|
type: 'input'
|
|
9271
9272
|
}]
|
|
9272
9273
|
},
|
|
9274
|
+
FormRoom: {
|
|
9275
|
+
type: 'Form',
|
|
9276
|
+
title: 'Renderjob',
|
|
9277
|
+
apiInterface: {
|
|
9278
|
+
update: {
|
|
9279
|
+
url: '${mediaService}/rooms/{_id}/',
|
|
9280
|
+
method: 'PATCH',
|
|
9281
|
+
jsonPatch: true
|
|
9282
|
+
}
|
|
9283
|
+
},
|
|
9284
|
+
items: [{
|
|
9285
|
+
name: '_id',
|
|
9286
|
+
label: 'ID',
|
|
9287
|
+
type: 'input',
|
|
9288
|
+
readonly: true
|
|
9289
|
+
}, {
|
|
9290
|
+
name: 'blenderVersion',
|
|
9291
|
+
label: 'Blender Version',
|
|
9292
|
+
type: 'input',
|
|
9293
|
+
readonly: true
|
|
9294
|
+
}, {
|
|
9295
|
+
name: 'mainCategory',
|
|
9296
|
+
label: 'Haupt Kategorie',
|
|
9297
|
+
type: 'input'
|
|
9298
|
+
}, {
|
|
9299
|
+
name: 'name',
|
|
9300
|
+
label: 'Name',
|
|
9301
|
+
type: 'input'
|
|
9302
|
+
}, {
|
|
9303
|
+
name: 'variants',
|
|
9304
|
+
label: 'variants',
|
|
9305
|
+
value: 'variants',
|
|
9306
|
+
type: 'array',
|
|
9307
|
+
disablePushOrPop: true,
|
|
9308
|
+
items: [{
|
|
9309
|
+
type: 'subTitle',
|
|
9310
|
+
name: 'Variante'
|
|
9311
|
+
}, {
|
|
9312
|
+
type: 'input',
|
|
9313
|
+
name: 'name'
|
|
9314
|
+
}, {
|
|
9315
|
+
type: 'input',
|
|
9316
|
+
name: 'description'
|
|
9317
|
+
}, {
|
|
9318
|
+
type: 'select',
|
|
9319
|
+
name: 'compatibleColors',
|
|
9320
|
+
mode: 'multiple',
|
|
9321
|
+
allowClear: true,
|
|
9322
|
+
values: ['black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua']
|
|
9323
|
+
}, {
|
|
9324
|
+
type: 'checkbox',
|
|
9325
|
+
name: 'default',
|
|
9326
|
+
readonly: true
|
|
9327
|
+
}, {
|
|
9328
|
+
type: 'input',
|
|
9329
|
+
name: 'sceneName'
|
|
9330
|
+
}, {
|
|
9331
|
+
type: 'select',
|
|
9332
|
+
name: 'style',
|
|
9333
|
+
mode: 'multiple',
|
|
9334
|
+
allowCreate: true
|
|
9335
|
+
}]
|
|
9336
|
+
}]
|
|
9337
|
+
},
|
|
9338
|
+
FormRoomViewpoints: {
|
|
9339
|
+
type: 'Form',
|
|
9340
|
+
title: 'Renderjob',
|
|
9341
|
+
items: [{
|
|
9342
|
+
name: 'variants',
|
|
9343
|
+
label: 'variants',
|
|
9344
|
+
value: 'variants',
|
|
9345
|
+
type: 'array',
|
|
9346
|
+
disablePushOrPop: true,
|
|
9347
|
+
items: [{
|
|
9348
|
+
type: 'input',
|
|
9349
|
+
name: 'name',
|
|
9350
|
+
readonly: true
|
|
9351
|
+
}, {
|
|
9352
|
+
type: 'array',
|
|
9353
|
+
name: 'viewpoints',
|
|
9354
|
+
items: [{
|
|
9355
|
+
type: 'input',
|
|
9356
|
+
name: 'name',
|
|
9357
|
+
readonly: true
|
|
9358
|
+
}],
|
|
9359
|
+
disablePushOrPop: true
|
|
9360
|
+
}]
|
|
9361
|
+
}]
|
|
9362
|
+
},
|
|
9273
9363
|
OrgTree: {
|
|
9274
9364
|
type: 'OrgTree',
|
|
9275
9365
|
expandAll: true,
|
|
@@ -13345,6 +13435,28 @@ function useFormData (_ref) {
|
|
|
13345
13435
|
}));
|
|
13346
13436
|
return _setDynamicFields.apply(this, arguments);
|
|
13347
13437
|
}
|
|
13438
|
+
function getRules(item, data) {
|
|
13439
|
+
var _item$rules;
|
|
13440
|
+
var rules = [];
|
|
13441
|
+
if (item.required != undefined) {
|
|
13442
|
+
var _hiddenRequiredDisabl;
|
|
13443
|
+
rules.push({
|
|
13444
|
+
required: (_hiddenRequiredDisabl = hiddenRequiredDisabled[typeof item.name == 'string' ? item.name : item.name.join('.')]) === null || _hiddenRequiredDisabl === void 0 ? void 0 : _hiddenRequiredDisabl.required
|
|
13445
|
+
});
|
|
13446
|
+
}
|
|
13447
|
+
if (((_item$rules = item.rules) === null || _item$rules === void 0 ? void 0 : _item$rules.type) == 'condition') {
|
|
13448
|
+
var condition = item.rules;
|
|
13449
|
+
var flatData = flatten(data);
|
|
13450
|
+
if (!condition.match.op && flatData[condition.match.field] == condition.match.value) {
|
|
13451
|
+
rules.push.apply(rules, _toConsumableArray(condition.rules));
|
|
13452
|
+
} else if (condition.match.op == 'gt' && flatData[condition.match.field] > condition.match.value) {
|
|
13453
|
+
rules.push.apply(rules, _toConsumableArray(condition.rules));
|
|
13454
|
+
}
|
|
13455
|
+
} else if (item.rules) {
|
|
13456
|
+
rules.push.apply(rules, _toConsumableArray(item.rules));
|
|
13457
|
+
}
|
|
13458
|
+
return rules;
|
|
13459
|
+
}
|
|
13348
13460
|
return _objectSpread$E(_objectSpread$E({}, state), {}, {
|
|
13349
13461
|
setUsedPreset: setUsedPreset,
|
|
13350
13462
|
configuration: configuration,
|
|
@@ -13363,7 +13475,8 @@ function useFormData (_ref) {
|
|
|
13363
13475
|
fieldErrors: fieldErrors,
|
|
13364
13476
|
hiddenRequiredDisabled: hiddenRequiredDisabled,
|
|
13365
13477
|
getData: getData,
|
|
13366
|
-
updateHiddenRequiredDisabled: updateHiddenRequiredDisabled
|
|
13478
|
+
updateHiddenRequiredDisabled: updateHiddenRequiredDisabled,
|
|
13479
|
+
getRules: getRules
|
|
13367
13480
|
});
|
|
13368
13481
|
}
|
|
13369
13482
|
function setFieldInObject(id, data, value) {
|
|
@@ -13403,730 +13516,139 @@ function getData(id, data) {
|
|
|
13403
13516
|
}
|
|
13404
13517
|
}
|
|
13405
13518
|
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
var
|
|
13414
|
-
var
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13519
|
+
var JsonEditor$2 = function JsonEditor(_ref) {
|
|
13520
|
+
var value = _ref.value,
|
|
13521
|
+
_onChange = _ref.onChange,
|
|
13522
|
+
setCanSave = _ref.setCanSave,
|
|
13523
|
+
data = _ref.data,
|
|
13524
|
+
height = _ref.height,
|
|
13525
|
+
savable = _ref.savable;
|
|
13526
|
+
var container = useRef(null);
|
|
13527
|
+
var _useState = useState(0),
|
|
13528
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13529
|
+
counter = _useState2[0],
|
|
13530
|
+
setCounter = _useState2[1];
|
|
13531
|
+
var jsonEditor = useRef(null);
|
|
13532
|
+
var options = {
|
|
13533
|
+
mode: 'code',
|
|
13534
|
+
onChange: function onChange() {
|
|
13535
|
+
try {
|
|
13536
|
+
var e = jsonEditor.current.get();
|
|
13537
|
+
jsonEditor.current.validate();
|
|
13538
|
+
_onChange === null || _onChange === void 0 || _onChange(e);
|
|
13539
|
+
setCanSave(savable);
|
|
13540
|
+
} catch (_unused) {
|
|
13541
|
+
setCanSave(false);
|
|
13542
|
+
return;
|
|
13543
|
+
}
|
|
13421
13544
|
}
|
|
13422
|
-
}
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13545
|
+
};
|
|
13546
|
+
useEffect(function () {
|
|
13547
|
+
jsonEditor.current = new JSONEditor(container.current, options);
|
|
13548
|
+
}, []);
|
|
13549
|
+
useEffect(function () {
|
|
13550
|
+
setCanSave(savable);
|
|
13551
|
+
// antd sets value after initiating once as undefined, the jsoneditor should only be set once with the initial value that gets set by antd
|
|
13552
|
+
if (counter == 2) {
|
|
13553
|
+
return;
|
|
13554
|
+
}
|
|
13555
|
+
if (!value) {
|
|
13556
|
+
jsonEditor.current.set(data !== null && data !== void 0 ? data : {});
|
|
13557
|
+
} else {
|
|
13558
|
+
jsonEditor.current.set(value);
|
|
13559
|
+
}
|
|
13560
|
+
setCounter(counter + 1);
|
|
13561
|
+
}, [value]);
|
|
13562
|
+
return /*#__PURE__*/jsx("div", {
|
|
13563
|
+
ref: container,
|
|
13564
|
+
id: "jsoneditor",
|
|
13565
|
+
style: {
|
|
13566
|
+
height: height !== null && height !== void 0 ? height : 600
|
|
13567
|
+
}
|
|
13568
|
+
});
|
|
13569
|
+
};
|
|
13429
13570
|
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
onChange = _ref.onChange,
|
|
13571
|
+
var FormList$2 = function FormList(_ref) {
|
|
13572
|
+
var _item$initialValue;
|
|
13573
|
+
var value = _ref.value,
|
|
13574
|
+
item = _ref.item,
|
|
13575
|
+
state = _ref.state,
|
|
13576
|
+
data = _ref.data,
|
|
13577
|
+
setCanSave = _ref.setCanSave,
|
|
13438
13578
|
onError = _ref.onError,
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
mode = _ref.mode,
|
|
13443
|
-
allowCreate = _ref.allowCreate,
|
|
13444
|
-
flow = _ref.flow,
|
|
13445
|
-
translationPrefix = _ref.translationPrefix,
|
|
13446
|
-
values = _ref.values,
|
|
13447
|
-
wholeData = _ref.wholeData,
|
|
13448
|
-
disabledConfig = _ref.disabledConfig,
|
|
13449
|
-
hardOptions = _ref.hardOptions,
|
|
13450
|
-
_ref$applyDefaultValu = _ref.applyDefaultValue,
|
|
13451
|
-
applyDefaultValue = _ref$applyDefaultValu === void 0 ? true : _ref$applyDefaultValu,
|
|
13452
|
-
defaultValue = _ref.defaultValue,
|
|
13453
|
-
useFirstValueAsDefault = _ref.useFirstValueAsDefault,
|
|
13454
|
-
canSetToUndefined = _ref.canSetToUndefined;
|
|
13455
|
-
var root = useStore();
|
|
13456
|
-
var _useTranslation = useTranslation$1(),
|
|
13579
|
+
form = _ref.form,
|
|
13580
|
+
root = _ref.root;
|
|
13581
|
+
var _useTranslation = useTranslation(),
|
|
13457
13582
|
t = _useTranslation.t;
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
setOptions(_toConsumableArray(hardOptions.map(function (v) {
|
|
13522
|
-
return {
|
|
13523
|
-
label: v.lable,
|
|
13524
|
-
value: v.value,
|
|
13525
|
-
data: v.data,
|
|
13526
|
-
disabled: v.disabled
|
|
13527
|
-
};
|
|
13528
|
-
})));
|
|
13529
|
-
}
|
|
13530
|
-
}, [wholeData]);
|
|
13531
|
-
useEffect(function () {
|
|
13532
|
-
if (!canSetToUndefined && (selected == undefined || selected.length == 0)) {
|
|
13533
|
-
doSetOptions();
|
|
13534
|
-
}
|
|
13535
|
-
}, [data]);
|
|
13536
|
-
useEffect(function () {
|
|
13537
|
-
if (!(selected !== null && selected !== void 0 && selected.length) && defaultValue && applyDefaultValue !== false) {
|
|
13538
|
-
setSelected([defaultValue]);
|
|
13539
|
-
}
|
|
13540
|
-
}, [defaultValue]);
|
|
13541
|
-
function doSetOptions() {
|
|
13542
|
-
var newData = data !== null && data !== void 0 ? data : defaultValue;
|
|
13543
|
-
if (newData != undefined && (!Array.isArray(newData) || newData.length != 0)) {
|
|
13544
|
-
if (initalValue == undefined) {
|
|
13545
|
-
setInitValue(newData);
|
|
13546
|
-
}
|
|
13547
|
-
var initData = isArray(newData) ? newData : [newData];
|
|
13548
|
-
var value = initData.map(function (d) {
|
|
13549
|
-
var _d$data, _d$_id, _d$selectMapping$valu, _d$data2, _ref2, _d$value, _d$data3;
|
|
13550
|
-
return {
|
|
13551
|
-
label: selectMapping !== null && selectMapping !== void 0 && selectMapping.label ? getCombinedValues((_d$data = d === null || d === void 0 ? void 0 : d.data) !== null && _d$data !== void 0 ? _d$data : d, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label) : _typeof(d) == 'object' ? (_d$_id = d._id) !== null && _d$_id !== void 0 ? _d$_id : d.label : translationPrefix ? t(translationPrefix + '.' + d) : d,
|
|
13552
|
-
value: selectMapping !== null && selectMapping !== void 0 && selectMapping.value ? (_d$selectMapping$valu = d === null || d === void 0 ? void 0 : d[selectMapping.value]) !== null && _d$selectMapping$valu !== void 0 ? _d$selectMapping$valu : d === null || d === void 0 || (_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2[selectMapping.value] : _typeof(d) == 'object' ? (_ref2 = (_d$value = d === null || d === void 0 ? void 0 : d.value) !== null && _d$value !== void 0 ? _d$value : d === null || d === void 0 || (_d$data3 = d.data) === null || _d$data3 === void 0 ? void 0 : _d$data3.value) !== null && _ref2 !== void 0 ? _ref2 : d === null || d === void 0 ? void 0 : d._id : d,
|
|
13553
|
-
data: d,
|
|
13554
|
-
disabled: false
|
|
13555
|
-
};
|
|
13556
|
-
});
|
|
13557
|
-
var val = value.length == 1 ? value[0].data : value;
|
|
13558
|
-
if (Array.isArray(val) && val.length) {
|
|
13559
|
-
val = val.map(function (v) {
|
|
13560
|
-
return v.data;
|
|
13561
|
-
});
|
|
13562
|
-
} else if (Array.isArray(val)) {
|
|
13563
|
-
val = initData;
|
|
13564
|
-
}
|
|
13565
|
-
if (flow && initData.length) {
|
|
13566
|
-
var _value$, _flow$value$0$value, _value$2;
|
|
13567
|
-
if (mode != 'single') {
|
|
13568
|
-
throw new Error('Flow is only implemented for single mode');
|
|
13569
|
-
}
|
|
13570
|
-
var missingFields = verifySelection((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.value);
|
|
13571
|
-
if (missingFields.length) {
|
|
13572
|
-
onError === null || onError === void 0 || onError((missingFields === null || missingFields === void 0 ? void 0 : missingFields.join(', ')) + ' not set or wrong value');
|
|
13573
|
-
return;
|
|
13574
|
-
} else {
|
|
13575
|
-
onError === null || onError === void 0 || onError('');
|
|
13576
|
-
}
|
|
13577
|
-
var flowData = (flow === null || flow === void 0 || (_flow$value$0$value = flow[(_value$2 = value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.value]) === null || _flow$value$0$value === void 0 ? void 0 : _flow$value$0$value.map(function (opt) {
|
|
13578
|
-
return {
|
|
13579
|
-
label: translationPrefix ? t(translationPrefix + '.' + opt) : opt.toString(),
|
|
13580
|
-
value: opt,
|
|
13581
|
-
data: opt
|
|
13582
|
-
};
|
|
13583
|
-
})) || [];
|
|
13584
|
-
var _defaultValue = initalValue !== null && initalValue !== void 0 ? initalValue : data;
|
|
13585
|
-
if (!flowData.find(function (fd) {
|
|
13586
|
-
return fd.value == _defaultValue;
|
|
13587
|
-
})) {
|
|
13588
|
-
flowData.push({
|
|
13589
|
-
label: translationPrefix ? t(translationPrefix + '.' + _defaultValue) : _defaultValue.toString(),
|
|
13590
|
-
value: _defaultValue,
|
|
13591
|
-
data: _defaultValue
|
|
13592
|
-
});
|
|
13593
|
-
}
|
|
13594
|
-
setOptions(_toConsumableArray(flowData));
|
|
13595
|
-
}
|
|
13596
|
-
onChange === null || onChange === void 0 || onChange(val, applyDefaultValue, defaultValue);
|
|
13597
|
-
setSelected(value);
|
|
13598
|
-
}
|
|
13599
|
-
}
|
|
13600
|
-
var loadOptions = /*#__PURE__*/function () {
|
|
13601
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
13602
|
-
var fetchId, newOptions, serverSideParams;
|
|
13603
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13604
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13605
|
-
case 0:
|
|
13606
|
-
fetchRef.current += 1;
|
|
13607
|
-
fetchId = fetchRef.current;
|
|
13608
|
-
if (!filterServerSide) {
|
|
13609
|
-
_context.next = 10;
|
|
13610
|
-
break;
|
|
13611
|
-
}
|
|
13612
|
-
setFetching(true);
|
|
13613
|
-
serverSideParams = {
|
|
13614
|
-
filters: selectMapping !== null && selectMapping !== void 0 && selectMapping.searchField ? selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.searchField.reduce(function (filter, field) {
|
|
13615
|
-
return _objectSpread$D(_objectSpread$D({}, filter), value !== undefined ? _defineProperty({}, field.field, [value, field.filter, true]) : {});
|
|
13616
|
-
}, {}) : {
|
|
13617
|
-
_id: [value, 'contains']
|
|
13618
|
-
},
|
|
13619
|
-
pagination: {
|
|
13620
|
-
pageSize: 100
|
|
13621
|
-
}
|
|
13622
|
-
};
|
|
13623
|
-
_context.next = 7;
|
|
13624
|
-
return apiHandler.readList(selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.prefilterMapping, wholeData, serverSideParams, undefined, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.prefilter).then(function (body) {
|
|
13625
|
-
return (body === null || body === void 0 ? void 0 : body.data.map(function (data) {
|
|
13626
|
-
return {
|
|
13627
|
-
label: selectMapping !== null && selectMapping !== void 0 && selectMapping.label ? getCombinedValues(data, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label) : data._id,
|
|
13628
|
-
value: selectMapping !== null && selectMapping !== void 0 && selectMapping.value ? data[selectMapping.value] : data._id,
|
|
13629
|
-
disabled: false,
|
|
13630
|
-
data: data
|
|
13631
|
-
};
|
|
13632
|
-
})) || [];
|
|
13633
|
-
});
|
|
13634
|
-
case 7:
|
|
13635
|
-
newOptions = _context.sent;
|
|
13636
|
-
_context.next = 12;
|
|
13637
|
-
break;
|
|
13638
|
-
case 10:
|
|
13639
|
-
newOptions = initOptions.filter(function (opt) {
|
|
13640
|
-
var _value$toLocaleLowerC;
|
|
13641
|
-
return opt.label.toLocaleLowerCase().includes((_value$toLocaleLowerC = value === null || value === void 0 ? void 0 : value.toLocaleLowerCase()) !== null && _value$toLocaleLowerC !== void 0 ? _value$toLocaleLowerC : '');
|
|
13642
|
-
});
|
|
13643
|
-
if (allowCreate && !newOptions.length) {
|
|
13644
|
-
newOptions = [{
|
|
13645
|
-
data: value,
|
|
13646
|
-
label: value,
|
|
13647
|
-
disabled: false,
|
|
13648
|
-
value: value
|
|
13649
|
-
}];
|
|
13650
|
-
}
|
|
13651
|
-
case 12:
|
|
13652
|
-
if (!(fetchId !== fetchRef.current)) {
|
|
13653
|
-
_context.next = 14;
|
|
13654
|
-
break;
|
|
13655
|
-
}
|
|
13656
|
-
return _context.abrupt("return");
|
|
13657
|
-
case 14:
|
|
13658
|
-
setOptions(newOptions);
|
|
13659
|
-
setFetching(false);
|
|
13660
|
-
case 16:
|
|
13661
|
-
case "end":
|
|
13662
|
-
return _context.stop();
|
|
13663
|
-
}
|
|
13664
|
-
}, _callee);
|
|
13665
|
-
}));
|
|
13666
|
-
return function loadOptions(_x) {
|
|
13667
|
-
return _ref3.apply(this, arguments);
|
|
13668
|
-
};
|
|
13669
|
-
}();
|
|
13670
|
-
var fetch = React.useMemo(function () {
|
|
13671
|
-
return debounce(loadOptions, 800);
|
|
13672
|
-
}, [selectMapping, initOptions, wholeData]);
|
|
13673
|
-
var verifySelection = function verifySelection(opt) {
|
|
13674
|
-
if (disabledConfig == undefined) return [];
|
|
13675
|
-
var _missingFields = [];
|
|
13676
|
-
var _iterator = _createForOfIteratorHelper$h(disabledConfig),
|
|
13677
|
-
_step;
|
|
13678
|
-
try {
|
|
13679
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13680
|
-
var disabled = _step.value;
|
|
13681
|
-
if (opt == (disabled === null || disabled === void 0 ? void 0 : disabled.value) && wholeData[disabled.onField.field] == disabled.onField.value) {
|
|
13682
|
-
if (!disabled.requiredFields) {
|
|
13683
|
-
return ['Job HQ', 'Job AR'];
|
|
13684
|
-
}
|
|
13685
|
-
disabled.requiredFields.forEach(function (fd) {
|
|
13686
|
-
if (typeof fd === 'string' && (wholeData[fd] === '' || wholeData[fd] === undefined)) {
|
|
13687
|
-
_missingFields.push(fd);
|
|
13688
|
-
} else if (_typeof(fd) == 'object') {
|
|
13689
|
-
if (!fd.value.some(function (v) {
|
|
13690
|
-
return v == wholeData[fd.field];
|
|
13691
|
-
})) {
|
|
13692
|
-
_missingFields.push(fd.field);
|
|
13693
|
-
}
|
|
13694
|
-
}
|
|
13695
|
-
});
|
|
13696
|
-
return _missingFields;
|
|
13697
|
-
}
|
|
13698
|
-
}
|
|
13699
|
-
} catch (err) {
|
|
13700
|
-
_iterator.e(err);
|
|
13701
|
-
} finally {
|
|
13702
|
-
_iterator.f();
|
|
13703
|
-
}
|
|
13704
|
-
return [];
|
|
13705
|
-
};
|
|
13706
|
-
|
|
13707
|
-
//state.configuration.dependencyRule.
|
|
13708
|
-
var onSelect = function onSelect(data) {
|
|
13709
|
-
//! tags works without labelInValue; data = string; get's converted to option afterwards in useeffect
|
|
13710
|
-
//because of a error in the typedefinition we have to cast it here
|
|
13711
|
-
var newSelected = data;
|
|
13712
|
-
var sel = selected;
|
|
13713
|
-
var option = options.find(function (o) {
|
|
13714
|
-
return o.value == newSelected.value;
|
|
13715
|
-
});
|
|
13716
|
-
if (option) {
|
|
13717
|
-
if (mode == 'tags') {
|
|
13718
|
-
throw new Error('select with options is not yet supported for mode tags');
|
|
13719
|
-
}
|
|
13720
|
-
if (mode == 'single') {
|
|
13721
|
-
var _option$data;
|
|
13722
|
-
if (flow) {
|
|
13723
|
-
var _flow$option$value;
|
|
13724
|
-
var missingFields = verifySelection(option.value);
|
|
13725
|
-
if (missingFields.length) {
|
|
13726
|
-
onError === null || onError === void 0 || onError((missingFields === null || missingFields === void 0 ? void 0 : missingFields.join(', ')) + ' not set or wrong value');
|
|
13727
|
-
return;
|
|
13728
|
-
} else {
|
|
13729
|
-
onError === null || onError === void 0 || onError('');
|
|
13730
|
-
}
|
|
13731
|
-
var flowData = (flow === null || flow === void 0 || (_flow$option$value = flow[option.value]) === null || _flow$option$value === void 0 ? void 0 : _flow$option$value.map(function (opt) {
|
|
13732
|
-
return {
|
|
13733
|
-
label: translationPrefix ? t(translationPrefix + '.' + opt) : opt.toString(),
|
|
13734
|
-
value: opt,
|
|
13735
|
-
data: opt
|
|
13736
|
-
};
|
|
13737
|
-
})) || [];
|
|
13738
|
-
var _defaultValue2 = initalValue !== null && initalValue !== void 0 ? initalValue : data;
|
|
13739
|
-
if (!flowData.find(function (fd) {
|
|
13740
|
-
return fd.value == _defaultValue2;
|
|
13741
|
-
})) {
|
|
13742
|
-
flowData.push({
|
|
13743
|
-
label: translationPrefix ? t(translationPrefix + '.' + _defaultValue2) : _defaultValue2.toString(),
|
|
13744
|
-
value: _defaultValue2,
|
|
13745
|
-
data: _defaultValue2
|
|
13746
|
-
});
|
|
13747
|
-
}
|
|
13748
|
-
setOptions(_toConsumableArray(flowData));
|
|
13749
|
-
}
|
|
13750
|
-
//if it is single mode there can always only be one selected or one new entry
|
|
13751
|
-
onChange === null || onChange === void 0 || onChange((_option$data = option === null || option === void 0 ? void 0 : option.data) !== null && _option$data !== void 0 ? _option$data : option, applyDefaultValue, defaultValue);
|
|
13752
|
-
setSelected([option]);
|
|
13753
|
-
} else {
|
|
13754
|
-
var selectedList = [].concat(_toConsumableArray(sel), [option]);
|
|
13755
|
-
setSelected(selectedList);
|
|
13756
|
-
onChange === null || onChange === void 0 || onChange(selectedList.map(function (s) {
|
|
13757
|
-
return s.data;
|
|
13758
|
-
}), applyDefaultValue, defaultValue);
|
|
13759
|
-
}
|
|
13760
|
-
} else {
|
|
13761
|
-
if (mode == 'tags' && typeof data === 'string') {
|
|
13762
|
-
onChange === null || onChange === void 0 || onChange([].concat(_toConsumableArray(sel.map(function (s) {
|
|
13763
|
-
return s.data;
|
|
13764
|
-
})), [data]), applyDefaultValue, defaultValue);
|
|
13765
|
-
setSelected([].concat(_toConsumableArray(sel), [data]));
|
|
13766
|
-
} else {
|
|
13767
|
-
throw new Error('select without options is not yet supported for modes other than tags');
|
|
13768
|
-
}
|
|
13769
|
-
}
|
|
13770
|
-
};
|
|
13771
|
-
|
|
13772
|
-
// if useFirstValueAsDefault is true we load the options and trigger an update with setGettingDefaultValue
|
|
13773
|
-
// at the 2. useEffect the options are loaded and set in state so we can set the first option
|
|
13774
|
-
useEffect(function () {
|
|
13775
|
-
if (useFirstValueAsDefault && !selected.length) {
|
|
13776
|
-
loadOptions(undefined).then(function () {
|
|
13777
|
-
return setGettingDefaultValue(true);
|
|
13778
|
-
});
|
|
13779
|
-
}
|
|
13780
|
-
}, []);
|
|
13781
|
-
useEffect(function () {
|
|
13782
|
-
if (gettingDefaultValue) onSelect(options[0]);
|
|
13783
|
-
}, [gettingDefaultValue]);
|
|
13784
|
-
var onFocus = function onFocus() {
|
|
13785
|
-
loadOptions(undefined);
|
|
13786
|
-
};
|
|
13787
|
-
var onRemove = function onRemove(data) {
|
|
13788
|
-
//because of a error in the typedefinition we have to cast it here
|
|
13789
|
-
var removed = data;
|
|
13790
|
-
var sel = selected;
|
|
13791
|
-
var newSelected;
|
|
13792
|
-
if (removed) {
|
|
13793
|
-
var index = sel.findIndex(function (s) {
|
|
13794
|
-
return s.value == removed.value;
|
|
13795
|
-
});
|
|
13796
|
-
newSelected = _toConsumableArray(sel);
|
|
13797
|
-
newSelected.splice(index, 1);
|
|
13798
|
-
} else {
|
|
13799
|
-
newSelected = [];
|
|
13800
|
-
}
|
|
13801
|
-
setSelected(newSelected);
|
|
13802
|
-
if (mode == 'single') {
|
|
13803
|
-
onChange === null || onChange === void 0 || onChange(undefined, applyDefaultValue, defaultValue);
|
|
13804
|
-
} else {
|
|
13805
|
-
onChange === null || onChange === void 0 || onChange(newSelected.map(function (s) {
|
|
13806
|
-
return s.data;
|
|
13807
|
-
}), applyDefaultValue, defaultValue);
|
|
13808
|
-
}
|
|
13809
|
-
};
|
|
13810
|
-
return {
|
|
13811
|
-
fetching: fetching,
|
|
13812
|
-
options: options,
|
|
13813
|
-
selected: selected,
|
|
13814
|
-
fetch: fetch,
|
|
13815
|
-
onRemove: onRemove,
|
|
13816
|
-
onFocus: onFocus,
|
|
13817
|
-
onSelect: onSelect
|
|
13818
|
-
};
|
|
13819
|
-
}
|
|
13820
|
-
|
|
13821
|
-
var css_248z$m = ".darkmode .ant-select-selection-search-input {\n color: #fff;\n}\n";
|
|
13822
|
-
styleInject(css_248z$m);
|
|
13823
|
-
|
|
13824
|
-
var SelectWrapper$1 = function SelectWrapper(_ref) {
|
|
13825
|
-
var onChange = _ref.onChange,
|
|
13826
|
-
onError = _ref.onError,
|
|
13827
|
-
value = _ref.value,
|
|
13828
|
-
apiInterface = _ref.apiInterface,
|
|
13829
|
-
selectMapping = _ref.selectMapping,
|
|
13830
|
-
mapping = _ref.mapping,
|
|
13831
|
-
mode = _ref.mode,
|
|
13832
|
-
initialValue = _ref.initialValue,
|
|
13833
|
-
minWidth = _ref.minWidth,
|
|
13834
|
-
allowCreate = _ref.allowCreate,
|
|
13835
|
-
allowClear = _ref.allowClear,
|
|
13836
|
-
search = _ref.search,
|
|
13837
|
-
flow = _ref.flow,
|
|
13838
|
-
translationPrefix = _ref.translationPrefix,
|
|
13839
|
-
values = _ref.values,
|
|
13840
|
-
disabled = _ref.disabled,
|
|
13841
|
-
wholeData = _ref.wholeData,
|
|
13842
|
-
disabledConfig = _ref.disabledConfig,
|
|
13843
|
-
placeholder = _ref.placeholder,
|
|
13844
|
-
options = _ref.options,
|
|
13845
|
-
applyDefaultValue = _ref.applyDefaultValue,
|
|
13846
|
-
useFirstValueAsDefault = _ref.useFirstValueAsDefault,
|
|
13847
|
-
canSetToUndefined = _ref.canSetToUndefined;
|
|
13848
|
-
var state = useSelectData({
|
|
13849
|
-
onChange: onChange,
|
|
13850
|
-
onError: onError,
|
|
13851
|
-
data: value,
|
|
13852
|
-
apiInterface: apiInterface,
|
|
13853
|
-
selectMapping: selectMapping,
|
|
13854
|
-
mapping: mapping,
|
|
13855
|
-
mode: mode,
|
|
13856
|
-
allowCreate: allowCreate,
|
|
13857
|
-
defaultValue: initialValue,
|
|
13858
|
-
flow: flow,
|
|
13859
|
-
translationPrefix: translationPrefix,
|
|
13860
|
-
values: values,
|
|
13861
|
-
wholeData: wholeData,
|
|
13862
|
-
disabledConfig: disabledConfig,
|
|
13863
|
-
hardOptions: options,
|
|
13864
|
-
applyDefaultValue: applyDefaultValue,
|
|
13865
|
-
useFirstValueAsDefault: useFirstValueAsDefault,
|
|
13866
|
-
canSetToUndefined: canSetToUndefined
|
|
13867
|
-
});
|
|
13868
|
-
var _useTranslation = useTranslation$1(),
|
|
13869
|
-
t = _useTranslation.t;
|
|
13870
|
-
var filterServerSide = _typeof(apiInterface) == 'object' && _typeof(apiInterface.read) == 'object' && apiInterface.read.filterServerSide;
|
|
13871
|
-
var selected = state.selected;
|
|
13872
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
13873
|
-
children: /*#__PURE__*/jsx(Select$1, {
|
|
13874
|
-
labelInValue: mode === 'tags' ? false : true,
|
|
13875
|
-
style: {
|
|
13876
|
-
width: '100%',
|
|
13877
|
-
minWidth: minWidth
|
|
13878
|
-
},
|
|
13879
|
-
filterOption: false,
|
|
13880
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('filter.global'),
|
|
13881
|
-
allowClear: allowClear !== null && allowClear !== void 0 ? allowClear : filterServerSide,
|
|
13882
|
-
showArrow: !filterServerSide || allowCreate || search,
|
|
13883
|
-
mode: mode == 'single' ? undefined : mode,
|
|
13884
|
-
showSearch: filterServerSide || allowCreate || search,
|
|
13885
|
-
onSearch: filterServerSide || allowCreate || search ? state.fetch : undefined,
|
|
13886
|
-
notFoundContent: state.fetching ? /*#__PURE__*/jsx(Spin, {
|
|
13887
|
-
size: "small"
|
|
13888
|
-
}) : null,
|
|
13889
|
-
options: state.options,
|
|
13890
|
-
onSelect: state.onSelect,
|
|
13891
|
-
disabled: disabled,
|
|
13892
|
-
onDeselect: state.onRemove,
|
|
13893
|
-
onFocus: filterServerSide || allowCreate || search ? state.onFocus : undefined,
|
|
13894
|
-
onClear: state.onRemove,
|
|
13895
|
-
value: selected
|
|
13896
|
-
})
|
|
13897
|
-
});
|
|
13898
|
-
};
|
|
13899
|
-
var Select = observer(SelectWrapper$1, {
|
|
13900
|
-
forwardRef: true
|
|
13901
|
-
});
|
|
13902
|
-
|
|
13903
|
-
function ownKeys$C(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13904
|
-
function _objectSpread$C(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$C(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$C(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13905
|
-
function _createForOfIteratorHelper$g(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$g(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13906
|
-
function _unsupportedIterableToArray$g(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$g(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$g(r, a) : void 0; } }
|
|
13907
|
-
function _arrayLikeToArray$g(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13908
|
-
var Presets = function Presets(_ref) {
|
|
13909
|
-
var state = _ref.state,
|
|
13910
|
-
apiHandler = _ref.apiHandler,
|
|
13911
|
-
form = _ref.form,
|
|
13912
|
-
root = _ref.root,
|
|
13913
|
-
setUsedPreset = _ref.setUsedPreset,
|
|
13914
|
-
presets = _ref.presets,
|
|
13915
|
-
setPresets = _ref.setPresets;
|
|
13916
|
-
var Option = Select$1.Option;
|
|
13917
|
-
var _useState = useState(false),
|
|
13918
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
13919
|
-
isModalVisible = _useState2[0],
|
|
13920
|
-
setIsModalVisible = _useState2[1];
|
|
13921
|
-
var _useState3 = useState(''),
|
|
13922
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
13923
|
-
newPresetName = _useState4[0],
|
|
13924
|
-
setNewPresetName = _useState4[1];
|
|
13925
|
-
var _useState5 = useState(),
|
|
13926
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
13927
|
-
value = _useState6[0],
|
|
13928
|
-
setValue = _useState6[1];
|
|
13929
|
-
var _useState7 = useState([]),
|
|
13930
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
13931
|
-
presetIds = _useState8[0],
|
|
13932
|
-
setPresetIds = _useState8[1];
|
|
13933
|
-
var _useTranslation = useTranslation$1(),
|
|
13934
|
-
t = _useTranslation.t;
|
|
13935
|
-
useEffect(function () {
|
|
13936
|
-
getPresets();
|
|
13937
|
-
}, []);
|
|
13938
|
-
var savePreset = function savePreset() {
|
|
13939
|
-
if (state.selectedItems == undefined) return;
|
|
13940
|
-
setIsModalVisible(false);
|
|
13941
|
-
var names = [];
|
|
13942
|
-
var _iterator = _createForOfIteratorHelper$g(state.selectedItems),
|
|
13943
|
-
_step;
|
|
13944
|
-
try {
|
|
13945
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13946
|
-
var item = _step.value;
|
|
13947
|
-
names.push(item.name);
|
|
13948
|
-
}
|
|
13949
|
-
} catch (err) {
|
|
13950
|
-
_iterator.e(err);
|
|
13951
|
-
} finally {
|
|
13952
|
-
_iterator.f();
|
|
13953
|
-
}
|
|
13954
|
-
var data = _objectSpread$C(_objectSpread$C({}, form.getFieldsValue(names)), {}, {
|
|
13955
|
-
newPresetName: newPresetName
|
|
13956
|
-
});
|
|
13957
|
-
data.dpi = parseInt(data.dpi);
|
|
13958
|
-
data.organization = root.getGlobalValue('organizationId');
|
|
13959
|
-
apiHandler.create({}, state.configuration.createPresetMapping, data);
|
|
13960
|
-
var dt = _objectSpread$C(_objectSpread$C({}, form.getFieldsValue(names)), {}, {
|
|
13961
|
-
name: newPresetName
|
|
13962
|
-
});
|
|
13963
|
-
setPresets({
|
|
13964
|
-
data: [dt].concat(_toConsumableArray(presets.data)),
|
|
13965
|
-
total: presets.total
|
|
13966
|
-
});
|
|
13967
|
-
};
|
|
13968
|
-
var getPresets = /*#__PURE__*/function () {
|
|
13969
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
13970
|
-
var res, ids, preset;
|
|
13971
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13972
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13973
|
-
case 0:
|
|
13974
|
-
_context.next = 2;
|
|
13975
|
-
return apiHandler.readList();
|
|
13976
|
-
case 2:
|
|
13977
|
-
res = _context.sent;
|
|
13978
|
-
ids = [];
|
|
13979
|
-
for (preset in res.data) {
|
|
13980
|
-
ids.push(res.data[preset]._id);
|
|
13981
|
-
delete res.data[preset]._id;
|
|
13982
|
-
}
|
|
13983
|
-
setPresetIds(ids);
|
|
13984
|
-
setPresets(res);
|
|
13985
|
-
case 7:
|
|
13986
|
-
case "end":
|
|
13987
|
-
return _context.stop();
|
|
13988
|
-
}
|
|
13989
|
-
}, _callee);
|
|
13990
|
-
}));
|
|
13991
|
-
return function getPresets() {
|
|
13992
|
-
return _ref2.apply(this, arguments);
|
|
13993
|
-
};
|
|
13994
|
-
}();
|
|
13995
|
-
var onPresetSelect = function onPresetSelect(index) {
|
|
13996
|
-
var preset = presets.data[index];
|
|
13997
|
-
if (!state.selectedItems) return;
|
|
13998
|
-
state.selectedItems.map(function (item) {
|
|
13999
|
-
if (isReadonly(item, form.getFieldsValue())) {
|
|
14000
|
-
delete preset[item.name];
|
|
14001
|
-
}
|
|
14002
|
-
});
|
|
14003
|
-
form.setFieldsValue(presets.data[index]);
|
|
14004
|
-
setUsedPreset({
|
|
14005
|
-
used: true,
|
|
14006
|
-
index: index
|
|
14007
|
-
});
|
|
14008
|
-
};
|
|
14009
|
-
var deletePreset = function deletePreset(index) {
|
|
14010
|
-
apiHandler["delete"](presetIds[index]);
|
|
14011
|
-
var data = presets.data;
|
|
14012
|
-
data.splice(index, 1);
|
|
14013
|
-
setPresets({
|
|
14014
|
-
data: data,
|
|
14015
|
-
total: presets.total
|
|
14016
|
-
});
|
|
14017
|
-
setValue(undefined);
|
|
14018
|
-
};
|
|
14019
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
14020
|
-
children: [/*#__PURE__*/jsx(Select$1, {
|
|
14021
|
-
showSearch: true,
|
|
14022
|
-
value: value,
|
|
14023
|
-
placeholder: t('backoffice.form.presets.placeholder'),
|
|
14024
|
-
optionFilterProp: "children",
|
|
14025
|
-
style: {
|
|
14026
|
-
width: '94%',
|
|
14027
|
-
paddingLeft: 0,
|
|
14028
|
-
marginBottom: 30
|
|
14029
|
-
},
|
|
14030
|
-
onChange: function onChange(index) {
|
|
14031
|
-
setValue(index);
|
|
14032
|
-
onPresetSelect(index);
|
|
14033
|
-
},
|
|
14034
|
-
children: presets === null || presets === void 0 ? void 0 : presets.data.map(function (dt, idx) {
|
|
14035
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
14036
|
-
children: /*#__PURE__*/jsxs(Option, {
|
|
14037
|
-
value: idx,
|
|
14038
|
-
children: [dt.name, /*#__PURE__*/jsx(Button, {
|
|
14039
|
-
icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
|
|
14040
|
-
style: {
|
|
14041
|
-
"float": 'right'
|
|
14042
|
-
},
|
|
14043
|
-
onClick: function onClick() {
|
|
14044
|
-
return deletePreset(idx);
|
|
14045
|
-
}
|
|
14046
|
-
})]
|
|
14047
|
-
}, idx)
|
|
14048
|
-
});
|
|
14049
|
-
})
|
|
14050
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
14051
|
-
type: "primary",
|
|
14052
|
-
onClick: function onClick() {
|
|
14053
|
-
return setIsModalVisible(true);
|
|
14054
|
-
},
|
|
14055
|
-
children: "Create"
|
|
14056
|
-
}), /*#__PURE__*/jsx(Modal$2, {
|
|
14057
|
-
title: "Create Preset",
|
|
14058
|
-
visible: isModalVisible,
|
|
14059
|
-
onOk: function onOk(e) {
|
|
14060
|
-
return savePreset();
|
|
14061
|
-
},
|
|
14062
|
-
onCancel: function onCancel() {
|
|
14063
|
-
return setIsModalVisible(false);
|
|
14064
|
-
},
|
|
14065
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
14066
|
-
value: newPresetName,
|
|
14067
|
-
placeholder: "Preset Name",
|
|
14068
|
-
onChange: function onChange(e) {
|
|
14069
|
-
setNewPresetName(e.target.value);
|
|
14070
|
-
},
|
|
14071
|
-
style: {
|
|
14072
|
-
marginBottom: 15
|
|
14073
|
-
}
|
|
14074
|
-
})
|
|
14075
|
-
})]
|
|
14076
|
-
});
|
|
14077
|
-
};
|
|
14078
|
-
|
|
14079
|
-
var JsonEditor$2 = function JsonEditor(_ref) {
|
|
14080
|
-
var value = _ref.value,
|
|
14081
|
-
_onChange = _ref.onChange,
|
|
14082
|
-
setCanSave = _ref.setCanSave,
|
|
14083
|
-
data = _ref.data,
|
|
14084
|
-
height = _ref.height,
|
|
14085
|
-
savable = _ref.savable;
|
|
14086
|
-
var container = useRef(null);
|
|
14087
|
-
var _useState = useState(0),
|
|
14088
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
14089
|
-
counter = _useState2[0],
|
|
14090
|
-
setCounter = _useState2[1];
|
|
14091
|
-
var jsonEditor = useRef(null);
|
|
14092
|
-
var options = {
|
|
14093
|
-
mode: 'code',
|
|
14094
|
-
onChange: function onChange() {
|
|
14095
|
-
try {
|
|
14096
|
-
var e = jsonEditor.current.get();
|
|
14097
|
-
jsonEditor.current.validate();
|
|
14098
|
-
_onChange === null || _onChange === void 0 || _onChange(e);
|
|
14099
|
-
setCanSave(savable);
|
|
14100
|
-
} catch (_unused) {
|
|
14101
|
-
setCanSave(false);
|
|
14102
|
-
return;
|
|
14103
|
-
}
|
|
14104
|
-
}
|
|
14105
|
-
};
|
|
14106
|
-
useEffect(function () {
|
|
14107
|
-
jsonEditor.current = new JSONEditor(container.current, options);
|
|
14108
|
-
}, []);
|
|
14109
|
-
useEffect(function () {
|
|
14110
|
-
setCanSave(savable);
|
|
14111
|
-
// antd sets value after initiating once as undefined, the jsoneditor should only be set once with the initial value that gets set by antd
|
|
14112
|
-
if (counter == 2) {
|
|
14113
|
-
return;
|
|
14114
|
-
}
|
|
14115
|
-
if (!value) {
|
|
14116
|
-
jsonEditor.current.set(data !== null && data !== void 0 ? data : {});
|
|
14117
|
-
} else {
|
|
14118
|
-
jsonEditor.current.set(value);
|
|
14119
|
-
}
|
|
14120
|
-
setCounter(counter + 1);
|
|
14121
|
-
}, [value]);
|
|
14122
|
-
return /*#__PURE__*/jsx("div", {
|
|
14123
|
-
ref: container,
|
|
14124
|
-
id: "jsoneditor",
|
|
14125
|
-
style: {
|
|
14126
|
-
height: height !== null && height !== void 0 ? height : 600
|
|
13583
|
+
return /*#__PURE__*/jsx(Form$1.List, {
|
|
13584
|
+
name: item.name,
|
|
13585
|
+
initialValue: (_item$initialValue = item.initialValue) !== null && _item$initialValue !== void 0 ? _item$initialValue : value,
|
|
13586
|
+
children: function children(fields, _ref2) {
|
|
13587
|
+
var add = _ref2.add,
|
|
13588
|
+
remove = _ref2.remove;
|
|
13589
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
13590
|
+
children: [fields.map(function (field, idx) {
|
|
13591
|
+
return /*#__PURE__*/jsxs("div", {
|
|
13592
|
+
id: field.key.toString(),
|
|
13593
|
+
style: {
|
|
13594
|
+
display: 'flex'
|
|
13595
|
+
},
|
|
13596
|
+
children: [!item.disablePushOrPop && /*#__PURE__*/jsx(MinusCircleOutlined, {
|
|
13597
|
+
onClick: function onClick() {
|
|
13598
|
+
return remove(field.name);
|
|
13599
|
+
}
|
|
13600
|
+
}), /*#__PURE__*/jsx("div", {
|
|
13601
|
+
style: {
|
|
13602
|
+
flexGrow: 1
|
|
13603
|
+
},
|
|
13604
|
+
children: item.items.map(function (i, idx) {
|
|
13605
|
+
var _state$hiddenRequired;
|
|
13606
|
+
var n = [field.name].concat(_toConsumableArray(Array.isArray(i.name) ? i.name : [i.name]));
|
|
13607
|
+
var hidden = !!i.hidden;
|
|
13608
|
+
if (i.hidden && data) {
|
|
13609
|
+
if (typeof i.hidden === 'function') {
|
|
13610
|
+
var _data;
|
|
13611
|
+
if ((_data = data[item.name]) !== null && _data !== void 0 && _data[n[0]]) {
|
|
13612
|
+
hidden = i.hidden(data[item.name][n[0]]);
|
|
13613
|
+
} else hidden = false;
|
|
13614
|
+
}
|
|
13615
|
+
}
|
|
13616
|
+
if (!hidden) hidden = (_state$hiddenRequired = state.hiddenRequiredDisabled[typeof n == 'string' ? n : n.join('.')]) === null || _state$hiddenRequired === void 0 ? void 0 : _state$hiddenRequired.hidden;
|
|
13617
|
+
var pathName = [].concat(_toConsumableArray(Array.isArray(item.name) ? item.name : [item.name]), _toConsumableArray(Array.isArray(n) ? n : [n]));
|
|
13618
|
+
return /*#__PURE__*/jsx(Form$1.Item, {
|
|
13619
|
+
id: idx.toString(),
|
|
13620
|
+
name: n,
|
|
13621
|
+
rules: state.getRules(i, state.data),
|
|
13622
|
+
label: getLabel(i, t),
|
|
13623
|
+
valuePropName: i.type == 'checkbox' ? 'checked' : 'value',
|
|
13624
|
+
initialValue: i === null || i === void 0 ? void 0 : i.defaultValue,
|
|
13625
|
+
hasFeedback: !!state.fieldErrors[n.toString()],
|
|
13626
|
+
validateStatus: !!state.fieldErrors[n.toString()] ? 'error' : undefined,
|
|
13627
|
+
help: state.fieldErrors[n.toString()],
|
|
13628
|
+
hidden: hidden,
|
|
13629
|
+
children: getElement(i, state.data, setCanSave, state, state.onInputChanged, onError, root, form, hidden, pathName)
|
|
13630
|
+
}, idx);
|
|
13631
|
+
})
|
|
13632
|
+
})]
|
|
13633
|
+
}, field.key);
|
|
13634
|
+
}), !item.disablePushOrPop && /*#__PURE__*/jsx(Form$1.Item, {
|
|
13635
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
13636
|
+
type: "dashed",
|
|
13637
|
+
onClick: function onClick() {
|
|
13638
|
+
return add();
|
|
13639
|
+
},
|
|
13640
|
+
block: true,
|
|
13641
|
+
icon: /*#__PURE__*/jsx(PlusOutlined, {}),
|
|
13642
|
+
children: t('backoffice.add_field')
|
|
13643
|
+
})
|
|
13644
|
+
})]
|
|
13645
|
+
});
|
|
14127
13646
|
}
|
|
14128
13647
|
});
|
|
14129
13648
|
};
|
|
13649
|
+
var FormList$3 = observer(FormList$2, {
|
|
13650
|
+
forwardRef: true
|
|
13651
|
+
});
|
|
14130
13652
|
|
|
14131
13653
|
var ApiKey = function ApiKey(_ref) {
|
|
14132
13654
|
var value = _ref.value,
|
|
@@ -14270,8 +13792,8 @@ var Result = function Result(_ref) {
|
|
|
14270
13792
|
|
|
14271
13793
|
var success = "success-tRJ7j";
|
|
14272
13794
|
var error = "error-MtAFB";
|
|
14273
|
-
var css_248z$
|
|
14274
|
-
styleInject(css_248z$
|
|
13795
|
+
var css_248z$m = ".success-tRJ7j {\n color: #fff !important;\n background-color: #449d44 !important;\n border-color: #398439 !important;\n}\n\n.error-MtAFB {\n color: #fff !important;\n background-color: #c9302c !important;\n border-color: #ac2925 !important;\n}\n";
|
|
13796
|
+
styleInject(css_248z$m);
|
|
14275
13797
|
|
|
14276
13798
|
var azureIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2048%22%20width%3D%2248px%22%20height%3D%2248px%22%3E%20%3ClinearGradient%20id%3D%22k8yl7~hDat~FaoWq8WjN6a%22%20x1%3D%22-1254.397%22%20x2%3D%22-1261.911%22%20y1%3D%22877.268%22%20y2%3D%22899.466%22%20gradientTransform%3D%22translate%281981.75%20-1362.063%29%20scale%281.5625%29%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%20%20%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23114a8b%22%2F%3E%20%20%3Cstop%20offset%3D%221%22%20stop-color%3D%22%230669bc%22%2F%3E%20%3C%2FlinearGradient%3E%20%3Cpath%20fill%3D%22url%28%23k8yl7~hDat~FaoWq8WjN6a%29%22%20d%3D%22M17.634%2C6h11.305L17.203%2C40.773c-0.247%2C0.733-0.934%2C1.226-1.708%2C1.226H6.697%20c-0.994%2C0-1.8-0.806-1.8-1.8c0-0.196%2C0.032-0.39%2C0.094-0.576L15.926%2C7.227C16.173%2C6.494%2C16.86%2C6%2C17.634%2C6L17.634%2C6z%22%2F%3E%20%3Cpath%20fill%3D%22%230078d4%22%20d%3D%22M34.062%2C29.324H16.135c-0.458-0.001-0.83%2C0.371-0.831%2C0.829c0%2C0.231%2C0.095%2C0.451%2C0.264%2C0.608%20l11.52%2C10.752C27.423%2C41.826%2C27.865%2C42%2C28.324%2C42h10.151L34.062%2C29.324z%22%2F%3E%20%3ClinearGradient%20id%3D%22k8yl7~hDat~FaoWq8WjN6b%22%20x1%3D%22-1252.05%22%20x2%3D%22-1253.788%22%20y1%3D%22887.612%22%20y2%3D%22888.2%22%20gradientTransform%3D%22translate%281981.75%20-1362.063%29%20scale%281.5625%29%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%20%20%3Cstop%20offset%3D%220%22%20stop-opacity%3D%22.3%22%2F%3E%20%20%3Cstop%20offset%3D%22.071%22%20stop-opacity%3D%22.2%22%2F%3E%20%20%3Cstop%20offset%3D%22.321%22%20stop-opacity%3D%22.1%22%2F%3E%20%20%3Cstop%20offset%3D%22.623%22%20stop-opacity%3D%22.05%22%2F%3E%20%20%3Cstop%20offset%3D%221%22%20stop-opacity%3D%220%22%2F%3E%20%3C%2FlinearGradient%3E%20%3Cpath%20fill%3D%22url%28%23k8yl7~hDat~FaoWq8WjN6b%29%22%20d%3D%22M17.634%2C6c-0.783-0.003-1.476%2C0.504-1.712%2C1.25L5.005%2C39.595%20c-0.335%2C0.934%2C0.151%2C1.964%2C1.085%2C2.299C6.286%2C41.964%2C6.493%2C42%2C6.702%2C42h9.026c0.684-0.122%2C1.25-0.603%2C1.481-1.259l2.177-6.416%20l7.776%2C7.253c0.326%2C0.27%2C0.735%2C0.419%2C1.158%2C0.422h10.114l-4.436-12.676l-12.931%2C0.003L28.98%2C6H17.634z%22%2F%3E%20%3ClinearGradient%20id%3D%22k8yl7~hDat~FaoWq8WjN6c%22%20x1%3D%22-1252.952%22%20x2%3D%22-1244.704%22%20y1%3D%22876.6%22%20y2%3D%22898.575%22%20gradientTransform%3D%22translate%281981.75%20-1362.063%29%20scale%281.5625%29%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%20%20%3Cstop%20offset%3D%220%22%20stop-color%3D%22%233ccbf4%22%2F%3E%20%20%3Cstop%20offset%3D%221%22%20stop-color%3D%22%232892df%22%2F%3E%20%3C%2FlinearGradient%3E%20%3Cpath%20fill%3D%22url%28%23k8yl7~hDat~FaoWq8WjN6c%29%22%20d%3D%22M32.074%2C7.225C31.827%2C6.493%2C31.141%2C6%2C30.368%2C6h-12.6c0.772%2C0%2C1.459%2C0.493%2C1.705%2C1.224%20l10.935%2C32.399c0.318%2C0.942-0.188%2C1.963-1.13%2C2.281C29.093%2C41.968%2C28.899%2C42%2C28.703%2C42h12.6c0.994%2C0%2C1.8-0.806%2C1.8-1.801%20c0-0.196-0.032-0.39-0.095-0.575L32.074%2C7.225z%22%2F%3E%3C%2Fsvg%3E";
|
|
14277
13799
|
|
|
@@ -14337,11 +13859,11 @@ var CustomButton$1 = observer(CustomButton, {
|
|
|
14337
13859
|
|
|
14338
13860
|
var wrapper$3 = "wrapper-GVe2h";
|
|
14339
13861
|
var buttonGroup = "button-group-GYt-T";
|
|
14340
|
-
var css_248z$
|
|
14341
|
-
styleInject(css_248z$
|
|
13862
|
+
var css_248z$l = ".wrapper-GVe2h {\n display: flex;\n flex-direction: row;\n gap: 12px;\n}\n\n.button-group-GYt-T {\n display: flex;\n flex-direction: row;\n gap: 12px;\n margin: 0 12px;\n}\n";
|
|
13863
|
+
styleInject(css_248z$l);
|
|
14342
13864
|
|
|
14343
|
-
function ownKeys$
|
|
14344
|
-
function _objectSpread$
|
|
13865
|
+
function ownKeys$D(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13866
|
+
function _objectSpread$D(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$D(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$D(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14345
13867
|
var SubTitle = function SubTitle(_ref) {
|
|
14346
13868
|
var _item$orientation, _item$buttonIds;
|
|
14347
13869
|
var item = _ref.item,
|
|
@@ -14350,7 +13872,7 @@ var SubTitle = function SubTitle(_ref) {
|
|
|
14350
13872
|
t = _useTranslation.t;
|
|
14351
13873
|
return /*#__PURE__*/jsx(Divider, {
|
|
14352
13874
|
orientation: (_item$orientation = item.orientation) !== null && _item$orientation !== void 0 ? _item$orientation : 'left',
|
|
14353
|
-
style: _objectSpread$
|
|
13875
|
+
style: _objectSpread$D({}, item.style),
|
|
14354
13876
|
children: /*#__PURE__*/jsxs("div", {
|
|
14355
13877
|
className: wrapper$3,
|
|
14356
13878
|
children: [Array.isArray(item.name) ? t(item.name[0].toString()) : t(item.name), ((_item$buttonIds = item.buttonIds) === null || _item$buttonIds === void 0 ? void 0 : _item$buttonIds.length) && item.buttonIds.map(function (b) {
|
|
@@ -14430,9 +13952,226 @@ var InputComponent = function InputComponent(_ref) {
|
|
|
14430
13952
|
}
|
|
14431
13953
|
});
|
|
14432
13954
|
};
|
|
14433
|
-
var InputComponent$1 = observer(InputComponent, {
|
|
14434
|
-
forwardRef: true
|
|
14435
|
-
});
|
|
13955
|
+
var InputComponent$1 = observer(InputComponent, {
|
|
13956
|
+
forwardRef: true
|
|
13957
|
+
});
|
|
13958
|
+
|
|
13959
|
+
function _createForOfIteratorHelper$i(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$i(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13960
|
+
function _unsupportedIterableToArray$i(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$i(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$i(r, a) : void 0; } }
|
|
13961
|
+
function _arrayLikeToArray$i(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13962
|
+
function getCombinedValues(data, pattern) {
|
|
13963
|
+
if (!pattern || !data) {
|
|
13964
|
+
return data;
|
|
13965
|
+
}
|
|
13966
|
+
var value = pattern;
|
|
13967
|
+
var _iterator = _createForOfIteratorHelper$i(pattern.matchAll(/\$\{(.*?)\}/g)),
|
|
13968
|
+
_step;
|
|
13969
|
+
try {
|
|
13970
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13971
|
+
var _flatten$match$;
|
|
13972
|
+
var match = _step.value;
|
|
13973
|
+
value = value.replace(match[0], (_flatten$match$ = flat(data)[match[1]]) !== null && _flatten$match$ !== void 0 ? _flatten$match$ : '');
|
|
13974
|
+
}
|
|
13975
|
+
} catch (err) {
|
|
13976
|
+
_iterator.e(err);
|
|
13977
|
+
} finally {
|
|
13978
|
+
_iterator.f();
|
|
13979
|
+
}
|
|
13980
|
+
return value;
|
|
13981
|
+
}
|
|
13982
|
+
|
|
13983
|
+
var LOG$8 = getLogger('Backoffice', 'SelectSimple');
|
|
13984
|
+
function useSelectSimpleData (_ref) {
|
|
13985
|
+
var apiInterface = _ref.apiInterface,
|
|
13986
|
+
selectMapping = _ref.selectMapping,
|
|
13987
|
+
apiMapping = _ref.apiMapping,
|
|
13988
|
+
onChange = _ref.onChange,
|
|
13989
|
+
value = _ref.value,
|
|
13990
|
+
configuredOptions = _ref.options;
|
|
13991
|
+
var root = useStore();
|
|
13992
|
+
var _useMemo = useMemo(function () {
|
|
13993
|
+
return {
|
|
13994
|
+
apiHandler: new _default$d({
|
|
13995
|
+
type: 'SelectSimple',
|
|
13996
|
+
apiInterface: apiInterface
|
|
13997
|
+
}, root)
|
|
13998
|
+
};
|
|
13999
|
+
}, []),
|
|
14000
|
+
apiHandler = _useMemo.apiHandler;
|
|
14001
|
+
var _useState = useState(true),
|
|
14002
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14003
|
+
loading = _useState2[0],
|
|
14004
|
+
setLoading = _useState2[1];
|
|
14005
|
+
var _useState3 = useState(),
|
|
14006
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
14007
|
+
options = _useState4[0],
|
|
14008
|
+
setOptions = _useState4[1];
|
|
14009
|
+
var _useState5 = useState(),
|
|
14010
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
14011
|
+
selected = _useState6[0],
|
|
14012
|
+
setSelected = _useState6[1];
|
|
14013
|
+
var currentValue = useMemo(function () {
|
|
14014
|
+
if (!selected) return undefined;
|
|
14015
|
+
if (Array.isArray(selected)) return selected.map(function (item) {
|
|
14016
|
+
return item.value;
|
|
14017
|
+
});
|
|
14018
|
+
return selected.value;
|
|
14019
|
+
}, [selected]);
|
|
14020
|
+
useEffect(function () {
|
|
14021
|
+
if (configuredOptions) {
|
|
14022
|
+
if (apiHandler.canReadList) LOG$8.warn('If options are provided, apiInterface will not be used');
|
|
14023
|
+
setOptions(configuredOptions);
|
|
14024
|
+
setLoading(false);
|
|
14025
|
+
return;
|
|
14026
|
+
}
|
|
14027
|
+
if (!apiHandler.canReadList) throw Error('SelectSimple: apiInterface must have readList method');
|
|
14028
|
+
setLoading(true);
|
|
14029
|
+
apiHandler.readList(apiMapping).then(function (data) {
|
|
14030
|
+
var _data$data;
|
|
14031
|
+
if (_typeof((_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data[0]) == 'object' && !selectMapping) throw Error('SelectSimple: selectMapping is required when data is an object');
|
|
14032
|
+
var options = data.data.map(function (item) {
|
|
14033
|
+
return parseDataEntry(item, selectMapping);
|
|
14034
|
+
});
|
|
14035
|
+
setOptions(options);
|
|
14036
|
+
})["finally"](function () {
|
|
14037
|
+
setLoading(false);
|
|
14038
|
+
});
|
|
14039
|
+
}, []);
|
|
14040
|
+
useEffect(function () {
|
|
14041
|
+
// set the selected option only after the options are loaded
|
|
14042
|
+
if (value && options) {
|
|
14043
|
+
LOG$8.debug('value changed', value);
|
|
14044
|
+
setSelected(findByValue(value, options, selectMapping));
|
|
14045
|
+
}
|
|
14046
|
+
}, [value, options]);
|
|
14047
|
+
var onSelectionChanged = function onSelectionChanged(value, option) {
|
|
14048
|
+
setSelected(option);
|
|
14049
|
+
onChange === null || onChange === void 0 || onChange(parseReturnData(option, selectMapping));
|
|
14050
|
+
};
|
|
14051
|
+
var onClear = function onClear() {
|
|
14052
|
+
setSelected(undefined);
|
|
14053
|
+
onChange === null || onChange === void 0 || onChange(undefined);
|
|
14054
|
+
};
|
|
14055
|
+
return {
|
|
14056
|
+
loading: loading,
|
|
14057
|
+
options: options,
|
|
14058
|
+
value: currentValue,
|
|
14059
|
+
onChange: onSelectionChanged,
|
|
14060
|
+
onClear: onClear
|
|
14061
|
+
};
|
|
14062
|
+
}
|
|
14063
|
+
|
|
14064
|
+
/**
|
|
14065
|
+
* Returns the option(s) that match the given external value
|
|
14066
|
+
*/
|
|
14067
|
+
function findByValue(value, options, selectMapping) {
|
|
14068
|
+
if (!value) return undefined;
|
|
14069
|
+
if (Array.isArray(value)) return value.map(function (item) {
|
|
14070
|
+
return findByValue(item, options, selectMapping);
|
|
14071
|
+
});
|
|
14072
|
+
// if the externalValue is value we can compare it directly, otherwise we have to parse both option.data and value with the selectMapping.value
|
|
14073
|
+
var option = options.find(function (option) {
|
|
14074
|
+
return (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? option.value == value : getCombinedValues(option.data, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value) == getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value);
|
|
14075
|
+
});
|
|
14076
|
+
if (!option) {
|
|
14077
|
+
LOG$8.debug('findByValue: option not found, add dummy option for current value', value, options);
|
|
14078
|
+
//TODO: if we and server side filtering, the dummy option must be handled differently
|
|
14079
|
+
option = {
|
|
14080
|
+
label: (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? value : getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label),
|
|
14081
|
+
value: (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? value : getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value),
|
|
14082
|
+
data: value,
|
|
14083
|
+
isDummy: true
|
|
14084
|
+
};
|
|
14085
|
+
}
|
|
14086
|
+
return option;
|
|
14087
|
+
}
|
|
14088
|
+
|
|
14089
|
+
/**
|
|
14090
|
+
* Returns an option entry based on the selectMapping configuration
|
|
14091
|
+
*/
|
|
14092
|
+
function parseDataEntry(item, selectMapping) {
|
|
14093
|
+
return {
|
|
14094
|
+
label: selectMapping ? getCombinedValues(item, selectMapping.label) : item,
|
|
14095
|
+
value: selectMapping ? getCombinedValues(item, selectMapping.value) : item,
|
|
14096
|
+
data: item
|
|
14097
|
+
};
|
|
14098
|
+
}
|
|
14099
|
+
|
|
14100
|
+
/**
|
|
14101
|
+
* Returns the data of the selected option(s) based on the selectMapping configuration
|
|
14102
|
+
*/
|
|
14103
|
+
function parseReturnData(options, selectMapping) {
|
|
14104
|
+
if (Array.isArray(options)) return options.map(function (option) {
|
|
14105
|
+
return parseReturnData(option, selectMapping);
|
|
14106
|
+
});
|
|
14107
|
+
return (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? options.value : options.data;
|
|
14108
|
+
}
|
|
14109
|
+
|
|
14110
|
+
var _excluded$3 = ["apiInterface", "selectMapping", "apiMapping", "onChange", "value", "search", "options"];
|
|
14111
|
+
function ownKeys$C(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14112
|
+
function _objectSpread$C(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$C(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$C(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14113
|
+
var SelectWrapper$1 = function SelectWrapper(_ref) {
|
|
14114
|
+
var apiInterface = _ref.apiInterface,
|
|
14115
|
+
selectMapping = _ref.selectMapping,
|
|
14116
|
+
apiMapping = _ref.apiMapping,
|
|
14117
|
+
onChange = _ref.onChange,
|
|
14118
|
+
value = _ref.value,
|
|
14119
|
+
search = _ref.search,
|
|
14120
|
+
options = _ref.options,
|
|
14121
|
+
selectProps = _objectWithoutProperties(_ref, _excluded$3);
|
|
14122
|
+
var state = useSelectSimpleData({
|
|
14123
|
+
apiInterface: apiInterface,
|
|
14124
|
+
selectMapping: selectMapping,
|
|
14125
|
+
apiMapping: apiMapping,
|
|
14126
|
+
onChange: onChange,
|
|
14127
|
+
value: value,
|
|
14128
|
+
type: 'SelectSimple',
|
|
14129
|
+
options: options
|
|
14130
|
+
});
|
|
14131
|
+
return /*#__PURE__*/jsx(Select$1, _objectSpread$C(_objectSpread$C({}, selectProps), {}, {
|
|
14132
|
+
showSearch: search,
|
|
14133
|
+
loading: state.loading,
|
|
14134
|
+
options: state.options,
|
|
14135
|
+
value: state.value,
|
|
14136
|
+
onChange: state.onChange,
|
|
14137
|
+
onClear: state.onClear,
|
|
14138
|
+
filterOption: filterOption
|
|
14139
|
+
}));
|
|
14140
|
+
};
|
|
14141
|
+
var SimpleSelect = observer(SelectWrapper$1, {
|
|
14142
|
+
forwardRef: true
|
|
14143
|
+
});
|
|
14144
|
+
var filterOption = function filterOption(input, option) {
|
|
14145
|
+
var _option$label;
|
|
14146
|
+
return ((_option$label = option === null || option === void 0 ? void 0 : option.label) !== null && _option$label !== void 0 ? _option$label : '').toLowerCase().includes(input.toLowerCase());
|
|
14147
|
+
};
|
|
14148
|
+
|
|
14149
|
+
var RichTextEditor = function RichTextEditor(_ref) {
|
|
14150
|
+
var initValue = _ref.initValue,
|
|
14151
|
+
onChange = _ref.onChange,
|
|
14152
|
+
name = _ref.name;
|
|
14153
|
+
var _useDivaCore = useDivaCore(),
|
|
14154
|
+
tinyMceApiKey = _useDivaCore.state.tinyMceApiKey;
|
|
14155
|
+
var val = useRef(initValue);
|
|
14156
|
+
return /*#__PURE__*/jsx(Editor, {
|
|
14157
|
+
apiKey: tinyMceApiKey,
|
|
14158
|
+
onEditorChange: function onEditorChange(val, e) {
|
|
14159
|
+
onChange === null || onChange === void 0 || onChange(name, val);
|
|
14160
|
+
},
|
|
14161
|
+
initialValue: val.current,
|
|
14162
|
+
textareaName: "text",
|
|
14163
|
+
init: {
|
|
14164
|
+
height: 500,
|
|
14165
|
+
menubar: false,
|
|
14166
|
+
plugins: ['advlist autolink lists link table paste'],
|
|
14167
|
+
contextmenu: '',
|
|
14168
|
+
resize: false,
|
|
14169
|
+
statusbar: false,
|
|
14170
|
+
toolbar: 'undo redo | formatselect | ' + 'bold italic backcolor | alignleft aligncenter ' + 'alignright alignjustify | bullist numlist outdent indent | table ',
|
|
14171
|
+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
|
|
14172
|
+
}
|
|
14173
|
+
});
|
|
14174
|
+
};
|
|
14436
14175
|
|
|
14437
14176
|
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14438
14177
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -15019,8 +14758,8 @@ var _default = /*#__PURE__*/function (_ApiHandler) {
|
|
|
15019
14758
|
}]);
|
|
15020
14759
|
}(_default$d);
|
|
15021
14760
|
|
|
15022
|
-
function ownKeys$
|
|
15023
|
-
function _objectSpread$
|
|
14761
|
+
function ownKeys$B(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14762
|
+
function _objectSpread$B(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$B(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$B(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15024
14763
|
getLogger('Backoffice', 'SelectClientRelationCatalog');
|
|
15025
14764
|
function useSelectClientRelationCatalog (_ref) {
|
|
15026
14765
|
var onSelectedCatalog = _ref.onSelectedCatalog,
|
|
@@ -15189,7 +14928,7 @@ function useSelectClientRelationCatalog (_ref) {
|
|
|
15189
14928
|
case 22:
|
|
15190
14929
|
supplierData = _context2.sent;
|
|
15191
14930
|
case 23:
|
|
15192
|
-
onSelectedSupplier === null || onSelectedSupplier === void 0 || onSelectedSupplier(_objectSpread$
|
|
14931
|
+
onSelectedSupplier === null || onSelectedSupplier === void 0 || onSelectedSupplier(_objectSpread$B(_objectSpread$B({}, _selectedSupplier), {}, {
|
|
15193
14932
|
supplierGuid: catalogList === null || catalogList === void 0 || (_catalogList$ = catalogList[0]) === null || _catalogList$ === void 0 ? void 0 : _catalogList$.Subfolder
|
|
15194
14933
|
}), supplierData);
|
|
15195
14934
|
if (catalogId && catalogList.find(function (c) {
|
|
@@ -15255,8 +14994,8 @@ var customSelect = "custom-select-ESUJX";
|
|
|
15255
14994
|
var customSelectOption = "custom-select-option-dUA7N";
|
|
15256
14995
|
var avatarWrapper = "avatar-wrapper-Vg-xe";
|
|
15257
14996
|
var selectTextWrapper = "select-text-wrapper-hPSZW";
|
|
15258
|
-
var css_248z$
|
|
15259
|
-
styleInject(css_248z$
|
|
14997
|
+
var css_248z$k = ".custom-select-ESUJX {\n width: 300px;\n}\n\n.custom-select-option-dUA7N {\n margin: 0px 12px;\n padding: 5px 0px;\n border-bottom: 1px solid #ddd;\n}\n\n.avatar-wrapper-Vg-xe {\n margin-right: 5px;\n height: 100%;\n width: 24px;\n float: left;\n position: relative;\n}\n\n.avatar-wrapper-Vg-xe > span {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n}\n\n.select-text-wrapper-hPSZW {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: normal;\n width: calc(100% - 29px);\n}\n";
|
|
14998
|
+
styleInject(css_248z$k);
|
|
15260
14999
|
|
|
15261
15000
|
var Selector = function Selector(_ref) {
|
|
15262
15001
|
var items = _ref.items,
|
|
@@ -15407,202 +15146,915 @@ function SelectClientRelationCatalog (_ref) {
|
|
|
15407
15146
|
});
|
|
15408
15147
|
}
|
|
15409
15148
|
|
|
15410
|
-
var
|
|
15411
|
-
function
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
var
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15149
|
+
function _createForOfIteratorHelper$h(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$h(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15150
|
+
function _unsupportedIterableToArray$h(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$h(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$h(r, a) : void 0; } }
|
|
15151
|
+
function _arrayLikeToArray$h(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15152
|
+
function ownKeys$A(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15153
|
+
function _objectSpread$A(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$A(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$A(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15154
|
+
function useSelectData (_ref) {
|
|
15155
|
+
var data = _ref.data,
|
|
15156
|
+
onChange = _ref.onChange,
|
|
15157
|
+
onError = _ref.onError,
|
|
15158
|
+
apiInterface = _ref.apiInterface,
|
|
15159
|
+
selectMapping = _ref.selectMapping,
|
|
15160
|
+
mapping = _ref.mapping,
|
|
15161
|
+
mode = _ref.mode,
|
|
15162
|
+
allowCreate = _ref.allowCreate,
|
|
15163
|
+
flow = _ref.flow,
|
|
15164
|
+
translationPrefix = _ref.translationPrefix,
|
|
15165
|
+
values = _ref.values,
|
|
15166
|
+
wholeData = _ref.wholeData,
|
|
15167
|
+
disabledConfig = _ref.disabledConfig,
|
|
15168
|
+
hardOptions = _ref.hardOptions,
|
|
15169
|
+
_ref$applyDefaultValu = _ref.applyDefaultValue,
|
|
15170
|
+
applyDefaultValue = _ref$applyDefaultValu === void 0 ? true : _ref$applyDefaultValu,
|
|
15171
|
+
defaultValue = _ref.defaultValue,
|
|
15172
|
+
useFirstValueAsDefault = _ref.useFirstValueAsDefault,
|
|
15173
|
+
canSetToUndefined = _ref.canSetToUndefined;
|
|
15174
|
+
var root = useStore();
|
|
15175
|
+
var _useTranslation = useTranslation$1(),
|
|
15176
|
+
t = _useTranslation.t;
|
|
15177
|
+
var filterServerSide = _typeof(apiInterface) == 'object' && _typeof(apiInterface.read) == 'object' && apiInterface.read.filterServerSide;
|
|
15178
|
+
var _useMemo = useMemo(function () {
|
|
15179
|
+
return {
|
|
15180
|
+
apiHandler: new _default$d({
|
|
15181
|
+
type: 'SelectOrCreate',
|
|
15182
|
+
apiInterface: apiInterface
|
|
15183
|
+
}, root)
|
|
15184
|
+
};
|
|
15185
|
+
}, []),
|
|
15186
|
+
apiHandler = _useMemo.apiHandler;
|
|
15187
|
+
var fetchRef = React.useRef(0);
|
|
15188
|
+
var _React$useState = React.useState(false),
|
|
15189
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
15190
|
+
fetching = _React$useState2[0],
|
|
15191
|
+
setFetching = _React$useState2[1];
|
|
15192
|
+
var _React$useState3 = React.useState([]),
|
|
15193
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
15194
|
+
initOptions = _React$useState4[0],
|
|
15195
|
+
setInitOptions = _React$useState4[1];
|
|
15196
|
+
var _React$useState5 = React.useState([]),
|
|
15197
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
15198
|
+
options = _React$useState6[0],
|
|
15199
|
+
setOptions = _React$useState6[1];
|
|
15200
|
+
var _React$useState7 = React.useState([]),
|
|
15201
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
15202
|
+
selected = _React$useState8[0],
|
|
15203
|
+
setSelected = _React$useState8[1];
|
|
15204
|
+
var _React$useState9 = React.useState(data),
|
|
15205
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
15206
|
+
initalValue = _React$useState10[0],
|
|
15207
|
+
setInitValue = _React$useState10[1];
|
|
15208
|
+
var _useState = useState(false),
|
|
15209
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15210
|
+
gettingDefaultValue = _useState2[0],
|
|
15211
|
+
setGettingDefaultValue = _useState2[1];
|
|
15212
|
+
useEffect(function () {
|
|
15213
|
+
if (!filterServerSide && apiHandler.canReadList) {
|
|
15214
|
+
setFetching(true);
|
|
15215
|
+
apiHandler.readList(mapping, wholeData).then(function (body) {
|
|
15216
|
+
var result = body === null || body === void 0 ? void 0 : body.data.map(function (d) {
|
|
15217
|
+
return {
|
|
15218
|
+
label: selectMapping !== null && selectMapping !== void 0 && selectMapping.label ? getCombinedValues(d, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label) : _typeof(d) == 'object' ? d._id : d,
|
|
15219
|
+
value: selectMapping !== null && selectMapping !== void 0 && selectMapping.value ? d[selectMapping.value] : _typeof(d) == 'object' ? d._id : d,
|
|
15220
|
+
data: d
|
|
15221
|
+
};
|
|
15222
|
+
});
|
|
15223
|
+
var opts = result.sort(function (a, b) {
|
|
15224
|
+
return a.label.localeCompare(b.label);
|
|
15225
|
+
});
|
|
15226
|
+
setOptions(opts);
|
|
15227
|
+
setInitOptions(opts);
|
|
15228
|
+
setFetching(false);
|
|
15229
|
+
});
|
|
15230
|
+
} else if (values) {
|
|
15231
|
+
setOptions(_toConsumableArray(values.map(function (v) {
|
|
15232
|
+
return {
|
|
15233
|
+
label: v,
|
|
15234
|
+
value: v,
|
|
15235
|
+
data: v,
|
|
15236
|
+
disabled: false
|
|
15237
|
+
};
|
|
15238
|
+
})));
|
|
15239
|
+
} else if (hardOptions) {
|
|
15240
|
+
setOptions(_toConsumableArray(hardOptions.map(function (v) {
|
|
15241
|
+
return {
|
|
15242
|
+
label: v.lable,
|
|
15243
|
+
value: v.value,
|
|
15244
|
+
data: v.data,
|
|
15245
|
+
disabled: v.disabled
|
|
15246
|
+
};
|
|
15247
|
+
})));
|
|
15248
|
+
}
|
|
15249
|
+
}, [wholeData]);
|
|
15250
|
+
useEffect(function () {
|
|
15251
|
+
if (!canSetToUndefined && (selected == undefined || selected.length == 0)) {
|
|
15252
|
+
doSetOptions();
|
|
15253
|
+
}
|
|
15254
|
+
}, [data]);
|
|
15255
|
+
useEffect(function () {
|
|
15256
|
+
if (!(selected !== null && selected !== void 0 && selected.length) && defaultValue && applyDefaultValue !== false) {
|
|
15257
|
+
setSelected([defaultValue]);
|
|
15258
|
+
}
|
|
15259
|
+
}, [defaultValue]);
|
|
15260
|
+
function doSetOptions() {
|
|
15261
|
+
var newData = data !== null && data !== void 0 ? data : defaultValue;
|
|
15262
|
+
if (newData != undefined && (!Array.isArray(newData) || newData.length != 0)) {
|
|
15263
|
+
if (initalValue == undefined) {
|
|
15264
|
+
setInitValue(newData);
|
|
15265
|
+
}
|
|
15266
|
+
var initData = isArray(newData) ? newData : [newData];
|
|
15267
|
+
var value = initData.map(function (d) {
|
|
15268
|
+
var _d$data, _d$_id, _d$selectMapping$valu, _d$data2, _ref2, _d$value, _d$data3;
|
|
15269
|
+
return {
|
|
15270
|
+
label: selectMapping !== null && selectMapping !== void 0 && selectMapping.label ? getCombinedValues((_d$data = d === null || d === void 0 ? void 0 : d.data) !== null && _d$data !== void 0 ? _d$data : d, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label) : _typeof(d) == 'object' ? (_d$_id = d._id) !== null && _d$_id !== void 0 ? _d$_id : d.label : translationPrefix ? t(translationPrefix + '.' + d) : d,
|
|
15271
|
+
value: selectMapping !== null && selectMapping !== void 0 && selectMapping.value ? (_d$selectMapping$valu = d === null || d === void 0 ? void 0 : d[selectMapping.value]) !== null && _d$selectMapping$valu !== void 0 ? _d$selectMapping$valu : d === null || d === void 0 || (_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2[selectMapping.value] : _typeof(d) == 'object' ? (_ref2 = (_d$value = d === null || d === void 0 ? void 0 : d.value) !== null && _d$value !== void 0 ? _d$value : d === null || d === void 0 || (_d$data3 = d.data) === null || _d$data3 === void 0 ? void 0 : _d$data3.value) !== null && _ref2 !== void 0 ? _ref2 : d === null || d === void 0 ? void 0 : d._id : d,
|
|
15272
|
+
data: d,
|
|
15273
|
+
disabled: false
|
|
15274
|
+
};
|
|
15275
|
+
});
|
|
15276
|
+
var val = value.length == 1 ? value[0].data : value;
|
|
15277
|
+
if (Array.isArray(val) && val.length) {
|
|
15278
|
+
val = val.map(function (v) {
|
|
15279
|
+
return v.data;
|
|
15280
|
+
});
|
|
15281
|
+
} else if (Array.isArray(val)) {
|
|
15282
|
+
val = initData;
|
|
15283
|
+
}
|
|
15284
|
+
if (flow && initData.length) {
|
|
15285
|
+
var _value$, _flow$value$0$value, _value$2;
|
|
15286
|
+
if (mode != 'single') {
|
|
15287
|
+
throw new Error('Flow is only implemented for single mode');
|
|
15288
|
+
}
|
|
15289
|
+
var missingFields = verifySelection((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.value);
|
|
15290
|
+
if (missingFields.length) {
|
|
15291
|
+
onError === null || onError === void 0 || onError((missingFields === null || missingFields === void 0 ? void 0 : missingFields.join(', ')) + ' not set or wrong value');
|
|
15292
|
+
return;
|
|
15293
|
+
} else {
|
|
15294
|
+
onError === null || onError === void 0 || onError('');
|
|
15295
|
+
}
|
|
15296
|
+
var flowData = (flow === null || flow === void 0 || (_flow$value$0$value = flow[(_value$2 = value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.value]) === null || _flow$value$0$value === void 0 ? void 0 : _flow$value$0$value.map(function (opt) {
|
|
15297
|
+
return {
|
|
15298
|
+
label: translationPrefix ? t(translationPrefix + '.' + opt) : opt.toString(),
|
|
15299
|
+
value: opt,
|
|
15300
|
+
data: opt
|
|
15301
|
+
};
|
|
15302
|
+
})) || [];
|
|
15303
|
+
var _defaultValue = initalValue !== null && initalValue !== void 0 ? initalValue : data;
|
|
15304
|
+
if (!flowData.find(function (fd) {
|
|
15305
|
+
return fd.value == _defaultValue;
|
|
15306
|
+
})) {
|
|
15307
|
+
flowData.push({
|
|
15308
|
+
label: translationPrefix ? t(translationPrefix + '.' + _defaultValue) : _defaultValue.toString(),
|
|
15309
|
+
value: _defaultValue,
|
|
15310
|
+
data: _defaultValue
|
|
15311
|
+
});
|
|
15312
|
+
}
|
|
15313
|
+
setOptions(_toConsumableArray(flowData));
|
|
15314
|
+
}
|
|
15315
|
+
onChange === null || onChange === void 0 || onChange(val, applyDefaultValue, defaultValue);
|
|
15316
|
+
setSelected(value);
|
|
15317
|
+
}
|
|
15318
|
+
}
|
|
15319
|
+
var loadOptions = /*#__PURE__*/function () {
|
|
15320
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
15321
|
+
var fetchId, newOptions, serverSideParams;
|
|
15322
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15323
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15324
|
+
case 0:
|
|
15325
|
+
fetchRef.current += 1;
|
|
15326
|
+
fetchId = fetchRef.current;
|
|
15327
|
+
if (!filterServerSide) {
|
|
15328
|
+
_context.next = 10;
|
|
15329
|
+
break;
|
|
15330
|
+
}
|
|
15331
|
+
setFetching(true);
|
|
15332
|
+
serverSideParams = {
|
|
15333
|
+
filters: selectMapping !== null && selectMapping !== void 0 && selectMapping.searchField ? selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.searchField.reduce(function (filter, field) {
|
|
15334
|
+
return _objectSpread$A(_objectSpread$A({}, filter), value !== undefined ? _defineProperty({}, field.field, [value, field.filter, true]) : {});
|
|
15335
|
+
}, {}) : {
|
|
15336
|
+
_id: [value, 'contains']
|
|
15337
|
+
},
|
|
15338
|
+
pagination: {
|
|
15339
|
+
pageSize: 100
|
|
15340
|
+
}
|
|
15341
|
+
};
|
|
15342
|
+
_context.next = 7;
|
|
15343
|
+
return apiHandler.readList(selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.prefilterMapping, wholeData, serverSideParams, undefined, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.prefilter).then(function (body) {
|
|
15344
|
+
return (body === null || body === void 0 ? void 0 : body.data.map(function (data) {
|
|
15345
|
+
return {
|
|
15346
|
+
label: selectMapping !== null && selectMapping !== void 0 && selectMapping.label ? getCombinedValues(data, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label) : data._id,
|
|
15347
|
+
value: selectMapping !== null && selectMapping !== void 0 && selectMapping.value ? data[selectMapping.value] : data._id,
|
|
15348
|
+
disabled: false,
|
|
15349
|
+
data: data
|
|
15350
|
+
};
|
|
15351
|
+
})) || [];
|
|
15352
|
+
});
|
|
15353
|
+
case 7:
|
|
15354
|
+
newOptions = _context.sent;
|
|
15355
|
+
_context.next = 12;
|
|
15356
|
+
break;
|
|
15357
|
+
case 10:
|
|
15358
|
+
newOptions = initOptions.filter(function (opt) {
|
|
15359
|
+
var _value$toLocaleLowerC;
|
|
15360
|
+
return opt.label.toLocaleLowerCase().includes((_value$toLocaleLowerC = value === null || value === void 0 ? void 0 : value.toLocaleLowerCase()) !== null && _value$toLocaleLowerC !== void 0 ? _value$toLocaleLowerC : '');
|
|
15361
|
+
});
|
|
15362
|
+
if (allowCreate && !newOptions.length) {
|
|
15363
|
+
newOptions = [{
|
|
15364
|
+
data: value,
|
|
15365
|
+
label: value,
|
|
15366
|
+
disabled: false,
|
|
15367
|
+
value: value
|
|
15368
|
+
}];
|
|
15369
|
+
}
|
|
15370
|
+
case 12:
|
|
15371
|
+
if (!(fetchId !== fetchRef.current)) {
|
|
15372
|
+
_context.next = 14;
|
|
15373
|
+
break;
|
|
15374
|
+
}
|
|
15375
|
+
return _context.abrupt("return");
|
|
15376
|
+
case 14:
|
|
15377
|
+
setOptions(newOptions);
|
|
15378
|
+
setFetching(false);
|
|
15379
|
+
case 16:
|
|
15380
|
+
case "end":
|
|
15381
|
+
return _context.stop();
|
|
15382
|
+
}
|
|
15383
|
+
}, _callee);
|
|
15384
|
+
}));
|
|
15385
|
+
return function loadOptions(_x) {
|
|
15386
|
+
return _ref3.apply(this, arguments);
|
|
15387
|
+
};
|
|
15388
|
+
}();
|
|
15389
|
+
var fetch = React.useMemo(function () {
|
|
15390
|
+
return debounce(loadOptions, 800);
|
|
15391
|
+
}, [selectMapping, initOptions, wholeData]);
|
|
15392
|
+
var verifySelection = function verifySelection(opt) {
|
|
15393
|
+
if (disabledConfig == undefined) return [];
|
|
15394
|
+
var _missingFields = [];
|
|
15395
|
+
var _iterator = _createForOfIteratorHelper$h(disabledConfig),
|
|
15396
|
+
_step;
|
|
15397
|
+
try {
|
|
15398
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15399
|
+
var disabled = _step.value;
|
|
15400
|
+
if (opt == (disabled === null || disabled === void 0 ? void 0 : disabled.value) && wholeData[disabled.onField.field] == disabled.onField.value) {
|
|
15401
|
+
if (!disabled.requiredFields) {
|
|
15402
|
+
return ['Job HQ', 'Job AR'];
|
|
15403
|
+
}
|
|
15404
|
+
disabled.requiredFields.forEach(function (fd) {
|
|
15405
|
+
if (typeof fd === 'string' && (wholeData[fd] === '' || wholeData[fd] === undefined)) {
|
|
15406
|
+
_missingFields.push(fd);
|
|
15407
|
+
} else if (_typeof(fd) == 'object') {
|
|
15408
|
+
if (!fd.value.some(function (v) {
|
|
15409
|
+
return v == wholeData[fd.field];
|
|
15410
|
+
})) {
|
|
15411
|
+
_missingFields.push(fd.field);
|
|
15412
|
+
}
|
|
15413
|
+
}
|
|
15414
|
+
});
|
|
15415
|
+
return _missingFields;
|
|
15416
|
+
}
|
|
15417
|
+
}
|
|
15418
|
+
} catch (err) {
|
|
15419
|
+
_iterator.e(err);
|
|
15420
|
+
} finally {
|
|
15421
|
+
_iterator.f();
|
|
15422
|
+
}
|
|
15423
|
+
return [];
|
|
15424
|
+
};
|
|
15425
|
+
|
|
15426
|
+
//state.configuration.dependencyRule.
|
|
15427
|
+
var onSelect = function onSelect(data) {
|
|
15428
|
+
//! tags works without labelInValue; data = string; get's converted to option afterwards in useeffect
|
|
15429
|
+
//because of a error in the typedefinition we have to cast it here
|
|
15430
|
+
var newSelected = data;
|
|
15431
|
+
var sel = selected;
|
|
15432
|
+
var option = options.find(function (o) {
|
|
15433
|
+
return o.value == newSelected.value;
|
|
15444
15434
|
});
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
if (
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15435
|
+
if (option) {
|
|
15436
|
+
if (mode == 'tags') {
|
|
15437
|
+
throw new Error('select with options is not yet supported for mode tags');
|
|
15438
|
+
}
|
|
15439
|
+
if (mode == 'single') {
|
|
15440
|
+
var _option$data;
|
|
15441
|
+
if (flow) {
|
|
15442
|
+
var _flow$option$value;
|
|
15443
|
+
var missingFields = verifySelection(option.value);
|
|
15444
|
+
if (missingFields.length) {
|
|
15445
|
+
onError === null || onError === void 0 || onError((missingFields === null || missingFields === void 0 ? void 0 : missingFields.join(', ')) + ' not set or wrong value');
|
|
15446
|
+
return;
|
|
15447
|
+
} else {
|
|
15448
|
+
onError === null || onError === void 0 || onError('');
|
|
15449
|
+
}
|
|
15450
|
+
var flowData = (flow === null || flow === void 0 || (_flow$option$value = flow[option.value]) === null || _flow$option$value === void 0 ? void 0 : _flow$option$value.map(function (opt) {
|
|
15451
|
+
return {
|
|
15452
|
+
label: translationPrefix ? t(translationPrefix + '.' + opt) : opt.toString(),
|
|
15453
|
+
value: opt,
|
|
15454
|
+
data: opt
|
|
15455
|
+
};
|
|
15456
|
+
})) || [];
|
|
15457
|
+
var _defaultValue2 = initalValue !== null && initalValue !== void 0 ? initalValue : data;
|
|
15458
|
+
if (!flowData.find(function (fd) {
|
|
15459
|
+
return fd.value == _defaultValue2;
|
|
15460
|
+
})) {
|
|
15461
|
+
flowData.push({
|
|
15462
|
+
label: translationPrefix ? t(translationPrefix + '.' + _defaultValue2) : _defaultValue2.toString(),
|
|
15463
|
+
value: _defaultValue2,
|
|
15464
|
+
data: _defaultValue2
|
|
15465
|
+
});
|
|
15466
|
+
}
|
|
15467
|
+
setOptions(_toConsumableArray(flowData));
|
|
15468
|
+
}
|
|
15469
|
+
//if it is single mode there can always only be one selected or one new entry
|
|
15470
|
+
onChange === null || onChange === void 0 || onChange((_option$data = option === null || option === void 0 ? void 0 : option.data) !== null && _option$data !== void 0 ? _option$data : option, applyDefaultValue, defaultValue);
|
|
15471
|
+
setSelected([option]);
|
|
15472
|
+
} else {
|
|
15473
|
+
var selectedList = [].concat(_toConsumableArray(sel), [option]);
|
|
15474
|
+
setSelected(selectedList);
|
|
15475
|
+
onChange === null || onChange === void 0 || onChange(selectedList.map(function (s) {
|
|
15476
|
+
return s.data;
|
|
15477
|
+
}), applyDefaultValue, defaultValue);
|
|
15478
|
+
}
|
|
15479
|
+
} else {
|
|
15480
|
+
if (mode == 'tags' && typeof data === 'string') {
|
|
15481
|
+
onChange === null || onChange === void 0 || onChange([].concat(_toConsumableArray(sel.map(function (s) {
|
|
15482
|
+
return s.data;
|
|
15483
|
+
})), [data]), applyDefaultValue, defaultValue);
|
|
15484
|
+
setSelected([].concat(_toConsumableArray(sel), [data]));
|
|
15485
|
+
} else {
|
|
15486
|
+
throw new Error('select without options is not yet supported for modes other than tags');
|
|
15487
|
+
}
|
|
15453
15488
|
}
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15489
|
+
};
|
|
15490
|
+
|
|
15491
|
+
// if useFirstValueAsDefault is true we load the options and trigger an update with setGettingDefaultValue
|
|
15492
|
+
// at the 2. useEffect the options are loaded and set in state so we can set the first option
|
|
15493
|
+
useEffect(function () {
|
|
15494
|
+
if (useFirstValueAsDefault && !selected.length) {
|
|
15495
|
+
loadOptions(undefined).then(function () {
|
|
15496
|
+
return setGettingDefaultValue(true);
|
|
15461
15497
|
});
|
|
15462
|
-
|
|
15463
|
-
})["finally"](function () {
|
|
15464
|
-
setLoading(false);
|
|
15465
|
-
});
|
|
15498
|
+
}
|
|
15466
15499
|
}, []);
|
|
15467
15500
|
useEffect(function () {
|
|
15468
|
-
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
}
|
|
15473
|
-
}, [value, options]);
|
|
15474
|
-
var onSelectionChanged = function onSelectionChanged(value, option) {
|
|
15475
|
-
setSelected(option);
|
|
15476
|
-
onChange === null || onChange === void 0 || onChange(parseReturnData(option, selectMapping));
|
|
15501
|
+
if (gettingDefaultValue) onSelect(options[0]);
|
|
15502
|
+
}, [gettingDefaultValue]);
|
|
15503
|
+
var onFocus = function onFocus() {
|
|
15504
|
+
loadOptions(undefined);
|
|
15477
15505
|
};
|
|
15478
|
-
var
|
|
15479
|
-
|
|
15480
|
-
|
|
15506
|
+
var onRemove = function onRemove(data) {
|
|
15507
|
+
//because of a error in the typedefinition we have to cast it here
|
|
15508
|
+
var removed = data;
|
|
15509
|
+
var sel = selected;
|
|
15510
|
+
var newSelected;
|
|
15511
|
+
if (removed) {
|
|
15512
|
+
var index = sel.findIndex(function (s) {
|
|
15513
|
+
return s.value == removed.value;
|
|
15514
|
+
});
|
|
15515
|
+
newSelected = _toConsumableArray(sel);
|
|
15516
|
+
newSelected.splice(index, 1);
|
|
15517
|
+
} else {
|
|
15518
|
+
newSelected = [];
|
|
15519
|
+
}
|
|
15520
|
+
setSelected(newSelected);
|
|
15521
|
+
if (mode == 'single') {
|
|
15522
|
+
onChange === null || onChange === void 0 || onChange(undefined, applyDefaultValue, defaultValue);
|
|
15523
|
+
} else {
|
|
15524
|
+
onChange === null || onChange === void 0 || onChange(newSelected.map(function (s) {
|
|
15525
|
+
return s.data;
|
|
15526
|
+
}), applyDefaultValue, defaultValue);
|
|
15527
|
+
}
|
|
15481
15528
|
};
|
|
15482
15529
|
return {
|
|
15483
|
-
|
|
15530
|
+
fetching: fetching,
|
|
15484
15531
|
options: options,
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
/**
|
|
15492
|
-
* Returns the option(s) that match the given external value
|
|
15493
|
-
*/
|
|
15494
|
-
function findByValue(value, options, selectMapping) {
|
|
15495
|
-
if (!value) return undefined;
|
|
15496
|
-
if (Array.isArray(value)) return value.map(function (item) {
|
|
15497
|
-
return findByValue(item, options, selectMapping);
|
|
15498
|
-
});
|
|
15499
|
-
// if the externalValue is value we can compare it directly, otherwise we have to parse both option.data and value with the selectMapping.value
|
|
15500
|
-
var option = options.find(function (option) {
|
|
15501
|
-
return (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? option.value == value : getCombinedValues(option.data, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value) == getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value);
|
|
15502
|
-
});
|
|
15503
|
-
if (!option) {
|
|
15504
|
-
LOG$8.debug('findByValue: option not found, add dummy option for current value', value, options);
|
|
15505
|
-
//TODO: if we and server side filtering, the dummy option must be handled differently
|
|
15506
|
-
option = {
|
|
15507
|
-
label: (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? value : getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.label),
|
|
15508
|
-
value: (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? value : getCombinedValues(value, selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.value),
|
|
15509
|
-
data: value,
|
|
15510
|
-
isDummy: true
|
|
15511
|
-
};
|
|
15512
|
-
}
|
|
15513
|
-
return option;
|
|
15514
|
-
}
|
|
15515
|
-
|
|
15516
|
-
/**
|
|
15517
|
-
* Returns an option entry based on the selectMapping configuration
|
|
15518
|
-
*/
|
|
15519
|
-
function parseDataEntry(item, selectMapping) {
|
|
15520
|
-
return {
|
|
15521
|
-
label: selectMapping ? getCombinedValues(item, selectMapping.label) : item,
|
|
15522
|
-
value: selectMapping ? getCombinedValues(item, selectMapping.value) : item,
|
|
15523
|
-
data: item
|
|
15532
|
+
selected: selected,
|
|
15533
|
+
fetch: fetch,
|
|
15534
|
+
onRemove: onRemove,
|
|
15535
|
+
onFocus: onFocus,
|
|
15536
|
+
onSelect: onSelect
|
|
15524
15537
|
};
|
|
15525
15538
|
}
|
|
15526
15539
|
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
*/
|
|
15530
|
-
function parseReturnData(options, selectMapping) {
|
|
15531
|
-
if (Array.isArray(options)) return options.map(function (option) {
|
|
15532
|
-
return parseReturnData(option, selectMapping);
|
|
15533
|
-
});
|
|
15534
|
-
return (selectMapping === null || selectMapping === void 0 ? void 0 : selectMapping.externalValue) == 'value' ? options.value : options.data;
|
|
15535
|
-
}
|
|
15540
|
+
var css_248z$j = ".darkmode .ant-select-selection-search-input {\n color: #fff;\n}\n";
|
|
15541
|
+
styleInject(css_248z$j);
|
|
15536
15542
|
|
|
15537
|
-
var _excluded$3 = ["apiInterface", "selectMapping", "apiMapping", "onChange", "value", "search", "options"];
|
|
15538
|
-
function ownKeys$z(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15539
|
-
function _objectSpread$z(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$z(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$z(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15540
15543
|
var SelectWrapper = function SelectWrapper(_ref) {
|
|
15541
|
-
var
|
|
15542
|
-
|
|
15543
|
-
apiMapping = _ref.apiMapping,
|
|
15544
|
-
onChange = _ref.onChange,
|
|
15544
|
+
var onChange = _ref.onChange,
|
|
15545
|
+
onError = _ref.onError,
|
|
15545
15546
|
value = _ref.value,
|
|
15547
|
+
apiInterface = _ref.apiInterface,
|
|
15548
|
+
selectMapping = _ref.selectMapping,
|
|
15549
|
+
mapping = _ref.mapping,
|
|
15550
|
+
mode = _ref.mode,
|
|
15551
|
+
initialValue = _ref.initialValue,
|
|
15552
|
+
minWidth = _ref.minWidth,
|
|
15553
|
+
allowCreate = _ref.allowCreate,
|
|
15554
|
+
allowClear = _ref.allowClear,
|
|
15546
15555
|
search = _ref.search,
|
|
15556
|
+
flow = _ref.flow,
|
|
15557
|
+
translationPrefix = _ref.translationPrefix,
|
|
15558
|
+
values = _ref.values,
|
|
15559
|
+
disabled = _ref.disabled,
|
|
15560
|
+
wholeData = _ref.wholeData,
|
|
15561
|
+
disabledConfig = _ref.disabledConfig,
|
|
15562
|
+
placeholder = _ref.placeholder,
|
|
15547
15563
|
options = _ref.options,
|
|
15548
|
-
|
|
15549
|
-
|
|
15564
|
+
applyDefaultValue = _ref.applyDefaultValue,
|
|
15565
|
+
useFirstValueAsDefault = _ref.useFirstValueAsDefault,
|
|
15566
|
+
canSetToUndefined = _ref.canSetToUndefined;
|
|
15567
|
+
var state = useSelectData({
|
|
15568
|
+
onChange: onChange,
|
|
15569
|
+
onError: onError,
|
|
15570
|
+
data: value,
|
|
15550
15571
|
apiInterface: apiInterface,
|
|
15551
15572
|
selectMapping: selectMapping,
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15573
|
+
mapping: mapping,
|
|
15574
|
+
mode: mode,
|
|
15575
|
+
allowCreate: allowCreate,
|
|
15576
|
+
defaultValue: initialValue,
|
|
15577
|
+
flow: flow,
|
|
15578
|
+
translationPrefix: translationPrefix,
|
|
15579
|
+
values: values,
|
|
15580
|
+
wholeData: wholeData,
|
|
15581
|
+
disabledConfig: disabledConfig,
|
|
15582
|
+
hardOptions: options,
|
|
15583
|
+
applyDefaultValue: applyDefaultValue,
|
|
15584
|
+
useFirstValueAsDefault: useFirstValueAsDefault,
|
|
15585
|
+
canSetToUndefined: canSetToUndefined
|
|
15557
15586
|
});
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15587
|
+
var _useTranslation = useTranslation$1(),
|
|
15588
|
+
t = _useTranslation.t;
|
|
15589
|
+
var filterServerSide = _typeof(apiInterface) == 'object' && _typeof(apiInterface.read) == 'object' && apiInterface.read.filterServerSide;
|
|
15590
|
+
var selected = state.selected;
|
|
15591
|
+
return /*#__PURE__*/jsx(Select$1, {
|
|
15592
|
+
labelInValue: mode === 'tags' ? false : true,
|
|
15593
|
+
style: {
|
|
15594
|
+
width: '100%',
|
|
15595
|
+
minWidth: minWidth
|
|
15596
|
+
},
|
|
15597
|
+
filterOption: false,
|
|
15598
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('filter.global'),
|
|
15599
|
+
allowClear: allowClear !== null && allowClear !== void 0 ? allowClear : filterServerSide,
|
|
15600
|
+
showArrow: !filterServerSide || allowCreate || search,
|
|
15601
|
+
mode: mode == 'single' ? undefined : mode,
|
|
15602
|
+
showSearch: filterServerSide || allowCreate || search,
|
|
15603
|
+
onSearch: filterServerSide || allowCreate || search ? state.fetch : undefined,
|
|
15604
|
+
notFoundContent: state.fetching ? /*#__PURE__*/jsx(Spin, {
|
|
15605
|
+
size: "small"
|
|
15606
|
+
}) : null,
|
|
15561
15607
|
options: state.options,
|
|
15562
|
-
|
|
15563
|
-
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15608
|
+
onSelect: state.onSelect,
|
|
15609
|
+
disabled: disabled,
|
|
15610
|
+
onDeselect: state.onRemove,
|
|
15611
|
+
onFocus: filterServerSide || allowCreate || search ? state.onFocus : undefined,
|
|
15612
|
+
onClear: state.onRemove,
|
|
15613
|
+
value: selected
|
|
15614
|
+
});
|
|
15567
15615
|
};
|
|
15568
|
-
var
|
|
15616
|
+
var Select = observer(SelectWrapper, {
|
|
15569
15617
|
forwardRef: true
|
|
15570
15618
|
});
|
|
15571
|
-
var filterOption = function filterOption(input, option) {
|
|
15572
|
-
var _option$label;
|
|
15573
|
-
return ((_option$label = option === null || option === void 0 ? void 0 : option.label) !== null && _option$label !== void 0 ? _option$label : '').toLowerCase().includes(input.toLowerCase());
|
|
15574
|
-
};
|
|
15575
15619
|
|
|
15576
|
-
var
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15620
|
+
function _createForOfIteratorHelper$g(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$g(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15621
|
+
function _unsupportedIterableToArray$g(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$g(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$g(r, a) : void 0; } }
|
|
15622
|
+
function _arrayLikeToArray$g(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15623
|
+
function ownKeys$z(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15624
|
+
function _objectSpread$z(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$z(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$z(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15625
|
+
function getElement(item, data, setCanSave, state, _onChange, _onError, root, form, hidden, overwrittenName) {
|
|
15626
|
+
var _isReadonly, _state$hiddenRequired;
|
|
15627
|
+
if (hidden) return /*#__PURE__*/jsx(Fragment, {});
|
|
15628
|
+
var name = overwrittenName || item.name;
|
|
15629
|
+
var disabled = (_isReadonly = isReadonly(item, data)) !== null && _isReadonly !== void 0 ? _isReadonly : (_state$hiddenRequired = state.hiddenRequiredDisabled[typeof name == 'string' ? name : name.join('.')]) === null || _state$hiddenRequired === void 0 ? void 0 : _state$hiddenRequired.disabled;
|
|
15630
|
+
switch (item.type) {
|
|
15631
|
+
case 'select':
|
|
15632
|
+
return /*#__PURE__*/jsx(Select, {
|
|
15633
|
+
initialValue: item.defaultValue,
|
|
15634
|
+
apiInterface: item.apiInterface,
|
|
15635
|
+
mode: item.mode,
|
|
15636
|
+
useFirstValueAsDefault: item.useFirstValueAsDefault,
|
|
15637
|
+
canSetToUndefined: item.canSetToUndefined,
|
|
15638
|
+
selectMapping: item.selectMapping,
|
|
15639
|
+
mapping: item.mapping,
|
|
15640
|
+
allowCreate: item.allowCreate,
|
|
15641
|
+
flow: item.flow,
|
|
15642
|
+
translationPrefix: item.translationPrefix,
|
|
15643
|
+
values: item.values,
|
|
15644
|
+
search: item.search,
|
|
15645
|
+
disabled: disabled,
|
|
15646
|
+
wholeData: state.data,
|
|
15647
|
+
disabledConfig: item === null || item === void 0 ? void 0 : item['disabledSelection'],
|
|
15648
|
+
onChange: function onChange(value) {
|
|
15649
|
+
_onChange(name, item.valueField ? value[item.valueField] : value);
|
|
15650
|
+
},
|
|
15651
|
+
allowClear: item.allowClear,
|
|
15652
|
+
placeholder: item.placeholder,
|
|
15653
|
+
onError: function onError(text) {
|
|
15654
|
+
return _onError(text, text);
|
|
15655
|
+
}
|
|
15656
|
+
});
|
|
15657
|
+
case 'selectSimple':
|
|
15658
|
+
return /*#__PURE__*/jsx(SimpleSelect, _objectSpread$z(_objectSpread$z({}, item), {}, {
|
|
15659
|
+
disabled: disabled,
|
|
15660
|
+
onChange: function onChange(value) {
|
|
15661
|
+
_onChange(name, value);
|
|
15662
|
+
}
|
|
15663
|
+
}));
|
|
15664
|
+
case 'textarea':
|
|
15665
|
+
return /*#__PURE__*/jsx(Input.TextArea, {
|
|
15666
|
+
disabled: disabled,
|
|
15667
|
+
autoSize: {
|
|
15668
|
+
minRows: 2,
|
|
15669
|
+
maxRows: 5
|
|
15670
|
+
},
|
|
15671
|
+
defaultValue: item.value,
|
|
15672
|
+
placeholder: item.placeholder,
|
|
15673
|
+
onChange: function onChange(e) {
|
|
15674
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(name, e.target.value);
|
|
15675
|
+
}
|
|
15676
|
+
});
|
|
15677
|
+
case 'input':
|
|
15678
|
+
case 'password':
|
|
15679
|
+
case undefined:
|
|
15680
|
+
if (item.syncDataWithUserInput) {
|
|
15681
|
+
return /*#__PURE__*/jsx(InputComponent$1, {
|
|
15682
|
+
item: item,
|
|
15683
|
+
data: data,
|
|
15684
|
+
value: item.value,
|
|
15685
|
+
onChange: state.onInputChanged
|
|
15686
|
+
});
|
|
15687
|
+
}
|
|
15688
|
+
if (item.type == 'password') return /*#__PURE__*/jsx(Input.Password, {
|
|
15689
|
+
addonBefore: item.prefix,
|
|
15690
|
+
addonAfter: item.suffix,
|
|
15691
|
+
disabled: disabled,
|
|
15692
|
+
value: item.value,
|
|
15693
|
+
placeholder: item.placeholder,
|
|
15694
|
+
autoComplete: "new-password"
|
|
15695
|
+
});
|
|
15696
|
+
return /*#__PURE__*/jsx(Input, {
|
|
15697
|
+
addonBefore: item.prefix,
|
|
15698
|
+
addonAfter: item.suffix,
|
|
15699
|
+
disabled: disabled,
|
|
15700
|
+
value: item.value,
|
|
15701
|
+
placeholder: item.placeholder
|
|
15702
|
+
});
|
|
15703
|
+
case 'detailaction':
|
|
15704
|
+
return /*#__PURE__*/jsx(Button, {
|
|
15705
|
+
onClick: function onClick() {
|
|
15706
|
+
var _root$detailStore$ope, _root$detailStore;
|
|
15707
|
+
return root === null || root === void 0 || (_root$detailStore$ope = (_root$detailStore = root.detailStore).openLeftDetail) === null || _root$detailStore$ope === void 0 ? void 0 : _root$detailStore$ope.call(_root$detailStore, {
|
|
15708
|
+
configurationId: item.action.id,
|
|
15709
|
+
data: data,
|
|
15710
|
+
mappingData: data,
|
|
15711
|
+
callback: function callback(data) {
|
|
15712
|
+
if (!item.callbackMapping) return;
|
|
15713
|
+
var _iterator = _createForOfIteratorHelper$g(item.callbackMapping),
|
|
15714
|
+
_step;
|
|
15715
|
+
try {
|
|
15716
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15717
|
+
var map = _step.value;
|
|
15718
|
+
form === null || form === void 0 || form.setFieldValue(map.sourceField, data[map.targetField]);
|
|
15719
|
+
}
|
|
15720
|
+
} catch (err) {
|
|
15721
|
+
_iterator.e(err);
|
|
15722
|
+
} finally {
|
|
15723
|
+
_iterator.f();
|
|
15724
|
+
}
|
|
15725
|
+
},
|
|
15726
|
+
title: item.action.label,
|
|
15727
|
+
type: item.action.type,
|
|
15728
|
+
description: item.action.description,
|
|
15729
|
+
footer: item.action.footer,
|
|
15730
|
+
width: item.action.width
|
|
15731
|
+
});
|
|
15732
|
+
},
|
|
15733
|
+
style: {
|
|
15734
|
+
width: '40%',
|
|
15735
|
+
marginLeft: '25%'
|
|
15736
|
+
},
|
|
15737
|
+
disabled: disabled,
|
|
15738
|
+
children: item.label
|
|
15739
|
+
});
|
|
15740
|
+
case 'richText':
|
|
15741
|
+
return /*#__PURE__*/jsx(RichTextEditor, {
|
|
15742
|
+
initValue: state.getData(name, data),
|
|
15743
|
+
name: name,
|
|
15744
|
+
onChange: _onChange
|
|
15745
|
+
});
|
|
15746
|
+
case 'number':
|
|
15747
|
+
return /*#__PURE__*/jsx(InputNumber, {
|
|
15748
|
+
disabled: disabled,
|
|
15749
|
+
value: item.value
|
|
15750
|
+
});
|
|
15751
|
+
case 'checkbox':
|
|
15752
|
+
return /*#__PURE__*/jsx(Checkbox, {
|
|
15753
|
+
disabled: disabled,
|
|
15754
|
+
value: item.value,
|
|
15755
|
+
onChange: function onChange(e) {
|
|
15756
|
+
var value = e.target.checked;
|
|
15757
|
+
var cbItem = item;
|
|
15758
|
+
if (value && cbItem !== null && cbItem !== void 0 && cbItem.valueOnEnabled) {
|
|
15759
|
+
value = root === null || root === void 0 ? void 0 : root.getGlobalValue(cbItem.valueOnEnabled.globalValue);
|
|
15760
|
+
}
|
|
15761
|
+
_onChange(name, value);
|
|
15762
|
+
}
|
|
15763
|
+
});
|
|
15764
|
+
case 'display':
|
|
15765
|
+
return /*#__PURE__*/jsx(DisplayInput, {
|
|
15766
|
+
translationPrefix: item.translationPrefix
|
|
15767
|
+
});
|
|
15768
|
+
case 'array':
|
|
15769
|
+
return /*#__PURE__*/jsx(FormList$3, {
|
|
15770
|
+
item: item,
|
|
15771
|
+
data: data,
|
|
15772
|
+
state: state,
|
|
15773
|
+
onError: _onError,
|
|
15774
|
+
root: root,
|
|
15775
|
+
setCanSave: setCanSave,
|
|
15776
|
+
form: form
|
|
15777
|
+
});
|
|
15778
|
+
case 'object':
|
|
15779
|
+
return /*#__PURE__*/jsx(JsonEditor$2, {
|
|
15780
|
+
setCanSave: setCanSave,
|
|
15781
|
+
data: data,
|
|
15782
|
+
height: item.height,
|
|
15783
|
+
savable: true
|
|
15784
|
+
});
|
|
15785
|
+
case 'date':
|
|
15786
|
+
return /*#__PURE__*/jsx(DatePicker, {
|
|
15787
|
+
disabled: disabled
|
|
15788
|
+
});
|
|
15789
|
+
case 'subTitle':
|
|
15790
|
+
return /*#__PURE__*/jsx(SubTitle$1, {
|
|
15791
|
+
item: item,
|
|
15792
|
+
data: data
|
|
15793
|
+
});
|
|
15794
|
+
case 'apiKey':
|
|
15795
|
+
return /*#__PURE__*/jsx(ApiKey, {
|
|
15796
|
+
value: item.value,
|
|
15797
|
+
placeholder: item.placeholder
|
|
15798
|
+
});
|
|
15799
|
+
case 'selectClientRelationCatalog':
|
|
15800
|
+
return /*#__PURE__*/jsx("div", {
|
|
15801
|
+
style: {
|
|
15802
|
+
display: 'flex',
|
|
15803
|
+
gap: 16
|
|
15804
|
+
},
|
|
15805
|
+
children: /*#__PURE__*/jsx(SelectClientRelationCatalog, {
|
|
15806
|
+
dontLoadCatalogData: true,
|
|
15807
|
+
onSelectedSupplier: function onSelectedSupplier(supplier) {
|
|
15808
|
+
if (item.accountName) {
|
|
15809
|
+
var newData = state.onInputChanged(item.accountName, supplier === null || supplier === void 0 ? void 0 : supplier._id);
|
|
15810
|
+
if (!supplier) {
|
|
15811
|
+
newData = state.onInputChanged(name, undefined, newData);
|
|
15812
|
+
if (item.catalogCodex) state.onInputChanged(item.catalogCodex, undefined, newData);
|
|
15813
|
+
}
|
|
15814
|
+
}
|
|
15815
|
+
},
|
|
15816
|
+
initAccountId: item.accountName ? state.getData(item.accountName, data) : undefined,
|
|
15817
|
+
initCatalogId: state.getData(name, data),
|
|
15818
|
+
currentOrganizationId: data._id,
|
|
15819
|
+
onSelectedCatalog: function onSelectedCatalog(catalogItem) {
|
|
15820
|
+
var newData = state.onInputChanged(name, catalogItem === null || catalogItem === void 0 ? void 0 : catalogItem._id);
|
|
15821
|
+
if (item.catalogCodex) state.onInputChanged(item.catalogCodex, catalogItem === null || catalogItem === void 0 ? void 0 : catalogItem.codex, newData);
|
|
15822
|
+
},
|
|
15823
|
+
onError: function onError(text) {
|
|
15824
|
+
return _onError(text, text);
|
|
15825
|
+
},
|
|
15826
|
+
apiInterface: item.apiInterface
|
|
15827
|
+
})
|
|
15828
|
+
});
|
|
15829
|
+
case 'radio':
|
|
15830
|
+
return /*#__PURE__*/jsx(Radio.Group, {
|
|
15831
|
+
value: item.value,
|
|
15832
|
+
options: item.options.map(function (o) {
|
|
15833
|
+
var _o$disabled;
|
|
15834
|
+
return _objectSpread$z(_objectSpread$z({}, o), {}, {
|
|
15835
|
+
disabled: (_o$disabled = o.disabled) === null || _o$disabled === void 0 ? void 0 : _o$disabled.call(o, data)
|
|
15836
|
+
});
|
|
15837
|
+
}),
|
|
15838
|
+
buttonStyle: item.buttonStyle,
|
|
15839
|
+
optionType: item.optionType,
|
|
15840
|
+
defaultValue: item.defaultValue,
|
|
15841
|
+
onChange: function onChange(_ref) {
|
|
15842
|
+
var value = _ref.target.value;
|
|
15843
|
+
_onChange(name, value);
|
|
15844
|
+
}
|
|
15845
|
+
});
|
|
15846
|
+
case 'button':
|
|
15847
|
+
return /*#__PURE__*/jsx(CustomButton$1, {
|
|
15848
|
+
id: item.buttonId,
|
|
15849
|
+
data: data,
|
|
15850
|
+
useActionResult: {
|
|
15851
|
+
styles: true,
|
|
15852
|
+
message: true
|
|
15853
|
+
},
|
|
15854
|
+
icon: item.icon,
|
|
15855
|
+
callback: function callback(data) {
|
|
15856
|
+
return form === null || form === void 0 ? void 0 : form.setFieldsValue(_objectSpread$z(_objectSpread$z({}, state.data), data));
|
|
15857
|
+
}
|
|
15858
|
+
});
|
|
15859
|
+
default:
|
|
15860
|
+
return /*#__PURE__*/jsx(Fragment, {});
|
|
15861
|
+
}
|
|
15862
|
+
}
|
|
15863
|
+
function DisplayInput(props) {
|
|
15864
|
+
var _useTranslation = useTranslation(),
|
|
15865
|
+
t = _useTranslation.t;
|
|
15866
|
+
return /*#__PURE__*/jsx(Input, _objectSpread$z(_objectSpread$z({}, props), {}, {
|
|
15867
|
+
disabled: true,
|
|
15868
|
+
value: t(props.translationPrefix + '.' + props.value)
|
|
15869
|
+
}));
|
|
15870
|
+
}
|
|
15871
|
+
function isReadonly(item, data) {
|
|
15872
|
+
if (_typeof(item.readonly) != 'object') {
|
|
15873
|
+
return item.readonly;
|
|
15874
|
+
}
|
|
15875
|
+
var flatData = flatten(data);
|
|
15876
|
+
if (!item.readonly.op && flatData[item.readonly.field] == item.readonly.value) {
|
|
15877
|
+
return true;
|
|
15878
|
+
} else if (item.readonly.op == 'gt' && flatData[item.readonly.field] > item.readonly.value) {
|
|
15879
|
+
return true;
|
|
15880
|
+
}
|
|
15881
|
+
return false;
|
|
15882
|
+
}
|
|
15883
|
+
|
|
15884
|
+
function ownKeys$y(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15885
|
+
function _objectSpread$y(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$y(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$y(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15886
|
+
function _createForOfIteratorHelper$f(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$f(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15887
|
+
function _unsupportedIterableToArray$f(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$f(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$f(r, a) : void 0; } }
|
|
15888
|
+
function _arrayLikeToArray$f(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15889
|
+
var Presets = function Presets(_ref) {
|
|
15890
|
+
var state = _ref.state,
|
|
15891
|
+
apiHandler = _ref.apiHandler,
|
|
15892
|
+
form = _ref.form,
|
|
15893
|
+
root = _ref.root,
|
|
15894
|
+
setUsedPreset = _ref.setUsedPreset,
|
|
15895
|
+
presets = _ref.presets,
|
|
15896
|
+
setPresets = _ref.setPresets;
|
|
15897
|
+
var Option = Select$1.Option;
|
|
15898
|
+
var _useState = useState(false),
|
|
15899
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15900
|
+
isModalVisible = _useState2[0],
|
|
15901
|
+
setIsModalVisible = _useState2[1];
|
|
15902
|
+
var _useState3 = useState(''),
|
|
15903
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
15904
|
+
newPresetName = _useState4[0],
|
|
15905
|
+
setNewPresetName = _useState4[1];
|
|
15906
|
+
var _useState5 = useState(),
|
|
15907
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
15908
|
+
value = _useState6[0],
|
|
15909
|
+
setValue = _useState6[1];
|
|
15910
|
+
var _useState7 = useState([]),
|
|
15911
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
15912
|
+
presetIds = _useState8[0],
|
|
15913
|
+
setPresetIds = _useState8[1];
|
|
15914
|
+
var _useTranslation = useTranslation$1(),
|
|
15915
|
+
t = _useTranslation.t;
|
|
15916
|
+
useEffect(function () {
|
|
15917
|
+
getPresets();
|
|
15918
|
+
}, []);
|
|
15919
|
+
var savePreset = function savePreset() {
|
|
15920
|
+
if (state.selectedItems == undefined) return;
|
|
15921
|
+
setIsModalVisible(false);
|
|
15922
|
+
var names = [];
|
|
15923
|
+
var _iterator = _createForOfIteratorHelper$f(state.selectedItems),
|
|
15924
|
+
_step;
|
|
15925
|
+
try {
|
|
15926
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15927
|
+
var item = _step.value;
|
|
15928
|
+
names.push(item.name);
|
|
15929
|
+
}
|
|
15930
|
+
} catch (err) {
|
|
15931
|
+
_iterator.e(err);
|
|
15932
|
+
} finally {
|
|
15933
|
+
_iterator.f();
|
|
15597
15934
|
}
|
|
15935
|
+
var data = _objectSpread$y(_objectSpread$y({}, form.getFieldsValue(names)), {}, {
|
|
15936
|
+
newPresetName: newPresetName
|
|
15937
|
+
});
|
|
15938
|
+
data.dpi = parseInt(data.dpi);
|
|
15939
|
+
data.organization = root.getGlobalValue('organizationId');
|
|
15940
|
+
apiHandler.create({}, state.configuration.createPresetMapping, data);
|
|
15941
|
+
var dt = _objectSpread$y(_objectSpread$y({}, form.getFieldsValue(names)), {}, {
|
|
15942
|
+
name: newPresetName
|
|
15943
|
+
});
|
|
15944
|
+
setPresets({
|
|
15945
|
+
data: [dt].concat(_toConsumableArray(presets.data)),
|
|
15946
|
+
total: presets.total
|
|
15947
|
+
});
|
|
15948
|
+
};
|
|
15949
|
+
var getPresets = /*#__PURE__*/function () {
|
|
15950
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
15951
|
+
var res, ids, preset;
|
|
15952
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15953
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15954
|
+
case 0:
|
|
15955
|
+
_context.next = 2;
|
|
15956
|
+
return apiHandler.readList();
|
|
15957
|
+
case 2:
|
|
15958
|
+
res = _context.sent;
|
|
15959
|
+
ids = [];
|
|
15960
|
+
for (preset in res.data) {
|
|
15961
|
+
ids.push(res.data[preset]._id);
|
|
15962
|
+
delete res.data[preset]._id;
|
|
15963
|
+
}
|
|
15964
|
+
setPresetIds(ids);
|
|
15965
|
+
setPresets(res);
|
|
15966
|
+
case 7:
|
|
15967
|
+
case "end":
|
|
15968
|
+
return _context.stop();
|
|
15969
|
+
}
|
|
15970
|
+
}, _callee);
|
|
15971
|
+
}));
|
|
15972
|
+
return function getPresets() {
|
|
15973
|
+
return _ref2.apply(this, arguments);
|
|
15974
|
+
};
|
|
15975
|
+
}();
|
|
15976
|
+
var onPresetSelect = function onPresetSelect(index) {
|
|
15977
|
+
var preset = presets.data[index];
|
|
15978
|
+
if (!state.selectedItems) return;
|
|
15979
|
+
state.selectedItems.map(function (item) {
|
|
15980
|
+
if (isReadonly(item, form.getFieldsValue())) {
|
|
15981
|
+
delete preset[item.name];
|
|
15982
|
+
}
|
|
15983
|
+
});
|
|
15984
|
+
form.setFieldsValue(presets.data[index]);
|
|
15985
|
+
setUsedPreset({
|
|
15986
|
+
used: true,
|
|
15987
|
+
index: index
|
|
15988
|
+
});
|
|
15989
|
+
};
|
|
15990
|
+
var deletePreset = function deletePreset(index) {
|
|
15991
|
+
apiHandler["delete"](presetIds[index]);
|
|
15992
|
+
var data = presets.data;
|
|
15993
|
+
data.splice(index, 1);
|
|
15994
|
+
setPresets({
|
|
15995
|
+
data: data,
|
|
15996
|
+
total: presets.total
|
|
15997
|
+
});
|
|
15998
|
+
setValue(undefined);
|
|
15999
|
+
};
|
|
16000
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
16001
|
+
children: [/*#__PURE__*/jsx(Select$1, {
|
|
16002
|
+
showSearch: true,
|
|
16003
|
+
value: value,
|
|
16004
|
+
placeholder: t('backoffice.form.presets.placeholder'),
|
|
16005
|
+
optionFilterProp: "children",
|
|
16006
|
+
style: {
|
|
16007
|
+
width: '94%',
|
|
16008
|
+
paddingLeft: 0,
|
|
16009
|
+
marginBottom: 30
|
|
16010
|
+
},
|
|
16011
|
+
onChange: function onChange(index) {
|
|
16012
|
+
setValue(index);
|
|
16013
|
+
onPresetSelect(index);
|
|
16014
|
+
},
|
|
16015
|
+
children: presets === null || presets === void 0 ? void 0 : presets.data.map(function (dt, idx) {
|
|
16016
|
+
return /*#__PURE__*/jsxs(Option, {
|
|
16017
|
+
value: idx,
|
|
16018
|
+
children: [dt.name, /*#__PURE__*/jsx(Button, {
|
|
16019
|
+
icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
|
|
16020
|
+
style: {
|
|
16021
|
+
"float": 'right'
|
|
16022
|
+
},
|
|
16023
|
+
onClick: function onClick() {
|
|
16024
|
+
return deletePreset(idx);
|
|
16025
|
+
}
|
|
16026
|
+
})]
|
|
16027
|
+
}, idx);
|
|
16028
|
+
})
|
|
16029
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
16030
|
+
type: "primary",
|
|
16031
|
+
onClick: function onClick() {
|
|
16032
|
+
return setIsModalVisible(true);
|
|
16033
|
+
},
|
|
16034
|
+
children: "Create"
|
|
16035
|
+
}), /*#__PURE__*/jsx(Modal$2, {
|
|
16036
|
+
title: "Create Preset",
|
|
16037
|
+
visible: isModalVisible,
|
|
16038
|
+
onOk: function onOk(e) {
|
|
16039
|
+
return savePreset();
|
|
16040
|
+
},
|
|
16041
|
+
onCancel: function onCancel() {
|
|
16042
|
+
return setIsModalVisible(false);
|
|
16043
|
+
},
|
|
16044
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
16045
|
+
value: newPresetName,
|
|
16046
|
+
placeholder: "Preset Name",
|
|
16047
|
+
onChange: function onChange(e) {
|
|
16048
|
+
setNewPresetName(e.target.value);
|
|
16049
|
+
},
|
|
16050
|
+
style: {
|
|
16051
|
+
marginBottom: 15
|
|
16052
|
+
}
|
|
16053
|
+
})
|
|
16054
|
+
})]
|
|
15598
16055
|
});
|
|
15599
16056
|
};
|
|
15600
16057
|
|
|
15601
|
-
function _createForOfIteratorHelper$f(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$f(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15602
|
-
function _unsupportedIterableToArray$f(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$f(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$f(r, a) : void 0; } }
|
|
15603
|
-
function _arrayLikeToArray$f(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15604
|
-
function ownKeys$y(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15605
|
-
function _objectSpread$y(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$y(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$y(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15606
16058
|
var LOG$7 = getLogger('Backoffice', 'Form');
|
|
15607
16059
|
var FormWrapper$1 = function FormWrapper(_ref, ref) {
|
|
15608
16060
|
var _state$selectedItems2;
|
|
@@ -15717,9 +16169,6 @@ var FormWrapper$1 = function FormWrapper(_ref, ref) {
|
|
|
15717
16169
|
return _ref4.apply(this, arguments);
|
|
15718
16170
|
};
|
|
15719
16171
|
}();
|
|
15720
|
-
var updateFormData = function updateFormData(data) {
|
|
15721
|
-
form.setFieldsValue(_objectSpread$y(_objectSpread$y({}, state.data), data));
|
|
15722
|
-
};
|
|
15723
16172
|
var onErrorInternal = function onErrorInternal(err, errorText) {
|
|
15724
16173
|
if (err instanceof DivaError && err.name) {
|
|
15725
16174
|
var _state$configuration$;
|
|
@@ -15750,263 +16199,6 @@ var FormWrapper$1 = function FormWrapper(_ref, ref) {
|
|
|
15750
16199
|
onErrorInternal('An unexpected error prevented finishing');
|
|
15751
16200
|
}
|
|
15752
16201
|
};
|
|
15753
|
-
function getRules(item, data) {
|
|
15754
|
-
var _item$rules;
|
|
15755
|
-
var rules = [];
|
|
15756
|
-
if (item.required != undefined) {
|
|
15757
|
-
var _state$hiddenRequired;
|
|
15758
|
-
rules.push({
|
|
15759
|
-
required: (_state$hiddenRequired = state.hiddenRequiredDisabled[typeof item.name == 'string' ? item.name : item.name.join('.')]) === null || _state$hiddenRequired === void 0 ? void 0 : _state$hiddenRequired.required
|
|
15760
|
-
});
|
|
15761
|
-
}
|
|
15762
|
-
if (((_item$rules = item.rules) === null || _item$rules === void 0 ? void 0 : _item$rules.type) == 'condition') {
|
|
15763
|
-
var condition = item.rules;
|
|
15764
|
-
var flatData = flatten(data);
|
|
15765
|
-
if (!condition.match.op && flatData[condition.match.field] == condition.match.value) {
|
|
15766
|
-
rules.push.apply(rules, _toConsumableArray(condition.rules));
|
|
15767
|
-
} else if (condition.match.op == 'gt' && flatData[condition.match.field] > condition.match.value) {
|
|
15768
|
-
rules.push.apply(rules, _toConsumableArray(condition.rules));
|
|
15769
|
-
}
|
|
15770
|
-
} else if (item.rules) {
|
|
15771
|
-
rules.push.apply(rules, _toConsumableArray(item.rules));
|
|
15772
|
-
}
|
|
15773
|
-
return rules;
|
|
15774
|
-
}
|
|
15775
|
-
function getLabel(item) {
|
|
15776
|
-
if (!item.label && item.type === 'button') return undefined;
|
|
15777
|
-
return item.label ? t(item.label, item.label) : item.name;
|
|
15778
|
-
}
|
|
15779
|
-
function getElement(item, data, setCanSave, state, _onChange, root, form, hidden, overwrittenName) {
|
|
15780
|
-
var _isReadonly, _state$hiddenRequired2;
|
|
15781
|
-
if (hidden) return /*#__PURE__*/jsx(Fragment, {});
|
|
15782
|
-
var name = overwrittenName || item.name;
|
|
15783
|
-
var disabled = (_isReadonly = isReadonly(item, data)) !== null && _isReadonly !== void 0 ? _isReadonly : (_state$hiddenRequired2 = state.hiddenRequiredDisabled[typeof name == 'string' ? name : name.join('.')]) === null || _state$hiddenRequired2 === void 0 ? void 0 : _state$hiddenRequired2.disabled;
|
|
15784
|
-
switch (item.type) {
|
|
15785
|
-
case 'select':
|
|
15786
|
-
return /*#__PURE__*/jsx(Select, {
|
|
15787
|
-
initialValue: item.defaultValue,
|
|
15788
|
-
apiInterface: item.apiInterface,
|
|
15789
|
-
mode: item.mode,
|
|
15790
|
-
useFirstValueAsDefault: item.useFirstValueAsDefault,
|
|
15791
|
-
canSetToUndefined: item.canSetToUndefined,
|
|
15792
|
-
selectMapping: item.selectMapping,
|
|
15793
|
-
mapping: item.mapping,
|
|
15794
|
-
allowCreate: item.allowCreate,
|
|
15795
|
-
flow: item.flow,
|
|
15796
|
-
translationPrefix: item.translationPrefix,
|
|
15797
|
-
values: item.values,
|
|
15798
|
-
search: item.search,
|
|
15799
|
-
disabled: disabled,
|
|
15800
|
-
wholeData: state.data,
|
|
15801
|
-
disabledConfig: item === null || item === void 0 ? void 0 : item['disabledSelection'],
|
|
15802
|
-
onChange: function onChange(value) {
|
|
15803
|
-
_onChange(name, item.valueField ? value[item.valueField] : value);
|
|
15804
|
-
},
|
|
15805
|
-
allowClear: item.allowClear,
|
|
15806
|
-
placeholder: item.placeholder,
|
|
15807
|
-
onError: function onError(text) {
|
|
15808
|
-
return onErrorInternal(text, text);
|
|
15809
|
-
}
|
|
15810
|
-
}, state.selectedItemsIndex);
|
|
15811
|
-
case 'selectSimple':
|
|
15812
|
-
return /*#__PURE__*/jsx(SimpleSelect, _objectSpread$y(_objectSpread$y({}, item), {}, {
|
|
15813
|
-
disabled: disabled,
|
|
15814
|
-
onChange: function onChange(value) {
|
|
15815
|
-
_onChange(name, value);
|
|
15816
|
-
}
|
|
15817
|
-
}));
|
|
15818
|
-
case 'textarea':
|
|
15819
|
-
return /*#__PURE__*/jsx(Input.TextArea, {
|
|
15820
|
-
disabled: disabled,
|
|
15821
|
-
autoSize: {
|
|
15822
|
-
minRows: 2,
|
|
15823
|
-
maxRows: 5
|
|
15824
|
-
},
|
|
15825
|
-
defaultValue: item.value,
|
|
15826
|
-
placeholder: item.placeholder,
|
|
15827
|
-
onChange: function onChange(e) {
|
|
15828
|
-
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(name, e.target.value);
|
|
15829
|
-
}
|
|
15830
|
-
});
|
|
15831
|
-
case 'input':
|
|
15832
|
-
case 'password':
|
|
15833
|
-
case undefined:
|
|
15834
|
-
if (item.syncDataWithUserInput) {
|
|
15835
|
-
return /*#__PURE__*/jsx(InputComponent$1, {
|
|
15836
|
-
item: item,
|
|
15837
|
-
data: data,
|
|
15838
|
-
value: item.value,
|
|
15839
|
-
onChange: state.onInputChanged
|
|
15840
|
-
});
|
|
15841
|
-
}
|
|
15842
|
-
if (item.type == 'password') return /*#__PURE__*/jsx(Input.Password, {
|
|
15843
|
-
addonBefore: item.prefix,
|
|
15844
|
-
addonAfter: item.suffix,
|
|
15845
|
-
disabled: disabled,
|
|
15846
|
-
value: item.value,
|
|
15847
|
-
placeholder: item.placeholder,
|
|
15848
|
-
autoComplete: "new-password"
|
|
15849
|
-
});
|
|
15850
|
-
return /*#__PURE__*/jsx(Input, {
|
|
15851
|
-
addonBefore: item.prefix,
|
|
15852
|
-
addonAfter: item.suffix,
|
|
15853
|
-
disabled: disabled,
|
|
15854
|
-
value: item.value,
|
|
15855
|
-
placeholder: item.placeholder
|
|
15856
|
-
});
|
|
15857
|
-
case 'detailaction':
|
|
15858
|
-
return /*#__PURE__*/jsx(Button, {
|
|
15859
|
-
onClick: function onClick() {
|
|
15860
|
-
var _root$detailStore$ope, _root$detailStore;
|
|
15861
|
-
return root === null || root === void 0 || (_root$detailStore$ope = (_root$detailStore = root.detailStore).openLeftDetail) === null || _root$detailStore$ope === void 0 ? void 0 : _root$detailStore$ope.call(_root$detailStore, {
|
|
15862
|
-
configurationId: item.action.id,
|
|
15863
|
-
data: data,
|
|
15864
|
-
mappingData: data,
|
|
15865
|
-
callback: function callback(data) {
|
|
15866
|
-
if (!item.callbackMapping) return;
|
|
15867
|
-
var _iterator = _createForOfIteratorHelper$f(item.callbackMapping),
|
|
15868
|
-
_step;
|
|
15869
|
-
try {
|
|
15870
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15871
|
-
var map = _step.value;
|
|
15872
|
-
form === null || form === void 0 || form.setFieldValue(map.sourceField, data[map.targetField]);
|
|
15873
|
-
}
|
|
15874
|
-
} catch (err) {
|
|
15875
|
-
_iterator.e(err);
|
|
15876
|
-
} finally {
|
|
15877
|
-
_iterator.f();
|
|
15878
|
-
}
|
|
15879
|
-
},
|
|
15880
|
-
title: item.action.label,
|
|
15881
|
-
type: item.action.type,
|
|
15882
|
-
description: item.action.description,
|
|
15883
|
-
footer: item.action.footer,
|
|
15884
|
-
width: item.action.width
|
|
15885
|
-
});
|
|
15886
|
-
},
|
|
15887
|
-
style: {
|
|
15888
|
-
width: '40%',
|
|
15889
|
-
marginLeft: '25%'
|
|
15890
|
-
},
|
|
15891
|
-
disabled: disabled,
|
|
15892
|
-
children: item.label
|
|
15893
|
-
});
|
|
15894
|
-
case 'richText':
|
|
15895
|
-
return /*#__PURE__*/jsx(RichTextEditor, {
|
|
15896
|
-
initValue: state.getData(name, data),
|
|
15897
|
-
name: name,
|
|
15898
|
-
onChange: _onChange
|
|
15899
|
-
});
|
|
15900
|
-
case 'number':
|
|
15901
|
-
return /*#__PURE__*/jsx(InputNumber, {
|
|
15902
|
-
disabled: disabled,
|
|
15903
|
-
value: item.value
|
|
15904
|
-
});
|
|
15905
|
-
case 'checkbox':
|
|
15906
|
-
return /*#__PURE__*/jsx(Checkbox, {
|
|
15907
|
-
disabled: disabled,
|
|
15908
|
-
value: item.value,
|
|
15909
|
-
onChange: function onChange(e) {
|
|
15910
|
-
var value = e.target.checked;
|
|
15911
|
-
var cbItem = item;
|
|
15912
|
-
if (value && cbItem !== null && cbItem !== void 0 && cbItem.valueOnEnabled) {
|
|
15913
|
-
value = root === null || root === void 0 ? void 0 : root.getGlobalValue(cbItem.valueOnEnabled.globalValue);
|
|
15914
|
-
}
|
|
15915
|
-
_onChange(name, value);
|
|
15916
|
-
}
|
|
15917
|
-
});
|
|
15918
|
-
case 'display':
|
|
15919
|
-
return /*#__PURE__*/jsx(DisplayInput, {
|
|
15920
|
-
translationPrefix: item.translationPrefix
|
|
15921
|
-
});
|
|
15922
|
-
case 'array':
|
|
15923
|
-
return /*#__PURE__*/jsx(FormList, {
|
|
15924
|
-
item: item,
|
|
15925
|
-
data: data
|
|
15926
|
-
});
|
|
15927
|
-
case 'object':
|
|
15928
|
-
return /*#__PURE__*/jsx(JsonEditor$2, {
|
|
15929
|
-
setCanSave: setCanSave,
|
|
15930
|
-
data: data,
|
|
15931
|
-
height: item.height,
|
|
15932
|
-
savable: true
|
|
15933
|
-
});
|
|
15934
|
-
case 'date':
|
|
15935
|
-
return /*#__PURE__*/jsx(DatePicker, {
|
|
15936
|
-
disabled: disabled
|
|
15937
|
-
});
|
|
15938
|
-
case 'subTitle':
|
|
15939
|
-
return /*#__PURE__*/jsx(SubTitle$1, {
|
|
15940
|
-
item: item,
|
|
15941
|
-
data: data
|
|
15942
|
-
});
|
|
15943
|
-
case 'apiKey':
|
|
15944
|
-
return /*#__PURE__*/jsx(ApiKey, {
|
|
15945
|
-
value: item.value,
|
|
15946
|
-
placeholder: item.placeholder
|
|
15947
|
-
});
|
|
15948
|
-
case 'selectClientRelationCatalog':
|
|
15949
|
-
return /*#__PURE__*/jsx("div", {
|
|
15950
|
-
style: {
|
|
15951
|
-
display: 'flex',
|
|
15952
|
-
gap: 16
|
|
15953
|
-
},
|
|
15954
|
-
children: /*#__PURE__*/jsx(SelectClientRelationCatalog, {
|
|
15955
|
-
dontLoadCatalogData: true,
|
|
15956
|
-
onSelectedSupplier: function onSelectedSupplier(supplier) {
|
|
15957
|
-
if (item.accountName) {
|
|
15958
|
-
var newData = state.onInputChanged(item.accountName, supplier === null || supplier === void 0 ? void 0 : supplier._id);
|
|
15959
|
-
if (!supplier) {
|
|
15960
|
-
newData = state.onInputChanged(name, undefined, newData);
|
|
15961
|
-
if (item.catalogCodex) state.onInputChanged(item.catalogCodex, undefined, newData);
|
|
15962
|
-
}
|
|
15963
|
-
}
|
|
15964
|
-
},
|
|
15965
|
-
initAccountId: item.accountName ? state.getData(item.accountName, data) : undefined,
|
|
15966
|
-
initCatalogId: state.getData(name, data),
|
|
15967
|
-
currentOrganizationId: data._id,
|
|
15968
|
-
onSelectedCatalog: function onSelectedCatalog(catalogItem) {
|
|
15969
|
-
var newData = state.onInputChanged(name, catalogItem === null || catalogItem === void 0 ? void 0 : catalogItem._id);
|
|
15970
|
-
if (item.catalogCodex) state.onInputChanged(item.catalogCodex, catalogItem === null || catalogItem === void 0 ? void 0 : catalogItem.codex, newData);
|
|
15971
|
-
},
|
|
15972
|
-
onError: function onError(text) {
|
|
15973
|
-
return onErrorInternal(text, text);
|
|
15974
|
-
},
|
|
15975
|
-
apiInterface: item.apiInterface
|
|
15976
|
-
})
|
|
15977
|
-
});
|
|
15978
|
-
case 'radio':
|
|
15979
|
-
return /*#__PURE__*/jsx(Radio.Group, {
|
|
15980
|
-
value: item.value,
|
|
15981
|
-
options: item.options.map(function (o) {
|
|
15982
|
-
var _o$disabled;
|
|
15983
|
-
return _objectSpread$y(_objectSpread$y({}, o), {}, {
|
|
15984
|
-
disabled: (_o$disabled = o.disabled) === null || _o$disabled === void 0 ? void 0 : _o$disabled.call(o, data)
|
|
15985
|
-
});
|
|
15986
|
-
}),
|
|
15987
|
-
buttonStyle: item.buttonStyle,
|
|
15988
|
-
optionType: item.optionType,
|
|
15989
|
-
defaultValue: item.defaultValue,
|
|
15990
|
-
onChange: function onChange(_ref7) {
|
|
15991
|
-
var value = _ref7.target.value;
|
|
15992
|
-
_onChange(name, value);
|
|
15993
|
-
}
|
|
15994
|
-
});
|
|
15995
|
-
case 'button':
|
|
15996
|
-
return /*#__PURE__*/jsx(CustomButton$1, {
|
|
15997
|
-
id: item.buttonId,
|
|
15998
|
-
data: data,
|
|
15999
|
-
useActionResult: {
|
|
16000
|
-
styles: true,
|
|
16001
|
-
message: true
|
|
16002
|
-
},
|
|
16003
|
-
icon: item.icon,
|
|
16004
|
-
callback: updateFormData
|
|
16005
|
-
});
|
|
16006
|
-
default:
|
|
16007
|
-
return /*#__PURE__*/jsx(Fragment, {});
|
|
16008
|
-
}
|
|
16009
|
-
}
|
|
16010
16202
|
return /*#__PURE__*/jsxs(Spin, {
|
|
16011
16203
|
spinning: state.loading,
|
|
16012
16204
|
children: [state.configuration.presetApiInterface && /*#__PURE__*/jsx(Presets, {
|
|
@@ -16035,125 +16227,37 @@ var FormWrapper$1 = function FormWrapper(_ref, ref) {
|
|
|
16035
16227
|
},
|
|
16036
16228
|
children: [state.configuration.itemSelector && /*#__PURE__*/jsx(Form$1.Item, {
|
|
16037
16229
|
name: state.configuration.itemSelector.name,
|
|
16038
|
-
rules: getRules(state.configuration.itemSelector, state.data),
|
|
16230
|
+
rules: state.getRules(state.configuration.itemSelector, state.data),
|
|
16039
16231
|
label: state.configuration.itemSelector.label ? t(state.configuration.itemSelector.label, state.configuration.itemSelector.label) : state.configuration.itemSelector.name,
|
|
16040
16232
|
valuePropName: state.configuration.itemSelector.type == 'checkbox' ? 'checked' : 'value',
|
|
16041
|
-
children: getElement(state.configuration.itemSelector, state.data, setCanSave, state, state.onItemSelectorChanged)
|
|
16233
|
+
children: getElement(state.configuration.itemSelector, state.data, setCanSave, state, state.onItemSelectorChanged, onErrorInternal)
|
|
16042
16234
|
}, state.configuration.itemSelector.name.toString()), (_state$selectedItems2 = state.selectedItems) === null || _state$selectedItems2 === void 0 ? void 0 : _state$selectedItems2.map(function (item) {
|
|
16043
|
-
var _state$
|
|
16235
|
+
var _state$hiddenRequired, _state$hiddenRequired2, _state$hiddenRequired3;
|
|
16044
16236
|
return /*#__PURE__*/jsxs("div", {
|
|
16045
|
-
children: [item.marker && /*#__PURE__*/jsx(InfoCircleOutlined, {}), ['subTitle', 'array'].includes(item.type) ? getElement(item, state.data, setCanSave, state, state.onInputChanged, undefined, undefined, (_state$
|
|
16237
|
+
children: [item.marker && /*#__PURE__*/jsx(InfoCircleOutlined, {}), ['subTitle', 'array'].includes(item.type) ? getElement(item, state.data, setCanSave, state, state.onInputChanged, onErrorInternal, undefined, undefined, (_state$hiddenRequired = state.hiddenRequiredDisabled[typeof item.name == 'string' ? item.name : item.name.join('.')]) === null || _state$hiddenRequired === void 0 ? void 0 : _state$hiddenRequired.hidden) : /*#__PURE__*/jsx(Form$1.Item, {
|
|
16046
16238
|
name: item.name,
|
|
16047
|
-
rules: getRules(item, state.data),
|
|
16048
|
-
label: getLabel(item),
|
|
16239
|
+
rules: state.getRules(item, state.data),
|
|
16240
|
+
label: getLabel(item, t),
|
|
16049
16241
|
valuePropName: item.type == 'checkbox' ? 'checked' : 'value',
|
|
16050
16242
|
initialValue: item === null || item === void 0 ? void 0 : item.defaultValue,
|
|
16051
16243
|
hasFeedback: !!state.fieldErrors[item.name.toString()],
|
|
16052
16244
|
validateStatus: !!state.fieldErrors[item.name.toString()] ? 'error' : undefined,
|
|
16053
16245
|
help: state.fieldErrors[item.name.toString()],
|
|
16054
|
-
hidden: (_state$
|
|
16055
|
-
children: getElement(item, state.data, setCanSave, state, state.onInputChanged, root, form, (_state$
|
|
16246
|
+
hidden: (_state$hiddenRequired2 = state.hiddenRequiredDisabled[typeof item.name == 'string' ? item.name : item.name.join('.')]) === null || _state$hiddenRequired2 === void 0 ? void 0 : _state$hiddenRequired2.hidden,
|
|
16247
|
+
children: getElement(item, state.data, setCanSave, state, state.onInputChanged, onErrorInternal, root, form, (_state$hiddenRequired3 = state.hiddenRequiredDisabled[typeof item.name == 'string' ? item.name : item.name.join('.')]) === null || _state$hiddenRequired3 === void 0 ? void 0 : _state$hiddenRequired3.hidden)
|
|
16056
16248
|
}, Array.isArray(item.name) ? item.name.join('.') : item.name)]
|
|
16057
16249
|
}, item.name.toString());
|
|
16058
16250
|
})]
|
|
16059
16251
|
})]
|
|
16060
16252
|
});
|
|
16061
|
-
function FormList(_ref8) {
|
|
16062
|
-
var item = _ref8.item,
|
|
16063
|
-
data = _ref8.data;
|
|
16064
|
-
return /*#__PURE__*/jsx(Form$1.List, {
|
|
16065
|
-
name: item.name,
|
|
16066
|
-
initialValue: item.initialValue,
|
|
16067
|
-
children: function children(fields, _ref9) {
|
|
16068
|
-
var add = _ref9.add,
|
|
16069
|
-
remove = _ref9.remove;
|
|
16070
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
16071
|
-
children: [fields.map(function (_ref10) {
|
|
16072
|
-
var key = _ref10.key,
|
|
16073
|
-
name = _ref10.name;
|
|
16074
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
16075
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
16076
|
-
style: {
|
|
16077
|
-
display: 'flex'
|
|
16078
|
-
},
|
|
16079
|
-
children: [/*#__PURE__*/jsx(MinusCircleOutlined, {
|
|
16080
|
-
onClick: function onClick() {
|
|
16081
|
-
return remove(name);
|
|
16082
|
-
}
|
|
16083
|
-
}), /*#__PURE__*/jsx("div", {
|
|
16084
|
-
style: {
|
|
16085
|
-
flexGrow: 1
|
|
16086
|
-
},
|
|
16087
|
-
children: item.items.map(function (i) {
|
|
16088
|
-
var _state$hiddenRequired6;
|
|
16089
|
-
var n = [name].concat(_toConsumableArray(Array.isArray(i.name) ? i.name : [i.name]));
|
|
16090
|
-
var hidden = !!i.hidden;
|
|
16091
|
-
if (i.hidden && data) {
|
|
16092
|
-
if (typeof i.hidden === 'function') {
|
|
16093
|
-
var _data;
|
|
16094
|
-
if ((_data = data[item.name]) !== null && _data !== void 0 && _data[n[0]]) {
|
|
16095
|
-
hidden = i.hidden(data[item.name][n[0]]);
|
|
16096
|
-
} else hidden = false;
|
|
16097
|
-
}
|
|
16098
|
-
}
|
|
16099
|
-
if (!hidden) hidden = (_state$hiddenRequired6 = state.hiddenRequiredDisabled[typeof n == 'string' ? n : n.join('.')]) === null || _state$hiddenRequired6 === void 0 ? void 0 : _state$hiddenRequired6.hidden;
|
|
16100
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
16101
|
-
children: /*#__PURE__*/jsx(Form$1.Item, {
|
|
16102
|
-
name: n,
|
|
16103
|
-
rules: getRules(i, state.data),
|
|
16104
|
-
label: getLabel(i),
|
|
16105
|
-
valuePropName: i.type == 'checkbox' ? 'checked' : 'value',
|
|
16106
|
-
initialValue: i === null || i === void 0 ? void 0 : i.defaultValue,
|
|
16107
|
-
hasFeedback: !!state.fieldErrors[n.toString()],
|
|
16108
|
-
validateStatus: !!state.fieldErrors[n.toString()] ? 'error' : undefined,
|
|
16109
|
-
help: state.fieldErrors[n.toString()],
|
|
16110
|
-
hidden: hidden,
|
|
16111
|
-
children: getElement(i, state.data, setCanSave, state, state.onInputChanged, root, form, hidden, [].concat(_toConsumableArray(item.name), _toConsumableArray(Array.isArray(n) ? n : [n])))
|
|
16112
|
-
}, key)
|
|
16113
|
-
});
|
|
16114
|
-
})
|
|
16115
|
-
})]
|
|
16116
|
-
})
|
|
16117
|
-
});
|
|
16118
|
-
}), /*#__PURE__*/jsx(Form$1.Item, {
|
|
16119
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
16120
|
-
type: "dashed",
|
|
16121
|
-
onClick: function onClick() {
|
|
16122
|
-
return add();
|
|
16123
|
-
},
|
|
16124
|
-
block: true,
|
|
16125
|
-
icon: /*#__PURE__*/jsx(PlusOutlined, {}),
|
|
16126
|
-
children: t('backoffice.add_field')
|
|
16127
|
-
})
|
|
16128
|
-
})]
|
|
16129
|
-
});
|
|
16130
|
-
}
|
|
16131
|
-
});
|
|
16132
|
-
}
|
|
16133
16253
|
};
|
|
16254
|
+
function getLabel(item, t) {
|
|
16255
|
+
if (!item.label && item.type === 'button') return undefined;
|
|
16256
|
+
return item.label ? t(item.label, item.label) : item.name;
|
|
16257
|
+
}
|
|
16134
16258
|
var Form = observer(FormWrapper$1, {
|
|
16135
16259
|
forwardRef: true
|
|
16136
16260
|
});
|
|
16137
|
-
function DisplayInput(props) {
|
|
16138
|
-
var _useTranslation2 = useTranslation$1(),
|
|
16139
|
-
t = _useTranslation2.t;
|
|
16140
|
-
return /*#__PURE__*/jsx(Input, _objectSpread$y(_objectSpread$y({}, props), {}, {
|
|
16141
|
-
disabled: true,
|
|
16142
|
-
value: t(props.translationPrefix + '.' + props.value)
|
|
16143
|
-
}));
|
|
16144
|
-
}
|
|
16145
|
-
function isReadonly(item, data) {
|
|
16146
|
-
if (_typeof(item.readonly) != 'object') {
|
|
16147
|
-
return item.readonly;
|
|
16148
|
-
}
|
|
16149
|
-
var flatData = flatten(data);
|
|
16150
|
-
if (!item.readonly.op && flatData[item.readonly.field] == item.readonly.value) {
|
|
16151
|
-
return true;
|
|
16152
|
-
} else if (item.readonly.op == 'gt' && flatData[item.readonly.field] > item.readonly.value) {
|
|
16153
|
-
return true;
|
|
16154
|
-
}
|
|
16155
|
-
return false;
|
|
16156
|
-
}
|
|
16157
16261
|
|
|
16158
16262
|
function ownKeys$x(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16159
16263
|
function _objectSpread$x(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$x(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$x(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -20111,7 +20215,7 @@ function _createForOfIteratorHelper$8(r, e) { var t = "undefined" != typeof Symb
|
|
|
20111
20215
|
function _unsupportedIterableToArray$8(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$8(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$8(r, a) : void 0; } }
|
|
20112
20216
|
function _arrayLikeToArray$8(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
20113
20217
|
var FileUploadWrapper = function FileUploadWrapper(_ref) {
|
|
20114
|
-
_ref.id;
|
|
20218
|
+
var id = _ref.id;
|
|
20115
20219
|
var _useDivaCore = useDivaCore(),
|
|
20116
20220
|
apiConfig = _useDivaCore.state.apiConfig;
|
|
20117
20221
|
var root = useStore();
|
|
@@ -20250,7 +20354,7 @@ var FileUploadWrapper = function FileUploadWrapper(_ref) {
|
|
|
20250
20354
|
return dt._id;
|
|
20251
20355
|
}));
|
|
20252
20356
|
}
|
|
20253
|
-
})
|
|
20357
|
+
}, id)
|
|
20254
20358
|
}), /*#__PURE__*/jsx(Button, {
|
|
20255
20359
|
htmlType: "submit",
|
|
20256
20360
|
type: "primary",
|
|
@@ -20591,7 +20695,8 @@ function getExpandedRowRenderer (config, root) {
|
|
|
20591
20695
|
var editableRow = "editable-row-9BEHi";
|
|
20592
20696
|
var checkbox = "checkbox-H7R-w";
|
|
20593
20697
|
var editableCellValueWrap = "editable-cell-value-wrap-ugTs4";
|
|
20594
|
-
var
|
|
20698
|
+
var contentWidth = "content-width-hGyVI";
|
|
20699
|
+
var css_248z$c = ".checkbox-readonly-0-bzT {\n cursor: default;\n}\n\n.checkbox-readonly-0-bzT .ant-checkbox-input {\n cursor: default;\n}\n\n.checkbox-readonly-0-bzT .ant-checkbox {\n cursor: default;\n}\n\n.editable-row-9BEHi:hover .checkbox-H7R-w .ant-checkbox {\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);\n}\n\n.editable-cell-value-wrap-ugTs4 {\n padding: 5px 12px;\n cursor: pointer;\n}\n\n.editable-row-9BEHi:hover .editable-cell-value-wrap-ugTs4 {\n padding: 4px 11px;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n}\n\n.content-width-hGyVI .ant-modal-confirm-content {\n width: 100%;\n}\n";
|
|
20595
20700
|
styleInject(css_248z$c);
|
|
20596
20701
|
|
|
20597
20702
|
function BooleanCell (_ref) {
|
|
@@ -20812,6 +20917,7 @@ function TextCell (_ref) {
|
|
|
20812
20917
|
onCancel: function onCancel() {
|
|
20813
20918
|
return setShowModal(false);
|
|
20814
20919
|
},
|
|
20920
|
+
className: contentWidth,
|
|
20815
20921
|
icon: /*#__PURE__*/jsx(Fragment, {}),
|
|
20816
20922
|
content: /*#__PURE__*/jsx(Form$1, {
|
|
20817
20923
|
form: form,
|
|
@@ -20824,7 +20930,7 @@ function TextCell (_ref) {
|
|
|
20824
20930
|
}] : [],
|
|
20825
20931
|
children: /*#__PURE__*/jsx(Input.TextArea, {
|
|
20826
20932
|
autoSize: {
|
|
20827
|
-
minRows:
|
|
20933
|
+
minRows: 6,
|
|
20828
20934
|
maxRows: 6
|
|
20829
20935
|
},
|
|
20830
20936
|
ref: inputRef
|
|
@@ -24920,7 +25026,7 @@ var FilterBox = /*#__PURE__*/memo(function (_ref) {
|
|
|
24920
25026
|
value: getLabelByValue((_value2 = data.value) !== null && _value2 !== void 0 ? _value2 : data, filter.options)
|
|
24921
25027
|
}]);
|
|
24922
25028
|
}
|
|
24923
|
-
})]
|
|
25029
|
+
}, id)]
|
|
24924
25030
|
}, filter.type + filter.title);
|
|
24925
25031
|
case 'slider':
|
|
24926
25032
|
//Masse
|
|
@@ -30055,7 +30161,7 @@ styleInject(css_248z$3);
|
|
|
30055
30161
|
var wrapper = "wrapper-wuBie";
|
|
30056
30162
|
var select = "select-w181d";
|
|
30057
30163
|
var button = "button-g8Tp4";
|
|
30058
|
-
var css_248z$2 = ".wrapper-wuBie {\n display: flex;\n gap: 16px;\n margin: 8px;\n justify-content: start;\n}\n\n.select-w181d {\n z-index: 1000;\n margin: 8px;\n flex-grow: 0.8;\n min-width: 100px;\n}\n.select-w181d div {\n border-color: grey !important;\n}\n.select-w181d div {\n box-shadow: none;\n box-shadow: initial;\n}\n\n.button-g8Tp4 {\n width: 40px;\n justify-content: center;\n}\n";
|
|
30164
|
+
var css_248z$2 = ".wrapper-wuBie {\n display: flex;\n gap: 16px;\n margin: 8px;\n justify-content: flex-start;\n}\n\n.select-w181d {\n z-index: 1000;\n margin: 8px;\n flex-grow: 0.8;\n min-width: 100px;\n}\n.select-w181d div {\n border-color: grey !important;\n}\n.select-w181d div {\n box-shadow: none;\n box-shadow: initial;\n}\n\n.button-g8Tp4 {\n width: 40px;\n justify-content: center;\n}\n";
|
|
30059
30165
|
styleInject(css_248z$2);
|
|
30060
30166
|
|
|
30061
30167
|
var ArticleSelection = function ArticleSelection(_ref) {
|