@afeefa/vue-app 0.0.56 → 0.0.59

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.56
1
+ 0.0.59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.56",
3
+ "version": "0.0.59",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -8,11 +8,13 @@
8
8
  >
9
9
  <template #activator="{ on, attrs }">
10
10
  <v-combobox
11
+ ref="input"
11
12
  :value="formattedDate"
12
13
  :label="label"
13
14
  :style="cwm_widthStyle"
14
15
  readonly
15
16
  v-bind="attrs"
17
+ :rules="validationRules"
16
18
  v-on="on"
17
19
  @click.native="on.click"
18
20
  />
@@ -37,7 +39,7 @@ import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
37
39
  props: ['value', 'validator']
38
40
  })
39
41
  export default class ADatePicker extends Mixins(ComponentWidthMixin) {
40
- value_ = new Date()
42
+ value_ = null
41
43
  menu = false
42
44
 
43
45
  created () {
@@ -26,8 +26,17 @@ export default class EditForm extends Vue {
26
26
  valid = false
27
27
  lastJson = null
28
28
 
29
- created () {
29
+ /**
30
+ * This will be triggered after the this.model has been set
31
+ * but before sub components may have changed model values
32
+ * as a date field, which could turn a null to a default date.
33
+ * Using the created() method would result in already having set
34
+ * the default date, hence not detecting a valid "change" anymore.
35
+ */
36
+ @Watch('model', {immediate: true})
37
+ modelChanged () {
30
38
  this.lastJson = this.json
39
+ this.$emit('update:changed', this.changed)
31
40
  }
32
41
 
33
42
  get json () {
@@ -38,11 +47,6 @@ export default class EditForm extends Vue {
38
47
  return this.json !== this.lastJson
39
48
  }
40
49
 
41
- @Watch('model')
42
- modelChanged () {
43
- this.lastJson = this.json
44
- }
45
-
46
50
  @Watch('valid')
47
51
  validChanged () {
48
52
  this.$emit('update:valid', this.valid)
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <div>
3
+ <slot name="fields" />
4
+
5
+ <slot :model="model" />
6
+ </div>
7
+ </template>
8
+
9
+
10
+ <script>
11
+ import { Component, Vue } from '@a-vue'
12
+
13
+ @Component({
14
+ props: ['model']
15
+ })
16
+ export default class NestedEditForm extends Vue {
17
+ EDIT_FORM = true
18
+
19
+ created () {
20
+ if (!this.model) {
21
+ console.warn('Nested edit form does not have a model.')
22
+ }
23
+ }
24
+ }
25
+ </script>
@@ -11,12 +11,14 @@ import FormFieldSelect from './form/fields/FormFieldSelect'
11
11
  import FormFieldSelect2 from './form/fields/FormFieldSelect2'
12
12
  import FormFieldText from './form/fields/FormFieldText'
13
13
  import FormFieldTextArea from './form/fields/FormFieldTextArea'
14
+ import NestedEditForm from './form/NestedEditForm'
14
15
  import ListFilterPage from './list/filters/ListFilterPage'
15
16
  import ListFilterSearch from './list/filters/ListFilterSearch'
16
17
  import ListFilterSelect from './list/filters/ListFilterSelect'
17
18
  import ListFilterRow from './list/ListFilterRow'
18
19
 
19
20
  Vue.component('EditForm', EditForm)
21
+ Vue.component('NestedEditForm', NestedEditForm)
20
22
  Vue.component('EditModal', EditModal)
21
23
  Vue.component('FormFieldText', FormFieldText)
22
24
  Vue.component('FormFieldTextArea', FormFieldTextArea)
@@ -17,7 +17,9 @@ import { Component, Mixins } from '@a-vue'
17
17
  import { ListFilterMixin } from '../ListFilterMixin'
18
18
  import { ListAction } from '@a-vue/api-resources/ApiActions'
19
19
 
20
- @Component
20
+ @Component({
21
+ props: ['itemTitle', 'itemValue']
22
+ })
21
23
  export default class ListFilterSelect extends Mixins(ListFilterMixin) {
22
24
  items = null
23
25
 
@@ -60,10 +62,20 @@ export default class ListFilterSelect extends Mixins(ListFilterMixin) {
60
62
 
61
63
  return [
62
64
  ...this.createOptions(),
63
- ...models.map(model => ({
64
- itemTitle: model.name,
65
- itemValue: model.id
66
- }))
65
+ ...models.map(model => {
66
+ let itemValue
67
+ if (this.itemValue) {
68
+ itemValue = this.itemValue(model)
69
+ } else if (model.value !== undefined) {
70
+ itemValue = model.value
71
+ } else {
72
+ itemValue = model.id
73
+ }
74
+ return {
75
+ itemTitle: (this.itemTitle && this.itemTitle(model)) || model.name || model.title,
76
+ itemValue
77
+ }
78
+ })
67
79
  ]
68
80
  }
69
81
 
@@ -28,6 +28,7 @@
28
28
  <a-table-row
29
29
  v-for="model in models_"
30
30
  :key="model.id"
31
+ :class="getModelClass(model)"
31
32
  >
32
33
  <v-icon
33
34
  v-if="$has.icon"
@@ -49,6 +50,7 @@
49
50
  <div
50
51
  v-for="model in models_"
51
52
  :key="model.id"
53
+ :class="getModelClass(model)"
52
54
  >
53
55
  <slot
54
56
  name="model"
@@ -73,7 +75,9 @@ import { Component, Watch, Mixins } from '@a-vue'
73
75
  import { ListViewMixin } from '@a-vue/components/list/ListViewMixin'
74
76
  import { LoadingEvent } from '@a-vue/events'
75
77
 
76
- @Component
78
+ @Component({
79
+ props: ['modelClass']
80
+ })
77
81
  export default class ListView extends Mixins(ListViewMixin) {
78
82
  $hasOptions = ['icon']
79
83
 
@@ -89,6 +93,10 @@ export default class ListView extends Mixins(ListViewMixin) {
89
93
  this.$emit('update:isLoading', this.isLoading)
90
94
  }
91
95
 
96
+ getModelClass (model) {
97
+ return this.modelClass && this.modelClass(model)
98
+ }
99
+
92
100
  setFilter (name, value) {
93
101
  this.filters[name].value = value
94
102
  }
@@ -23,14 +23,6 @@
23
23
  </v-btn>
24
24
  </app-bar-button>
25
25
 
26
- <component
27
- :is="Component"
28
- v-if="false"
29
- :model="modelToEdit"
30
- :valid.sync="valid"
31
- :changed.sync="changed"
32
- />
33
-
34
26
  <edit-form
35
27
  :model="modelToEdit"
36
28
  :valid.sync="valid"
@@ -83,14 +75,12 @@ export default class EditPage extends Mixins(EditPageMixin) {
83
75
 
84
76
  this.model_ = this.model
85
77
  this.reset()
86
- this.$emit('model', this.modelToEdit)
87
78
  }
88
79
 
89
80
  @Watch('model')
90
81
  modelChanged () {
91
82
  this.model_ = this.model
92
83
  this.reset()
93
- this.$emit('model', this.modelToEdit)
94
84
  }
95
85
 
96
86
  get editConfig () {
@@ -1,6 +1,6 @@
1
+ import { Component, Vue } from '@a-vue'
1
2
  import { SaveAction } from '@a-vue/api-resources/ApiActions'
2
3
  import { DialogEvent } from '@a-vue/events'
3
- import { Component, Vue } from '@a-vue'
4
4
 
5
5
  @Component({
6
6
  props: ['saveAction']
@@ -79,6 +79,7 @@ export class EditPageMixin extends Vue {
79
79
 
80
80
  reset () {
81
81
  this.modelToEdit = this.createModelToEdit()
82
+ this.$emit('model', this.modelToEdit)
82
83
  }
83
84
 
84
85
  afterSave (_model) {