quasar-ui-danx 0.3.25 → 0.3.27

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.25",
3
+ "version": "0.3.27",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -1,109 +1,109 @@
1
1
  <template>
2
- <div class="rendered-form">
3
- <div
4
- v-if="form.variations > 1"
5
- class="mb-4"
6
- >
7
- <QTabs
8
- v-model="currentVariation"
9
- class="text-xs"
10
- >
11
- <QTab
12
- v-for="(name, index) in variationNames"
13
- :key="name"
14
- :name="name"
15
- class="p-0"
16
- content-class="w-full"
17
- >
18
- <div class="flex flex-nowrap items-center text-sm w-full">
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
- >
33
- <a
34
- class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-blue-200 rounded"
35
- @click="() => (variationToEdit = name) && (newVariationName = name)"
36
- >
37
- <EditIcon class="w-3 text-blue-900" />
38
- </a>
39
- <a
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"
43
- >
44
- <RemoveIcon class="w-3 text-red-900" />
45
- </a>
46
- </div>
47
- </div>
48
- </QTab>
49
- <QTab
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"
55
- >
56
- <template v-if="saving">
57
- <QSpinnerBall class="w-4" />
58
- </template>
59
- <template v-else>
60
- + Add Variation
61
- </template>
62
- </QTab>
63
- </QTabs>
64
- </div>
65
- <div
66
- v-for="(field, index) in mappedFields"
67
- :key="field.id"
68
- :class="{ 'mt-4': index > 0 }"
69
- >
70
- <Component
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
- :clearable="field.clearable || clearable"
79
- :disable="disable"
80
- :readonly="readonly"
81
- @update:model-value="onInput(field.name, $event)"
82
- />
83
- </div>
84
- <ConfirmDialog
85
- v-if="variationToEdit !== false"
86
- title="Change variation name"
87
- @confirm="onChangeVariationName"
88
- @close="variationToEdit = false"
89
- >
90
- <TextField
91
- v-model="newVariationName"
92
- label="Enter name"
93
- placeholder="Variation Name"
94
- input-class="bg-white"
95
- />
96
- </ConfirmDialog>
97
- <ConfirmDialog
98
- v-if="variationToDelete"
99
- :title="`Remove variation ${variationToDelete}?`"
100
- content="You cannot undo this action. If there was any analytics collected for this variation, it will still be attributed to the ad."
101
- confirm-class="bg-red-900 text-white"
102
- content-class="w-96"
103
- @confirm="onRemoveVariation(variationToDelete)"
104
- @close="variationToDelete = ''"
105
- />
106
- </div>
2
+ <div class="rendered-form">
3
+ <div
4
+ v-if="form.variations > 1"
5
+ class="mb-4"
6
+ >
7
+ <QTabs
8
+ v-model="currentVariation"
9
+ class="text-xs"
10
+ >
11
+ <QTab
12
+ v-for="(name, index) in variationNames"
13
+ :key="name"
14
+ :name="name"
15
+ class="p-0"
16
+ content-class="w-full"
17
+ >
18
+ <div class="flex flex-nowrap items-center text-sm w-full">
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
+ >
33
+ <a
34
+ class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-blue-200 rounded"
35
+ @click="() => (variationToEdit = name) && (newVariationName = name)"
36
+ >
37
+ <EditIcon class="w-3 text-blue-900" />
38
+ </a>
39
+ <a
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"
43
+ >
44
+ <RemoveIcon class="w-3 text-red-900" />
45
+ </a>
46
+ </div>
47
+ </div>
48
+ </QTab>
49
+ <QTab
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"
55
+ >
56
+ <template v-if="saving">
57
+ <QSpinnerBall class="w-4" />
58
+ </template>
59
+ <template v-else>
60
+ + Add Variation
61
+ </template>
62
+ </QTab>
63
+ </QTabs>
64
+ </div>
65
+ <div
66
+ v-for="(field, index) in mappedFields"
67
+ :key="field.id"
68
+ :class="{ 'mt-4': index > 0 }"
69
+ >
70
+ <Component
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
+ :clearable="field.clearable || clearable"
79
+ :disable="disable"
80
+ :readonly="readonly"
81
+ @update:model-value="onInput(field.name, $event)"
82
+ />
83
+ </div>
84
+ <ConfirmDialog
85
+ v-if="variationToEdit !== false"
86
+ title="Change variation name"
87
+ @confirm="onChangeVariationName"
88
+ @close="variationToEdit = false"
89
+ >
90
+ <TextField
91
+ v-model="newVariationName"
92
+ label="Enter name"
93
+ placeholder="Variation Name"
94
+ input-class="bg-white"
95
+ />
96
+ </ConfirmDialog>
97
+ <ConfirmDialog
98
+ v-if="variationToDelete"
99
+ :title="`Remove variation ${variationToDelete}?`"
100
+ content="You cannot undo this action. If there was any analytics collected for this variation, it will still be attributed to the ad."
101
+ confirm-class="bg-red-900 text-white"
102
+ content-class="w-96"
103
+ @confirm="onRemoveVariation(variationToDelete)"
104
+ @close="variationToDelete = ''"
105
+ />
106
+ </div>
107
107
  </template>
108
108
  <script setup>
109
109
  import { ExclamationCircleIcon as MissingIcon, PencilIcon as EditIcon } from "@heroicons/vue/solid";
@@ -161,8 +161,7 @@ const FORM_FIELD_MAP = {
161
161
  const mappedFields = props.form.fields.map((field) => ({
162
162
  placeholder: `Enter ${field.label}`,
163
163
  ...field,
164
- component: FORM_FIELD_MAP[field.type],
165
- default: field.type === "BOOLEAN" ? false : ""
164
+ component: FORM_FIELD_MAP[field.type]
166
165
  }));
167
166
 
168
167
  const variationNames = computed(() => {
@@ -202,7 +201,7 @@ function createVariation(variation) {
202
201
  return props.form.fields.map((field) => ({
203
202
  variation,
204
203
  name: field.name,
205
- value: field.type === "BOOLEAN" ? false : null
204
+ value: field.default_value === undefined ? null : field.default_value
206
205
  }));
207
206
  }
208
207
 
@@ -2,81 +2,82 @@ import { computed, ref, watch } from "vue";
2
2
  import { getItem, setItem } from "../../helpers";
3
3
 
4
4
  export interface TableColumn {
5
- actionMenu?: object,
6
- align?: string,
7
- category?: string,
8
- class?: string | object,
9
- field: string,
10
- format?: Function,
11
- innerClass?: string | object,
12
- style?: string | object,
13
- headerStyle?: string | object,
14
- isSavingRow?: boolean | Function,
15
- label: string,
16
- maxWidth?: number,
17
- minWidth?: number,
18
- name: string,
19
- onClick?: Function,
20
- required?: boolean,
21
- resizeable?: boolean,
22
- sortable?: boolean,
23
- sortBy?: string,
24
- sortByExpression?: string,
25
- titleColumns?: Function,
26
- vnode?: Function,
5
+ actionMenu?: object,
6
+ align?: string,
7
+ category?: string,
8
+ class?: string | object,
9
+ field: string,
10
+ format?: Function,
11
+ innerClass?: string | object,
12
+ style?: string | object,
13
+ headerStyle?: string | object,
14
+ isSavingRow?: boolean | Function,
15
+ label: string,
16
+ maxWidth?: number,
17
+ minWidth?: number,
18
+ name: string,
19
+ onClick?: Function,
20
+ required?: boolean,
21
+ resizeable?: boolean,
22
+ sortable?: boolean,
23
+ sortBy?: string,
24
+ sortByExpression?: string,
25
+ titleColumns?: Function,
26
+ vnode?: Function,
27
27
  }
28
28
 
29
29
  export function useTableColumns(name: string, columns: TableColumn[]) {
30
- const COLUMN_ORDER_KEY = `${name}-column-order`;
31
- const VISIBLE_COLUMNS_KEY = `${name}-visible-columns`;
32
- const TITLE_COLUMNS_KEY = `${name}-title-columns`;
30
+ const COLUMN_ORDER_KEY = `${name}-column-order`;
31
+ const VISIBLE_COLUMNS_KEY = `${name}-visible-columns`;
32
+ const TITLE_COLUMNS_KEY = `${name}-title-columns`;
33
33
 
34
- // The list that defines the order the columns should appear in
35
- const columnOrder = ref(getItem(COLUMN_ORDER_KEY) || []);
34
+ // The list that defines the order the columns should appear in
35
+ const columnOrder = ref(getItem(COLUMN_ORDER_KEY) || []);
36
36
 
37
- // Manages visible columns on the table
38
- const hiddenColumnNames = ref(getItem(VISIBLE_COLUMNS_KEY, []));
37
+ // Manages visible columns on the table
38
+ const hiddenColumnNames = ref(getItem(VISIBLE_COLUMNS_KEY, []));
39
39
 
40
- // Title columns will have their name appear on the first column of the table as part of the records' title
41
- const titleColumnNames = ref(getItem(TITLE_COLUMNS_KEY, []));
40
+ // Title columns will have their name appear on the first column of the table as part of the records' title
41
+ const titleColumnNames = ref(getItem(TITLE_COLUMNS_KEY, []));
42
42
 
43
- // Columns that should be locked to the left side of the table
44
- const lockedColumns = computed(() => orderedColumns.value.slice(0, 1));
43
+ // Columns that should be locked to the left side of the table
44
+ const lockedColumns = computed(() => orderedColumns.value.slice(0, 1));
45
45
 
46
- // The resolved list of columns in the order they should appear in
47
- const orderedColumns = computed(() => [...columns].sort((a, b) => {
48
- const aIndex = columnOrder.value.indexOf(a.name);
49
- const bIndex = columnOrder.value.indexOf(b.name);
50
- return aIndex === -1 ? 1 : bIndex === -1 ? -1 : aIndex - bIndex;
51
- }));
46
+ // The resolved list of columns in the order they should appear in
47
+ const orderedColumns = computed(() => [...columns].sort((a, b) => {
48
+ const aIndex = columnOrder.value.indexOf(a.name);
49
+ const bIndex = columnOrder.value.indexOf(b.name);
50
+ return aIndex === -1 ? 1 : bIndex === -1 ? -1 : aIndex - bIndex;
51
+ }));
52
52
 
53
- // The ordered list of columns. The ordering of this list is editable and will be stored in localStorage
54
- const sortableColumns = computed({
55
- get() {
56
- return orderedColumns.value.slice(1);
57
- },
58
- set(newColumns) {
59
- columnOrder.value = [...lockedColumns.value.map(c => c.name), ...newColumns.map(c => c.name)];
60
- setItem(COLUMN_ORDER_KEY, columnOrder.value);
61
- }
62
- });
53
+ // The ordered list of columns. The ordering of this list is editable and will be stored in localStorage
54
+ const sortableColumns = computed({
55
+ get() {
56
+ return orderedColumns.value.slice(1);
57
+ },
58
+ set(newColumns) {
59
+ columnOrder.value = [...lockedColumns.value.map(c => c.name), ...newColumns.map(c => c.name)];
60
+ setItem(COLUMN_ORDER_KEY, columnOrder.value);
61
+ }
62
+ });
63
63
 
64
- // The list of columns that are visible. To edit the visible columns, edit the hiddenColumnNames list
65
- const visibleColumns = computed(() => orderedColumns.value.filter(c => !hiddenColumnNames.value.includes(c.name)));
64
+ // The list of columns that are visible. To edit the visible columns, edit the hiddenColumnNames list
65
+ const visibleColumns = computed(() => orderedColumns.value.filter(c => !hiddenColumnNames.value.includes(c.name)));
66
66
 
67
- // The list of columns that should be included in the title of a row
68
- const orderedTitleColumns = computed(() => orderedColumns.value.filter(c => titleColumnNames.value.includes(c.name)));
67
+ // The list of columns that should be included in the title of a row
68
+ const orderedTitleColumns = computed(() => orderedColumns.value.filter(c => titleColumnNames.value.includes(c.name)));
69
69
 
70
- // Save changes to the list of hidden columns in localStorage
71
- watch(() => hiddenColumnNames.value, () => setItem(VISIBLE_COLUMNS_KEY, hiddenColumnNames.value));
72
- watch(() => titleColumnNames.value, () => setItem(TITLE_COLUMNS_KEY, titleColumnNames.value));
70
+ // Save changes to the list of hidden columns in localStorage
71
+ watch(() => hiddenColumnNames.value, () => setItem(VISIBLE_COLUMNS_KEY, hiddenColumnNames.value));
72
+ watch(() => titleColumnNames.value, () => setItem(TITLE_COLUMNS_KEY, titleColumnNames.value));
73
73
 
74
- return {
75
- sortableColumns,
76
- lockedColumns,
77
- visibleColumns,
78
- hiddenColumnNames,
79
- titleColumnNames,
80
- orderedTitleColumns
81
- };
74
+ return {
75
+ sortableColumns,
76
+ lockedColumns,
77
+ visibleColumns,
78
+ hiddenColumnNames,
79
+ columnOrder,
80
+ titleColumnNames,
81
+ orderedTitleColumns
82
+ };
82
83
  }