@ditojs/admin 3.1.2 → 3.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/admin",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "type": "module",
5
5
  "description": "Dito.js Admin is a schema based admin interface for Dito.js Server, featuring auto-generated views and forms and built with Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/main/packages/admin",
@@ -41,8 +41,8 @@
41
41
  "not ie_mob > 0"
42
42
  ],
43
43
  "dependencies": {
44
- "@ditojs/ui": "^3.1.2",
45
- "@ditojs/utils": "^3.1.2"
44
+ "@ditojs/ui": "^3.1.3",
45
+ "@ditojs/utils": "^3.1.3"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@kyvg/vue3-notification": "^3.4.2",
@@ -87,7 +87,7 @@
87
87
  "vue-upload-component": "^3.2.2"
88
88
  },
89
89
  "devDependencies": {
90
- "@ditojs/build": "^3.1.2",
90
+ "@ditojs/build": "^3.1.3",
91
91
  "@kyvg/vue3-notification": "^3.4.2",
92
92
  "@tiptap/core": "^3.31.4",
93
93
  "@tiptap/extension-blockquote": "^3.31.4",
@@ -131,5 +131,5 @@
131
131
  "vue-router": "^5.3.1",
132
132
  "vue-upload-component": "^3.2.2"
133
133
  },
134
- "gitHead": "a87ccff01f65386d9363366fb19bb993d38e8fbc"
134
+ "gitHead": "3dba854ad248a56da1614122b960ad8a7eda70dd"
135
135
  }
@@ -4,7 +4,7 @@
4
4
  v-if="creatableForm"
5
5
  :type="isInlined ? 'button' : 'submit'"
6
6
  :disabled="disabled"
7
- v-bind="getButtonAttributes(verb, formLabel)"
7
+ v-bind="getButtonAttributes(verb, formLabel, text)"
8
8
  @click="createItem(creatableForm)"
9
9
  ) {{ text }}
10
10
  template(
@@ -13,7 +13,10 @@
13
13
  button.dito-button(
14
14
  type="button"
15
15
  :disabled="disabled"
16
- v-bind="{ ...pulldownTriggerAttributes, ...getButtonAttributes(verb) }"
16
+ v-bind=`{
17
+ ...pulldownTriggerAttributes,
18
+ ...getButtonAttributes(verb, null, text)
19
+ }`
17
20
  @mousedown.stop="onPulldownMouseDown()"
18
21
  ) {{ text }}
19
22
  ul.dito-pulldown(
@@ -295,13 +295,18 @@ export default {
295
295
  : labelize(name) || ''
296
296
  },
297
297
 
298
- getButtonAttributes(verb, subject = null) {
299
- // Name buttons by what they act on if known, e.g. 'Add Section'.
300
- const label = subject ? `${labelize(verb)} ${subject}` : labelize(verb)
298
+ getButtonAttributes(verb, subject = null, text = null) {
299
+ // Buttons that display text are named by it, others by what they act on
300
+ // if known, e.g. 'Add Section'.
301
+ const label = text
302
+ ? null
303
+ : `${labelize(verb)}${subject ? ` ${subject}` : ''}`
301
304
  return {
302
- 'class': `dito-button--${verb}`,
303
- 'title': label,
304
- 'aria-label': label
305
+ class: `dito-button--${verb}`,
306
+ ...(label && {
307
+ 'title': label,
308
+ 'aria-label': label
309
+ })
305
310
  }
306
311
  },
307
312
 
@@ -82,11 +82,6 @@ export default {
82
82
  return this.getOptionForValue(this.selectedValue)
83
83
  },
84
84
 
85
- // The form model of the data, owned by the dialog or route component.
86
- formModel() {
87
- return (this.dialogComponent ?? this.routeComponent).formModel
88
- },
89
-
90
85
  // The resolver of the options in the form model of the data, which loads
91
86
  // them and shares them with the computes of the form. It is looked up with
92
87
  // the entry of this component, in the shape of the entries of
@@ -424,7 +424,7 @@ export default {
424
424
  // @override ResourceMixin.clearData()
425
425
  clearData() {
426
426
  this.total = 0
427
- this.value = null
427
+ this.setLoadedValue(null)
428
428
  },
429
429
 
430
430
  // @override ResourceMixin.setData()
@@ -437,7 +437,7 @@ export default {
437
437
  if (this.isListSource && isArray(data)) {
438
438
  this.setLoadedListItems(data)
439
439
  } else if (!data || this.isObjectSource && isObject(data)) {
440
- this.value = data
440
+ this.setLoadedValue(data)
441
441
  } else if (this.unwrapListData(data)) {
442
442
  // The format didn't match, see if we received a `{ results, total }`
443
443
  // object, in which case `this.value` was already set by
@@ -483,7 +483,21 @@ export default {
483
483
  // current order. Lists in the data of forms, views and dialogs are
484
484
  // numbered by `FormModel`, see `initializeData()`.
485
485
  setLoadedListItems(items) {
486
- this.value = updateOrder(this.sourceSchema, items, this.paginationRange)
486
+ this.setLoadedValue(
487
+ updateOrder(this.sourceSchema, items, this.paginationRange)
488
+ )
489
+ },
490
+
491
+ // Writes the value loaded through the source's resource. Loading isn't an
492
+ // edit of the data, so the value is written as a clean change, which
493
+ // doesn't make the form dirty, e.g. for sources whose value is stored,
494
+ // like the order of their items, see `FormModel.applyCleanChanges()`.
495
+ setLoadedValue(value) {
496
+ this.formModel
497
+ .applyCleanChanges(() => {
498
+ this.value = value
499
+ })
500
+ .catch(console.error)
487
501
  },
488
502
 
489
503
  createItem(schema, type, index = null) {
@@ -37,6 +37,11 @@ export default {
37
37
  return this.schema.name
38
38
  },
39
39
 
40
+ // The form model of the data, owned by the dialog or route component.
41
+ formModel() {
42
+ return (this.dialogComponent ?? this.routeComponent).formModel
43
+ },
44
+
40
45
  type() {
41
46
  return this.schema.type
42
47
  },
@@ -251,9 +251,11 @@ export default DitoTypeComponent.register('markup', {
251
251
  const onFocus = () => this.onFocus()
252
252
 
253
253
  const onBlur = () => {
254
- // Write the value first, so that validating on blur validates it.
254
+ // Write the value first, so that validating on blur validates it, and
255
+ // emit the change once the editor isn't focused anymore.
255
256
  updateValue()
256
257
  this.onBlur()
258
+ emitChange()
257
259
  }
258
260
 
259
261
  const onUpdate = () => {
@@ -275,9 +277,16 @@ export default DitoTypeComponent.register('markup', {
275
277
  ignoreWatch = true
276
278
  this.value = value
277
279
  }
278
- if (!this.focused && changed) {
279
- this.onChange()
280
+ if (!this.focused) {
281
+ emitChange()
282
+ }
283
+ }
284
+
285
+ // Emits the change of the value, once the editing is done.
286
+ const emitChange = () => {
287
+ if (changed) {
280
288
  changed = false
289
+ this.onChange()
281
290
  }
282
291
  }
283
292