glib-web 2.4.1 → 3.0.0-beta1

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.
Files changed (100) hide show
  1. package/LICENSE +0 -0
  2. package/action.js +6 -1
  3. package/actions/auth/restart.js +0 -0
  4. package/actions/commands/enqueue.js +17 -0
  5. package/actions/components/update.js +13 -14
  6. package/actions/dialogs/oauth.js +0 -0
  7. package/actions/dialogs/options.js +0 -0
  8. package/app.vue +25 -26
  9. package/components/_button.vue +21 -28
  10. package/components/_chip.vue +14 -19
  11. package/components/_dropdownMenu.vue +10 -23
  12. package/components/_icon.vue +5 -5
  13. package/components/_message.vue +0 -0
  14. package/components/_responsive.vue +7 -21
  15. package/components/avatar.vue +11 -15
  16. package/components/banners/alert.vue +2 -7
  17. package/components/banners/select.vue +18 -30
  18. package/components/button.vue +5 -5
  19. package/components/component.vue +97 -100
  20. package/components/datetime.vue +0 -0
  21. package/components/fab.vue +0 -0
  22. package/components/fields/_patternText.vue +5 -19
  23. package/components/fields/_select.vue +7 -28
  24. package/components/fields/autocomplete.vue +5 -21
  25. package/components/fields/check.vue +19 -11
  26. package/components/fields/country/countries.js +0 -0
  27. package/components/fields/country/field.vue +9 -27
  28. package/components/fields/country/regions.js +0 -0
  29. package/components/fields/date.vue +5 -5
  30. package/components/fields/datetime.vue +5 -5
  31. package/components/fields/dynamicSelect.vue +8 -29
  32. package/components/fields/newRichText.vue +66 -53
  33. package/components/fields/otpField.vue +90 -0
  34. package/components/fields/phone/field.vue +60 -78
  35. package/components/fields/radio.vue +16 -23
  36. package/components/fields/rating.vue +9 -16
  37. package/components/fields/richText.vue +8 -28
  38. package/components/fields/select.vue +10 -7
  39. package/components/fields/stripeExternalAccount.vue +10 -24
  40. package/components/fields/text.vue +24 -40
  41. package/components/fields/textarea.vue +13 -27
  42. package/components/fields/timeZone.vue +9 -6
  43. package/components/fields/timer.vue +3 -10
  44. package/components/hr.vue +0 -0
  45. package/components/html.vue +0 -0
  46. package/components/image.vue +13 -20
  47. package/components/map.vue +115 -29
  48. package/components/markdown.vue +15 -8
  49. package/components/mixins/events.js +17 -6
  50. package/components/mixins/longClick.js +0 -0
  51. package/components/mixins/scrolling.js +0 -0
  52. package/components/mixins/styles.js +18 -15
  53. package/components/mixins/table/export.js +0 -0
  54. package/components/mixins/table/import.js +0 -0
  55. package/components/p.vue +0 -0
  56. package/components/panels/column.vue +5 -5
  57. package/components/panels/custom.vue +15 -15
  58. package/components/panels/flow.vue +19 -13
  59. package/components/panels/form.vue +17 -28
  60. package/components/panels/grid.vue +15 -9
  61. package/components/panels/horizontal.vue +149 -18
  62. package/components/panels/list.vue +63 -70
  63. package/components/panels/responsive.vue +13 -33
  64. package/components/panels/split.vue +2 -2
  65. package/components/panels/table.vue +27 -61
  66. package/components/panels/timeline.vue +20 -30
  67. package/components/panels/vertical.vue +9 -14
  68. package/components/tabBar.vue +27 -19
  69. package/index.js +68 -72
  70. package/keys.js +0 -0
  71. package/nav/appbar.vue +4 -4
  72. package/nav/dialog.vue +24 -34
  73. package/nav/drawer.vue +39 -51
  74. package/nav/drawerButton.vue +5 -7
  75. package/nav/drawerLabel.vue +2 -3
  76. package/nav/sheet.vue +18 -24
  77. package/nav/snackbar.vue +16 -26
  78. package/package.json +10 -11
  79. package/plugins/driverCustomBehavior.js +1 -1
  80. package/plugins/updatableComponent.js +1 -7
  81. package/plugins/vuetify.js +27 -0
  82. package/settings.json.example +0 -0
  83. package/styles/test.sass +0 -0
  84. package/styles/test.scss +0 -0
  85. package/templates/comment.vue +42 -19
  86. package/templates/featured.vue +8 -9
  87. package/templates/thumbnail-old.vue +188 -0
  88. package/templates/thumbnail.vue +5 -188
  89. package/templates/unsupported.vue +0 -0
  90. package/tsconfig.json +1 -1
  91. package/utils/dom.js +0 -0
  92. package/utils/eventBus.js +9 -2
  93. package/utils/history.js +7 -4
  94. package/utils/http.js +7 -2
  95. package/utils/launch.js +43 -51
  96. package/utils/public.js +6 -0
  97. package/utils/queue.js +110 -0
  98. package/utils/settings.js +3 -1
  99. package/utils/storage.js +0 -0
  100. package/utils/url.js +0 -0
@@ -1,19 +1,8 @@
1
1
  <template>
2
- <v-form
3
- ref="form"
4
- :style="parentStyles"
5
- :action="url"
6
- :method="spec.method"
7
- :data-local="spec.local"
8
- @submit="onSubmit"
9
- >
10
- <template v-for="(value, key, index) in params">
11
- <input
12
- :key="`hidden_${index}`"
13
- type="hidden"
14
- :name="key"
15
- :value="value"
16
- />
2
+ <v-form ref="form" :style="parentStyles" :action="url" :method="spec.method" :data-local="spec.local"
3
+ @submit="onSubmit">
4
+ <template v-for="(value, key, index) in params" :key="`hidden_${index}`">
5
+ <input type="hidden" :name="key" :model-value="value" />
17
6
  </template>
18
7
 
19
8
  <panels-responsive :spec="modifiedSpec" />
@@ -28,7 +17,7 @@
28
17
 
29
18
  export default {
30
19
  props: {
31
- spec: { type: Object, required: true }
20
+ spec: { type: Object, required: true },
32
21
  },
33
22
  data: () => ({
34
23
  url: null,
@@ -36,22 +25,22 @@ export default {
36
25
  parentStyles: {},
37
26
  formElement: null,
38
27
  submitButtons: [],
39
- modifiedSpec: {}
28
+ modifiedSpec: {},
40
29
  }),
41
30
  watch: {
42
- $isBusy: function(val, oldVal) {
31
+ $isBusy: function (val, oldVal) {
43
32
  for (const button of this.submitButtons) {
44
33
  button._isBusy = val;
45
34
  }
46
- }
35
+ },
47
36
  },
48
37
  methods: {
49
38
  $mounted() {
50
- this.$onEvent("forms/addSubmit", e => {
39
+ this.$onEvent("forms/addSubmit", (e) => {
51
40
  this.submitButtons.push(e.data);
52
41
  });
53
42
 
54
- this.$onEvent("forms/setBusy", e => {
43
+ this.$onEvent("forms/setBusy", (e) => {
55
44
  if (e.data.value) {
56
45
  Utils.http.startIndicator(this);
57
46
  } else {
@@ -59,11 +48,11 @@ export default {
59
48
  }
60
49
  });
61
50
 
62
- this.$onEvent("forms/submit", e => {
51
+ this.$onEvent("forms/submit", (e) => {
63
52
  this.submit();
64
53
  });
65
54
 
66
- this.$onEvent("forms/directSubmit", e => {
55
+ this.$onEvent("forms/directSubmit", (e) => {
67
56
  this.directSubmit(e.data.url);
68
57
  });
69
58
  },
@@ -80,7 +69,7 @@ export default {
80
69
 
81
70
  let firstAutoFocus = false;
82
71
  this.modifiedSpec = this.spec;
83
- this.modifiedSpec.childViews.map(childView => {
72
+ this.modifiedSpec.childViews.map((childView) => {
84
73
  if (
85
74
  childView.view.startsWith("fields/") &&
86
75
  childView.view !== "fields/hidden-v1" &&
@@ -103,10 +92,10 @@ export default {
103
92
  this.validate(() => {
104
93
  Utils.type.ifObject(
105
94
  this.spec.onSubmit,
106
- onSubmit => {
95
+ (onSubmit) => {
107
96
  const formData = Utils.url.toMap(new FormData(this.formElement));
108
97
  const params = {
109
- [this.spec.paramNameForFormData || "formData"]: formData
98
+ [this.spec.paramNameForFormData || "formData"]: formData,
110
99
  };
111
100
  const data = Object.assign({}, onSubmit, params);
112
101
  GLib.action.execute(data, this);
@@ -138,11 +127,11 @@ export default {
138
127
  },
139
128
  action_clear() {
140
129
  this.formElement.reset();
141
- }
130
+ },
142
131
  // $dialogContainer() {
143
132
  // return this.formElement;
144
133
  // }
145
- }
134
+ },
146
135
  };
147
136
  </script>
148
137
 
@@ -1,7 +1,13 @@
1
1
  <template>
2
- <div :class="$classes()" :style="cssStyles">
3
- <template v-for="(item, index) in spec.childViews">
4
- <div :key="index">
2
+ <div
3
+ :class="$classes()"
4
+ :style="cssStyles"
5
+ >
6
+ <template
7
+ v-for="(item, index) in spec.childViews"
8
+ :key="index"
9
+ >
10
+ <div>
5
11
  <glib-component :spec="item" />
6
12
  </div>
7
13
  </template>
@@ -11,20 +17,20 @@
11
17
  <script>
12
18
  export default {
13
19
  props: {
14
- spec: { type: Object, required: true }
20
+ spec: { type: Object, required: true },
15
21
  },
16
22
  computed: {
17
- cssStyles: function() {
23
+ cssStyles: function () {
18
24
  const styles = this.$styles();
19
25
 
20
26
  styles["display"] = "grid";
21
27
  Utils.type.ifNumber(
22
28
  this.spec.columnGap,
23
- columnGap => (styles["columnGap"] = `${columnGap}px`)
29
+ (columnGap) => (styles["columnGap"] = `${columnGap}px`)
24
30
  );
25
31
  Utils.type.ifNumber(
26
32
  this.spec.rowGap,
27
- rowGap => (styles["rowGap"] = `${rowGap}px`)
33
+ (rowGap) => (styles["rowGap"] = `${rowGap}px`)
28
34
  );
29
35
  const boxMaxWidth = this.spec.boxMaxWidth
30
36
  ? `${this.spec.boxMaxWidth}px`
@@ -35,8 +41,8 @@ export default {
35
41
  ] = `repeat(auto-fit, minmax(${this.spec.boxMinWidth}px, ${boxMaxWidth}))`;
36
42
 
37
43
  return styles;
38
- }
39
- }
44
+ },
45
+ },
40
46
  };
41
47
  </script>
42
48
 
@@ -1,25 +1,55 @@
1
1
  <template>
2
- <component
2
+ <!-- <component
3
3
  :is="componentName"
4
4
  :class="cssClasses"
5
5
  :style="cssStyles"
6
6
  :href="$href()"
7
7
  @click="$onClick()"
8
8
  >
9
- <template v-for="(item, index) in spec.childViews">
10
- <glib-component :key="index" :spec="item" />
9
+ <template
10
+ v-for="(item, index) in spec.childViews"
11
+ :key="index"
12
+ >
13
+ <glib-component :spec="item" />
11
14
  </template>
15
+ </component> -->
16
+ <component :is="componentName" :style="parentStyles" :class="parentClasses" :href="$href()" @click="$onClick()">
17
+ <!-- <draggable :style="childStyles" :class="childClasses" ghost-class="ghost" -->
18
+ <!-- :group="dragSupport ? dragSupport.groupId || 'common' : 'common'" :data-dragPanelId="spec.id"
19
+ :disabled="!$type.isObject(spec.dragSupport)" @start="onDragStart" @end="onDragEnd"> -->
20
+ <!-- Using `item.id` as key is important to make sure the item gets updated
21
+ when dragging ends. -->
22
+ <div :style="childStyles" :class="childClasses">
23
+ <template v-for="(item, index) in childViews" :key="item.id || index">
24
+ <glib-component :spec="item" />
25
+ </template>
26
+ </div>
27
+ <!-- </draggable> -->
12
28
  </component>
13
29
  </template>
14
30
 
15
31
  <script>
32
+ // import draggable from "vuedraggable";
33
+
16
34
  export default {
35
+ components: {
36
+ // draggable
37
+ },
17
38
  props: {
18
- spec: { type: Object, required: true }
39
+ spec: { type: Object, required: true },
40
+ },
41
+ data: function () {
42
+ return {
43
+ dragSupport: null,
44
+ childViews: []
45
+ };
19
46
  },
20
47
  computed: {
21
- cssClasses: function() {
22
- const classes = this.$classes().concat("layouts-horizontal");
48
+ parentClasses: function () {
49
+ return this.$classes();
50
+ },
51
+ childClasses() {
52
+ const classes = ["layouts-horizontal"];
23
53
  const distribution = this.spec.distribution;
24
54
  switch (distribution) {
25
55
  case "fillEqually":
@@ -29,9 +59,12 @@ export default {
29
59
  classes.push("layouts-horizontal--space-equally");
30
60
  break;
31
61
  default:
32
- Utils.type.ifString(distribution, distribution => {
62
+ Utils.type.ifString(distribution, (distribution) => {
33
63
  // Uses Material Design spacings: https://vuetifyjs.com/en/styles/spacing/#how-it-works
34
- if (distribution.startsWith("overlap")) {
64
+ if (
65
+ distribution.startsWith("overlap-") ||
66
+ distribution.startsWith("space-")
67
+ ) {
35
68
  classes.push(`layouts-horizontal--${distribution}`);
36
69
  }
37
70
  });
@@ -39,8 +72,16 @@ export default {
39
72
  }
40
73
  return classes;
41
74
  },
42
- cssStyles: function() {
43
- const styles = this.genericStyles();
75
+ parentStyles() {
76
+ const styles = this.$styles();
77
+ if (this.spec.width == "matchParent") {
78
+ styles["width"] = "100%";
79
+ }
80
+ return styles;
81
+ },
82
+ childStyles() {
83
+ const styles = {};
84
+
44
85
  switch (this.spec.align) {
45
86
  case "middle":
46
87
  styles["align-items"] = "center";
@@ -51,15 +92,55 @@ export default {
51
92
  default:
52
93
  styles["align-items"] = "flex-start";
53
94
  }
95
+
54
96
  return styles;
55
97
  },
56
98
  componentName() {
57
- return this.$href() ? "a" : "div";
99
+ return this.spec.onClick ? "a" : "div";
58
100
  }
59
101
  },
60
102
  methods: {
103
+ $ready() {
104
+ this.dragSupport = this.spec.dragSupport;
105
+ this.childViews = this.spec.childViews;
106
+ },
61
107
  $displayValue() {
62
108
  return "flex";
109
+ },
110
+ onDragStart(event) {
111
+ // This allows custom components to detect if something is being dragged.
112
+ window.vueApp.draggedComponent = this;
113
+ },
114
+ onDragEnd(event) {
115
+ window.vueApp.draggedComponent = null;
116
+
117
+ const targetRowIndex = event.newIndex;
118
+ if (event.from == event.to && event.oldIndex == targetRowIndex) {
119
+ console.log("Reordering canceled");
120
+ return;
121
+ }
122
+
123
+ console.log("DRAG1", this.childViews);
124
+
125
+ const itemId = event.clone.dataset.dragitemid; // The item that got dragged/dropped
126
+ const oldPanelId = event.from.dataset.dragpanelid;
127
+ const newPanelId = event.to.dataset.dragpanelid;
128
+
129
+ const dragSpec = this.spec.dragSupport;
130
+ const mergedSpec = Object.assign(dragSpec.onDrop, {
131
+ [dragSpec.paramNameForFormData || "formData"]: {
132
+ [dragSpec.paramNameForNewAbsoluteIndex || "newIndex"]: targetRowIndex,
133
+ [dragSpec.paramNameForItemId || "itemId"]: itemId,
134
+ [dragSpec.paramNameForOldPanelId || "oldPanelId"]: oldPanelId,
135
+ [dragSpec.paramNameForNewPanelId || "newPanelId"]: newPanelId
136
+ }
137
+ });
138
+
139
+ console.log("DRAG2", mergedSpec, event.clone, event);
140
+
141
+ GLib.action.execute(mergedSpec, this);
142
+
143
+ console.log("DRAG3", this.childViews);
63
144
  }
64
145
  }
65
146
  };
@@ -100,26 +181,76 @@ a.panels-horizontal {
100
181
  </style>
101
182
 
102
183
  <style>
103
- .layouts-horizontal--fill-equally > * {
184
+ .layouts-horizontal--fill-equally>* {
104
185
  flex: initial;
105
186
  width: 100%;
106
187
  }
107
- .layouts-horizontal--space-equally > * {
188
+
189
+ .layouts-horizontal--space-equally>* {
108
190
  flex: initial;
109
191
  }
110
- .layouts-horizontal--overlap-1 > *:not(:first-child) {
192
+
193
+ .layouts-horizontal--overlap-1>*:not(:first-child) {
111
194
  margin-left: -4px;
112
195
  }
113
- .layouts-horizontal--overlap-2 > *:not(:first-child) {
196
+
197
+ .layouts-horizontal--overlap-2>*:not(:first-child) {
114
198
  margin-left: -8px;
115
199
  }
116
- .layouts-horizontal--overlap-3 > *:not(:first-child) {
200
+
201
+ .layouts-horizontal--overlap-3>*:not(:first-child) {
117
202
  margin-left: -12px;
118
203
  }
119
- .layouts-horizontal--overlap-4 > *:not(:first-child) {
204
+
205
+ .layouts-horizontal--overlap-4>*:not(:first-child) {
120
206
  margin-left: -16px;
121
207
  }
122
- .layouts-horizontal--overlap-5 > *:not(:first-child) {
208
+
209
+ .layouts-horizontal--overlap-5>*:not(:first-child) {
123
210
  margin-left: -20px;
124
211
  }
212
+
213
+ .layouts-horizontal--overlap-6>*:not(:first-child) {
214
+ margin-left: -24px;
215
+ }
216
+
217
+ .layouts-horizontal--overlap-7>*:not(:first-child) {
218
+ margin-left: -28px;
219
+ }
220
+
221
+ .layouts-horizontal--overlap-8>*:not(:first-child) {
222
+ margin-left: -32px;
223
+ }
224
+
225
+ .layouts-horizontal--space-1>*:not(:first-child) {
226
+ margin-left: 4px;
227
+ }
228
+
229
+ .layouts-horizontal--space-2>*:not(:first-child) {
230
+ margin-left: 8px;
231
+ }
232
+
233
+ .layouts-horizontal--space-3>*:not(:first-child) {
234
+ margin-left: 12px;
235
+ }
236
+
237
+ .layouts-horizontal--space-4>*:not(:first-child) {
238
+ margin-left: 16px;
239
+ }
240
+
241
+ .layouts-horizontal--space-5>*:not(:first-child) {
242
+ margin-left: 20px;
243
+ }
244
+
245
+ .layouts-horizontal--space-6>*:not(:first-child) {
246
+ margin-left: 24px;
247
+ }
248
+
249
+ .layouts-horizontal--space-7>*:not(:first-child) {
250
+ margin-left: 28px;
251
+ }
252
+
253
+ .layouts-horizontal--space-8>*:not(:first-child) {
254
+ margin-left: 32px;
255
+ }
125
256
  </style>
@@ -1,51 +1,31 @@
1
1
  <template>
2
- <v-list
3
- :two-line="twoLine"
4
- :three-line="threeLine"
5
- class="py-0"
6
- :style="genericStyles()"
7
- >
2
+ <v-list :two-line="twoLine || null" :three-line="threeLine || null" class="py-0" :class="$classes()" :style="$styles()">
8
3
  <div ref="topAnchor">
9
4
  <div v-if="prevPageUrl" class="py-3 px-4">
10
5
  Loading...
11
6
  </div>
12
7
  </div>
13
8
 
14
- <template v-for="(section, sectionIndex) in sections">
15
- <div :key="`section${sectionIndex}`">
9
+ <template v-for="(section, sectionIndex) in sections" :key="`section${sectionIndex}`">
10
+ <div>
16
11
  <panels-responsive v-if="section.header" :spec="section.header" />
17
12
 
18
- <draggable
19
- v-model="section.rows"
20
- ghost-class="ghost"
21
- group="a"
22
- handle=".handle"
23
- :data-index="sectionIndex"
24
- @end="onDragEnd"
25
- >
26
- <div
27
- v-for="(row, rowIndex) in section.rows"
28
- :key="`${sectionIndex}_${rowIndex}`"
29
- :ref="`row_${sectionIndex}_${rowIndex}`"
30
- :class="row.styleClasses"
31
- >
32
- <v-divider v-if="!spec.responsiveCols && rowIndex == 0" />
13
+ <!-- <draggable v-model="section.rows" ghost-class="ghost"
14
+ :group="dragSupport ? dragSupport.groupId || 'common' : 'common'" :data-dragListId="spec.id"
15
+ :data-dragSectionIndex="sectionIndex" :disabled="!$type.isObject(dragSupport)" @start="onDragStart"
16
+ @end="onDragEnd"> -->
17
+ <div v-for="(row, rowIndex) in section.rows" :key="`${sectionIndex}_${rowIndex}`"
18
+ :ref="`row_${sectionIndex}_${rowIndex}`" :data-dragRowId="row.id">
19
+ <v-divider v-if="!spec.responsiveCols && rowIndex == 0" />
33
20
 
34
- <component
35
- :is="template(row)"
36
- :spec="rowSpec(row)"
37
- :responsive-cols="spec.responsiveCols"
38
- :index="rowIndex"
39
- />
40
- <v-divider
41
- v-if="
42
- !spec.responsiveCols &&
43
- (rowIndex != section.rows.length - 1 ||
44
- sectionIndex != sections.length - 1)
45
- "
46
- />
47
- </div>
48
- </draggable>
21
+ <component :is="template(row)" :spec="rowSpec(row)" :responsive-cols="spec.responsiveCols" :index="rowIndex" />
22
+ <v-divider v-if="
23
+ !spec.responsiveCols &&
24
+ (rowIndex != section.rows.length - 1 ||
25
+ sectionIndex != sections.length - 1)
26
+ " />
27
+ </div>
28
+ <!-- </draggable> -->
49
29
 
50
30
  <panels-responsive v-if="section.footer" :spec="section.footer" />
51
31
  </div>
@@ -60,28 +40,29 @@
60
40
  </template>
61
41
 
62
42
  <script>
63
- import draggable from "vuedraggable";
43
+ // import draggable from "vuedraggable";
64
44
  import autoloadMixin from "../mixins/list/autoload.js";
65
- import ThumbnailTemplate from "../../templates/thumbnail";
66
- import FeaturedTemplate from "../../templates/featured";
67
- import CommentTemplate from "../../templates/comment";
45
+ import ThumbnailTemplate from "../../templates/thumbnail.vue";
46
+ import FeaturedTemplate from "../../templates/featured.vue";
47
+ import CommentTemplate from "../../templates/comment.vue";
68
48
  import actionCableMixin from "../mixins/ws/actionCable.js";
69
49
 
70
50
  export default {
71
51
  components: {
72
- draggable,
52
+ // draggable,
73
53
  "template-thumbnail": ThumbnailTemplate,
74
54
  "template-featured": FeaturedTemplate,
75
55
  "template-commentOutgoing": CommentTemplate,
76
- "template-commentIncoming": CommentTemplate
56
+ "template-commentIncoming": CommentTemplate,
77
57
  },
78
58
  mixins: [autoloadMixin, actionCableMixin],
79
59
  props: {
80
- spec: { type: Object, required: true }
60
+ spec: { type: Object, required: true },
81
61
  },
82
- data: function() {
62
+ data: function () {
83
63
  return {
84
- sections: []
64
+ sections: [],
65
+ dragSupport: null
85
66
  };
86
67
  },
87
68
  computed: {
@@ -106,11 +87,12 @@ export default {
106
87
  }
107
88
  }
108
89
  return false;
109
- }
90
+ },
110
91
  },
111
92
  methods: {
112
93
  $ready() {
113
94
  this.sections = this.spec.sections || [];
95
+ this.dragSupport = this.spec.dragSupport;
114
96
  this.autoloadAll(this.spec.nextPage);
115
97
  this.enableInfiniteScrollIfApplicable();
116
98
  this.$wsSubscribeEvents(this.spec.phoenixSocket);
@@ -128,7 +110,7 @@ export default {
128
110
  fieldTitleName: this.spec.fieldTitleName
129
111
  ? `${prefix}[${this.spec.fieldTitleName}]`
130
112
  : null,
131
- fieldCheckValueIf: this.spec.fieldCheckValueIf
113
+ fieldCheckValueIf: this.spec.fieldCheckValueIf,
132
114
  });
133
115
  }
134
116
  return row;
@@ -151,7 +133,7 @@ export default {
151
133
  this.$set(section, "rows", []);
152
134
  }
153
135
 
154
- Utils.type.ifArray(appendedSection.rows, rows => {
136
+ Utils.type.ifArray(appendedSection.rows, (rows) => {
155
137
  for (const row of rows) {
156
138
  section.rows.push(row);
157
139
  }
@@ -161,14 +143,14 @@ export default {
161
143
  action_update(spec) {
162
144
  const updatedRows = {};
163
145
 
164
- Utils.type.ifArray(spec.rows, rows => {
146
+ Utils.type.ifArray(spec.rows, (rows) => {
165
147
  for (const row of rows) {
166
148
  updatedRows[row.id] = row;
167
149
  }
168
150
  });
169
151
 
170
152
  for (const section of this.sections) {
171
- section.rows = section.rows.map(row => {
153
+ section.rows = section.rows.map((row) => {
172
154
  const updatedRow = updatedRows[row.id];
173
155
  if (updatedRow) {
174
156
  return updatedRow;
@@ -180,14 +162,14 @@ export default {
180
162
  },
181
163
  action_delete(spec) {
182
164
  const deletedRows = {};
183
- Utils.type.ifArray(spec.rows, rows => {
165
+ Utils.type.ifArray(spec.rows, (rows) => {
184
166
  for (const row of rows) {
185
167
  deletedRows[row.id] = row;
186
168
  }
187
169
  });
188
170
 
189
171
  for (const section of this.sections) {
190
- section.rows = section.rows.filter(row => {
172
+ section.rows = section.rows.filter((row) => {
191
173
  // return !rows.includes(row.id);
192
174
  return !deletedRows[row.id];
193
175
  });
@@ -212,37 +194,48 @@ export default {
212
194
  serializedSpec(row) {
213
195
  return JSON.stringify(row);
214
196
  },
197
+ onDragStart(event) {
198
+ // This allows custom components to detect if something is being dragged.
199
+ window.vueApp.draggedComponent = this;
200
+ },
215
201
  onDragEnd(event) {
202
+ window.vueApp.draggedComponent = null;
203
+
216
204
  const targetSectionedRowIndex = event.newIndex;
205
+ // const sourceSectionedRowIndex = event.oldIndex;
217
206
  if (event.from == event.to && event.oldIndex == targetSectionedRowIndex) {
218
207
  console.log("Reordering canceled");
219
208
  return;
220
209
  }
221
-
222
210
  const targetSectionIndex = this.getSectionIndex(event.to);
223
- const targetSection = this.getSection(targetSectionIndex);
224
- // The dragged row is now on the new index
225
- const draggedRow = targetSection.rows[targetSectionedRowIndex];
211
+ // const targetSection = this.getSection(targetSectionIndex);
226
212
 
227
213
  const targetAbsoluteIndex =
228
214
  this.previousSectionsRowCount(event.to) + targetSectionedRowIndex;
229
215
 
230
- const mergedSpec = Object.assign(draggedRow.onReorder, {
231
- [draggedRow.paramNameForFormData || "formData"]: {
232
- [draggedRow.paramNameForNewIndex]: targetAbsoluteIndex, // Deprecated
233
- [draggedRow.paramNameForNewAbsoluteIndex ||
234
- "newAbsoluteIndex"]: targetAbsoluteIndex,
235
- [draggedRow.paramNameForNewSectionIndex ||
236
- "newSectionIndex"]: targetSectionIndex,
237
- [draggedRow.paramNameForNewSectionedRowIndex ||
238
- "newSectionedRowIndex"]: targetSectionedRowIndex
216
+ const rowId = event.clone.dataset.dragrowid; // The item that got dragged/dropped
217
+ const oldListId = event.from.dataset.draglistid;
218
+ const newListId = event.to.dataset.draglistid;
219
+
220
+ const dragSpec = this.dragSupport;
221
+ const mergedSpec = Object.assign(dragSpec.onDrop, {
222
+ [dragSpec.paramNameForFormData || "formData"]: {
223
+ [dragSpec.paramNameForNewAbsoluteIndex ||
224
+ "newAbsoluteIndex"]: targetAbsoluteIndex,
225
+ [dragSpec.paramNameForNewSectionIndex ||
226
+ "newSectionIndex"]: targetSectionIndex,
227
+ [dragSpec.paramNameForNewSectionedRowIndex ||
228
+ "newSectionedRowIndex"]: targetSectionedRowIndex,
229
+ [dragSpec.paramNameForRowId || "rowId"]: rowId,
230
+ [dragSpec.paramNameForOldListId || "oldListId"]: oldListId,
231
+ [dragSpec.paramNameForNewListId || "newListId"]: newListId
239
232
  }
240
233
  });
241
234
 
242
235
  GLib.action.execute(mergedSpec, this);
243
236
  },
244
237
  getSectionIndex(element) {
245
- return element.dataset.index;
238
+ return element.dataset.dragsectionindex;
246
239
  },
247
240
  getSection(sectionIndex) {
248
241
  return this.sections[sectionIndex];
@@ -254,8 +247,8 @@ export default {
254
247
  count += this.getSection(i).rows.length;
255
248
  }
256
249
  return count;
257
- }
258
- }
250
+ },
251
+ },
259
252
  };
260
253
  </script>
261
254