@7365admin1/layer-common 3.0.11 → 3.0.12

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.
@@ -288,7 +288,7 @@ watch(
288
288
  );
289
289
 
290
290
  function toLocalDate(utcString: string) {
291
- return new Date(utcString).toLocaleString("en-US", {
291
+ return new Date(utcString).toLocaleString("en-GB", {
292
292
  year: "numeric",
293
293
  month: "2-digit",
294
294
  day: "2-digit",
@@ -143,7 +143,7 @@
143
143
  }}
144
144
  </p>
145
145
  </v-col>
146
- <v-col cols="6" class="pa-3">
146
+ <v-col cols="12" class="pa-3">
147
147
  <p class="font-weight-bold">Brief Description</p>
148
148
  <p>
149
149
  {{
@@ -5,17 +5,21 @@
5
5
  v-model="selectedCode"
6
6
  :variant="variant"
7
7
  :items="countries"
8
- item-title="code"
8
+ item-title="dial_code"
9
9
  item-value="code"
10
10
  hide-details
11
11
  class="px-0"
12
12
  :density="density"
13
- style="max-width: 95px"
13
+ style="max-width: 110px"
14
14
  :rules="[...props.rules]"
15
15
  :readonly="props.readOnly"
16
16
  :disabled="props.disabled"
17
17
  @update:model-value="handleUpdateCountry"
18
18
  >
19
+ <template v-slot:selection="{ item }">
20
+ <span>{{ item.raw.dial_code }}</span>
21
+ </template>
22
+
19
23
  <template v-slot:item="{ props: itemProps, item }">
20
24
  <v-list-item
21
25
  v-bind="itemProps"
@@ -38,7 +42,6 @@
38
42
  hide-details
39
43
  persistent-hint
40
44
  return-masked-value
41
- :prefix="phonePrefix || ''"
42
45
  persistent-placeholder
43
46
  :density="density"
44
47
  :disabled="props.disabled"
@@ -52,7 +55,7 @@
52
55
  </template>
53
56
 
54
57
  <script setup lang="ts">
55
- import { ref, computed, watch, onMounted, type PropType } from 'vue'
58
+ import { ref, computed, watch, type PropType } from 'vue'
56
59
  //@ts-ignore
57
60
  import phoneMasks from '~/utils/phoneMasks'
58
61
  import type { ValidationRule } from 'vuetify/lib/types.mjs'
@@ -101,6 +104,10 @@ const phonePrefix = computed(() => {
101
104
  return country?.dial_code || ''
102
105
  })
103
106
 
107
+ const countriesByLongestDialCode = computed(() => {
108
+ return [...countries].sort((a: TPhoneMask, b: TPhoneMask) => b.dial_code.length - a.dial_code.length)
109
+ })
110
+
104
111
  function generateMaskFromRegex(regex: string): string {
105
112
  let pattern = regex.replace(/^\^|\$$/g, '')
106
113
  pattern = pattern.replace(/\(\?:\+?\d+\)\?/g, '')
@@ -125,13 +132,19 @@ const validatePhone = (): boolean | string => {
125
132
  return isValid
126
133
  }
127
134
 
135
+ function findCountryFromPhone(value: string): TPhoneMask | undefined {
136
+ return countriesByLongestDialCode.value.find((c: TPhoneMask) => value.startsWith(c.dial_code))
137
+ }
138
+
139
+ function syncInputFromPhone(value: string) {
140
+ const prefix = phonePrefix.value
141
+ if (!value) input.value = ''
142
+ else input.value = value.startsWith(prefix) ? value.slice(prefix.length) : value
143
+ }
144
+
128
145
  function handleUpdateCountry() {
129
146
  const prefix = phonePrefix.value
130
- if (phone.value?.startsWith(prefix)) {
131
- input.value = phone.value.slice(prefix.length)
132
- } else {
133
- input.value = ''
134
- }
147
+ phone.value = input.value ? prefix + input.value : ''
135
148
  }
136
149
 
137
150
 
@@ -150,28 +163,19 @@ watch(
150
163
  )
151
164
 
152
165
 
153
- watch(phone, (newVal) => {
154
- const prefix = phonePrefix.value
155
- if (!newVal) input.value = ''
156
- else input.value = newVal.startsWith(prefix) ? newVal.slice(prefix.length) : newVal
157
- emit('update:modelValue', newVal)
158
- })
166
+ watch(
167
+ phone,
168
+ (newVal) => {
169
+ const country = newVal ? findCountryFromPhone(newVal) : undefined
170
+ if (country && country.code !== selectedCode.value) selectedCode.value = country.code
171
+ syncInputFromPhone(newVal)
172
+ emit('update:modelValue', newVal)
173
+ },
174
+ { immediate: true }
175
+ )
159
176
 
160
177
 
161
178
  watch(selectedCode, () => {
162
- const prefix = phonePrefix.value
163
- if (phone.value?.startsWith(prefix)) input.value = phone.value.slice(prefix.length)
164
- else input.value = phone.value || ''
165
- })
166
-
167
-
168
- onMounted(() => {
169
- if (phone.value) {
170
- const found = countries.find((c: TPhoneMask) => phone.value.startsWith(c.dial_code))
171
- if (found) selectedCode.value = found.code
172
- const prefix = phonePrefix.value
173
- input.value = phone.value.startsWith(prefix) ? phone.value.slice(prefix.length) : phone.value
174
- maskKey.value++
175
- }
179
+ maskKey.value++
176
180
  })
177
181
  </script>
@@ -2,6 +2,7 @@
2
2
  <v-text-field
3
3
  id="_password"
4
4
  v-model="password"
5
+ placeholder="Password"
5
6
  :type="showPassword ? 'text' : 'password'"
6
7
  :append-inner-icon="showPassword ? 'mdi-eye-off' : 'mdi-eye'"
7
8
  v-bind="$attrs"
@@ -56,8 +56,8 @@
56
56
  </v-col>
57
57
 
58
58
  <v-col v-if="shouldShowField('nric')" cols="12">
59
- <InputLabel class="text-capitalize" title="NRIC" required />
60
- <InputNRICNumber v-model="vehicle.nric" density="comfortable" :rules="[requiredRule]"
59
+ <InputLabel class="text-capitalize" title="NRIC"/>
60
+ <InputNRICNumber v-model="vehicle.nric" density="comfortable"
61
61
  :disabled="disablePrefilledInputs && type !== 'blocklist' && prop.mode !== 'edit'" />
62
62
  </v-col>
63
63
 
@@ -74,8 +74,8 @@
74
74
 
75
75
 
76
76
  <v-col v-if="shouldShowField('phone')" cols="12">
77
- <InputLabel class="text-capitalize" title="Phone Number" required />
78
- <InputPhoneNumberV2 v-model="vehicle.phoneNumber" density="comfortable" :rules="[requiredRule]" />
77
+ <InputLabel class="text-capitalize" title="Phone Number"/>
78
+ <InputPhoneNumberV2 v-model="vehicle.phoneNumber" density="comfortable" />
79
79
  </v-col>
80
80
 
81
81
  <v-col v-if="shouldShowField('plateNumber')" cols="12">
@@ -770,6 +770,8 @@ watch(
770
770
  async (newUnit) => {
771
771
  if (prefillingRecords.value) return;
772
772
 
773
+ if(prop.mode === 'edit') return;
774
+
773
775
  resetVehicleDetails();
774
776
  matchingPeople.value = [];
775
777
  if (!newUnit) return;
@@ -78,7 +78,7 @@
78
78
  </v-chip>
79
79
  </template>
80
80
  <template #item.action="{ item: plateNumberItem, value }">
81
- <v-menu>
81
+ <v-menu v-if="hasVehicleActions(plateNumberItem as TPlateNumber)">
82
82
  <template #activator="{ props: menuProps }">
83
83
  <v-btn icon="mdi-dots-vertical" v-bind="menuProps" flat size="x-small" />
84
84
  </template>
@@ -382,6 +382,21 @@ function handleUpdateType(item: TPlateNumber) {
382
382
  dialog.updateVehicleType = true;
383
383
  }
384
384
 
385
+ function hasVehicleActions(item: TPlateNumber) {
386
+ const isActive = item?.status === "active";
387
+ const isPending = item?.status === "pending";
388
+ const isDeleted = item?.status === "deleted";
389
+ const canUpdateType = item?.type === "whitelist" || item?.type === "blocklist";
390
+
391
+ return (
392
+ isActive ||
393
+ (props.app === "property_management_agency" && isPending) ||
394
+ isDeleted ||
395
+ (canUpdateType && isActive) ||
396
+ (props.canDeleteVehicle && isActive)
397
+ );
398
+ }
399
+
385
400
  function handleSelectVehicleStatus(value: TVehicleType) {
386
401
  vehicleType.value = value;
387
402
  dialog.showSelection = false;
@@ -4,7 +4,7 @@ export function useAttendancePermission() {
4
4
  const { userAppRole } = useLocalSetup();
5
5
 
6
6
  const canViewAllAttendance = computed(() => {
7
- if (!userAppRole.value) return true;
7
+ if (!userAppRole.value) return false;
8
8
  if (userAppRole.value.permissions.includes("*")) return true;
9
9
  return hasPermission(
10
10
  userAppRole.value,
@@ -15,7 +15,7 @@ export function useAttendancePermission() {
15
15
  });
16
16
 
17
17
  const canViewAttendanceDetails = computed(() => {
18
- if (!userAppRole.value) return true;
18
+ if (!userAppRole.value) return false;
19
19
  if (userAppRole.value.permissions.includes("*")) return true;
20
20
  return hasPermission(
21
21
  userAppRole.value,
@@ -26,7 +26,7 @@ export function useAttendancePermission() {
26
26
  });
27
27
 
28
28
  const canManageAttendanceSettings = computed(() => {
29
- if (!userAppRole.value) return true;
29
+ if (!userAppRole.value) return false;
30
30
  if (userAppRole.value.permissions.includes("*")) return true;
31
31
  return hasPermission(
32
32
  userAppRole.value,
@@ -37,7 +37,7 @@ export function useAttendancePermission() {
37
37
  });
38
38
 
39
39
  const canViewOwnAttendance = computed(() => {
40
- if (!userAppRole.value) return true;
40
+ if (!userAppRole.value) return false;
41
41
  if (userAppRole.value.permissions.includes("*")) return true;
42
42
  return hasPermission(
43
43
  userAppRole.value,
@@ -48,7 +48,7 @@ export function useAttendancePermission() {
48
48
  });
49
49
 
50
50
  const canCheckInOut = computed(() => {
51
- if (!userAppRole.value) return true;
51
+ if (!userAppRole.value) return false;
52
52
  if (userAppRole.value.permissions.includes("*")) return true;
53
53
  return hasPermission(
54
54
  userAppRole.value,
@@ -7,25 +7,25 @@ export function useBulletinBoardPermission() {
7
7
  const { userAppRole } = useLocalSetup();
8
8
 
9
9
  const canViewBulletinBoard = computed(() => {
10
- if (!userAppRole.value) return true;
10
+ if (!userAppRole.value) return false;
11
11
  if (userAppRole.value.permissions.includes("*")) return true;
12
12
  return hasPermission(userAppRole.value, permissions, "bulletin-board", "see-all-bulletin-boards");
13
13
  });
14
14
 
15
15
  const canCreateBulletinBoard = computed(() => {
16
- if (!userAppRole.value) return true;
16
+ if (!userAppRole.value) return false;
17
17
  if (userAppRole.value.permissions.includes("*")) return true;
18
18
  return hasPermission(userAppRole.value, permissions, "bulletin-board", "add-bulletin-board");
19
19
  });
20
20
 
21
21
  const canUpdateBulletinBoard = computed(() => {
22
- if (!userAppRole.value) return true;
22
+ if (!userAppRole.value) return false;
23
23
  if (userAppRole.value.permissions.includes("*")) return true;
24
24
  return hasPermission(userAppRole.value, permissions, "bulletin-board", "update-bulletin-board");
25
25
  });
26
26
 
27
27
  const canViewBulletinBoardDetails = computed(() => {
28
- if (!userAppRole.value) return true;
28
+ if (!userAppRole.value) return false;
29
29
  if (userAppRole.value.permissions.includes("*")) return true;
30
30
  return hasPermission(userAppRole.value, permissions, "bulletin-board", "see-bulletin-board-details");
31
31
  });
@@ -33,7 +33,7 @@ export function useBulletinBoardPermission() {
33
33
 
34
34
 
35
35
  const canDeleteBulletinBoard = computed(() => {
36
- if (!userAppRole.value) return true;
36
+ if (!userAppRole.value) return false;
37
37
  if (userAppRole.value.permissions.includes("*")) return true;
38
38
  return hasPermission(userAppRole.value, permissions, "bulletin-board", "delete-bulletin-board");
39
39
  });
@@ -278,6 +278,45 @@ export function useCommonPermissions() {
278
278
  },
279
279
 
280
280
  }
281
+
282
+ const dashboardPermissions: Record<string, TPermission> = {
283
+ "view-activity": {
284
+ check: true,
285
+ description: "Allows the user to view the activity chart widget.",
286
+ },
287
+ "view-task-schedule": {
288
+ check: true,
289
+ description: "Allows the user to view the task schedule widget.",
290
+ },
291
+ "view-attendance-widget": {
292
+ check: true,
293
+ description: "Allows the user to view the attendance/staff status widget.",
294
+ },
295
+ "view-feedbacks-widget": {
296
+ check: true,
297
+ description: "Allows the user to view the feedbacks widget.",
298
+ },
299
+ "view-upcoming-events": {
300
+ check: true,
301
+ description: "Allows the user to view the upcoming events widget.",
302
+ },
303
+ "view-today-reminders": {
304
+ check: true,
305
+ description: "Allows the user to view the today's reminders widget.",
306
+ },
307
+ "view-today-attentions": {
308
+ check: true,
309
+ description: "Allows the user to view the today's attentions widget.",
310
+ },
311
+ "view-work-order-status": {
312
+ check: true,
313
+ description: "Allows the user to view the work order status widget.",
314
+ },
315
+ "view-active-patrol": {
316
+ check: true,
317
+ description: "Allows the user to view the active patrol widget.",
318
+ },
319
+ }
281
320
 
282
321
  return {
283
322
  invitationPermissions,
@@ -289,6 +328,7 @@ export function useCommonPermissions() {
289
328
  buildingManagementPermissions,
290
329
  buildingUnitManagementPermissions,
291
330
  bulletinBoardPermissions,
292
- siteSettingsPermissions
331
+ siteSettingsPermissions,
332
+ dashboardPermissions
293
333
  };
294
334
  }
@@ -6,7 +6,7 @@ export function useSettingsPermission() {
6
6
  const { userAppRole } = useLocalSetup();
7
7
 
8
8
  const canManageSiteInformation = computed(() => {
9
- if (!userAppRole.value) return true;
9
+ if (!userAppRole.value) return false;
10
10
  if (userAppRole.value.permissions.includes("*")) return true;
11
11
  return hasPermission(
12
12
  userAppRole.value,
@@ -16,7 +16,7 @@ export function useSettingsPermission() {
16
16
  );
17
17
  });
18
18
  const canManageANPRCamera = computed(() => {
19
- if (!userAppRole.value) return true;
19
+ if (!userAppRole.value) return false;
20
20
  if (userAppRole.value.permissions.includes("*")) return true;
21
21
  return hasPermission(
22
22
  userAppRole.value,
@@ -26,7 +26,7 @@ export function useSettingsPermission() {
26
26
  );
27
27
  });
28
28
  const canManageCCTVCamera = computed(() => {
29
- if (!userAppRole.value) return true;
29
+ if (!userAppRole.value) return false;
30
30
  if (userAppRole.value.permissions.includes("*")) return true;
31
31
  return hasPermission(
32
32
  userAppRole.value,
@@ -36,7 +36,7 @@ export function useSettingsPermission() {
36
36
  );
37
37
  });
38
38
  const canManageDeliveryCompanies = computed(() => {
39
- if (!userAppRole.value) return true;
39
+ if (!userAppRole.value) return false;
40
40
  if (userAppRole.value.permissions.includes("*")) return true;
41
41
  return hasPermission(
42
42
  userAppRole.value,
@@ -46,7 +46,7 @@ export function useSettingsPermission() {
46
46
  );
47
47
  });
48
48
  const canManageResidentVisitors = computed(() => {
49
- if (!userAppRole.value) return true;
49
+ if (!userAppRole.value) return false;
50
50
  if (userAppRole.value.permissions.includes("*")) return true;
51
51
  return hasPermission(
52
52
  userAppRole.value,
@@ -56,7 +56,7 @@ export function useSettingsPermission() {
56
56
  );
57
57
  });
58
58
  const canManageWorkOrderSettings = computed(() => {
59
- if (!userAppRole.value) return true;
59
+ if (!userAppRole.value) return false;
60
60
  if (userAppRole.value.permissions.includes("*")) return true;
61
61
  return hasPermission(
62
62
  userAppRole.value,
@@ -66,7 +66,7 @@ export function useSettingsPermission() {
66
66
  );
67
67
  });
68
68
  const canManageBillingAndSOAConfiguration = computed(() => {
69
- if (!userAppRole.value) return true;
69
+ if (!userAppRole.value) return false;
70
70
  if (userAppRole.value.permissions.includes("*")) return true;
71
71
  return hasPermission(
72
72
  userAppRole.value,
@@ -76,7 +76,7 @@ export function useSettingsPermission() {
76
76
  );
77
77
  });
78
78
  const canManageNFCManagement = computed(() => {
79
- if (!userAppRole.value) return true;
79
+ if (!userAppRole.value) return false;
80
80
  if (userAppRole.value.permissions.includes("*")) return true;
81
81
  return hasPermission(
82
82
  userAppRole.value,
@@ -86,7 +86,7 @@ export function useSettingsPermission() {
86
86
  );
87
87
  });
88
88
  const canManageNFCPatrolSettings = computed(() => {
89
- if (!userAppRole.value) return true;
89
+ if (!userAppRole.value) return false;
90
90
  if (userAppRole.value.permissions.includes("*")) return true;
91
91
  return hasPermission(
92
92
  userAppRole.value,
@@ -96,7 +96,7 @@ export function useSettingsPermission() {
96
96
  );
97
97
  });
98
98
  const canManageEntryPass = computed(() => {
99
- if (!userAppRole.value) return true;
99
+ if (!userAppRole.value) return false;
100
100
  if (userAppRole.value.permissions.includes("*")) return true;
101
101
  return hasPermission(
102
102
  userAppRole.value,
@@ -106,7 +106,7 @@ export function useSettingsPermission() {
106
106
  );
107
107
  });
108
108
  const canManageRedDotSettings = computed(() => {
109
- if (!userAppRole.value) return true;
109
+ if (!userAppRole.value) return false;
110
110
  if (userAppRole.value.permissions.includes("*")) return true;
111
111
  return hasPermission(
112
112
  userAppRole.value,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "3.0.11",
5
+ "version": "3.0.12",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {