@ditojs/admin 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dito-admin.es.js +2065 -1969
- package/dist/dito-admin.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +32 -31
- package/src/DitoAdmin.js +66 -31
- package/src/DitoComponent.js +4 -1
- package/src/DitoContext.js +13 -5
- package/src/{TypeComponent.js → DitoTypeComponent.js} +8 -5
- package/src/components/DitoAccount.vue +20 -19
- package/src/components/DitoButtons.vue +14 -12
- package/src/components/DitoClipboard.vue +16 -8
- package/src/components/DitoContainer.vue +56 -43
- package/src/components/DitoCreateButton.vue +20 -15
- package/src/components/DitoDialog.vue +78 -53
- package/src/components/DitoEditButtons.vue +16 -14
- package/src/components/DitoElement.vue +2 -3
- package/src/components/DitoErrors.vue +18 -13
- package/src/components/DitoForm.vue +41 -24
- package/src/components/DitoFormNested.vue +12 -10
- package/src/components/DitoHeader.vue +103 -69
- package/src/components/DitoLabel.vue +108 -81
- package/src/components/DitoMenu.vue +52 -36
- package/src/components/DitoPagination.vue +9 -7
- package/src/components/DitoPane.vue +53 -45
- package/src/components/DitoPanel.vue +62 -42
- package/src/components/DitoPanels.vue +11 -10
- package/src/components/DitoRoot.vue +57 -46
- package/src/components/DitoSchema.vue +179 -131
- package/src/components/DitoSchemaInlined.vue +39 -28
- package/src/components/DitoScopes.vue +41 -31
- package/src/components/DitoSpinner.vue +31 -40
- package/src/components/DitoTableCell.vue +9 -9
- package/src/components/DitoTableHead.vue +52 -37
- package/src/components/DitoTabs.vue +39 -29
- package/src/components/DitoTreeItem.vue +140 -86
- package/src/components/DitoVNode.vue +1 -1
- package/src/components/DitoView.vue +13 -11
- package/src/mixins/DataMixin.js +11 -9
- package/src/mixins/DitoMixin.js +47 -25
- package/src/mixins/EmitterMixin.js +2 -1
- package/src/mixins/ItemMixin.js +15 -10
- package/src/mixins/LoadingMixin.js +2 -1
- package/src/mixins/NumberMixin.js +15 -10
- package/src/mixins/OptionsMixin.js +24 -12
- package/src/mixins/ResourceMixin.js +42 -34
- package/src/mixins/RouteMixin.js +8 -8
- package/src/mixins/SortableMixin.js +1 -1
- package/src/mixins/SourceMixin.js +68 -34
- package/src/mixins/TypeMixin.js +5 -4
- package/src/mixins/ValidationMixin.js +3 -0
- package/src/styles/_base.scss +17 -0
- package/src/styles/_button.scss +212 -0
- package/src/styles/_imports.scss +2 -0
- package/src/styles/_layout.scss +22 -0
- package/src/styles/_notifications.scss +54 -0
- package/src/styles/_pulldown.scss +39 -0
- package/src/styles/_scroll.scss +15 -0
- package/src/styles/_settings.scss +68 -0
- package/src/styles/_sortable.scss +13 -0
- package/src/styles/_table.scss +224 -0
- package/src/styles/style.scss +9 -0
- package/src/types/DitoTypeButton.vue +72 -0
- package/src/types/{TypeCheckbox.vue → DitoTypeCheckbox.vue} +12 -11
- package/src/types/{TypeCheckboxes.vue → DitoTypeCheckboxes.vue} +21 -15
- package/src/types/{TypeCode.vue → DitoTypeCode.vue} +46 -34
- package/src/types/{TypeColor.vue → DitoTypeColor.vue} +71 -52
- package/src/types/{TypeComponent.vue → DitoTypeComponent.vue} +2 -2
- package/src/types/DitoTypeComputed.vue +54 -0
- package/src/types/DitoTypeDate.vue +64 -0
- package/src/types/DitoTypeLabel.vue +23 -0
- package/src/types/{TypeList.vue → DitoTypeList.vue} +83 -61
- package/src/types/{TypeMarkup.vue → DitoTypeMarkup.vue} +172 -122
- package/src/types/DitoTypeMultiselect.vue +434 -0
- package/src/types/DitoTypeNumber.vue +46 -0
- package/src/types/{TypeObject.vue → DitoTypeObject.vue} +41 -26
- package/src/types/{TypePanel.vue → DitoTypePanel.vue} +2 -2
- package/src/types/{TypeProgress.vue → DitoTypeProgress.vue} +4 -6
- package/src/types/{TypeRadio.vue → DitoTypeRadio.vue} +17 -13
- package/src/types/{TypeSection.vue → DitoTypeSection.vue} +17 -17
- package/src/types/{TypeSelect.vue → DitoTypeSelect.vue} +39 -35
- package/src/types/{TypeSlider.vue → DitoTypeSlider.vue} +29 -23
- package/src/types/{TypeSwitch.vue → DitoTypeSwitch.vue} +15 -13
- package/src/types/DitoTypeText.vue +77 -0
- package/src/types/{TypeTextarea.vue → DitoTypeTextarea.vue} +17 -14
- package/src/types/DitoTypeTreeList.vue +191 -0
- package/src/types/{TypeUpload.vue → DitoTypeUpload.vue} +92 -65
- package/src/types/index.js +26 -26
- package/src/utils/SchemaGraph.js +21 -13
- package/src/utils/accessor.js +17 -9
- package/src/utils/data.js +4 -1
- package/src/utils/filter.js +8 -10
- package/src/utils/options.js +3 -3
- package/src/utils/resource.js +12 -10
- package/src/utils/schema.js +190 -125
- package/src/utils/type.js +31 -20
- package/src/validations/_decimals.js +1 -2
- package/types/index.d.ts +27 -23
- package/src/styles/_base.sass +0 -15
- package/src/styles/_button.sass +0 -127
- package/src/styles/_imports.sass +0 -2
- package/src/styles/_layout.sass +0 -13
- package/src/styles/_notifications.sass +0 -33
- package/src/styles/_pulldown.sass +0 -26
- package/src/styles/_scroll.sass +0 -13
- package/src/styles/_settings.sass +0 -55
- package/src/styles/_sortable.sass +0 -9
- package/src/styles/_table.sass +0 -153
- package/src/styles/style.sass +0 -10
- package/src/types/TypeButton.vue +0 -73
- package/src/types/TypeComputed.vue +0 -53
- package/src/types/TypeDate.vue +0 -64
- package/src/types/TypeLabel.vue +0 -19
- package/src/types/TypeMultiselect.vue +0 -376
- package/src/types/TypeNumber.vue +0 -44
- package/src/types/TypeText.vue +0 -67
- package/src/types/TypeTreeList.vue +0 -164
|
@@ -12,26 +12,38 @@
|
|
|
12
12
|
span Status
|
|
13
13
|
th
|
|
14
14
|
span
|
|
15
|
-
|
|
16
|
-
tag="tbody"
|
|
15
|
+
UseSortable(
|
|
17
16
|
v-model="files"
|
|
17
|
+
tag="tbody"
|
|
18
18
|
:options="getSortableOptions(draggable)"
|
|
19
19
|
)
|
|
20
20
|
tr(
|
|
21
21
|
v-for="(file, index) in files"
|
|
22
22
|
:key="file.key"
|
|
23
23
|
)
|
|
24
|
-
td(
|
|
24
|
+
td(
|
|
25
|
+
v-html="renderFile(file, index)"
|
|
26
|
+
)
|
|
25
27
|
td {{ formatFileSize(file.size) }}
|
|
26
28
|
td
|
|
27
|
-
template(
|
|
28
|
-
|
|
29
|
+
template(
|
|
30
|
+
v-if="file.upload"
|
|
31
|
+
)
|
|
32
|
+
template(
|
|
33
|
+
v-if="file.upload.error"
|
|
34
|
+
)
|
|
29
35
|
| Error: {{ file.upload.error }}
|
|
30
|
-
template(
|
|
36
|
+
template(
|
|
37
|
+
v-else-if="file.upload.active"
|
|
38
|
+
)
|
|
31
39
|
| Uploading...
|
|
32
|
-
template(
|
|
40
|
+
template(
|
|
41
|
+
v-else-if="file.upload.success"
|
|
42
|
+
)
|
|
33
43
|
| Uploaded
|
|
34
|
-
template(
|
|
44
|
+
template(
|
|
45
|
+
v-else
|
|
46
|
+
)
|
|
35
47
|
| Stored
|
|
36
48
|
td.dito-cell-edit-buttons
|
|
37
49
|
.dito-buttons.dito-buttons-round
|
|
@@ -43,8 +55,8 @@
|
|
|
43
55
|
button.dito-button(
|
|
44
56
|
v-if="deletable"
|
|
45
57
|
type="button"
|
|
46
|
-
@click="deleteFile(file, index)"
|
|
47
58
|
v-bind="getButtonAttributes(verbs.delete)"
|
|
59
|
+
@click="deleteFile(file, index)"
|
|
48
60
|
)
|
|
49
61
|
tfoot
|
|
50
62
|
tr
|
|
@@ -66,46 +78,25 @@
|
|
|
66
78
|
type="button"
|
|
67
79
|
@click.prevent="upload.active = true"
|
|
68
80
|
) Upload All
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
VueUpload.dito-button.dito-button-add-upload(
|
|
82
|
+
ref="upload"
|
|
83
|
+
v-model="uploads"
|
|
84
|
+
:inputId="dataPath"
|
|
71
85
|
:name="dataPath"
|
|
72
86
|
:disabled="disabled"
|
|
73
|
-
:
|
|
87
|
+
:postAction="uploadPath"
|
|
74
88
|
:extensions="extensions"
|
|
75
89
|
:accept="accept"
|
|
76
90
|
:multiple="multiple"
|
|
77
91
|
:size="maxSize"
|
|
78
|
-
|
|
92
|
+
title="Upload Files"
|
|
79
93
|
@input-filter="inputFilter"
|
|
80
94
|
@input-file="inputFile"
|
|
81
|
-
ref="upload"
|
|
82
|
-
title="Upload Files"
|
|
83
95
|
)
|
|
84
96
|
</template>
|
|
85
97
|
|
|
86
|
-
<style lang="sass">
|
|
87
|
-
@import '../styles/_imports'
|
|
88
|
-
|
|
89
|
-
.dito-upload
|
|
90
|
-
.dito-table
|
|
91
|
-
tr
|
|
92
|
-
vertical-align: middle
|
|
93
|
-
.dito-button-add-upload
|
|
94
|
-
padding: 0
|
|
95
|
-
> *
|
|
96
|
-
position: absolute
|
|
97
|
-
cursor: pointer
|
|
98
|
-
.dito-upload-footer
|
|
99
|
-
display: flex
|
|
100
|
-
justify-content: flex-end
|
|
101
|
-
align-items: center
|
|
102
|
-
.dito-progress
|
|
103
|
-
flex: auto
|
|
104
|
-
margin-right: $form-spacing
|
|
105
|
-
</style>
|
|
106
|
-
|
|
107
98
|
<script>
|
|
108
|
-
import
|
|
99
|
+
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
109
100
|
import DitoContext from '../DitoContext.js'
|
|
110
101
|
import SortableMixin from '../mixins/SortableMixin.js'
|
|
111
102
|
import parseFileSize from 'filesize-parser'
|
|
@@ -116,9 +107,9 @@ import { isArray, asArray, escapeHtml } from '@ditojs/utils'
|
|
|
116
107
|
import VueUpload from 'vue-upload-component'
|
|
117
108
|
|
|
118
109
|
// @vue/component
|
|
119
|
-
export default
|
|
120
|
-
components: { VueUpload },
|
|
110
|
+
export default DitoTypeComponent.register('upload', {
|
|
121
111
|
mixins: [SortableMixin],
|
|
112
|
+
components: { VueUpload },
|
|
122
113
|
|
|
123
114
|
data() {
|
|
124
115
|
return {
|
|
@@ -174,8 +165,10 @@ export default TypeComponent.register('upload', {
|
|
|
174
165
|
}),
|
|
175
166
|
|
|
176
167
|
isUploadReady() {
|
|
177
|
-
return
|
|
168
|
+
return (
|
|
169
|
+
this.uploads.length &&
|
|
178
170
|
!(this.upload.active || this.upload.uploaded)
|
|
171
|
+
)
|
|
179
172
|
},
|
|
180
173
|
|
|
181
174
|
isUploadActive() {
|
|
@@ -204,22 +197,25 @@ export default TypeComponent.register('upload', {
|
|
|
204
197
|
const { render } = this.schema
|
|
205
198
|
return render
|
|
206
199
|
? render.call(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
200
|
+
this,
|
|
201
|
+
new DitoContext(this, {
|
|
202
|
+
value: file,
|
|
203
|
+
data: this.files,
|
|
204
|
+
index,
|
|
205
|
+
dataPath: appendDataPath(this.dataPath, index)
|
|
206
|
+
})
|
|
207
|
+
)
|
|
215
208
|
: escapeHtml(file.name)
|
|
216
209
|
},
|
|
217
210
|
|
|
218
211
|
deleteFile(file, index) {
|
|
219
212
|
const { name } = file
|
|
220
213
|
|
|
221
|
-
if (
|
|
222
|
-
|
|
214
|
+
if (
|
|
215
|
+
file &&
|
|
216
|
+
window.confirm(
|
|
217
|
+
`Do you really want to ${this.verbs.remove} ${name}?`
|
|
218
|
+
)
|
|
223
219
|
) {
|
|
224
220
|
if (this.multiple) {
|
|
225
221
|
this.value.splice(index, 1)
|
|
@@ -294,16 +290,18 @@ export default TypeComponent.register('upload', {
|
|
|
294
290
|
this.removeFile(newFile)
|
|
295
291
|
}
|
|
296
292
|
} else if (error) {
|
|
297
|
-
const text =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
293
|
+
const text = (
|
|
294
|
+
{
|
|
295
|
+
abort: 'Upload aborted',
|
|
296
|
+
denied: 'Upload denied',
|
|
297
|
+
extension: `Unsupported file-type: ${newFile.name}`,
|
|
298
|
+
network: 'Network error encountered during upload',
|
|
299
|
+
server: 'Server error occurred during upload',
|
|
300
|
+
size: `File is too large: ${formatFileSize(newFile.size)}`,
|
|
301
|
+
timeout: 'Timeout occurred during upload'
|
|
302
|
+
}[error] ||
|
|
303
|
+
`Unknown File Upload Error: '${error}'`
|
|
304
|
+
)
|
|
307
305
|
this.notify({
|
|
308
306
|
type: 'error',
|
|
309
307
|
title: 'File Upload Error',
|
|
@@ -314,7 +312,7 @@ export default TypeComponent.register('upload', {
|
|
|
314
312
|
}
|
|
315
313
|
},
|
|
316
314
|
|
|
317
|
-
inputFilter(newFile/*, oldFile, prevent */) {
|
|
315
|
+
inputFilter(newFile /*, oldFile, prevent */) {
|
|
318
316
|
const xhr = newFile?.xhr
|
|
319
317
|
if (this.api.cors?.credentials && xhr && !xhr.withCredentials) {
|
|
320
318
|
xhr.withCredentials = true
|
|
@@ -325,9 +323,7 @@ export default TypeComponent.register('upload', {
|
|
|
325
323
|
processValue(schema, value) {
|
|
326
324
|
// Filter out all newly added files that weren't actually uploaded.
|
|
327
325
|
const files = asFiles(value)
|
|
328
|
-
.map(
|
|
329
|
-
({ upload, ...file }) => !upload || upload.success ? file : null
|
|
330
|
-
)
|
|
326
|
+
.map(({ upload, ...file }) => (!upload || upload.success ? file : null))
|
|
331
327
|
.filter(file => file)
|
|
332
328
|
return schema.multiple ? files : files[0] || null
|
|
333
329
|
}
|
|
@@ -336,5 +332,36 @@ export default TypeComponent.register('upload', {
|
|
|
336
332
|
function asFiles(value) {
|
|
337
333
|
return value ? asArray(value) : []
|
|
338
334
|
}
|
|
339
|
-
|
|
340
335
|
</script>
|
|
336
|
+
|
|
337
|
+
<style lang="scss">
|
|
338
|
+
@import '../styles/_imports';
|
|
339
|
+
|
|
340
|
+
.dito-upload {
|
|
341
|
+
.dito-table {
|
|
342
|
+
tr {
|
|
343
|
+
vertical-align: middle;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.dito-button-add-upload {
|
|
348
|
+
padding: 0;
|
|
349
|
+
|
|
350
|
+
> * {
|
|
351
|
+
position: absolute;
|
|
352
|
+
cursor: pointer;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.dito-upload-footer {
|
|
357
|
+
display: flex;
|
|
358
|
+
justify-content: flex-end;
|
|
359
|
+
align-items: center;
|
|
360
|
+
|
|
361
|
+
.dito-progress {
|
|
362
|
+
flex: auto;
|
|
363
|
+
margin-right: $form-spacing;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
</style>
|
package/src/types/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
// NOTE: index.js exports nothing, but type components will be registered in
|
|
2
|
-
// DitoComponent and can be retrieved through
|
|
2
|
+
// DitoComponent and can be retrieved through DitoTypeComponent.get(type) and
|
|
3
3
|
// rendered through their component-names (e.g. dito-type-list).
|
|
4
4
|
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export { default as
|
|
13
|
-
export { default as
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
16
|
-
export { default as
|
|
17
|
-
export { default as
|
|
18
|
-
export { default as
|
|
19
|
-
export { default as
|
|
20
|
-
export { default as
|
|
21
|
-
export { default as
|
|
22
|
-
export { default as
|
|
23
|
-
export { default as
|
|
24
|
-
export { default as
|
|
25
|
-
export { default as
|
|
26
|
-
export { default as
|
|
27
|
-
export { default as
|
|
28
|
-
export { default as
|
|
29
|
-
export { default as
|
|
5
|
+
export { default as DitoTypeButton } from './DitoTypeButton.vue'
|
|
6
|
+
export { default as DitoTypeCheckbox } from './DitoTypeCheckbox.vue'
|
|
7
|
+
export { default as DitoTypeCheckboxes } from './DitoTypeCheckboxes.vue'
|
|
8
|
+
export { default as DitoTypeCode } from './DitoTypeCode.vue'
|
|
9
|
+
export { default as DitoTypeColor } from './DitoTypeColor.vue'
|
|
10
|
+
export { default as DitoDitoTypeComponent } from './DitoTypeComponent.vue'
|
|
11
|
+
export { default as DitoTypeComputed } from './DitoTypeComputed.vue'
|
|
12
|
+
export { default as DitoTypeDate } from './DitoTypeDate.vue'
|
|
13
|
+
export { default as DitoTypeList } from './DitoTypeList.vue'
|
|
14
|
+
export { default as DitoTypeLabel } from './DitoTypeLabel.vue'
|
|
15
|
+
export { default as DitoTypeMarkup } from './DitoTypeMarkup.vue'
|
|
16
|
+
export { default as DitoTypeMultiselect } from './DitoTypeMultiselect.vue'
|
|
17
|
+
export { default as DitoTypeNumber } from './DitoTypeNumber.vue'
|
|
18
|
+
export { default as DitoTypeObject } from './DitoTypeObject.vue'
|
|
19
|
+
export { default as DitoTypePanel } from './DitoTypePanel.vue'
|
|
20
|
+
export { default as DitoTypeProgress } from './DitoTypeProgress.vue'
|
|
21
|
+
export { default as DitoTypeRadio } from './DitoTypeRadio.vue'
|
|
22
|
+
export { default as DitoTypeSection } from './DitoTypeSection.vue'
|
|
23
|
+
export { default as DitoTypeSelect } from './DitoTypeSelect.vue'
|
|
24
|
+
export { default as DitoTypeSlider } from './DitoTypeSlider.vue'
|
|
25
|
+
export { default as DitoTypeSwitch } from './DitoTypeSwitch.vue'
|
|
26
|
+
export { default as DitoTypeText } from './DitoTypeText.vue'
|
|
27
|
+
export { default as DitoTypeTextarea } from './DitoTypeTextarea.vue'
|
|
28
|
+
export { default as DitoTypeTreeList } from './DitoTypeTreeList.vue'
|
|
29
|
+
export { default as DitoTypeUpload } from './DitoTypeUpload.vue'
|
package/src/utils/SchemaGraph.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isTemporaryId } from './data.js'
|
|
2
2
|
import {
|
|
3
|
-
isInteger,
|
|
3
|
+
isInteger,
|
|
4
|
+
asArray,
|
|
5
|
+
parseDataPath,
|
|
6
|
+
getValueAtDataPath
|
|
4
7
|
} from '@ditojs/utils'
|
|
5
8
|
import { nanoid } from 'nanoid'
|
|
6
9
|
|
|
@@ -29,7 +32,7 @@ export class SchemaGraph {
|
|
|
29
32
|
let subGraph = this.graph
|
|
30
33
|
for (const part of dataPath) {
|
|
31
34
|
const key = isInteger(+part) ? '*' : part
|
|
32
|
-
subGraph =
|
|
35
|
+
subGraph = subGraph[key] ??= {}
|
|
33
36
|
}
|
|
34
37
|
subGraph.$settings = {
|
|
35
38
|
...defaults, // See `addSource(dataPath)`
|
|
@@ -95,9 +98,11 @@ export class SchemaGraph {
|
|
|
95
98
|
if (source || relation && internal) {
|
|
96
99
|
const values = getValueAtDataPath(data, dataPath, () => null)
|
|
97
100
|
const removeId = clipboard && source && !related
|
|
98
|
-
const referenceId =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
const referenceId = (
|
|
102
|
+
clipboard && (
|
|
103
|
+
relation && internal ||
|
|
104
|
+
source && related
|
|
105
|
+
)
|
|
101
106
|
)
|
|
102
107
|
for (const value of asArray(values).flat()) {
|
|
103
108
|
const idKey = (
|
|
@@ -109,20 +114,23 @@ export class SchemaGraph {
|
|
|
109
114
|
if (id != null) {
|
|
110
115
|
if (removeId) {
|
|
111
116
|
delete value[idKey]
|
|
112
|
-
}
|
|
117
|
+
}
|
|
118
|
+
if (referenceId || isTemporaryId(id)) {
|
|
113
119
|
if (isTemporaryId(id)) {
|
|
114
120
|
id = id.slice(1)
|
|
115
121
|
}
|
|
116
122
|
const refKey = clipboard
|
|
117
|
-
// Clipboard just needs temporary ids under the actual `idKey
|
|
118
|
-
|
|
119
|
-
// Server wants Objection-style '#id' / '#ref' pairs.
|
|
120
|
-
|
|
123
|
+
? // Clipboard just needs temporary ids under the actual `idKey`
|
|
124
|
+
idKey
|
|
125
|
+
: // Server wants Objection-style '#id' / '#ref' pairs.
|
|
126
|
+
source
|
|
127
|
+
? '#id'
|
|
128
|
+
: '#ref'
|
|
121
129
|
const revValue = clipboard
|
|
122
130
|
? `@${id}`
|
|
123
|
-
// Keep the ids unique in reference groups, since they
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
: // Keep the ids unique in reference groups, since they
|
|
132
|
+
// reference across the full graph.
|
|
133
|
+
reference
|
|
126
134
|
? `${reference}-${id}`
|
|
127
135
|
: id // A temporary id without a related, just preserve it.
|
|
128
136
|
value[refKey] = revValue
|
package/src/utils/accessor.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isFunction,
|
|
2
|
+
isFunction,
|
|
3
|
+
isString,
|
|
4
|
+
parseDataPath,
|
|
5
|
+
normalizeDataPath
|
|
3
6
|
} from '@ditojs/utils'
|
|
4
7
|
|
|
5
8
|
export function getSchemaAccessor(
|
|
@@ -17,14 +20,19 @@ export function getSchemaAccessor(
|
|
|
17
20
|
get() {
|
|
18
21
|
// Only determine schema value if we have no getter, or the getter
|
|
19
22
|
// wants to receive the value and process it further:
|
|
20
|
-
const value =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const value =
|
|
24
|
+
!get || get.length > 0
|
|
25
|
+
? // NOTE: Because `schema` objects are retrieved from `meta`, they
|
|
26
|
+
// don't seem to be reactive. To allow changed in `schema` values,
|
|
27
|
+
// `set()` stores changed values in the separate `overrides` object.
|
|
28
|
+
this.overrides && name in this.overrides
|
|
29
|
+
? this.overrides[name]
|
|
30
|
+
: this.getSchemaValue(keyOrDataPath, {
|
|
31
|
+
type,
|
|
32
|
+
default: def,
|
|
33
|
+
callback
|
|
34
|
+
})
|
|
35
|
+
: undefined
|
|
28
36
|
return get ? get.call(this, value) : value
|
|
29
37
|
},
|
|
30
38
|
|
package/src/utils/data.js
CHANGED
package/src/utils/filter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isArray, asArray, labelize } from '@ditojs/utils'
|
|
2
2
|
|
|
3
3
|
export const filterComponents = {
|
|
4
|
-
text(filter) {
|
|
4
|
+
'text'(filter) {
|
|
5
5
|
const options = [
|
|
6
6
|
{
|
|
7
7
|
label: 'contains',
|
|
@@ -23,15 +23,14 @@ export const filterComponents = {
|
|
|
23
23
|
return {
|
|
24
24
|
operator: filter.operators
|
|
25
25
|
? {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
isArray(filter.operators)
|
|
26
|
+
type: 'select',
|
|
27
|
+
options: isArray(filter.operators)
|
|
29
28
|
? options.filter(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
option => filter.operators.includes(option.value)
|
|
30
|
+
)
|
|
32
31
|
: options,
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
width: '40%'
|
|
33
|
+
}
|
|
35
34
|
: null,
|
|
36
35
|
text: {
|
|
37
36
|
type: 'text',
|
|
@@ -186,8 +185,7 @@ function parseFiltersData(schema, query) {
|
|
|
186
185
|
const [, name, json] = filter.match(/^(\w+):(.*)$/)
|
|
187
186
|
try {
|
|
188
187
|
filters[name] = asArray(JSON.parse(`[${json}]`))
|
|
189
|
-
} catch (error) {
|
|
190
|
-
}
|
|
188
|
+
} catch (error) {}
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
const filtersData = {}
|
package/src/utils/options.js
CHANGED
package/src/utils/resource.js
CHANGED
|
@@ -6,9 +6,11 @@ export function hasResource(schema) {
|
|
|
6
6
|
|
|
7
7
|
export function getResource(resource, defaults = {}) {
|
|
8
8
|
const { parent, ...defs } = defaults
|
|
9
|
-
resource = isObject(resource)
|
|
10
|
-
|
|
11
|
-
:
|
|
9
|
+
resource = isObject(resource)
|
|
10
|
+
? { ...defs, ...resource }
|
|
11
|
+
: isString(resource)
|
|
12
|
+
? { ...defs, path: resource }
|
|
13
|
+
: null
|
|
12
14
|
// Only set parent if path doesn't start with '/', so relative URLs are
|
|
13
15
|
// dealt with correctly.
|
|
14
16
|
if (
|
|
@@ -28,12 +30,12 @@ export function getResource(resource, defaults = {}) {
|
|
|
28
30
|
export function getMemberResource(id, resource) {
|
|
29
31
|
return id != null && resource?.type === 'collection'
|
|
30
32
|
? {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
type: 'member',
|
|
34
|
+
...pickBy(
|
|
35
|
+
resource,
|
|
36
|
+
(value, key) => ['method', 'path', 'parent'].includes(key)
|
|
37
|
+
),
|
|
38
|
+
id: `${id}`
|
|
39
|
+
}
|
|
38
40
|
: null
|
|
39
41
|
}
|