quasar-ui-danx 0.3.7 → 0.3.9

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.7",
3
+ "version": "0.3.9",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -28,6 +28,7 @@
28
28
  "core-js": "^3.0.0",
29
29
  "cssnano": "^4.1.10",
30
30
  "eslint": "^8.5.0",
31
+ "eslint-plugin-import": "^2.29.1",
31
32
  "eslint-plugin-vue": "^9.24.1",
32
33
  "fs-extra": "^8.1.0",
33
34
  "postcss": "^8.4.38",
@@ -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,29 +1,46 @@
1
1
  <template>
2
2
  <div
3
- class="p-4"
4
- :class="{ 'is-collapsed': collapsed }"
3
+ class="p-4"
4
+ :class="{ 'is-collapsed': collapsed }"
5
5
  >
6
6
  <div
7
- v-for="item in allowedItems"
8
- :key="'nav-item-' + item.label"
9
- class="nav-menu-item"
10
- :class="item.class || itemClass"
7
+ v-for="item in allowedItems"
8
+ :key="'nav-item-' + item.label"
9
+ class="nav-menu-item-box"
11
10
  >
12
- <div class="flex flex-nowrap" @click="item.onClick">
13
- <div v-if="item.icon">
11
+ <div
12
+ class="nav-menu-item flex flex-nowrap"
13
+ :class="item.class || itemClass"
14
+ @click="item.onClick"
15
+ >
16
+ <div
17
+ v-if="item.icon"
18
+ class="flex-shrink-0"
19
+ >
14
20
  <component
15
- :is="item.icon"
16
- class="nav-icon"
17
- :class="item.iconClass"
21
+ :is="item.icon"
22
+ class="nav-icon"
23
+ :class="item.iconClass"
18
24
  />
19
25
  </div>
20
- <div class="label ml-2" :class="item.labelClass">{{ item.label }}</div>
21
- <QTooltip v-if="collapsed" v-bind="item.tooltip">{{ item.tooltip?.text || item.label }}</QTooltip>
26
+ <div
27
+ v-if="!collapsed"
28
+ class="label ml-2"
29
+ :class="item.labelClass"
30
+ >
31
+ {{ item.label }}
32
+ </div>
33
+ <QTooltip
34
+ v-if="collapsed"
35
+ v-bind="item.tooltip"
36
+ >
37
+ {{ item.tooltip?.text || item.label }}
38
+ </QTooltip>
22
39
  </div>
23
40
  <QSeparator
24
- v-if="item.separator"
25
- :key="'separator-' + item.label"
26
- class="my-2"
41
+ v-if="item.separator"
42
+ :key="'separator-' + item.label"
43
+ class="my-2"
27
44
  />
28
45
  </div>
29
46
  </div>
@@ -52,12 +69,10 @@ const allowedItems = computed(() => props.items.filter((item) => !item.hidden));
52
69
 
53
70
  <style lang="scss">
54
71
  .nav-menu-item {
55
- padding: 1.2em;
72
+ padding: 1em;
56
73
  border-radius: 0.5em;
57
74
  font-weight: bold;
58
75
  font-size: 14px;
59
- height: 3.8em;
60
- width: 13em;
61
76
  transition: all 150ms, color 0ms;
62
77
  cursor: pointer;
63
78
 
@@ -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>
@@ -2,5 +2,6 @@
2
2
  @tailwind components;
3
3
  @tailwind utilities;
4
4
 
5
- @import 'quasar-reset';
5
+ @import "quasar-reset";
6
6
  @import "general";
7
+ @import "transitions";
@@ -0,0 +1,15 @@
1
+ body.disable-all-transitions {
2
+ * {
3
+ transition: none !important;
4
+ }
5
+ }
6
+
7
+ .v-enter-active,
8
+ .v-leave-active {
9
+ transition: opacity 0.5s ease;
10
+ }
11
+
12
+ .v-enter-from,
13
+ .v-leave-to {
14
+ opacity: 0;
15
+ }