@7365admin1/layer-common 4.97.1-staging.720 → 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.
package/components/AreaMain.vue
CHANGED
|
@@ -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
|
/>
|
|
@@ -25,12 +25,20 @@
|
|
|
25
25
|
density="comfortable"
|
|
26
26
|
show-size
|
|
27
27
|
:disabled="busy"
|
|
28
|
-
@update:model-value="
|
|
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
|
-
|
|
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
|
-
|
|
157
|
+
reset();
|
|
134
158
|
}
|
|
135
159
|
});
|
|
136
160
|
</script>
|
package/components/UnitMain.vue
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
22
|
-
|
|
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.
|
|
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.",
|