@afeefa/vue-app 0.0.96 → 0.0.98

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.
@@ -1 +1 @@
1
- 0.0.96
1
+ 0.0.98
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.96",
3
+ "version": "0.0.98",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -58,10 +58,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
58
58
  }
59
59
 
60
60
  mounted () {
61
- if (this.validator) {
62
- this.$refs.input.validate(true)
63
- }
64
- this.$refs.input.validate(true)
61
+ this.validate()
65
62
  }
66
63
 
67
64
  @Watch('value')
@@ -71,6 +68,10 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
71
68
 
72
69
  @Watch('value_')
73
70
  value_Changed () { // validate on any change
71
+ this.validateDateValue()
72
+ }
73
+
74
+ validateDateValue () {
74
75
  this.errorMessages = []
75
76
  if (this.validator) {
76
77
  const rules = this.validator.getRules(this.label)
@@ -130,6 +131,10 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
130
131
  return formatDate(new Date(date))
131
132
  }
132
133
 
134
+ validate () {
135
+ this.validateDateValue()
136
+ }
137
+
133
138
  get validationRules () {
134
139
  if (this.type !== 'month') {
135
140
  const dateFormat = v => {
@@ -80,10 +80,10 @@
80
80
  <v-btn
81
81
  small
82
82
  class="menu-button"
83
- :class="{ 'is-active': editorFocus && editorSelectionIs('#0000FF')}"
83
+ :class="{ 'is-active': editorFocus && editor.isActive('highlight', { color: '#6161FF' })}"
84
84
  title="blau"
85
85
  color="blue--text"
86
- @click="editorSelectionIs('#0000FF') ? editor.chain().focus().unsetColor().run() : editor.chain().focus().setColor('#0000FF').run()"
86
+ @click="editor.chain().focus().toggleHighlight({ color: '#6161FF' }).run()"
87
87
  >
88
88
  <v-icon>$paletteIcon</v-icon>
89
89
  </v-btn>
@@ -91,10 +91,10 @@
91
91
  <v-btn
92
92
  small
93
93
  class="menu-button"
94
- :class="{ 'is-active': editorFocus && editorSelectionIs('#FF0000')}"
94
+ :class="{ 'is-active': editorFocus && editor.isActive('highlight', { color: '#FF0000' })}"
95
95
  title="rot"
96
96
  color="red--text"
97
- @click="editorSelectionIs('#FF0000') ? editor.chain().focus().unsetColor().run() : editor.chain().focus().setColor('#FF0000').run()"
97
+ @click="editor.chain().focus().toggleHighlight({ color: '#FF0000' }).run()"
98
98
  >
99
99
  <v-icon>$paletteIcon</v-icon>
100
100
  </v-btn>
@@ -141,7 +141,7 @@ import {
141
141
  mdiRotateRight
142
142
  } from '@mdi/js'
143
143
  import { Color } from '@tiptap/extension-color'
144
- import TextStyle from '@tiptap/extension-text-style'
144
+ import Highlight from '@tiptap/extension-highlight'
145
145
 
146
146
  @Component({
147
147
  props: ['value', 'validator', 'focus'],
@@ -183,7 +183,7 @@ export default class ARichTextArea extends Vue {
183
183
  autofocus: this.focus ? 'end' : false,
184
184
  extensions: [
185
185
  StarterKit,
186
- TextStyle,
186
+ Highlight.configure({ multicolor: true }),
187
187
  Color
188
188
  ],
189
189
  onUpdate: () => {
@@ -204,10 +204,6 @@ export default class ARichTextArea extends Vue {
204
204
  this.editor.destroy()
205
205
  }
206
206
 
207
- editorSelectionIs (color) {
208
- return this.editor.isActive('textStyle', { color: color })
209
- }
210
-
211
207
  /**
212
208
  * reset the text area to disable the undo button
213
209
  * e.g. after saving the form while keeping it open
@@ -32,10 +32,15 @@ export default class EditForm extends Vue {
32
32
  lastJson = null
33
33
  forcedUnchange = false
34
34
 
35
+
35
36
  created () {
36
37
  this.reset()
37
38
  }
38
39
 
40
+ validate () {
41
+ this.$refs.form.validate()
42
+ }
43
+
39
44
  getField = name => {
40
45
  const modelType = this.$apiResources.getType(this.model.type)
41
46
  const update = !!this.model.id
@@ -100,9 +100,7 @@ export class FormFieldMixin extends Vue {
100
100
  get validator () {
101
101
  const validator = this.field.getValidator()
102
102
  if (this.additionalRules) {
103
- this.additionalRules.forEach(validate => {
104
- validator.addRule(validate)
105
- })
103
+ validator.setAdditionalRules(this.additionalRules)
106
104
  }
107
105
  return this.field.getValidator()
108
106
  }
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <a-date-picker
3
+ ref="datePicker"
3
4
  v-model="model[name]"
4
5
  :label="label || name"
5
6
  :validator="validator"
6
7
  v-bind="$attrs"
8
+ v-on="$listeners"
7
9
  />
8
10
  </template>
9
11
 
@@ -13,5 +15,8 @@ import { FormFieldMixin } from '../FormFieldMixin'
13
15
 
14
16
  @Component
15
17
  export default class FormFieldDate extends Mixins(FormFieldMixin) {
18
+ validate () {
19
+ this.$refs.datePicker.validate()
20
+ }
16
21
  }
17
22
  </script>
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  class CascadingWindowEventDispatcher {
8
+ windowListeners = {}
8
9
  listeners = {}
9
10
 
10
11
  addEventListener (event, listener) {
@@ -12,9 +13,7 @@ class CascadingWindowEventDispatcher {
12
13
  this.listeners[event] = []
13
14
  }
14
15
 
15
- if (!this.listeners[event].length) {
16
- this.listeners[event] = []
17
-
16
+ if (!this.windowListeners[event]) {
18
17
  window.addEventListener(event, e => {
19
18
  for (const listener of this.listeners[event]) {
20
19
  const result = listener(e)
@@ -23,6 +22,8 @@ class CascadingWindowEventDispatcher {
23
22
  }
24
23
  }
25
24
  })
25
+
26
+ this.windowListeners[event] = true
26
27
  }
27
28
 
28
29
  this.listeners[event].unshift(listener)