@7365admin1/layer-common 2.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
@@ -1,5 +1,22 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a00d5cf: Enhancement on Unit Form
8
+ - a00d5cf: Enhancement on Building Management
9
+
10
+ ## 3.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - f4ee57d: Refactor Building Management Module
15
+
16
+ ### Patch Changes
17
+
18
+ - 34bd7cf: Update on Building Unit Page
19
+
3
20
  ## 2.0.0
4
21
 
5
22
  ### Major Changes
@@ -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-text-field v-model.trim="newLevelsArray[index]" density="comfortable"></v-text-field>
95
- <v-col cols="2" class="d-flex align-center pb-5 justify-end">
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
- await batchUpdateLevels(building.value.levels as { _id: string; name: string }[]);
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 message = error.response?._data?.message || "Failed to delete level";
465
- message.value = message;
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
 
@@ -105,10 +105,10 @@ const props = defineProps({
105
105
  title: "Level",
106
106
  value: "level.name",
107
107
  },
108
- {
109
- title: "Block",
110
- value: "block",
111
- },
108
+ // {
109
+ // title: "Block",
110
+ // value: "block",
111
+ // },
112
112
  {
113
113
  title: "Block Name",
114
114
  value: "buildingName",
@@ -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" class="mt-2">
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" density="comfortable"
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="`Unit ${unitLabelIndex + 1}`" />
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
  }
@@ -276,13 +276,16 @@
276
276
  <v-col cols="6" class="text-body-1">Document</v-col>
277
277
  <v-col cols="6" class="text-right text-body-1">
278
278
  <NuxtLink
279
- v-if="selectedDocument?.attachment"
279
+ v-if="selectedDocument?.attachment && isViewable"
280
280
  :to="getFileUrl(selectedDocument.attachment)"
281
281
  external
282
282
  target="_blank"
283
283
  >
284
284
  View Document
285
285
  </NuxtLink>
286
+ <span v-else-if="selectedDocument?.attachment" class="text-grey" style="opacity: 0.6; cursor: not-allowed;">
287
+ View Document
288
+ </span>
286
289
  <span v-else>N/A</span>
287
290
  </v-col>
288
291
  </v-row>
@@ -660,6 +663,11 @@ const selectedDocument = ref<TDocument>({
660
663
  type: "",
661
664
  });
662
665
 
666
+ const isViewable = computed(() => {
667
+ const lowerType = String(selectedDocument.value?.type || "").trim().toLowerCase();
668
+ return ["pdf", "doc", "csv"].includes(lowerType);
669
+ });
670
+
663
671
  const previewDetails = computed(() => {
664
672
  const document = selectedDocument.value as Record<string, any>;
665
673
  const fileType =
@@ -548,7 +548,7 @@
548
548
  </v-col>
549
549
  <v-col cols="12" class="mt-4">
550
550
  <v-number-input
551
- v-model="facility.maxNumberGuest"
551
+ v-model="facility.maxNumberGuestLimit"
552
552
  :reverse="false"
553
553
  controlVariant="default"
554
554
  label="Maximum no. of guests"
@@ -1015,30 +1015,30 @@ const handlePolicy = (newContent: string) => {
1015
1015
 
1016
1016
  function onToggleBookingUnitLimit(val: any) {
1017
1017
  if (val) {
1018
- isBookingUnitLimitEnabled.value = true;
1018
+ facility.value.isBookingUnitLimitEnabled = true;
1019
1019
  facility.value.bookingUnitLimit = 1;
1020
1020
  } else {
1021
- isBookingUnitLimitEnabled.value = false;
1021
+ facility.value.isBookingUnitLimitEnabled = false;
1022
1022
  facility.value.bookingUnitLimit = null;
1023
1023
  }
1024
1024
  }
1025
1025
 
1026
1026
  function onToggleMaxNumberGuestLimit(val: any) {
1027
1027
  if (val) {
1028
- isMaxNumberGuestLimitEnabled.value = true;
1029
- facility.value.maxNumberGuest = 1;
1028
+ facility.value.isMaxNumberGuestLimitEnabled = true;
1029
+ facility.value.maxNumberGuestLimit = 1;
1030
1030
  } else {
1031
- isMaxNumberGuestLimitEnabled.value = false;
1032
- facility.value.maxNumberGuest = null;
1031
+ facility.value.isMaxNumberGuestLimitEnabled = false;
1032
+ facility.value.maxNumberGuestLimit = null;
1033
1033
  }
1034
1034
  }
1035
1035
 
1036
1036
  function onToggleCancelAllowedLimit(val: any) {
1037
1037
  if (val) {
1038
- isCancelAllowedLimitEnabled.value = true;
1038
+ facility.value.isCancelAllowedLimitEnabled = true;
1039
1039
  facility.value.daysAllowedCancel = 1;
1040
1040
  } else {
1041
- isCancelAllowedLimitEnabled.value = false;
1041
+ facility.value.isCancelAllowedLimitEnabled = false;
1042
1042
  facility.value.daysAllowedCancel = null;
1043
1043
  }
1044
1044
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "2.0.0",
5
+ "version": "3.0.1",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {