quasar-ui-danx 0.3.8 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -1,27 +1,45 @@
1
1
  <template>
2
2
  <div class="rendered-form">
3
- <div v-if="form.variations > 1" class="mb-4">
4
- <QTabs v-model="currentVariation" class="text-xs">
3
+ <div
4
+ v-if="form.variations > 1"
5
+ class="mb-4"
6
+ >
7
+ <QTabs
8
+ v-model="currentVariation"
9
+ class="text-xs"
10
+ >
5
11
  <QTab
6
- v-for="(name, index) in variationNames"
7
- :key="name"
8
- :name="name"
9
- class="p-0"
10
- content-class="w-full"
12
+ v-for="(name, index) in variationNames"
13
+ :key="name"
14
+ :name="name"
15
+ class="p-0"
16
+ content-class="w-full"
11
17
  >
12
18
  <div class="flex flex-nowrap items-center text-sm w-full">
13
- <div class="flex-grow">{{ name || "1" }}</div>
14
- <div v-if="!disable && !readonly && canModifyVariations" class="flex flex-nowrap items-center mr-2">
19
+ <div
20
+ v-if="!isVariationFormComplete(name)"
21
+ class="variation-missing-icon pl-1"
22
+ >
23
+ <MissingIcon class="text-red-400 w-4" />
24
+ <QTooltip>Creative Form Incomplete</QTooltip>
25
+ </div>
26
+ <div class="flex-grow">
27
+ {{ name || "1" }}
28
+ </div>
29
+ <div
30
+ v-if="!disable && !readonly && canModifyVariations"
31
+ class="flex flex-nowrap items-center mr-2"
32
+ >
15
33
  <a
16
- @click="() => (variationToEdit = name) && (newVariationName = name)"
17
- class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-blue-200 rounded"
34
+ class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-blue-200 rounded"
35
+ @click="() => (variationToEdit = name) && (newVariationName = name)"
18
36
  >
19
37
  <EditIcon class="w-3 text-blue-900" />
20
38
  </a>
21
39
  <a
22
- v-if="index > 0"
23
- @click="variationToDelete = name"
24
- class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-red-200 rounded"
40
+ v-if="index > 0"
41
+ class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-red-200 rounded"
42
+ @click="variationToDelete = name"
25
43
  >
26
44
  <RemoveIcon class="w-3 text-red-900" />
27
45
  </a>
@@ -29,63 +47,65 @@
29
47
  </div>
30
48
  </QTab>
31
49
  <QTab
32
- v-if="canAddVariation"
33
- name="add"
34
- key="add-new-variation"
35
- @click="onAddVariation"
36
- class="bg-blue-600 rounded-t-lg !text-white"
50
+ v-if="canAddVariation"
51
+ key="add-new-variation"
52
+ name="add"
53
+ class="bg-blue-600 rounded-t-lg !text-white"
54
+ @click="onAddVariation"
37
55
  >
38
56
  <template v-if="saving">
39
57
  <QSpinnerBall class="w-4" />
40
58
  </template>
41
- <template v-else>+ Add Variation</template>
59
+ <template v-else>
60
+ + Add Variation
61
+ </template>
42
62
  </QTab>
43
63
  </QTabs>
44
64
  </div>
45
65
  <div
46
- v-for="(field, index) in mappedFields"
47
- :key="field.id"
48
- :class="{ 'mt-4': index > 0 }"
66
+ v-for="(field, index) in mappedFields"
67
+ :key="field.id"
68
+ :class="{ 'mt-4': index > 0 }"
49
69
  >
50
70
  <Component
51
- :is="field.component"
52
- :key="field.name + '-' + currentVariation"
53
- :model-value="getFieldValue(field.name)"
54
- :field="field"
55
- :label="field.label || undefined"
56
- :no-label="noLabel"
57
- :show-name="showName"
58
- :disable="disable"
59
- :readonly="readonly"
60
- @update:model-value="onInput(field.name, $event)"
71
+ :is="field.component"
72
+ :key="field.name + '-' + currentVariation"
73
+ :model-value="getFieldValue(field.name)"
74
+ :field="field"
75
+ :label="field.label || undefined"
76
+ :no-label="noLabel"
77
+ :show-name="showName"
78
+ :disable="disable"
79
+ :readonly="readonly"
80
+ @update:model-value="onInput(field.name, $event)"
61
81
  />
62
82
  </div>
63
83
  <ConfirmDialog
64
- v-if="variationToEdit !== false"
65
- title="Change variation name"
66
- @confirm="onChangeVariationName"
67
- @close="variationToEdit = false"
84
+ v-if="variationToEdit !== false"
85
+ title="Change variation name"
86
+ @confirm="onChangeVariationName"
87
+ @close="variationToEdit = false"
68
88
  >
69
89
  <TextField
70
- v-model="newVariationName"
71
- label="Enter name"
72
- placeholder="Variation Name"
73
- input-class="bg-white"
90
+ v-model="newVariationName"
91
+ label="Enter name"
92
+ placeholder="Variation Name"
93
+ input-class="bg-white"
74
94
  />
75
95
  </ConfirmDialog>
76
96
  <ConfirmDialog
77
- v-if="variationToDelete"
78
- :title="`Remove variation ${variationToDelete}?`"
79
- content="You cannot undo this action. If there was any analytics collected for this variation, it will still be attributed to the ad."
80
- confirm-class="bg-red-900 text-white"
81
- content-class="w-96"
82
- @confirm="onRemoveVariation(variationToDelete)"
83
- @close="variationToDelete = ''"
97
+ v-if="variationToDelete"
98
+ :title="`Remove variation ${variationToDelete}?`"
99
+ content="You cannot undo this action. If there was any analytics collected for this variation, it will still be attributed to the ad."
100
+ confirm-class="bg-red-900 text-white"
101
+ content-class="w-96"
102
+ @confirm="onRemoveVariation(variationToDelete)"
103
+ @close="variationToDelete = ''"
84
104
  />
85
105
  </div>
86
106
  </template>
87
107
  <script setup>
88
- import { PencilIcon as EditIcon } from "@heroicons/vue/solid";
108
+ import { ExclamationCircleIcon as MissingIcon, PencilIcon as EditIcon } from "@heroicons/vue/solid";
89
109
  import { computed, ref } from "vue";
90
110
  import { FlashMessages, incrementName, replace } from "../../../helpers";
91
111
  import { TrashIcon as RemoveIcon } from "../../../svg";
@@ -154,9 +174,9 @@ const variationToEdit = ref(false);
154
174
  const variationToDelete = ref("");
155
175
  const canAddVariation = computed(() => props.canModifyVariations && !props.readonly && !props.disable && variationNames.value.length < props.form.variations);
156
176
 
157
- function getFieldResponse(name) {
177
+ function getFieldResponse(name, variation) {
158
178
  if (!props.values) return undefined;
159
- return props.values.find((v) => v.variation === currentVariation.value && v.name === name);
179
+ return props.values.find((v) => v.variation === (variation !== undefined ? variation : currentVariation.value) && v.name === name);
160
180
  }
161
181
  function getFieldValue(name) {
162
182
  return getFieldResponse(name)?.value;
@@ -224,4 +244,19 @@ function onRemoveVariation(name) {
224
244
  }
225
245
  variationToDelete.value = "";
226
246
  }
247
+
248
+ function isVariationFormComplete(variation) {
249
+ const requiredGroups = {};
250
+ return props.form.fields.filter(r => r.required || r.required_group).every((field) => {
251
+ const fieldResponse = getFieldResponse(field.name, variation);
252
+ const hasValue = !!fieldResponse && fieldResponse.value !== null;
253
+ if (field.required_group) {
254
+ // This required group has already been satisfied
255
+ if (requiredGroups[field.required_group]) return true;
256
+ return requiredGroups[field.required_group] = hasValue;
257
+ } else {
258
+ return hasValue;
259
+ }
260
+ });
261
+ }
227
262
  </script>
@@ -1,20 +1,22 @@
1
1
  <template>
2
2
  <QTab
3
- :name="name"
4
- class="w-full"
5
- content-class="w-full"
3
+ :name="name"
4
+ class="w-full"
5
+ content-class="w-full"
6
6
  >
7
7
  <div class="flex items-center w-full">
8
- <div class="flex-grow text-sm">{{ label }}</div>
8
+ <div class="flex-grow text-sm">
9
+ {{ label }}
10
+ </div>
9
11
  <div>
10
12
  <OverdueIcon
11
- v-if="overdue"
12
- class="w-5 ml-2"
13
- :class="isActive ? 'text-white' : 'text-red-400'"
13
+ v-if="overdue"
14
+ class="w-5 ml-2"
15
+ :class="isActive ? 'text-white' : 'text-red-400'"
14
16
  />
15
17
  <WarningIcon
16
- v-else-if="warning"
17
- class="text-yellow-600 w-5"
18
+ v-else-if="warning"
19
+ class="text-yellow-600 w-5"
18
20
  />
19
21
  </div>
20
22
  </div>