@protobase/ui 0.12.3 → 0.12.4
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/dist/app/record-page.js +115 -111
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-Cqr5Ze7R.js → app-C1uXjaoy.js} +2 -2
- package/dist/shell/assets/{index-DheSSTn2.css → index-BVOqIEYd.css} +1 -1
- package/dist/shell/assets/{index-ntYv19kQ.js → index-uIZKnNIY.js} +1 -1
- package/dist/shell/assets/{shared-protobase-ui-eH-UjL47.js → shared-protobase-ui-DDq8y6_Q.js} +1 -1
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +1 -1
- package/package.json +4 -4
package/dist/app/record-page.js
CHANGED
|
@@ -114,6 +114,7 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
|
|
|
114
114
|
const permissions = usePermissions(model.name);
|
|
115
115
|
const restore = useRestore(model);
|
|
116
116
|
const canUpdate = can(permissions, "update") && stored.permissions?.update !== false;
|
|
117
|
+
const canDelete = can(permissions, "delete") && stored.permissions?.delete !== false;
|
|
117
118
|
const remove = useDeleteFlow({
|
|
118
119
|
model,
|
|
119
120
|
view,
|
|
@@ -210,7 +211,7 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
|
|
|
210
211
|
onClick: editor.discard,
|
|
211
212
|
children: "Discard"
|
|
212
213
|
}),
|
|
213
|
-
|
|
214
|
+
canDelete && /* @__PURE__ */ jsx(Button, {
|
|
214
215
|
variant: "danger",
|
|
215
216
|
className: "max-md:min-h-11",
|
|
216
217
|
onClick: () => void remove.start({
|
|
@@ -231,122 +232,125 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
|
|
|
231
232
|
})
|
|
232
233
|
] });
|
|
233
234
|
return /* @__PURE__ */ jsxs("div", {
|
|
234
|
-
className: "min-h-0 flex-1
|
|
235
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
235
236
|
children: [
|
|
236
237
|
remove.dialogs,
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
className: "
|
|
239
|
-
children:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
children: [/* @__PURE__ */ jsx(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
238
|
+
/* @__PURE__ */ jsx("div", {
|
|
239
|
+
className: "min-h-0 flex-1 overflow-y-auto",
|
|
240
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
241
|
+
className: "mx-auto max-w-[1100px] px-4 pb-8 pt-6 md:px-10 md:py-8",
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsx(RecordHeader, {
|
|
244
|
+
collection: view?.names?.plural ?? humanize(model.name),
|
|
245
|
+
title,
|
|
246
|
+
status: {
|
|
247
|
+
label: status ? enumLabel(status, hint("status")?.valueLabels) : singular,
|
|
248
|
+
tone: status ? toneFor(status) : "neutral"
|
|
249
|
+
},
|
|
250
|
+
lastEditedBy: { ago: updated === void 0 ? "recently" : formatRelativeTime(updated) },
|
|
251
|
+
actions: /* @__PURE__ */ jsx("div", {
|
|
252
|
+
className: "hidden items-center gap-4 md:flex",
|
|
253
|
+
children: saveControls
|
|
254
|
+
})
|
|
255
|
+
}),
|
|
256
|
+
editor.message && /* @__PURE__ */ jsx("div", {
|
|
257
|
+
className: "mt-4",
|
|
258
|
+
children: /* @__PURE__ */ jsx(ErrorBanner, {
|
|
259
|
+
title: "Not saved",
|
|
260
|
+
error: new Error(editor.message)
|
|
261
|
+
})
|
|
262
|
+
}),
|
|
263
|
+
editor.linesConflict && /* @__PURE__ */ jsx("div", {
|
|
264
|
+
className: "mt-4",
|
|
265
|
+
children: /* @__PURE__ */ jsx(ErrorBanner, {
|
|
266
|
+
title: "The lines were changed by someone else",
|
|
267
|
+
error: /* @__PURE__ */ new Error("The lines were reloaded. Your new order is kept: Save again to apply it, or Discard to drop it.")
|
|
268
|
+
})
|
|
269
|
+
}),
|
|
270
|
+
editor.restored && /* @__PURE__ */ jsxs("div", {
|
|
271
|
+
className: "mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2 text-[13px]",
|
|
272
|
+
role: "status",
|
|
273
|
+
children: [/* @__PURE__ */ jsx("span", { children: "Your unsaved changes were restored." }), /* @__PURE__ */ jsxs("span", {
|
|
274
|
+
className: "flex gap-2",
|
|
275
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
276
|
+
size: "sm",
|
|
277
|
+
onClick: editor.dismissRestored,
|
|
278
|
+
children: "Keep"
|
|
279
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
280
|
+
size: "sm",
|
|
281
|
+
onClick: editor.discard,
|
|
282
|
+
children: "Discard"
|
|
283
|
+
})]
|
|
280
284
|
})]
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ jsxs("div", {
|
|
287
|
+
className: "grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12",
|
|
288
|
+
children: [/* @__PURE__ */ jsxs("main", {
|
|
289
|
+
className: "divide-y divide-border",
|
|
290
|
+
children: [layout.flatMap((item, index) => {
|
|
291
|
+
if (item.kind === "related") return [/* @__PURE__ */ jsx(RelatedSection, {
|
|
292
|
+
item,
|
|
293
|
+
recordKey
|
|
294
|
+
}, `related:${item.title}`)];
|
|
295
|
+
if (item.kind === "custom") return item.sidebar ? [] : [/* @__PURE__ */ jsx(CustomSection, {
|
|
296
|
+
item,
|
|
297
|
+
scope
|
|
298
|
+
}, `custom:${index}`)];
|
|
299
|
+
if (item.kind !== "section") return [];
|
|
300
|
+
const fields = item.fields.filter((name) => model.fields[name] && visible(name));
|
|
301
|
+
if (fields.length === 0) return [];
|
|
302
|
+
return [/* @__PURE__ */ jsx(Section, {
|
|
303
|
+
title: item.title,
|
|
304
|
+
help: item.help,
|
|
305
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
306
|
+
className: "grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2",
|
|
307
|
+
children: fields.map(fieldView)
|
|
308
|
+
})
|
|
309
|
+
}, item.title)];
|
|
310
|
+
}), linesModel && /* @__PURE__ */ jsx(RecordLines, {
|
|
311
|
+
lines: linesModel,
|
|
312
|
+
draft: linesDraft,
|
|
313
|
+
vatRate: Number(stored.record.vatRate ?? 21) / 100,
|
|
314
|
+
saving: editor.saving
|
|
315
|
+
})]
|
|
316
|
+
}), /* @__PURE__ */ jsxs("aside", {
|
|
317
|
+
className: "space-y-4 md:pt-8",
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ jsx(RecordActions, {
|
|
320
|
+
model,
|
|
321
|
+
stored,
|
|
322
|
+
recordKey
|
|
323
|
+
}),
|
|
324
|
+
firstSidebar === -1 && summary,
|
|
325
|
+
layout.map((item, index) => item.kind === "custom" && item.sidebar ? /* @__PURE__ */ jsx(CustomSection, {
|
|
326
|
+
item,
|
|
327
|
+
scope
|
|
328
|
+
}, `custom:${index}`) : index === firstSidebar ? /* @__PURE__ */ jsx(Fragment, { children: summary }, "summary") : null),
|
|
329
|
+
/* @__PURE__ */ jsx(MetadataCard, {
|
|
330
|
+
title: "Details",
|
|
331
|
+
rows: [auditField(model, "created"), updatedAt].flatMap((name) => {
|
|
332
|
+
const field = name ? model.fields[name] : void 0;
|
|
333
|
+
return name && field && visible(name) ? [{
|
|
334
|
+
label: hint(name)?.label ?? humanize(name),
|
|
335
|
+
value: displayValue(field, stored.record[name], hint(name))
|
|
336
|
+
}] : [];
|
|
337
|
+
})
|
|
338
|
+
}),
|
|
339
|
+
related.records.length > 0 && /* @__PURE__ */ jsx(SidebarCard, {
|
|
340
|
+
title: "Related records",
|
|
341
|
+
children: /* @__PURE__ */ jsx(RelatedRecords, {
|
|
342
|
+
records: related.records,
|
|
343
|
+
onNavigate: open
|
|
344
|
+
})
|
|
305
345
|
})
|
|
306
|
-
|
|
307
|
-
}), linesModel && /* @__PURE__ */ jsx(RecordLines, {
|
|
308
|
-
lines: linesModel,
|
|
309
|
-
draft: linesDraft,
|
|
310
|
-
vatRate: Number(stored.record.vatRate ?? 21) / 100,
|
|
311
|
-
saving: editor.saving
|
|
346
|
+
]
|
|
312
347
|
})]
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
/* @__PURE__ */ jsx(RecordActions, {
|
|
317
|
-
model,
|
|
318
|
-
stored,
|
|
319
|
-
recordKey
|
|
320
|
-
}),
|
|
321
|
-
firstSidebar === -1 && summary,
|
|
322
|
-
layout.map((item, index) => item.kind === "custom" && item.sidebar ? /* @__PURE__ */ jsx(CustomSection, {
|
|
323
|
-
item,
|
|
324
|
-
scope
|
|
325
|
-
}, `custom:${index}`) : index === firstSidebar ? /* @__PURE__ */ jsx(Fragment, { children: summary }, "summary") : null),
|
|
326
|
-
/* @__PURE__ */ jsx(MetadataCard, {
|
|
327
|
-
title: "Details",
|
|
328
|
-
rows: [auditField(model, "created"), updatedAt].flatMap((name) => {
|
|
329
|
-
const field = name ? model.fields[name] : void 0;
|
|
330
|
-
return name && field && visible(name) ? [{
|
|
331
|
-
label: hint(name)?.label ?? humanize(name),
|
|
332
|
-
value: displayValue(field, stored.record[name], hint(name))
|
|
333
|
-
}] : [];
|
|
334
|
-
})
|
|
335
|
-
}),
|
|
336
|
-
related.records.length > 0 && /* @__PURE__ */ jsx(SidebarCard, {
|
|
337
|
-
title: "Related records",
|
|
338
|
-
children: /* @__PURE__ */ jsx(RelatedRecords, {
|
|
339
|
-
records: related.records,
|
|
340
|
-
onNavigate: open
|
|
341
|
-
})
|
|
342
|
-
})
|
|
343
|
-
]
|
|
344
|
-
})]
|
|
345
|
-
})
|
|
346
|
-
]
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
})
|
|
347
351
|
}),
|
|
348
|
-
/* @__PURE__ */ jsx("div", {
|
|
349
|
-
className: "
|
|
352
|
+
(editor.dirty || canDelete || canUpdate) && /* @__PURE__ */ jsx("div", {
|
|
353
|
+
className: "flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden",
|
|
350
354
|
children: saveControls
|
|
351
355
|
})
|
|
352
356
|
]
|
package/dist/package.js
CHANGED