quasar-ui-danx 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/danx.es.js +1107 -1094
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +5 -5
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/Filters/FilterListToggle.vue +5 -1
- package/src/components/ActionTable/Form/RenderedForm.vue +29 -16
@@ -7,10 +7,11 @@
|
|
7
7
|
:key="name"
|
8
8
|
:name="name"
|
9
9
|
class="p-0"
|
10
|
+
content-class="w-full"
|
10
11
|
>
|
11
|
-
<div class="flex flex-nowrap items-center text-sm">
|
12
|
-
<div>{{ name || "
|
13
|
-
<
|
12
|
+
<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">
|
14
15
|
<a
|
15
16
|
@click="() => (variationToEdit = name) && (newVariationName = name)"
|
16
17
|
class="ml-1 p-1 hover:opacity-100 opacity-20 hover:bg-blue-200 rounded"
|
@@ -24,7 +25,7 @@
|
|
24
25
|
>
|
25
26
|
<RemoveIcon class="w-3 text-red-900" />
|
26
27
|
</a>
|
27
|
-
</
|
28
|
+
</div>
|
28
29
|
</div>
|
29
30
|
</QTab>
|
30
31
|
<QTab
|
@@ -115,7 +116,8 @@ const props = defineProps({
|
|
115
116
|
showName: Boolean,
|
116
117
|
disable: Boolean,
|
117
118
|
readonly: Boolean,
|
118
|
-
saving: Boolean
|
119
|
+
saving: Boolean,
|
120
|
+
canModifyVariations: Boolean
|
119
121
|
});
|
120
122
|
|
121
123
|
const FORM_FIELD_MAP = {
|
@@ -138,14 +140,19 @@ const mappedFields = props.form.fields.map((field) => ({
|
|
138
140
|
}));
|
139
141
|
|
140
142
|
const variationNames = computed(() => {
|
141
|
-
|
143
|
+
const names = [...new Set(props.values.map(v => v.variation))].sort();
|
144
|
+
// Always guarantee that we show the default variation
|
145
|
+
if (names.length === 0) {
|
146
|
+
names.push("");
|
147
|
+
}
|
148
|
+
return names;
|
142
149
|
});
|
143
150
|
|
144
151
|
const currentVariation = ref(variationNames.value[0] || "");
|
145
152
|
const newVariationName = ref("");
|
146
153
|
const variationToEdit = ref(false);
|
147
154
|
const variationToDelete = ref("");
|
148
|
-
const canAddVariation = computed(() =>
|
155
|
+
const canAddVariation = computed(() => props.canModifyVariations && !props.readonly && !props.disable && variationNames.value.length < props.form.variations);
|
149
156
|
|
150
157
|
function getFieldResponse(name) {
|
151
158
|
if (!props.values) return undefined;
|
@@ -165,19 +172,25 @@ function onInput(name, value) {
|
|
165
172
|
emit("update:values", newValues);
|
166
173
|
}
|
167
174
|
|
175
|
+
function createVariation(variation) {
|
176
|
+
return props.form.fields.map((field) => ({
|
177
|
+
variation,
|
178
|
+
name: field.name,
|
179
|
+
value: field.type === "BOOLEAN" ? false : null
|
180
|
+
}));
|
181
|
+
}
|
182
|
+
|
168
183
|
function onAddVariation() {
|
169
184
|
if (props.saving) return;
|
185
|
+
let newValues = [...props.values];
|
170
186
|
|
187
|
+
if (newValues.length === 0) {
|
188
|
+
newValues = createVariation("");
|
189
|
+
}
|
171
190
|
const previousName = variationNames.value[variationNames.value.length - 1];
|
172
|
-
const newName = incrementName(!previousName ? "
|
173
|
-
|
174
|
-
|
175
|
-
variation: newName,
|
176
|
-
name: field.name,
|
177
|
-
value: field.type === "BOOLEAN" ? false : null
|
178
|
-
}));
|
179
|
-
const newValues = [...props.values, ...newVariation];
|
180
|
-
emit("update:values", newValues);
|
191
|
+
const newName = incrementName(!previousName ? "1" : previousName);
|
192
|
+
const newVariation = createVariation(newName);
|
193
|
+
emit("update:values", [...newValues, ...newVariation]);
|
181
194
|
currentVariation.value = newName;
|
182
195
|
}
|
183
196
|
|