@afeefa/vue-app 0.0.347 → 0.0.349

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.347
1
+ 0.0.349
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.347",
3
+ "version": "0.0.349",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  </template>
17
17
 
18
18
  <script>
19
- import { Component, Mixins } from '@a-vue'
19
+ import { Component, Mixins, Watch } from '@a-vue'
20
20
  import { FormFieldMixin } from '../FormFieldMixin'
21
21
 
22
22
  @Component
@@ -27,10 +27,28 @@ export default class FormFieldSelect extends Mixins(FormFieldMixin) {
27
27
  this.reloadOptions()
28
28
  }
29
29
 
30
+ // Beim Recycling der Komponente (z.B. ein v-if-Block mit Select wird durch
31
+ // einen anderen v-if-Block mit Select an gleicher Position ersetzt) läuft
32
+ // created() nicht erneut. Ändert sich dabei das angebundene Feld (name) oder
33
+ // dessen optionRequestParams, müssen die Options neu geladen werden – sonst
34
+ // zeigt das Select die Optionen des vorherigen Felds.
35
+ //
36
+ // Vergleich per Wert (nicht per Referenz): Ein als Inline-Objekt übergebenes
37
+ // optionRequestParams (:optionRequestParams="{ key: value }") erzeugt bei
38
+ // jedem Re-Render eine neue Referenz, obwohl sich der Inhalt nicht ändert.
39
+ // Würde der Watch darauf neu laden, entstünde eine Endlosschleife
40
+ // (reloadOptions → optionsLoaded → State-Änderung → Re-Render → neue Referenz).
41
+ @Watch('name')
42
+ @Watch('optionRequestParams')
43
+ onFieldChanged (newValue, oldValue) {
44
+ if (JSON.stringify(newValue) === JSON.stringify(oldValue)) {
45
+ return
46
+ }
47
+ this.reloadOptions()
48
+ }
49
+
30
50
  reloadOptions () {
31
- if (this.fieldHasOptionsRequest()) {
32
- this.items = this.getSelectOptions()
33
- } else if (this.fieldHasOptions()) {
51
+ if (this.fieldHasOptionsRequest() || this.fieldHasOptions()) {
34
52
  this.items = this.getSelectOptions()
35
53
  }
36
54
  }