@7365admin1/layer-common 3.0.0 → 3.0.1
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/CHANGELOG.md
CHANGED
|
@@ -91,8 +91,10 @@
|
|
|
91
91
|
|
|
92
92
|
<v-row no-gutters class="px-6 w-100">
|
|
93
93
|
<v-row no-gutters v-for="(newLevelsItem, index) in newLevelsArray" :key="index" :cols="12" class="w-100">
|
|
94
|
-
<v-
|
|
95
|
-
|
|
94
|
+
<v-col :cols="prop.mode === 'edit' ? 10 : 12">
|
|
95
|
+
<v-text-field v-model.trim="newLevelsArray[index]" density="comfortable"></v-text-field>
|
|
96
|
+
</v-col>
|
|
97
|
+
<v-col v-if="prop.mode === 'edit'" cols="2" class="d-flex align-center pb-5 justify-end">
|
|
96
98
|
<v-btn icon variant="text" color="error" @click="newLevelsArray.splice(index, 1)">
|
|
97
99
|
<v-icon icon="mdi-trash-can-outline"></v-icon>
|
|
98
100
|
</v-btn>
|
|
@@ -192,6 +194,8 @@
|
|
|
192
194
|
</v-row>
|
|
193
195
|
</template>
|
|
194
196
|
</ConfirmDialog>
|
|
197
|
+
|
|
198
|
+
<Snackbar v-model="deleteLevelToast.show" :text="deleteLevelToast.message" :color="deleteLevelToast.color" />
|
|
195
199
|
</v-card>
|
|
196
200
|
</template>
|
|
197
201
|
|
|
@@ -271,6 +275,12 @@ const loading = reactive({
|
|
|
271
275
|
deletingLevel: false,
|
|
272
276
|
});
|
|
273
277
|
|
|
278
|
+
const deleteLevelToast = reactive({
|
|
279
|
+
show: false,
|
|
280
|
+
message: "",
|
|
281
|
+
color: "success" as "success" | "error",
|
|
282
|
+
});
|
|
283
|
+
|
|
274
284
|
const show = ref(false);
|
|
275
285
|
const confirmDeleteLevelDialog = ref(false);
|
|
276
286
|
const levelPendingDeleteIndex = ref<number | null>(null);
|
|
@@ -309,6 +319,12 @@ function closeDeleteLevelPrompt() {
|
|
|
309
319
|
levelPendingDeleteIndex.value = null;
|
|
310
320
|
}
|
|
311
321
|
|
|
322
|
+
function showDeleteLevelToast(message: string, color: "success" | "error") {
|
|
323
|
+
deleteLevelToast.message = message;
|
|
324
|
+
deleteLevelToast.color = color;
|
|
325
|
+
deleteLevelToast.show = true;
|
|
326
|
+
}
|
|
327
|
+
|
|
312
328
|
async function deleteLevelPlaceholder(levelName: string, levelIndex: number) {
|
|
313
329
|
// Placeholder integration for future delete-level API call.
|
|
314
330
|
return { success: true, levelName, levelIndex };
|
|
@@ -393,12 +409,12 @@ async function submit() {
|
|
|
393
409
|
|
|
394
410
|
console.log('Updating building with levels:', building.value.levels);
|
|
395
411
|
|
|
396
|
-
if(JSON.stringify(initialBuildingLevels.value) !== JSON.stringify(building.value.levels)) {
|
|
397
|
-
|
|
412
|
+
if (JSON.stringify(initialBuildingLevels.value) !== JSON.stringify(building.value.levels)) {
|
|
413
|
+
await batchUpdateLevels(building.value.levels as { _id: string; name: string }[]);
|
|
398
414
|
}
|
|
399
415
|
|
|
400
416
|
const newLevels = [...newLevelsArray.value, ...(activeNewLevelInput.value.trim() ? [activeNewLevelInput.value.trim()] : [])];
|
|
401
|
-
|
|
417
|
+
|
|
402
418
|
await updateById(building.value._id ?? "", {
|
|
403
419
|
name: building.value.name,
|
|
404
420
|
block: building.value.block,
|
|
@@ -441,11 +457,13 @@ const confirmDeleteLevel = async () => {
|
|
|
441
457
|
const levelIndex = levelPendingDeleteIndex.value;
|
|
442
458
|
if (levelIndex === null) {
|
|
443
459
|
console.error("No level selected for deletion.");
|
|
460
|
+
showDeleteLevelToast("No level selected for deletion.", "error");
|
|
444
461
|
return;
|
|
445
462
|
}
|
|
446
463
|
const levelId = building.value.levels[levelIndex]._id;
|
|
447
464
|
if (!levelId) {
|
|
448
465
|
console.error("Level ID is missing. Cannot delete level.");
|
|
466
|
+
showDeleteLevelToast("Level ID is missing. Cannot delete level.", "error");
|
|
449
467
|
return;
|
|
450
468
|
}
|
|
451
469
|
|
|
@@ -459,10 +477,11 @@ const confirmDeleteLevel = async () => {
|
|
|
459
477
|
buildingLevels.value = building.value.levels.length;
|
|
460
478
|
}
|
|
461
479
|
emit('refresh')
|
|
480
|
+
showDeleteLevelToast("Level deleted successfully.", "success");
|
|
462
481
|
} catch (error: any) {
|
|
463
482
|
console.error("Failed to delete level:", error);
|
|
464
|
-
const
|
|
465
|
-
|
|
483
|
+
const errorMessage = error.response?._data?.message || "Failed to delete level";
|
|
484
|
+
showDeleteLevelToast(errorMessage, "error");
|
|
466
485
|
} finally {
|
|
467
486
|
loading.deletingLevel = false;
|
|
468
487
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
<!-- Create Dialog -->
|
|
43
43
|
<v-dialog v-model="createDialog" width="450" persistent>
|
|
44
|
-
<BuildingForm :site="site" :blocks="items" @cancel="createDialog = false" @success="successCreate()"
|
|
44
|
+
<BuildingForm :site="site" mode="add" :blocks="items" @cancel="createDialog = false" @success="successCreate()"
|
|
45
45
|
@success:create-more="getBuildings()" />
|
|
46
46
|
</v-dialog>
|
|
47
47
|
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
</v-list-item>
|
|
37
37
|
</template>
|
|
38
38
|
<template v-slot:selection="{ item }">
|
|
39
|
-
{{ buildingUnit.building && `${item?.raw?.name}`
|
|
39
|
+
{{ buildingUnit.building && `${item?.raw?.name}` }}
|
|
40
40
|
</template>
|
|
41
41
|
</v-autocomplete>
|
|
42
42
|
</v-col>
|
|
43
43
|
</v-row>
|
|
44
44
|
</v-col>
|
|
45
45
|
|
|
46
|
-
<v-col cols="12" md="6"
|
|
46
|
+
<v-col cols="12" md="6" class="mt-2">
|
|
47
47
|
<v-row no-gutters>
|
|
48
48
|
<InputLabel class="text-capitalize" title="Level" required />
|
|
49
49
|
<v-col cols="12">
|
|
50
|
-
<v-select v-model="buildingUnit.level" :items="buildingLevels" item-title="name" item-value="_id"
|
|
51
|
-
:rules="[requiredRule]"></v-select>
|
|
50
|
+
<v-select v-model="buildingUnit.level" :items="buildingLevels" item-title="name" item-value="_id"
|
|
51
|
+
density="comfortable" :rules="[requiredRule]"></v-select>
|
|
52
52
|
</v-col>
|
|
53
53
|
</v-row>
|
|
54
54
|
</v-col>
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
<v-row>
|
|
175
175
|
<v-col cols="12">
|
|
176
176
|
<v-row no-gutters>
|
|
177
|
-
<InputLabel class="text-capitalize font-weight-bold" :title="
|
|
177
|
+
<!-- <InputLabel class="text-capitalize font-weight-bold" :title="`#${unitLabelIndex + 1}`" /> -->
|
|
178
178
|
<v-col cols="12">
|
|
179
179
|
<v-text-field v-model.trim="unitLabels[unitLabelIndex]"
|
|
180
180
|
density="comfortable"></v-text-field>
|
|
@@ -241,6 +241,8 @@
|
|
|
241
241
|
</v-col>
|
|
242
242
|
</v-row>
|
|
243
243
|
</v-toolbar>
|
|
244
|
+
|
|
245
|
+
<Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
|
|
244
246
|
</v-card>
|
|
245
247
|
</template>
|
|
246
248
|
|
|
@@ -335,9 +337,17 @@ const disable = ref(false);
|
|
|
335
337
|
const { requiredRule, validateDate } = useUtils();
|
|
336
338
|
|
|
337
339
|
const message = ref("");
|
|
340
|
+
const messageSnackbar = ref(false);
|
|
341
|
+
const messageColor = ref("");
|
|
338
342
|
|
|
339
343
|
const { add, categories: unitCategories } = useBuildingUnit();
|
|
340
344
|
|
|
345
|
+
function showMessage(msg: string, color: string) {
|
|
346
|
+
message.value = msg;
|
|
347
|
+
messageColor.value = color;
|
|
348
|
+
messageSnackbar.value = true;
|
|
349
|
+
}
|
|
350
|
+
|
|
341
351
|
function setBuildingUnit() {
|
|
342
352
|
buildingUnit.value.site = prop.site ?? "";
|
|
343
353
|
buildingUnit.value.name = "Unit";
|
|
@@ -368,6 +378,7 @@ async function submit() {
|
|
|
368
378
|
if (createMore.value) {
|
|
369
379
|
setBuildingUnit();
|
|
370
380
|
message.value = "";
|
|
381
|
+
showMessage("Unit created successfully!", "success");
|
|
371
382
|
emit("success:create-more");
|
|
372
383
|
return;
|
|
373
384
|
}
|
|
@@ -376,6 +387,7 @@ async function submit() {
|
|
|
376
387
|
} catch (error: any) {
|
|
377
388
|
message.value =
|
|
378
389
|
error.response?._data?.message || "Failed to create building";
|
|
390
|
+
showMessage(message.value, "error");
|
|
379
391
|
} finally {
|
|
380
392
|
disable.value = false;
|
|
381
393
|
}
|