@7365admin1/layer-common 4.15.2 → 4.15.3-staging.326
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/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidIntercomManagement.vue +193 -43
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +771 -212
- package/components/InvitationClientForm.vue +19 -1
- package/components/Layout/Header.vue +26 -0
- package/components/NotificationBell.vue +321 -0
- package/components/VehicleAddSelection.vue +7 -2
- package/components/VehicleBulkAddForm.vue +1392 -0
- package/components/VehicleManagement.vue +31 -3
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +97 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useMember.ts +12 -2
- package/composables/useNotification.ts +78 -0
- package/composables/usePeople.ts +19 -0
- package/composables/useVehicle.ts +35 -0
- package/composables/useWebUsb.ts +14 -11
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/plugins/secure-member.client.ts +68 -14
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +4 -1
- package/utils/materialSymbols.ts +3 -0
- package/utils/vehicle-bulk-rows.ts +534 -0
- package/utils/vehicle-bulk-sheet.ts +361 -0
|
@@ -0,0 +1,1392 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card width="100%" class="screen-modal bulk-vehicle">
|
|
3
|
+
<v-card-title class="d-flex align-center flex-wrap ga-2">
|
|
4
|
+
<span>Add Vehicles (Whitelist)</span>
|
|
5
|
+
<v-chip size="small" color="primary" variant="flat" label>Bulk</v-chip>
|
|
6
|
+
</v-card-title>
|
|
7
|
+
|
|
8
|
+
<v-card-text class="screen-modal__body pa-5">
|
|
9
|
+
<div class="d-flex align-center flex-wrap ga-2 mb-3">
|
|
10
|
+
<!-- How many rows the sheet holds. Rows left blank are ignored, so a
|
|
11
|
+
bigger sheet costs nothing but the scrolling. -->
|
|
12
|
+
<v-select
|
|
13
|
+
v-model="sheetSize"
|
|
14
|
+
class="bulk-sheet__size"
|
|
15
|
+
:items="sizeItems"
|
|
16
|
+
label="Rows"
|
|
17
|
+
density="compact"
|
|
18
|
+
variant="outlined"
|
|
19
|
+
hide-details
|
|
20
|
+
:disabled="busy"
|
|
21
|
+
@update:model-value="applySheetSize"
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<!-- Fill it in at a desk, in Excel, and bring it back. -->
|
|
25
|
+
<v-btn
|
|
26
|
+
class="text-none bulk-sheet__action"
|
|
27
|
+
variant="outlined"
|
|
28
|
+
size="small"
|
|
29
|
+
height="40"
|
|
30
|
+
prepend-icon="mdi-download"
|
|
31
|
+
:disabled="busy"
|
|
32
|
+
@click="downloadTemplate"
|
|
33
|
+
>
|
|
34
|
+
Download template
|
|
35
|
+
</v-btn>
|
|
36
|
+
<v-btn
|
|
37
|
+
class="text-none bulk-sheet__action"
|
|
38
|
+
variant="outlined"
|
|
39
|
+
size="small"
|
|
40
|
+
height="40"
|
|
41
|
+
prepend-icon="mdi-upload"
|
|
42
|
+
:loading="uploading"
|
|
43
|
+
:disabled="busy"
|
|
44
|
+
@click="fileEl?.click()"
|
|
45
|
+
>
|
|
46
|
+
Upload file
|
|
47
|
+
</v-btn>
|
|
48
|
+
<input
|
|
49
|
+
ref="fileEl"
|
|
50
|
+
type="file"
|
|
51
|
+
class="d-none"
|
|
52
|
+
accept=".csv,.tsv,.txt,.xlsx,.xlsm"
|
|
53
|
+
@change="onFileChosen"
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
<v-spacer />
|
|
57
|
+
|
|
58
|
+
<v-chip size="small" variant="tonal" color="success">
|
|
59
|
+
Added {{ counts.added }}
|
|
60
|
+
</v-chip>
|
|
61
|
+
<v-chip size="small" variant="tonal" color="error">
|
|
62
|
+
Failed {{ counts.failed }}
|
|
63
|
+
</v-chip>
|
|
64
|
+
<v-chip size="small" variant="tonal">Pending {{ counts.pending }}</v-chip>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<v-alert
|
|
68
|
+
v-if="formError"
|
|
69
|
+
class="mb-3"
|
|
70
|
+
type="error"
|
|
71
|
+
variant="tonal"
|
|
72
|
+
density="compact"
|
|
73
|
+
:text="formError"
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
<v-alert
|
|
77
|
+
v-if="progressNote"
|
|
78
|
+
class="mb-3"
|
|
79
|
+
type="info"
|
|
80
|
+
variant="tonal"
|
|
81
|
+
density="compact"
|
|
82
|
+
:text="progressNote"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<v-alert
|
|
86
|
+
v-if="resultNote"
|
|
87
|
+
class="mb-3"
|
|
88
|
+
:type="counts.failed ? 'warning' : 'success'"
|
|
89
|
+
variant="tonal"
|
|
90
|
+
density="compact"
|
|
91
|
+
:text="resultNote"
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<!-- The sheet. Click a cell to select it, drag or shift-click to select
|
|
95
|
+
more, type or double-click to edit, and drag the small square at the
|
|
96
|
+
bottom-right of the selection to fill down. Ctrl+C / Ctrl+V move
|
|
97
|
+
cells in and out, Excel included. -->
|
|
98
|
+
<div
|
|
99
|
+
ref="gridEl"
|
|
100
|
+
class="bulk-sheet"
|
|
101
|
+
tabindex="0"
|
|
102
|
+
@keydown="onKeydown"
|
|
103
|
+
@copy="onCopy"
|
|
104
|
+
@cut="onCut"
|
|
105
|
+
@paste="onPaste"
|
|
106
|
+
@mouseup="endDrag"
|
|
107
|
+
@mouseleave="endDrag"
|
|
108
|
+
>
|
|
109
|
+
<table class="bulk-sheet__table" :style="{ width: `${tableWidth}px` }">
|
|
110
|
+
<!-- Fixed widths, so nothing the sheet holds - a long name, a cell
|
|
111
|
+
being edited - can move a column. Drag a header edge to resize. -->
|
|
112
|
+
<colgroup>
|
|
113
|
+
<col :style="{ width: `${ROWNUM_WIDTH}px` }" />
|
|
114
|
+
<col
|
|
115
|
+
v-for="(column, index) in COLUMNS"
|
|
116
|
+
:key="column.key"
|
|
117
|
+
:style="{ width: `${colWidths[index]}px` }"
|
|
118
|
+
/>
|
|
119
|
+
<col :style="{ width: `${STATUS_WIDTH}px` }" />
|
|
120
|
+
</colgroup>
|
|
121
|
+
|
|
122
|
+
<thead>
|
|
123
|
+
<tr>
|
|
124
|
+
<th class="bulk-sheet__corner"></th>
|
|
125
|
+
<th
|
|
126
|
+
v-for="(column, colIndex) in COLUMNS"
|
|
127
|
+
:key="column.key"
|
|
128
|
+
class="bulk-sheet__head"
|
|
129
|
+
>
|
|
130
|
+
{{ column.label }}
|
|
131
|
+
<span
|
|
132
|
+
class="bulk-sheet__resizer"
|
|
133
|
+
@mousedown.stop.prevent="startResize(colIndex, $event)"
|
|
134
|
+
@dblclick.stop.prevent="resetWidth(colIndex)"
|
|
135
|
+
/>
|
|
136
|
+
</th>
|
|
137
|
+
<th>Status</th>
|
|
138
|
+
</tr>
|
|
139
|
+
</thead>
|
|
140
|
+
<tbody>
|
|
141
|
+
<tr v-for="(row, rowIndex) in rows" :key="row.id">
|
|
142
|
+
<td class="bulk-sheet__rownum">{{ rowIndex + 1 }}</td>
|
|
143
|
+
|
|
144
|
+
<td
|
|
145
|
+
v-for="(column, colIndex) in COLUMNS"
|
|
146
|
+
:key="column.key"
|
|
147
|
+
class="bulk-sheet__cell"
|
|
148
|
+
:class="cellClass(row, rowIndex, colIndex, column.key)"
|
|
149
|
+
@mousedown="startSelect(rowIndex, colIndex, $event)"
|
|
150
|
+
@mouseover="dragSelect(rowIndex, colIndex)"
|
|
151
|
+
@dblclick="beginEdit(rowIndex, colIndex)"
|
|
152
|
+
>
|
|
153
|
+
<!-- The cell being edited: a picker for block, level and unit
|
|
154
|
+
(open, and typing narrows it), a plain box for the rest. -->
|
|
155
|
+
<v-autocomplete
|
|
156
|
+
v-if="isEditing(rowIndex, colIndex) && column.type === 'option'"
|
|
157
|
+
v-model:menu="menuOpen"
|
|
158
|
+
v-model:search="editorSearch"
|
|
159
|
+
class="bulk-sheet__picker"
|
|
160
|
+
:model-value="row[column.key]"
|
|
161
|
+
:items="optionsFor(row, column.key)"
|
|
162
|
+
item-title="title"
|
|
163
|
+
item-value="value"
|
|
164
|
+
density="compact"
|
|
165
|
+
variant="plain"
|
|
166
|
+
hide-details
|
|
167
|
+
autofocus
|
|
168
|
+
auto-select-first
|
|
169
|
+
:menu-props="{ maxHeight: 280 }"
|
|
170
|
+
@update:model-value="onOptionChosen(row, column.key, String($event ?? ''))"
|
|
171
|
+
@keydown.esc.stop="endEdit"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
<input
|
|
175
|
+
v-else-if="isEditing(rowIndex, colIndex)"
|
|
176
|
+
ref="editorEl"
|
|
177
|
+
class="bulk-sheet__editor"
|
|
178
|
+
:value="row[column.key]"
|
|
179
|
+
@input="onTextInput(row, column.key, ($event.target as HTMLInputElement).value)"
|
|
180
|
+
@blur="endEdit"
|
|
181
|
+
@keydown.esc.stop="endEdit"
|
|
182
|
+
@keydown.enter.stop.prevent="commitAndMoveDown()"
|
|
183
|
+
@keydown.tab.stop.prevent="commitAndMoveRight()"
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
<span v-else class="bulk-sheet__text">
|
|
187
|
+
{{ displayValue(row, column.key) }}
|
|
188
|
+
</span>
|
|
189
|
+
|
|
190
|
+
<!-- The fill handle, on the bottom-right cell of the selection. -->
|
|
191
|
+
<span
|
|
192
|
+
v-if="isFillCorner(rowIndex, colIndex)"
|
|
193
|
+
class="bulk-sheet__handle"
|
|
194
|
+
@mousedown.stop.prevent="startFill"
|
|
195
|
+
/>
|
|
196
|
+
</td>
|
|
197
|
+
|
|
198
|
+
<td class="bulk-sheet__status">
|
|
199
|
+
<div v-if="statusFor(row)" class="d-flex align-center ga-1">
|
|
200
|
+
<!-- A plain word while a row waits its turn: a sheet can hold
|
|
201
|
+
a thousand of them, and a thousand chips is a slow sheet. -->
|
|
202
|
+
<span
|
|
203
|
+
v-if="row.status === 'pending'"
|
|
204
|
+
class="text-caption text-medium-emphasis"
|
|
205
|
+
>
|
|
206
|
+
{{ statusFor(row) }}
|
|
207
|
+
</span>
|
|
208
|
+
<v-chip v-else size="x-small" variant="tonal" :color="statusColour(row.status)">
|
|
209
|
+
<v-progress-circular
|
|
210
|
+
v-if="row.status === 'adding'"
|
|
211
|
+
class="mr-1"
|
|
212
|
+
indeterminate
|
|
213
|
+
size="10"
|
|
214
|
+
width="2"
|
|
215
|
+
/>
|
|
216
|
+
{{ statusFor(row) }}
|
|
217
|
+
</v-chip>
|
|
218
|
+
|
|
219
|
+
<v-tooltip v-if="row.message" location="top" max-width="420">
|
|
220
|
+
<template #activator="{ props: tip }">
|
|
221
|
+
<v-icon
|
|
222
|
+
v-bind="tip"
|
|
223
|
+
size="small"
|
|
224
|
+
:color="row.status === 'failed' ? 'error' : 'info'"
|
|
225
|
+
>
|
|
226
|
+
mdi-information-outline
|
|
227
|
+
</v-icon>
|
|
228
|
+
</template>
|
|
229
|
+
{{ row.message }}
|
|
230
|
+
</v-tooltip>
|
|
231
|
+
</div>
|
|
232
|
+
</td>
|
|
233
|
+
</tr>
|
|
234
|
+
</tbody>
|
|
235
|
+
</table>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<p class="text-caption text-medium-emphasis mt-2">
|
|
239
|
+
Click a cell to select it; drag or shift-click for a block of cells.
|
|
240
|
+
Type, or double-click, to edit. <strong>Download template</strong> gives
|
|
241
|
+
you the sheet's columns to fill in elsewhere;
|
|
242
|
+
<strong>Upload file</strong> reads a filled-in .csv or .xlsx back into
|
|
243
|
+
the rows below. <strong>Ctrl+C</strong> and
|
|
244
|
+
<strong>Ctrl+V</strong> copy and paste between cells and to and from
|
|
245
|
+
Excel; drag the small square at the corner of the selection (or press
|
|
246
|
+
<strong>Ctrl+D</strong>) to fill down; <strong>Delete</strong> empties
|
|
247
|
+
the selected cells, and dragging the edge of a column header sets that
|
|
248
|
+
column's width (double-click it to put it back). Block, Level, Unit,
|
|
249
|
+
Full Name and
|
|
250
|
+
Vehicle No. are needed on every row you fill in; rows left completely
|
|
251
|
+
blank are ignored. <strong>Code</strong> is the phone's country, +65 unless
|
|
252
|
+
you change it.
|
|
253
|
+
</p>
|
|
254
|
+
</v-card-text>
|
|
255
|
+
|
|
256
|
+
<v-card-actions class="screen-modal__footer">
|
|
257
|
+
<div class="d-flex flex-wrap justify-end ga-2 w-100">
|
|
258
|
+
<v-btn
|
|
259
|
+
variant="outlined"
|
|
260
|
+
class="text-none screen-btn-ghost"
|
|
261
|
+
:disabled="busy"
|
|
262
|
+
@click="emit('back')"
|
|
263
|
+
text="Back to Selection"
|
|
264
|
+
/>
|
|
265
|
+
<v-btn
|
|
266
|
+
variant="outlined"
|
|
267
|
+
class="text-none"
|
|
268
|
+
:disabled="busy"
|
|
269
|
+
@click="close"
|
|
270
|
+
text="Close"
|
|
271
|
+
/>
|
|
272
|
+
<v-btn
|
|
273
|
+
variant="flat"
|
|
274
|
+
class="text-none screen-btn-primary"
|
|
275
|
+
:loading="submitting"
|
|
276
|
+
:disabled="busy || (!counts.pending && !counts.failed)"
|
|
277
|
+
@click="submit"
|
|
278
|
+
:text="submitLabel"
|
|
279
|
+
/>
|
|
280
|
+
</div>
|
|
281
|
+
</v-card-actions>
|
|
282
|
+
</v-card>
|
|
283
|
+
</template>
|
|
284
|
+
|
|
285
|
+
<script setup lang="ts">
|
|
286
|
+
import useVehicle from "../composables/useVehicle";
|
|
287
|
+
import useBuilding from "../composables/useBuilding";
|
|
288
|
+
import { errorConverter } from "../utils/data";
|
|
289
|
+
// @ts-ignore - the country list the one-vehicle form's phone field uses.
|
|
290
|
+
import phoneMasks from "~/utils/phoneMasks";
|
|
291
|
+
import {
|
|
292
|
+
BULK_SHEET_DEFAULT_SIZE,
|
|
293
|
+
BULK_SHEET_SIZES,
|
|
294
|
+
DEFAULT_DIAL_CODE,
|
|
295
|
+
bulkPhoneToStore,
|
|
296
|
+
bulkRowCounts,
|
|
297
|
+
bulkSubmitBatches,
|
|
298
|
+
emptyBulkRow,
|
|
299
|
+
isBulkRowEmpty,
|
|
300
|
+
resizeBulkRows,
|
|
301
|
+
isInRange,
|
|
302
|
+
matchOptionByTitle,
|
|
303
|
+
normaliseRange,
|
|
304
|
+
parsePastedGrid,
|
|
305
|
+
planFill,
|
|
306
|
+
planPaste,
|
|
307
|
+
rangeToTsv,
|
|
308
|
+
validateBulkRows,
|
|
309
|
+
type BulkDialRules,
|
|
310
|
+
type BulkRowStatus,
|
|
311
|
+
type BulkVehicleRow,
|
|
312
|
+
type CellRef,
|
|
313
|
+
} from "../utils/vehicle-bulk-rows";
|
|
314
|
+
import {
|
|
315
|
+
BULK_SHEET_HEADINGS,
|
|
316
|
+
isWorkbookName,
|
|
317
|
+
mapUploadedGrid,
|
|
318
|
+
vehicleBulkTemplateCsv,
|
|
319
|
+
xlsxToGrid,
|
|
320
|
+
} from "../utils/vehicle-bulk-sheet";
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Many whitelist vehicles at once, as a SHEET rather than a stack of forms.
|
|
324
|
+
*
|
|
325
|
+
* It behaves the way a spreadsheet does, because that is what the job is:
|
|
326
|
+
* select a cell or a block of cells, type into them, copy and paste between
|
|
327
|
+
* them (and to and from Excel), and drag the corner handle to fill a value
|
|
328
|
+
* down a column. Block, level and unit are still this site's own records - a
|
|
329
|
+
* cell holds the id, the sheet shows and copies the NAME - so a pasted name
|
|
330
|
+
* that matches nothing is left blank and marked red rather than invented.
|
|
331
|
+
*
|
|
332
|
+
* Submit checks the cells first and sends nothing while any are red. Once they
|
|
333
|
+
* are right, every row goes with its own id and comes back with its own
|
|
334
|
+
* outcome: added rows lock, refused rows turn red with the reason and are the
|
|
335
|
+
* only ones sent again. The server adds each row exactly as the one-vehicle
|
|
336
|
+
* form does, including the pending-or-active rule and the ANPR cameras.
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
const prop = defineProps({
|
|
340
|
+
site: { type: String, required: true },
|
|
341
|
+
org: { type: String, required: true },
|
|
342
|
+
startingRows: { type: Number, default: BULK_SHEET_DEFAULT_SIZE },
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const emit = defineEmits(["back", "close", "added"]);
|
|
346
|
+
|
|
347
|
+
const { addVehiclesBulk } = useVehicle();
|
|
348
|
+
const { getBlocksSelection, getLevelsSelection, getUnitSelection } = useBuilding();
|
|
349
|
+
|
|
350
|
+
type Option = { title: string; value: string };
|
|
351
|
+
type ColumnKey =
|
|
352
|
+
| "block"
|
|
353
|
+
| "level"
|
|
354
|
+
| "unit"
|
|
355
|
+
| "nric"
|
|
356
|
+
| "name"
|
|
357
|
+
| "dialCode"
|
|
358
|
+
| "phone"
|
|
359
|
+
| "plateNumber";
|
|
360
|
+
|
|
361
|
+
/** The sheet's columns, left to right. `option` columns hold ids. */
|
|
362
|
+
const COLUMNS: Array<{
|
|
363
|
+
key: ColumnKey;
|
|
364
|
+
label: string;
|
|
365
|
+
type: "option" | "text";
|
|
366
|
+
width: number;
|
|
367
|
+
}> = [
|
|
368
|
+
{ key: "block", label: "Block *", type: "option", width: 150 },
|
|
369
|
+
{ key: "level", label: "Level *", type: "option", width: 130 },
|
|
370
|
+
{ key: "unit", label: "Unit *", type: "option", width: 130 },
|
|
371
|
+
{ key: "nric", label: "NRIC", type: "text", width: 140 },
|
|
372
|
+
{ key: "name", label: "Full Name *", type: "text", width: 200 },
|
|
373
|
+
{ key: "dialCode", label: "Code", type: "option", width: 110 },
|
|
374
|
+
{ key: "phone", label: "Phone Number", type: "text", width: 150 },
|
|
375
|
+
{ key: "plateNumber", label: "Vehicle No. *", type: "text", width: 150 },
|
|
376
|
+
];
|
|
377
|
+
|
|
378
|
+
const ROWNUM_WIDTH = 44;
|
|
379
|
+
const STATUS_WIDTH = 130;
|
|
380
|
+
const MIN_COLUMN_WIDTH = 70;
|
|
381
|
+
|
|
382
|
+
/** The rows one uploaded file may carry - the biggest sheet there is. */
|
|
383
|
+
const MAX_UPLOAD_ROWS = BULK_SHEET_SIZES[BULK_SHEET_SIZES.length - 1];
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* The Code column's list: every country's dial code, from the same file the
|
|
387
|
+
* one-vehicle form's phone field uses. One entry per code (a code several
|
|
388
|
+
* countries share is listed once, under the first of them), Singapore first
|
|
389
|
+
* because that is where these sites are, then by name.
|
|
390
|
+
*/
|
|
391
|
+
const DIAL_CODES: Array<Option & { name: string }> = (() => {
|
|
392
|
+
const seen = new Map<string, string>();
|
|
393
|
+
for (const country of phoneMasks as Array<{ name: string; dial_code: string }>) {
|
|
394
|
+
const code = String(country?.dial_code ?? "").trim();
|
|
395
|
+
if (code && !seen.has(code)) seen.set(code, String(country?.name ?? ""));
|
|
396
|
+
}
|
|
397
|
+
return [...seen.entries()]
|
|
398
|
+
.map(([value, name]) => ({ value, title: `${value} ${name}`, name }))
|
|
399
|
+
.sort((a, b) =>
|
|
400
|
+
a.value === DEFAULT_DIAL_CODE
|
|
401
|
+
? -1
|
|
402
|
+
: b.value === DEFAULT_DIAL_CODE
|
|
403
|
+
? 1
|
|
404
|
+
: a.name.localeCompare(b.name),
|
|
405
|
+
);
|
|
406
|
+
})();
|
|
407
|
+
|
|
408
|
+
const DIAL_CODE_VALUES = DIAL_CODES.map((option) => option.value);
|
|
409
|
+
|
|
410
|
+
/** What a number has to look like under each code - the form's own patterns. */
|
|
411
|
+
const DIAL_RULES: BulkDialRules = (() => {
|
|
412
|
+
const rules: BulkDialRules = {};
|
|
413
|
+
for (const country of phoneMasks as Array<{ dial_code: string; regex: string }>) {
|
|
414
|
+
const code = String(country?.dial_code ?? "").trim();
|
|
415
|
+
const pattern = String(country?.regex ?? "").trim();
|
|
416
|
+
if (!code) continue;
|
|
417
|
+
rules[code] = rules[code] ?? [];
|
|
418
|
+
// Several countries can share a code and expect different numbers; a
|
|
419
|
+
// number that suits any one of them suits the code.
|
|
420
|
+
if (pattern && !rules[code].includes(pattern)) rules[code].push(pattern);
|
|
421
|
+
}
|
|
422
|
+
return rules;
|
|
423
|
+
})();
|
|
424
|
+
|
|
425
|
+
const rows = ref<BulkVehicleRow[]>([]);
|
|
426
|
+
const sheetSize = ref<number>(prop.startingRows);
|
|
427
|
+
const blocks = ref<Option[]>([]);
|
|
428
|
+
const levelsByBlock = reactive<Record<string, Option[]>>({});
|
|
429
|
+
const unitsByLevel = reactive<Record<string, Option[]>>({});
|
|
430
|
+
|
|
431
|
+
const gridEl = ref<HTMLElement | null>(null);
|
|
432
|
+
const editorEl = ref<HTMLElement[] | HTMLElement | null>(null);
|
|
433
|
+
|
|
434
|
+
const anchor = ref<CellRef>({ row: 0, col: 0 });
|
|
435
|
+
const focus = ref<CellRef>({ row: 0, col: 0 });
|
|
436
|
+
const editing = ref<CellRef | null>(null);
|
|
437
|
+
/** The picker's menu, open from the moment a block/level/unit cell is edited. */
|
|
438
|
+
const menuOpen = ref(false);
|
|
439
|
+
/** What has been typed into the picker - seeded by the key that opened it. */
|
|
440
|
+
const editorSearch = ref("");
|
|
441
|
+
const selecting = ref(false);
|
|
442
|
+
/** Column widths in pixels, changed by dragging a header edge. */
|
|
443
|
+
const colWidths = ref<number[]>(COLUMNS.map((column) => column.width));
|
|
444
|
+
const resizing = ref<{ col: number; startX: number; startWidth: number } | null>(null);
|
|
445
|
+
const filling = ref(false);
|
|
446
|
+
const fillToRow = ref<number | null>(null);
|
|
447
|
+
|
|
448
|
+
const submitting = ref(false);
|
|
449
|
+
const uploading = ref(false);
|
|
450
|
+
const fileEl = ref<HTMLInputElement | null>(null);
|
|
451
|
+
const formError = ref("");
|
|
452
|
+
const resultNote = ref("");
|
|
453
|
+
/** Which batch is in flight, while a big sheet is being sent. */
|
|
454
|
+
const progressNote = ref("");
|
|
455
|
+
|
|
456
|
+
const busy = computed(() => submitting.value || uploading.value);
|
|
457
|
+
const counts = computed(() => bulkRowCounts(rows.value));
|
|
458
|
+
/** An uploaded file may leave the sheet at a size that is not on the list. */
|
|
459
|
+
const sizeItems = computed(() => {
|
|
460
|
+
const list = [...BULK_SHEET_SIZES];
|
|
461
|
+
if (!list.includes(sheetSize.value)) list.push(sheetSize.value);
|
|
462
|
+
return list.sort((a, b) => a - b);
|
|
463
|
+
});
|
|
464
|
+
const selection = computed(() => normaliseRange(anchor.value, focus.value));
|
|
465
|
+
const tableWidth = computed(
|
|
466
|
+
() =>
|
|
467
|
+
ROWNUM_WIDTH +
|
|
468
|
+
STATUS_WIDTH +
|
|
469
|
+
colWidths.value.reduce((total, width) => total + width, 0),
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
const submitLabel = computed(() =>
|
|
473
|
+
counts.value.failed && !counts.value.pending
|
|
474
|
+
? `Retry ${counts.value.failed} row(s)`
|
|
475
|
+
: `Submit ${counts.value.pending + counts.value.failed} row(s)`,
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
/* ------------------------------- the cells -------------------------------- */
|
|
479
|
+
|
|
480
|
+
function optionsFor(row: BulkVehicleRow, key: ColumnKey): Option[] {
|
|
481
|
+
if (key === "dialCode") return DIAL_CODES;
|
|
482
|
+
if (key === "block") return blocks.value;
|
|
483
|
+
if (key === "level") return levelsByBlock[row.block] ?? [];
|
|
484
|
+
if (key === "unit") return unitsByLevel[`${row.block}|${row.level}`] ?? [];
|
|
485
|
+
return [];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** What the cell shows and what Ctrl+C puts on the clipboard: the NAME. */
|
|
489
|
+
function displayValue(row: BulkVehicleRow, key: ColumnKey): string {
|
|
490
|
+
const value = String(row[key] ?? "");
|
|
491
|
+
const column = COLUMNS.find((entry) => entry.key === key);
|
|
492
|
+
// A dial code IS its own name; the country is only there to search by.
|
|
493
|
+
if (key === "dialCode") return value;
|
|
494
|
+
if (column?.type !== "option" || !value) return value;
|
|
495
|
+
return optionsFor(row, key).find((option) => option.value === value)?.title ?? value;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function valueAt(rowIndex: number, colIndex: number): string {
|
|
499
|
+
const row = rows.value[rowIndex];
|
|
500
|
+
const column = COLUMNS[colIndex];
|
|
501
|
+
if (!row || !column) return "";
|
|
502
|
+
return displayValue(row, column.key);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* A row nothing may write into: one already added, or any row while the sheet
|
|
507
|
+
* is being sent. NOT while a file is being read - that read is what fills the
|
|
508
|
+
* rows in, and locking them would leave the sheet empty after the upload said
|
|
509
|
+
* it had read them.
|
|
510
|
+
*/
|
|
511
|
+
function isLocked(row?: BulkVehicleRow) {
|
|
512
|
+
return !row || row.status === "added" || submitting.value;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function isEditing(rowIndex: number, colIndex: number) {
|
|
516
|
+
return editing.value?.row === rowIndex && editing.value?.col === colIndex;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function isFillCorner(rowIndex: number, colIndex: number) {
|
|
520
|
+
return (
|
|
521
|
+
!editing.value &&
|
|
522
|
+
rowIndex === selection.value.bottom &&
|
|
523
|
+
colIndex === selection.value.right
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function cellClass(
|
|
528
|
+
row: BulkVehicleRow,
|
|
529
|
+
rowIndex: number,
|
|
530
|
+
colIndex: number,
|
|
531
|
+
key: ColumnKey,
|
|
532
|
+
) {
|
|
533
|
+
return {
|
|
534
|
+
"is-selected": isInRange(selection.value, rowIndex, colIndex),
|
|
535
|
+
"is-active": anchor.value.row === rowIndex && anchor.value.col === colIndex,
|
|
536
|
+
"is-invalid": row.invalid.includes(key),
|
|
537
|
+
"is-locked": row.status === "added",
|
|
538
|
+
"is-filling":
|
|
539
|
+
filling.value &&
|
|
540
|
+
fillToRow.value !== null &&
|
|
541
|
+
colIndex >= selection.value.left &&
|
|
542
|
+
colIndex <= selection.value.right &&
|
|
543
|
+
rowIndex > selection.value.bottom &&
|
|
544
|
+
rowIndex <= fillToRow.value,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/* ----------------------------- selecting cells ---------------------------- */
|
|
549
|
+
|
|
550
|
+
function startSelect(rowIndex: number, colIndex: number, event: MouseEvent) {
|
|
551
|
+
// A click INSIDE the cell being edited belongs to the editor - placing the
|
|
552
|
+
// caret, dragging over the text to select it, double-clicking a word - so
|
|
553
|
+
// the sheet neither takes it nor prevents what the browser does with it.
|
|
554
|
+
if (isEditing(rowIndex, colIndex)) return;
|
|
555
|
+
|
|
556
|
+
// Anywhere else, the drag selects CELLS, not the text drawn in them.
|
|
557
|
+
event.preventDefault();
|
|
558
|
+
gridEl.value?.focus();
|
|
559
|
+
editing.value = null;
|
|
560
|
+
if (event.shiftKey) {
|
|
561
|
+
focus.value = { row: rowIndex, col: colIndex };
|
|
562
|
+
} else {
|
|
563
|
+
anchor.value = { row: rowIndex, col: colIndex };
|
|
564
|
+
focus.value = { row: rowIndex, col: colIndex };
|
|
565
|
+
}
|
|
566
|
+
selecting.value = true;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function dragSelect(rowIndex: number, colIndex: number) {
|
|
570
|
+
if (selecting.value) focus.value = { row: rowIndex, col: colIndex };
|
|
571
|
+
if (filling.value) fillToRow.value = rowIndex;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function endDrag() {
|
|
575
|
+
selecting.value = false;
|
|
576
|
+
if (filling.value) {
|
|
577
|
+
applyFill();
|
|
578
|
+
filling.value = false;
|
|
579
|
+
fillToRow.value = null;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function moveTo(rowIndex: number, colIndex: number, extend = false) {
|
|
584
|
+
const row = Math.max(0, Math.min(rows.value.length - 1, rowIndex));
|
|
585
|
+
const col = Math.max(0, Math.min(COLUMNS.length - 1, colIndex));
|
|
586
|
+
focus.value = { row, col };
|
|
587
|
+
if (!extend) anchor.value = { row, col };
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/* ---------------------------- column widths ------------------------------- */
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Drag the line at the right edge of a column header to make that column wider
|
|
594
|
+
* or narrower, as in a spreadsheet; double-click it to put it back. The drag is
|
|
595
|
+
* followed on the window so it keeps up even when the pointer leaves the sheet.
|
|
596
|
+
*/
|
|
597
|
+
function startResize(colIndex: number, event: MouseEvent) {
|
|
598
|
+
resizing.value = {
|
|
599
|
+
col: colIndex,
|
|
600
|
+
startX: event.clientX,
|
|
601
|
+
startWidth: colWidths.value[colIndex],
|
|
602
|
+
};
|
|
603
|
+
window.addEventListener("mousemove", onResizeMove);
|
|
604
|
+
window.addEventListener("mouseup", stopResize);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function onResizeMove(event: MouseEvent) {
|
|
608
|
+
const state = resizing.value;
|
|
609
|
+
if (!state) return;
|
|
610
|
+
const widths = colWidths.value.slice();
|
|
611
|
+
widths[state.col] = Math.max(
|
|
612
|
+
MIN_COLUMN_WIDTH,
|
|
613
|
+
Math.round(state.startWidth + (event.clientX - state.startX)),
|
|
614
|
+
);
|
|
615
|
+
colWidths.value = widths;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function stopResize() {
|
|
619
|
+
resizing.value = null;
|
|
620
|
+
window.removeEventListener("mousemove", onResizeMove);
|
|
621
|
+
window.removeEventListener("mouseup", stopResize);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function resetWidth(colIndex: number) {
|
|
625
|
+
const widths = colWidths.value.slice();
|
|
626
|
+
widths[colIndex] = COLUMNS[colIndex].width;
|
|
627
|
+
colWidths.value = widths;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
onBeforeUnmount(stopResize);
|
|
631
|
+
|
|
632
|
+
/* ------------------------------ editing cells ----------------------------- */
|
|
633
|
+
|
|
634
|
+
async function beginEdit(rowIndex: number, colIndex: number, initial?: string) {
|
|
635
|
+
const row = rows.value[rowIndex];
|
|
636
|
+
if (isLocked(row)) return;
|
|
637
|
+
// Already editing this cell: a second double-click is the browser selecting
|
|
638
|
+
// a word inside it, and re-opening the editor would throw that away.
|
|
639
|
+
if (isEditing(rowIndex, colIndex)) return;
|
|
640
|
+
|
|
641
|
+
anchor.value = { row: rowIndex, col: colIndex };
|
|
642
|
+
focus.value = { row: rowIndex, col: colIndex };
|
|
643
|
+
editing.value = { row: rowIndex, col: colIndex };
|
|
644
|
+
|
|
645
|
+
const column = COLUMNS[colIndex];
|
|
646
|
+
if (column.key === "level") await ensureLevels(row.block);
|
|
647
|
+
if (column.key === "unit") await ensureUnits(row.block, row.level);
|
|
648
|
+
|
|
649
|
+
if (column.type === "option") {
|
|
650
|
+
// Typing a letter on a picker cell opens it and starts the search with it.
|
|
651
|
+
editorSearch.value = initial ?? "";
|
|
652
|
+
menuOpen.value = true;
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (initial !== undefined) setCell(row, column.key, initial);
|
|
657
|
+
|
|
658
|
+
await nextTick();
|
|
659
|
+
const editor = Array.isArray(editorEl.value) ? editorEl.value[0] : editorEl.value;
|
|
660
|
+
(editor as HTMLInputElement | null)?.focus?.();
|
|
661
|
+
if (editor instanceof HTMLInputElement) {
|
|
662
|
+
editor.setSelectionRange(editor.value.length, editor.value.length);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function endEdit() {
|
|
667
|
+
editing.value = null;
|
|
668
|
+
menuOpen.value = false;
|
|
669
|
+
editorSearch.value = "";
|
|
670
|
+
gridEl.value?.focus();
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function commitAndMoveDown() {
|
|
674
|
+
const { row, col } = editing.value ?? anchor.value;
|
|
675
|
+
endEdit();
|
|
676
|
+
moveTo(row + 1, col);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function commitAndMoveRight() {
|
|
680
|
+
const { row, col } = editing.value ?? anchor.value;
|
|
681
|
+
endEdit();
|
|
682
|
+
moveTo(row, col + 1);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function setCell(row: BulkVehicleRow, key: ColumnKey, value: string) {
|
|
686
|
+
if (isLocked(row)) return;
|
|
687
|
+
if (key === "plateNumber") row.plateNumber = value.toUpperCase();
|
|
688
|
+
// A row without a dial code would store a number under nobody's country, so
|
|
689
|
+
// emptying the cell puts the default back rather than leaving it blank.
|
|
690
|
+
else if (key === "dialCode") row.dialCode = value.trim() || DEFAULT_DIAL_CODE;
|
|
691
|
+
else row[key] = value;
|
|
692
|
+
row.invalid = row.invalid.filter((field) => field !== key);
|
|
693
|
+
|
|
694
|
+
// Emptied of everything again: whatever happened to it last time no longer
|
|
695
|
+
// describes it, so the row goes back to being one nobody has typed in.
|
|
696
|
+
if (row.status !== "added" && isBulkRowEmpty(row)) {
|
|
697
|
+
row.status = "pending";
|
|
698
|
+
row.message = "";
|
|
699
|
+
row.invalid = [];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function onTextInput(row: BulkVehicleRow, key: ColumnKey, value: string) {
|
|
704
|
+
setCell(row, key, value);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
async function onOptionChosen(row: BulkVehicleRow, key: ColumnKey, value: string) {
|
|
708
|
+
setCell(row, key, value);
|
|
709
|
+
if (key === "block") {
|
|
710
|
+
row.level = "";
|
|
711
|
+
row.unit = "";
|
|
712
|
+
await ensureLevels(value);
|
|
713
|
+
}
|
|
714
|
+
if (key === "level") {
|
|
715
|
+
row.unit = "";
|
|
716
|
+
await ensureUnits(row.block, value);
|
|
717
|
+
}
|
|
718
|
+
endEdit();
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/* -------------------------------- keyboard -------------------------------- */
|
|
722
|
+
|
|
723
|
+
function onKeydown(event: KeyboardEvent) {
|
|
724
|
+
if (editing.value) return;
|
|
725
|
+
|
|
726
|
+
const { row, col } = focus.value;
|
|
727
|
+
const extend = event.shiftKey;
|
|
728
|
+
|
|
729
|
+
switch (event.key) {
|
|
730
|
+
case "ArrowDown":
|
|
731
|
+
event.preventDefault();
|
|
732
|
+
return moveTo(row + 1, col, extend);
|
|
733
|
+
case "ArrowUp":
|
|
734
|
+
event.preventDefault();
|
|
735
|
+
return moveTo(row - 1, col, extend);
|
|
736
|
+
case "ArrowLeft":
|
|
737
|
+
event.preventDefault();
|
|
738
|
+
return moveTo(row, col - 1, extend);
|
|
739
|
+
case "ArrowRight":
|
|
740
|
+
event.preventDefault();
|
|
741
|
+
return moveTo(row, col + 1, extend);
|
|
742
|
+
case "Tab":
|
|
743
|
+
event.preventDefault();
|
|
744
|
+
return moveTo(row, col + (event.shiftKey ? -1 : 1));
|
|
745
|
+
case "Enter":
|
|
746
|
+
case "F2":
|
|
747
|
+
event.preventDefault();
|
|
748
|
+
return void beginEdit(anchor.value.row, anchor.value.col);
|
|
749
|
+
case "Delete":
|
|
750
|
+
case "Backspace":
|
|
751
|
+
event.preventDefault();
|
|
752
|
+
return clearSelection();
|
|
753
|
+
default:
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "d") {
|
|
758
|
+
event.preventDefault();
|
|
759
|
+
return fillDownFromSelection();
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// Typing over a cell replaces it, as a spreadsheet does.
|
|
763
|
+
if (
|
|
764
|
+
!event.ctrlKey &&
|
|
765
|
+
!event.metaKey &&
|
|
766
|
+
!event.altKey &&
|
|
767
|
+
event.key.length === 1
|
|
768
|
+
) {
|
|
769
|
+
event.preventDefault();
|
|
770
|
+
void beginEdit(anchor.value.row, anchor.value.col, event.key);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function clearSelection() {
|
|
775
|
+
const range = selection.value;
|
|
776
|
+
for (let rowIndex = range.top; rowIndex <= range.bottom; rowIndex++) {
|
|
777
|
+
const row = rows.value[rowIndex];
|
|
778
|
+
if (isLocked(row)) continue;
|
|
779
|
+
for (let colIndex = range.left; colIndex <= range.right; colIndex++) {
|
|
780
|
+
setCell(row, COLUMNS[colIndex].key, "");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/* --------------------------- clipboard and fill --------------------------- */
|
|
786
|
+
|
|
787
|
+
function onCopy(event: ClipboardEvent) {
|
|
788
|
+
if (editing.value) return;
|
|
789
|
+
event.preventDefault();
|
|
790
|
+
event.clipboardData?.setData("text/plain", rangeToTsv(selection.value, valueAt));
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function onCut(event: ClipboardEvent) {
|
|
794
|
+
if (editing.value) return;
|
|
795
|
+
onCopy(event);
|
|
796
|
+
clearSelection();
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
async function onPaste(event: ClipboardEvent) {
|
|
800
|
+
if (editing.value) return;
|
|
801
|
+
const text = event.clipboardData?.getData("text/plain") ?? "";
|
|
802
|
+
if (!text) return;
|
|
803
|
+
event.preventDefault();
|
|
804
|
+
await pasteGrid(parsePastedGrid(text), anchor.value);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Write a block of text cells into the sheet from `start`, growing it if the
|
|
809
|
+
* block runs past the last row. Names in the block, level and unit columns are
|
|
810
|
+
* matched to this site's records; one that matches nothing leaves the cell
|
|
811
|
+
* blank and red.
|
|
812
|
+
*/
|
|
813
|
+
async function pasteGrid(grid: string[][], start: CellRef) {
|
|
814
|
+
if (!grid.length) return;
|
|
815
|
+
|
|
816
|
+
const { writes, extraRows } = planPaste(grid, start, {
|
|
817
|
+
rows: rows.value.length,
|
|
818
|
+
cols: COLUMNS.length,
|
|
819
|
+
});
|
|
820
|
+
addRows(extraRows);
|
|
821
|
+
|
|
822
|
+
for (const write of writes) {
|
|
823
|
+
const row = rows.value[write.row];
|
|
824
|
+
if (isLocked(row)) continue;
|
|
825
|
+
const column = COLUMNS[write.col];
|
|
826
|
+
|
|
827
|
+
if (column.type !== "option") {
|
|
828
|
+
setCell(row, column.key, write.value);
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (column.key === "dialCode") {
|
|
833
|
+
// "+65", "65" and "0065" all mean the same country; anything else is red.
|
|
834
|
+
const typed = write.value.replace(/[\s()\-]/g, "").replace(/^00/, "+");
|
|
835
|
+
const code = typed.startsWith("+") ? typed : typed ? `+${typed}` : "";
|
|
836
|
+
const known = DIAL_CODE_VALUES.includes(code);
|
|
837
|
+
row.dialCode = known ? code : DEFAULT_DIAL_CODE;
|
|
838
|
+
markMatch(row, "dialCode", write.value, known ? code : "");
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (column.key === "block") {
|
|
843
|
+
const id = matchOptionByTitle(blocks.value, write.value);
|
|
844
|
+
row.block = id;
|
|
845
|
+
row.level = "";
|
|
846
|
+
row.unit = "";
|
|
847
|
+
if (id) await ensureLevels(id);
|
|
848
|
+
markMatch(row, "block", write.value, id);
|
|
849
|
+
} else if (column.key === "level") {
|
|
850
|
+
const id = matchOptionByTitle(levelsByBlock[row.block] ?? [], write.value);
|
|
851
|
+
row.level = id;
|
|
852
|
+
row.unit = "";
|
|
853
|
+
if (id) await ensureUnits(row.block, id);
|
|
854
|
+
markMatch(row, "level", write.value, id);
|
|
855
|
+
} else {
|
|
856
|
+
const id = matchOptionByTitle(
|
|
857
|
+
unitsByLevel[`${row.block}|${row.level}`] ?? [],
|
|
858
|
+
write.value,
|
|
859
|
+
);
|
|
860
|
+
row.unit = id;
|
|
861
|
+
markMatch(row, "unit", write.value, id);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** A pasted name that matched nothing is shown red rather than dropped quietly. */
|
|
867
|
+
function markMatch(row: BulkVehicleRow, key: ColumnKey, pasted: string, id: string) {
|
|
868
|
+
const missed = Boolean(String(pasted ?? "").trim()) && !id;
|
|
869
|
+
row.invalid = missed
|
|
870
|
+
? Array.from(new Set([...row.invalid, key]))
|
|
871
|
+
: row.invalid.filter((field) => field !== key);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function startFill() {
|
|
875
|
+
filling.value = true;
|
|
876
|
+
fillToRow.value = selection.value.bottom;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function applyFill() {
|
|
880
|
+
if (fillToRow.value === null) return;
|
|
881
|
+
applyWrites(planFill(selection.value, fillToRow.value, valueAt));
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function fillDownFromSelection() {
|
|
885
|
+
const range = selection.value;
|
|
886
|
+
if (range.bottom === range.top) return;
|
|
887
|
+
// Ctrl+D: the top row of the selection fills the rest, as in a spreadsheet.
|
|
888
|
+
applyWrites(
|
|
889
|
+
planFill({ ...range, bottom: range.top }, range.bottom, valueAt),
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** Fill writes carry NAMES, so they go through the same matching as a paste. */
|
|
894
|
+
function applyWrites(writes: Array<{ row: number; col: number; value: string }>) {
|
|
895
|
+
const byRow = new Map<number, Array<{ col: number; value: string }>>();
|
|
896
|
+
for (const write of writes) {
|
|
897
|
+
if (!byRow.has(write.row)) byRow.set(write.row, []);
|
|
898
|
+
byRow.get(write.row)!.push({ col: write.col, value: write.value });
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
void (async () => {
|
|
902
|
+
for (const [rowIndex, cells] of byRow) {
|
|
903
|
+
const grid = [[] as string[]];
|
|
904
|
+
const left = Math.min(...cells.map((cell) => cell.col));
|
|
905
|
+
cells
|
|
906
|
+
.sort((a, b) => a.col - b.col)
|
|
907
|
+
.forEach((cell) => grid[0].push(cell.value));
|
|
908
|
+
await pasteGrid(grid, { row: rowIndex, col: left });
|
|
909
|
+
}
|
|
910
|
+
})();
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/* ------------------------------ the pickers ------------------------------- */
|
|
914
|
+
|
|
915
|
+
async function loadBlocks() {
|
|
916
|
+
try {
|
|
917
|
+
const response: any = await getBlocksSelection({ siteId: prop.site });
|
|
918
|
+
const list = Array.isArray(response?.data) ? response.data : [];
|
|
919
|
+
blocks.value = list.map((block: any) => ({
|
|
920
|
+
title: String(block?.name ?? ""),
|
|
921
|
+
value: String(block?._id ?? ""),
|
|
922
|
+
}));
|
|
923
|
+
} catch (error: any) {
|
|
924
|
+
formError.value = errorConverter(error);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
async function ensureLevels(blockId: string): Promise<Option[]> {
|
|
929
|
+
if (!blockId) return [];
|
|
930
|
+
if (levelsByBlock[blockId]) return levelsByBlock[blockId];
|
|
931
|
+
|
|
932
|
+
try {
|
|
933
|
+
const response: any = await getLevelsSelection({ siteId: prop.site, blockId });
|
|
934
|
+
const list = Array.isArray(response?.data) ? response.data : [];
|
|
935
|
+
levelsByBlock[blockId] = list.map((level: any) => ({
|
|
936
|
+
title: String(level?.name ?? ""),
|
|
937
|
+
value: String(level?._id ?? ""),
|
|
938
|
+
}));
|
|
939
|
+
} catch (error: any) {
|
|
940
|
+
levelsByBlock[blockId] = [];
|
|
941
|
+
formError.value = errorConverter(error);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
return levelsByBlock[blockId] ?? [];
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
async function ensureUnits(blockId: string, levelId: string): Promise<Option[]> {
|
|
948
|
+
if (!blockId || !levelId) return [];
|
|
949
|
+
const key = `${blockId}|${levelId}`;
|
|
950
|
+
if (unitsByLevel[key]) return unitsByLevel[key];
|
|
951
|
+
|
|
952
|
+
try {
|
|
953
|
+
const response: any = await getUnitSelection({
|
|
954
|
+
siteId: prop.site,
|
|
955
|
+
block: blockId,
|
|
956
|
+
level: levelId,
|
|
957
|
+
});
|
|
958
|
+
const list = Array.isArray(response) ? response : (response?.data ?? []);
|
|
959
|
+
unitsByLevel[key] = (Array.isArray(list) ? list : []).map((unit: any) => ({
|
|
960
|
+
title: String(unit?.name ?? ""),
|
|
961
|
+
value: String(unit?._id ?? ""),
|
|
962
|
+
}));
|
|
963
|
+
} catch (error: any) {
|
|
964
|
+
unitsByLevel[key] = [];
|
|
965
|
+
formError.value = errorConverter(error);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return unitsByLevel[key] ?? [];
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/* --------------------------------- rows ---------------------------------- */
|
|
972
|
+
|
|
973
|
+
function addRows(count: number) {
|
|
974
|
+
for (let index = 0; index < count; index++) rows.value.push(emptyBulkRow());
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Set the sheet to the chosen number of rows. Growing adds blank rows at the
|
|
979
|
+
* bottom; shrinking only removes rows nobody has typed in, so a smaller size
|
|
980
|
+
* can never throw away work. Blank rows are ignored on submit.
|
|
981
|
+
*/
|
|
982
|
+
function applySheetSize(size: number | string) {
|
|
983
|
+
const wanted = Number(size) || BULK_SHEET_DEFAULT_SIZE;
|
|
984
|
+
sheetSize.value = wanted;
|
|
985
|
+
rows.value = resizeBulkRows(rows.value, wanted);
|
|
986
|
+
moveTo(Math.min(anchor.value.row, rows.value.length - 1), anchor.value.col);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
function close() {
|
|
990
|
+
emit("close");
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* What the Status column shows for a row - and nothing at all is the usual
|
|
995
|
+
* answer. A row nobody has typed in has no outcome to report, and a row that
|
|
996
|
+
* has not been sent yet has not failed or succeeded either; the column fills
|
|
997
|
+
* in from the moment Submit starts, and empties again if the row is cleared.
|
|
998
|
+
*/
|
|
999
|
+
function statusFor(row: BulkVehicleRow): string {
|
|
1000
|
+
if (isBulkRowEmpty(row)) return "";
|
|
1001
|
+
if (row.status === "pending" && !submitting.value) return "";
|
|
1002
|
+
return statusLabel(row.status);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function statusLabel(status: BulkRowStatus) {
|
|
1006
|
+
if (status === "adding") return "Adding…";
|
|
1007
|
+
if (status === "added") return "Added";
|
|
1008
|
+
if (status === "failed") return "Failed";
|
|
1009
|
+
return "Pending";
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function statusColour(status: BulkRowStatus) {
|
|
1013
|
+
if (status === "added") return "success";
|
|
1014
|
+
if (status === "failed") return "error";
|
|
1015
|
+
if (status === "adding") return "info";
|
|
1016
|
+
return undefined;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/* --------------------------- template and file ---------------------------- */
|
|
1020
|
+
|
|
1021
|
+
/** The blank sheet, for filling in somewhere else. Opens in Excel or Sheets. */
|
|
1022
|
+
function downloadTemplate() {
|
|
1023
|
+
// A BOM, so Excel opens it as UTF-8 and a name with an accent survives.
|
|
1024
|
+
const blob = new Blob(["", vehicleBulkTemplateCsv()], {
|
|
1025
|
+
type: "text/csv;charset=utf-8;",
|
|
1026
|
+
});
|
|
1027
|
+
const url = URL.createObjectURL(blob);
|
|
1028
|
+
const link = document.createElement("a");
|
|
1029
|
+
link.href = url;
|
|
1030
|
+
link.download = "vehicle-whitelist-template.csv";
|
|
1031
|
+
link.click();
|
|
1032
|
+
URL.revokeObjectURL(url);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/** The first row that is free to be written into. */
|
|
1036
|
+
function firstFreeRow(): number {
|
|
1037
|
+
const index = rows.value.findIndex(
|
|
1038
|
+
(row) => row.status === "pending" && isBulkRowEmpty(row),
|
|
1039
|
+
);
|
|
1040
|
+
return index >= 0 ? index : rows.value.length;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* A filled-in sheet, back from Excel. The rows land in the sheet exactly as a
|
|
1045
|
+
* paste does - block, level and unit matched by name, anything unmatched left
|
|
1046
|
+
* blank and red - so nothing is saved until the cells have been looked at and
|
|
1047
|
+
* Submit is pressed.
|
|
1048
|
+
*/
|
|
1049
|
+
async function onFileChosen(event: Event) {
|
|
1050
|
+
const input = event.target as HTMLInputElement;
|
|
1051
|
+
const chosen = input.files?.[0];
|
|
1052
|
+
// Cleared, so choosing the same file again is still a change.
|
|
1053
|
+
input.value = "";
|
|
1054
|
+
if (!chosen) return;
|
|
1055
|
+
|
|
1056
|
+
formError.value = "";
|
|
1057
|
+
resultNote.value = "";
|
|
1058
|
+
uploading.value = true;
|
|
1059
|
+
|
|
1060
|
+
try {
|
|
1061
|
+
const grid = isWorkbookName(chosen.name)
|
|
1062
|
+
? await xlsxToGrid(await chosen.arrayBuffer())
|
|
1063
|
+
: parsePastedGrid(await chosen.text());
|
|
1064
|
+
const sheet = mapUploadedGrid(grid);
|
|
1065
|
+
|
|
1066
|
+
if (!sheet.matchesTemplate) {
|
|
1067
|
+
const found = sheet.header.filter(Boolean).join(", ");
|
|
1068
|
+
formError.value =
|
|
1069
|
+
`This file's columns do not match the template. The first line has ` +
|
|
1070
|
+
`to name these columns, in this order: ` +
|
|
1071
|
+
`${BULK_SHEET_HEADINGS.join(", ")}.` +
|
|
1072
|
+
(found ? ` This file has: ${found}.` : "") +
|
|
1073
|
+
` Download the template, fill that in, and upload it again.`;
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
if (!sheet.rows.length) {
|
|
1078
|
+
formError.value = "This file has the column headings but no rows under them.";
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
if (sheet.rows.length > MAX_UPLOAD_ROWS) {
|
|
1083
|
+
formError.value =
|
|
1084
|
+
`This file has ${sheet.rows.length} rows. Up to ${MAX_UPLOAD_ROWS} can ` +
|
|
1085
|
+
`be added at a time - split it and upload each part.`;
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
const start = firstFreeRow();
|
|
1090
|
+
await pasteGrid(sheet.rows, { row: start, col: 0 });
|
|
1091
|
+
sheetSize.value = rows.value.length;
|
|
1092
|
+
moveTo(start, 0);
|
|
1093
|
+
|
|
1094
|
+
resultNote.value =
|
|
1095
|
+
`${sheet.rows.length} row(s) read from ${chosen.name}. Check anything ` +
|
|
1096
|
+
`marked red - a block, level or unit that is not one of this site's own ` +
|
|
1097
|
+
`is left blank - then press Submit.`;
|
|
1098
|
+
} catch {
|
|
1099
|
+
formError.value =
|
|
1100
|
+
"This file could not be read. Save it as CSV or .xlsx from your " +
|
|
1101
|
+
"spreadsheet app and try again.";
|
|
1102
|
+
} finally {
|
|
1103
|
+
uploading.value = false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/* --------------------------------- submit -------------------------------- */
|
|
1108
|
+
|
|
1109
|
+
async function submit() {
|
|
1110
|
+
formError.value = "";
|
|
1111
|
+
resultNote.value = "";
|
|
1112
|
+
endEdit();
|
|
1113
|
+
|
|
1114
|
+
const bad = validateBulkRows(rows.value, (row) => ({
|
|
1115
|
+
blockIds: blocks.value.map((block) => block.value),
|
|
1116
|
+
levelIds: (levelsByBlock[row.block] ?? []).map((level) => level.value),
|
|
1117
|
+
unitIds: (unitsByLevel[`${row.block}|${row.level}`] ?? []).map((unit) => unit.value),
|
|
1118
|
+
dialCodes: DIAL_CODE_VALUES,
|
|
1119
|
+
dialRules: DIAL_RULES,
|
|
1120
|
+
}));
|
|
1121
|
+
|
|
1122
|
+
if (bad.length) {
|
|
1123
|
+
formError.value =
|
|
1124
|
+
`${bad.length} row(s) need attention. The cells marked in red are ` +
|
|
1125
|
+
`missing, not one of this site's blocks, levels or units, a phone ` +
|
|
1126
|
+
`number that is not one its Code's country would issue, or the same ` +
|
|
1127
|
+
`vehicle number twice. Nothing has been saved - please correct them ` +
|
|
1128
|
+
`and press Submit again.`;
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// Only the rows with something in them are sent, in batches the endpoint
|
|
1133
|
+
// accepts; the blank rows of a big sheet are simply ignored.
|
|
1134
|
+
const batches = bulkSubmitBatches(rows.value);
|
|
1135
|
+
if (!batches.length) {
|
|
1136
|
+
formError.value = "Fill in at least one row before submitting.";
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
submitting.value = true;
|
|
1141
|
+
batches.flat().forEach((row) => {
|
|
1142
|
+
row.status = "adding";
|
|
1143
|
+
row.message = "";
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
let sent = 0;
|
|
1147
|
+
|
|
1148
|
+
try {
|
|
1149
|
+
for (const [index, batch] of batches.entries()) {
|
|
1150
|
+
progressNote.value =
|
|
1151
|
+
batches.length > 1
|
|
1152
|
+
? `Sending rows ${sent + 1}-${sent + batch.length} of ${batches.flat().length}…`
|
|
1153
|
+
: "";
|
|
1154
|
+
|
|
1155
|
+
try {
|
|
1156
|
+
const response: any = await addVehiclesBulk({
|
|
1157
|
+
site: prop.site,
|
|
1158
|
+
org: prop.org,
|
|
1159
|
+
rows: batch.map((row) => ({
|
|
1160
|
+
id: row.id,
|
|
1161
|
+
block: row.block,
|
|
1162
|
+
level: row.level,
|
|
1163
|
+
unit: row.unit,
|
|
1164
|
+
name: row.name,
|
|
1165
|
+
plateNumber: row.plateNumber,
|
|
1166
|
+
nric: row.nric,
|
|
1167
|
+
phoneNumber: bulkPhoneToStore(row.phone, row.dialCode),
|
|
1168
|
+
})),
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
const results: Array<{ id: string; ok: boolean; message: string }> =
|
|
1172
|
+
Array.isArray(response?.results) ? response.results : [];
|
|
1173
|
+
|
|
1174
|
+
for (const row of batch) {
|
|
1175
|
+
const result = results.find((entry) => entry.id === row.id);
|
|
1176
|
+
if (!result) {
|
|
1177
|
+
// No answer for this row: it is not known to have been added, so
|
|
1178
|
+
// it stays as a row to send again.
|
|
1179
|
+
row.status = "failed";
|
|
1180
|
+
row.message = "The server did not answer for this row. Please try again.";
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
row.status = result.ok ? "added" : "failed";
|
|
1184
|
+
row.message = String(result.message ?? "");
|
|
1185
|
+
row.invalid = [];
|
|
1186
|
+
}
|
|
1187
|
+
} catch (error: any) {
|
|
1188
|
+
// This request was refused outright - none of ITS rows were tried, and
|
|
1189
|
+
// neither were the batches behind it. They all go back to pending so
|
|
1190
|
+
// Submit sends exactly those again.
|
|
1191
|
+
batches
|
|
1192
|
+
.slice(index)
|
|
1193
|
+
.flat()
|
|
1194
|
+
.forEach((row) => {
|
|
1195
|
+
row.status = "pending";
|
|
1196
|
+
});
|
|
1197
|
+
formError.value = errorConverter(error);
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
sent += batch.length;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
resultNote.value = counts.value.added
|
|
1205
|
+
? `${counts.value.added} vehicle(s) added` +
|
|
1206
|
+
(counts.value.failed ? `, ${counts.value.failed} refused.` : ".")
|
|
1207
|
+
: "";
|
|
1208
|
+
if (counts.value.added) emit("added");
|
|
1209
|
+
} finally {
|
|
1210
|
+
progressNote.value = "";
|
|
1211
|
+
submitting.value = false;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
onMounted(() => {
|
|
1216
|
+
applySheetSize(Math.max(1, prop.startingRows));
|
|
1217
|
+
loadBlocks();
|
|
1218
|
+
nextTick(() => gridEl.value?.focus());
|
|
1219
|
+
});
|
|
1220
|
+
</script>
|
|
1221
|
+
|
|
1222
|
+
<style scoped>
|
|
1223
|
+
.bulk-sheet__size {
|
|
1224
|
+
max-width: 120px;
|
|
1225
|
+
flex: 0 0 120px;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/* The same 40px as the compact Rows box beside them, so the row lines up. */
|
|
1229
|
+
.bulk-sheet__action {
|
|
1230
|
+
align-self: center;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
.bulk-sheet {
|
|
1234
|
+
max-height: 440px;
|
|
1235
|
+
overflow: auto;
|
|
1236
|
+
border: 1px solid rgba(128, 128, 128, 0.4);
|
|
1237
|
+
border-radius: 6px;
|
|
1238
|
+
outline: none;
|
|
1239
|
+
user-select: none;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/* Fixed layout: the widths come from the colgroup, so what is IN a cell - a
|
|
1243
|
+
long name, or the box you are typing into - never moves a column. */
|
|
1244
|
+
.bulk-sheet__table {
|
|
1245
|
+
border-collapse: collapse;
|
|
1246
|
+
table-layout: fixed;
|
|
1247
|
+
font-size: 0.82rem;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
.bulk-sheet__table th {
|
|
1251
|
+
position: sticky;
|
|
1252
|
+
top: 0;
|
|
1253
|
+
z-index: 2;
|
|
1254
|
+
background: rgb(var(--v-theme-surface));
|
|
1255
|
+
text-align: left;
|
|
1256
|
+
font-weight: 600;
|
|
1257
|
+
padding: 8px;
|
|
1258
|
+
white-space: nowrap;
|
|
1259
|
+
overflow: hidden;
|
|
1260
|
+
text-overflow: ellipsis;
|
|
1261
|
+
border: 1px solid rgba(128, 128, 128, 0.3);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/* `position: sticky` above already anchors the resizer inside the header. */
|
|
1265
|
+
.bulk-sheet__head {
|
|
1266
|
+
padding-right: 12px;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* The line you drag to set a column's width. */
|
|
1270
|
+
.bulk-sheet__resizer {
|
|
1271
|
+
position: absolute;
|
|
1272
|
+
top: 0;
|
|
1273
|
+
right: -3px;
|
|
1274
|
+
width: 7px;
|
|
1275
|
+
height: 100%;
|
|
1276
|
+
cursor: col-resize;
|
|
1277
|
+
z-index: 3;
|
|
1278
|
+
user-select: none;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
.bulk-sheet__resizer:hover {
|
|
1282
|
+
background: rgba(var(--v-theme-primary), 0.35);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
.bulk-sheet__cell {
|
|
1286
|
+
position: relative;
|
|
1287
|
+
padding: 0;
|
|
1288
|
+
height: 34px;
|
|
1289
|
+
overflow: hidden;
|
|
1290
|
+
border: 1px solid rgba(128, 128, 128, 0.3);
|
|
1291
|
+
cursor: cell;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
.bulk-sheet__text {
|
|
1295
|
+
display: block;
|
|
1296
|
+
padding: 6px 8px;
|
|
1297
|
+
white-space: nowrap;
|
|
1298
|
+
overflow: hidden;
|
|
1299
|
+
text-overflow: ellipsis;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/* Both editors fill the cell exactly and nothing more, so clicking into a
|
|
1303
|
+
cell cannot make it - or its column - grow. */
|
|
1304
|
+
.bulk-sheet__picker {
|
|
1305
|
+
position: absolute;
|
|
1306
|
+
inset: 0;
|
|
1307
|
+
width: 100%;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
.bulk-sheet__picker :deep(.v-input__control),
|
|
1311
|
+
.bulk-sheet__picker :deep(.v-field) {
|
|
1312
|
+
height: 100%;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
.bulk-sheet__picker :deep(.v-field__input) {
|
|
1316
|
+
min-height: 32px;
|
|
1317
|
+
padding: 2px 6px;
|
|
1318
|
+
font-size: 0.82rem;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/* The sheet does not select text, but what you are typing in must. */
|
|
1322
|
+
.bulk-sheet__editor,
|
|
1323
|
+
.bulk-sheet__picker {
|
|
1324
|
+
user-select: text;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
.bulk-sheet__editor {
|
|
1328
|
+
position: absolute;
|
|
1329
|
+
inset: 0;
|
|
1330
|
+
width: 100%;
|
|
1331
|
+
height: 100%;
|
|
1332
|
+
padding: 4px 6px;
|
|
1333
|
+
border: none;
|
|
1334
|
+
outline: none;
|
|
1335
|
+
box-sizing: border-box;
|
|
1336
|
+
background: rgb(var(--v-theme-surface));
|
|
1337
|
+
color: inherit;
|
|
1338
|
+
font: inherit;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
.bulk-sheet__cell.is-selected {
|
|
1342
|
+
background: rgba(var(--v-theme-primary), 0.1);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
.bulk-sheet__cell.is-active {
|
|
1346
|
+
box-shadow: inset 0 0 0 2px rgb(var(--v-theme-primary));
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
.bulk-sheet__cell.is-invalid {
|
|
1350
|
+
background: rgba(var(--v-theme-error), 0.14);
|
|
1351
|
+
box-shadow: inset 0 0 0 1px rgb(var(--v-theme-error));
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
.bulk-sheet__cell.is-locked {
|
|
1355
|
+
opacity: 0.65;
|
|
1356
|
+
cursor: not-allowed;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
.bulk-sheet__cell.is-filling {
|
|
1360
|
+
box-shadow: inset 0 0 0 1px rgba(var(--v-theme-primary), 0.7);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/* The little square you drag to copy a value down a column. */
|
|
1364
|
+
/* Inside the cell, because a cell now clips what it holds. */
|
|
1365
|
+
.bulk-sheet__handle {
|
|
1366
|
+
position: absolute;
|
|
1367
|
+
right: 0;
|
|
1368
|
+
bottom: 0;
|
|
1369
|
+
width: 8px;
|
|
1370
|
+
height: 8px;
|
|
1371
|
+
background: rgb(var(--v-theme-primary));
|
|
1372
|
+
border: 1px solid rgb(var(--v-theme-surface));
|
|
1373
|
+
cursor: crosshair;
|
|
1374
|
+
z-index: 1;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
.bulk-sheet__rownum,
|
|
1378
|
+
.bulk-sheet__corner {
|
|
1379
|
+
text-align: center;
|
|
1380
|
+
color: rgba(128, 128, 128, 0.9);
|
|
1381
|
+
background: rgba(128, 128, 128, 0.08);
|
|
1382
|
+
border: 1px solid rgba(128, 128, 128, 0.3);
|
|
1383
|
+
padding: 2px;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
.bulk-sheet__status {
|
|
1387
|
+
padding: 2px 6px;
|
|
1388
|
+
white-space: nowrap;
|
|
1389
|
+
overflow: hidden;
|
|
1390
|
+
border: 1px solid rgba(128, 128, 128, 0.3);
|
|
1391
|
+
}
|
|
1392
|
+
</style>
|