@7365admin1/layer-common 4.97.1-staging.719 → 4.97.1-staging.721

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.
@@ -321,8 +321,8 @@
321
321
  duplicate-note="Areas already on the list (same name and type) are skipped and left unchanged."
322
322
  template-file-name="areas-import-template.xlsx"
323
323
  :download-template="() => downloadTemplate('areas', importQuery)"
324
- :check="(file: File) => checkImport('areas', file, importQuery)"
325
- :commit="(file: File) => commitImport('areas', file, importQuery)"
324
+ :check="(file: File, extra?: { otherProperty?: boolean }) => checkImport('areas', file, { ...importQuery, ...extra })"
325
+ :commit="(file: File, extra?: { otherProperty?: boolean }) => commitImport('areas', file, { ...importQuery, ...extra })"
326
326
  @done="getTaskRefresh()"
327
327
  @error="(text: string) => showMessage(text, 'error')"
328
328
  />
@@ -35,8 +35,8 @@
35
35
  duplicate-note="Units already on that level are skipped and left unchanged."
36
36
  template-file-name="units-import-template.xlsx"
37
37
  :download-template="() => downloadTemplate('building-units', { site })"
38
- :check="(file: File) => checkImport('building-units', file, { site })"
39
- :commit="(file: File) => commitImport('building-units', file, { site })"
38
+ :check="(file: File, extra?: { otherProperty?: boolean }) => checkImport('building-units', file, { site, ...extra })"
39
+ :commit="(file: File, extra?: { otherProperty?: boolean }) => commitImport('building-units', file, { site, ...extra })"
40
40
  @done="getBuildingUnit()"
41
41
  @error="(text: string) => showMessage(text, 'error')"
42
42
  />
@@ -190,6 +190,55 @@
190
190
  </div>
191
191
  </v-col>
192
192
 
193
+ <v-divider />
194
+
195
+ <!-- Resident QR Code Validity -->
196
+ <!--
197
+ How long a resident's access QR stays valid before the app renews
198
+ it. Stored as `settings.validityMinutes`, which this screen already
199
+ loaded and saved but never showed. Empty saves null.
200
+ -->
201
+ <v-col cols="12">
202
+ <div class="mt-5 pb-5">
203
+ <p class="font-weight-medium mb-1">
204
+ Resident QR Code Validity
205
+ <span class="d-block text-caption screen-hint mt-1">
206
+ How long a resident's access QR code stays valid, in minutes,
207
+ before the resident app renews it.
208
+ </span>
209
+ </p>
210
+ <v-row class="mt-2">
211
+ <v-col cols="12" md="3">
212
+ <v-text-field
213
+ data-testid="entrypass-resident-qr-validity"
214
+ label="Validity (minutes)"
215
+ placeholder="e.g. 20"
216
+ type="number"
217
+ min="1"
218
+ :max="QR_VALIDITY_MAX_MINUTES"
219
+ density="comfortable"
220
+ clearable
221
+ :error-messages="qrValidityError"
222
+ v-model="currentEntryPassSettings.qrCodeValidityMinutes"
223
+ @update:modelValue="qrValidityError = ''"
224
+ />
225
+ </v-col>
226
+ </v-row>
227
+ <v-row>
228
+ <v-col cols="12" md="3">
229
+ <v-btn
230
+ color="primary"
231
+ variant="flat"
232
+ prepend-icon="mdi-content-save"
233
+ block
234
+ @click="saveQrValidity()"
235
+ >
236
+ Save
237
+ </v-btn>
238
+ </v-col>
239
+ </v-row>
240
+ </div>
241
+ </v-col>
193
242
 
194
243
  </v-row>
195
244
  </v-window-item>
@@ -933,7 +982,7 @@ function buildPayload() {
933
982
  subText: currentEntryPassSettings.value.qrCodeTemplateHeaderSubText,
934
983
  date: currentEntryPassSettings.value.qrCodeTemplateDate || null,
935
984
  },
936
- validityMinutes: currentEntryPassSettings.value.qrCodeValidityMinutes || null,
985
+ validityMinutes: validityMinutesForSave(),
937
986
  disclaimerMessage: currentEntryPassSettings.value.disclaimerMessage || "",
938
987
  url: currentEntryPassSettings.value.url,
939
988
  template: currentEntryPassSettings.value.template?.id
@@ -1003,6 +1052,44 @@ async function saveQrCodeTemplate() {
1003
1052
  getSiteEntryPassSettings();
1004
1053
  }
1005
1054
 
1055
+ /** One day. The QR payload can carry up to 65535 minutes, but a resident
1056
+ access QR lasting longer than a day defeats the point of renewing it. */
1057
+ const QR_VALIDITY_MAX_MINUTES = 1440;
1058
+ const qrValidityError = ref("");
1059
+
1060
+ /** Every Save on this screen sends the whole payload, so an unsaved, invalid
1061
+ entry in the validity field must not ride along with another section's
1062
+ save: anything but whole minutes in range sends what is already saved. */
1063
+ function validityMinutesForSave(): number | null {
1064
+ const minutes = Number(currentEntryPassSettings.value.qrCodeValidityMinutes);
1065
+ if (Number.isInteger(minutes) && minutes >= 1 && minutes <= QR_VALIDITY_MAX_MINUTES) {
1066
+ return minutes;
1067
+ }
1068
+ const raw = currentEntryPassSettings.value.qrCodeValidityMinutes;
1069
+ if (raw === null || raw === undefined || String(raw).trim() === "") return null;
1070
+ return getSiteEntryPassSettingsReq.value?.data?.settings?.validityMinutes ?? null;
1071
+ }
1072
+
1073
+ async function saveQrValidity() {
1074
+ const raw = currentEntryPassSettings.value.qrCodeValidityMinutes;
1075
+ // Cleared (null, or "" from the number field) saves null: no site value.
1076
+ if (raw === null || raw === undefined || String(raw).trim() === "") {
1077
+ currentEntryPassSettings.value.qrCodeValidityMinutes = null;
1078
+ } else {
1079
+ const minutes = Number(raw);
1080
+ if (!Number.isInteger(minutes) || minutes < 1 || minutes > QR_VALIDITY_MAX_MINUTES) {
1081
+ qrValidityError.value = `Enter whole minutes from 1 to ${QR_VALIDITY_MAX_MINUTES}.`;
1082
+ return;
1083
+ }
1084
+ // The number field hands back a string; store a number.
1085
+ currentEntryPassSettings.value.qrCodeValidityMinutes = minutes;
1086
+ }
1087
+ qrValidityError.value = "";
1088
+ await _save(buildPayload());
1089
+ showMessage("Resident QR code validity saved successfully!", "success");
1090
+ getSiteEntryPassSettings();
1091
+ }
1092
+
1006
1093
  async function saveResidentAppDisclaimerMsg() {
1007
1094
  await _save(buildPayload());
1008
1095
  showMessage("Disclaimer message saved successfully!", "success");
@@ -25,12 +25,20 @@
25
25
  density="comfortable"
26
26
  show-size
27
27
  :disabled="busy"
28
- @update:model-value="result = null"
28
+ @update:model-value="reset"
29
29
  />
30
30
 
31
+ <!-- Template made on another property: offer to check its rows here instead of starting again. -->
32
+ <v-alert v-if="otherPlaceMessage" type="warning" variant="tonal" class="mb-3">
33
+ {{ otherPlaceMessage }}
34
+ <div class="mt-2">Or keep your rows: they are checked against this property and shown to you before anything is saved, and saved to this property only.</div>
35
+ <v-btn size="small" variant="outlined" class="text-none mt-2" prepend-icon="mdi-file-check-outline" :loading="busy" @click="useOtherPlaceFile">Check these rows for this property</v-btn>
36
+ </v-alert>
37
+
31
38
  <template v-if="result">
32
39
  <v-alert :type="result.committed ? 'success' : result.errors ? 'error' : 'info'" variant="tonal" class="mb-3">
33
40
  {{ importSummary(result, noun) }}
41
+ <div v-if="otherProperty" class="mt-1">This file was made on another property. Its rows were checked against this property and are saved here only.</div>
34
42
  <div v-if="result.errors && !result.committed" class="mt-2">
35
43
  Fix the rows marked "Needs fixing" in your file, save it, then choose it again above.
36
44
  <br />
@@ -87,8 +95,8 @@ const props = defineProps({
87
95
  duplicateNote: { type: String, default: "Rows already in the system are skipped and left unchanged." },
88
96
  templateFileName: { type: String, required: true },
89
97
  downloadTemplate: { type: Function as PropType<() => Promise<Blob>>, required: true },
90
- check: { type: Function as PropType<(file: File) => Promise<TImportResult>>, required: true },
91
- commit: { type: Function as PropType<(file: File) => Promise<TImportResult>>, required: true },
98
+ check: { type: Function as PropType<(file: File, extra?: { otherProperty?: boolean }) => Promise<TImportResult>>, required: true },
99
+ commit: { type: Function as PropType<(file: File, extra?: { otherProperty?: boolean }) => Promise<TImportResult>>, required: true },
92
100
  });
93
101
  const emit = defineEmits<{ done: [result: TImportResult]; error: [message: string] }>();
94
102
 
@@ -97,6 +105,21 @@ const selected = computed<File | null>(() => (Array.isArray(file.value) ? (file.
97
105
  const result = ref<TImportResult | null>(null);
98
106
  const busy = ref(false);
99
107
  const downloading = ref(false);
108
+ /** Set when the user chose to check a file made on another property against this one. */
109
+ const otherProperty = ref(false);
110
+ const otherPlaceMessage = ref("");
111
+
112
+ function reset() {
113
+ result.value = null;
114
+ otherProperty.value = false;
115
+ otherPlaceMessage.value = "";
116
+ }
117
+
118
+ function useOtherPlaceFile() {
119
+ otherProperty.value = true;
120
+ otherPlaceMessage.value = "";
121
+ run(false);
122
+ }
100
123
 
101
124
  async function download() {
102
125
  downloading.value = true;
@@ -118,10 +141,11 @@ async function run(commit: boolean) {
118
141
  if (!selected.value) return;
119
142
  busy.value = true;
120
143
  try {
121
- result.value = await (commit ? props.commit : props.check)(selected.value);
144
+ result.value = await (commit ? props.commit : props.check)(selected.value, otherProperty.value ? { otherProperty: true } : undefined);
122
145
  if (commit) emit("done", result.value);
123
146
  } catch (error: any) {
124
- emit("error", error?.data?.message || "Could not read the file.");
147
+ if (error?.data?.name === "OtherPropertyFile" && !otherProperty.value) otherPlaceMessage.value = error.data.message;
148
+ else emit("error", error?.data?.message || "Could not read the file.");
125
149
  } finally {
126
150
  busy.value = false;
127
151
  }
@@ -130,7 +154,7 @@ async function run(commit: boolean) {
130
154
  watch(show, (open) => {
131
155
  if (open) {
132
156
  file.value = null;
133
- result.value = null;
157
+ reset();
134
158
  }
135
159
  });
136
160
  </script>
@@ -193,8 +193,8 @@
193
193
  duplicate-note="Units already on the list are skipped and left unchanged."
194
194
  template-file-name="units-import-template.xlsx"
195
195
  :download-template="() => downloadTemplate('units', importQuery)"
196
- :check="(file: File) => checkImport('units', file, importQuery)"
197
- :commit="(file: File) => commitImport('units', file, importQuery)"
196
+ :check="(file: File, extra?: { otherProperty?: boolean }) => checkImport('units', file, { ...importQuery, ...extra })"
197
+ :commit="(file: File, extra?: { otherProperty?: boolean }) => commitImport('units', file, { ...importQuery, ...extra })"
198
198
  @done="getUnitsRefresh()"
199
199
  @error="(text: string) => showMessage(text, 'error')"
200
200
  />
@@ -8,17 +8,20 @@ import type { TImportResult } from "../utils/import-result";
8
8
  */
9
9
  export type TTemplateKind = "building-units" | "areas" | "units" | "vehicles" | "cameras";
10
10
 
11
+ type TImportQuery = { site: string; serviceType?: string; otherProperty?: boolean };
12
+
11
13
  export default function useImportTemplates() {
12
14
  const api = <T = any>(kind: TTemplateKind, path: string, options: Record<string, any> = {}) =>
13
15
  useNuxtApp().$api<T>(`/api/import-templates/${kind}/${path}`, options);
14
- const send = (kind: TTemplateKind, path: "check" | "commit", file: File, query: Record<string, string | undefined>) => {
16
+ const send = (kind: TTemplateKind, path: "check" | "commit", file: File, query: TImportQuery) => {
15
17
  const body = new FormData();
16
18
  body.append("file", file);
17
19
  return api<TImportResult>(kind, path, { method: "POST", body, query });
18
20
  };
19
21
  return {
20
22
  downloadTemplate: (kind: TTemplateKind, query: { site: string; serviceType?: string }) => api<Blob>(kind, "template", { query, responseType: "blob" }),
21
- checkImport: (kind: TTemplateKind, file: File, query: { site: string; serviceType?: string }) => send(kind, "check", file, query),
22
- commitImport: (kind: TTemplateKind, file: File, query: { site: string; serviceType?: string }) => send(kind, "commit", file, query),
23
+ // otherProperty: the user chose to check a file made on another property against this one (rows still saved to `site`).
24
+ checkImport: (kind: TTemplateKind, file: File, query: TImportQuery) => send(kind, "check", file, query),
25
+ commitImport: (kind: TTemplateKind, file: File, query: TImportQuery) => send(kind, "commit", file, query),
23
26
  };
24
27
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.97.1-staging.719",
5
+ "version": "4.97.1-staging.721",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",