@protobase/ui 0.19.13 → 0.19.14
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/create/create-values.js +8 -3
- package/dist/app/gallery/detail-fields.js +4 -3
- package/dist/app/record-mode/record-mode.js +7 -1
- package/dist/app/record-page.js +3 -3
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-D65L8GHE.js → app-Bet1bgM_.js} +39 -39
- package/dist/shell/assets/{index-ztKNmFFb.js → index-DF5WCYEC.js} +1 -1
- package/dist/shell/assets/{maplibre-CsiuejGw.js → maplibre-DYbWlNbK.js} +1 -1
- package/dist/shell/assets/{markdown-content-4BktGTHi.js → markdown-content-o9fxfOx0.js} +1 -1
- package/dist/shell/assets/{record-map-De6U-Z0I.js → record-map-CmVH3wtS.js} +1 -1
- package/dist/shell/assets/{records-map-DaIZwI2y.js → records-map-XibwyiR4.js} +1 -1
- package/dist/shell/assets/{shared-protobase-ui-DdZuFJz6.js → shared-protobase-ui-DNhP23mn.js} +1 -1
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/package.json +4 -4
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { isEditable, toPatchValue } from "../../live/field-values.js";
|
|
2
|
+
import { whenShown } from "../record-mode/record-mode.js";
|
|
2
3
|
//#region src/app/create/create-values.ts
|
|
3
4
|
const isChosen = (value) => typeof value === "object" && value !== null && "key" in value;
|
|
4
5
|
/** Fields the user can set on a new record: not read-only, not the tenant, and not structured data. */
|
|
5
6
|
const isCreatable = (model, field) => field.name !== model.tenant && !field.readOnly && (field.type === "relation" || isEditable(field));
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The view's sections limited to creatable fields, plus a section for any creatable field the layout leaves out. The
|
|
9
|
+
* create form is a form, so sections and fields meant only for reading the record stay out of their sections, and a
|
|
10
|
+
* creatable field among them lands in that last section.
|
|
11
|
+
*/
|
|
7
12
|
const createSections = (model, view) => {
|
|
8
13
|
const creatable = Object.values(model.fields).filter((field) => isCreatable(model, field)).map((field) => field.name);
|
|
9
14
|
const placed = /* @__PURE__ */ new Set();
|
|
10
15
|
const sections = (view?.layout ?? []).flatMap((item) => {
|
|
11
|
-
if (item.kind !== "section") return [];
|
|
12
|
-
const fields = item.fields.filter((name) => creatable.includes(name) && !placed.has(name));
|
|
16
|
+
if (item.kind !== "section" || !whenShown(item.when, true)) return [];
|
|
17
|
+
const fields = item.fields.filter((name) => creatable.includes(name) && !placed.has(name) && whenShown(view?.fields[name]?.when, true));
|
|
13
18
|
fields.forEach((name) => placed.add(name));
|
|
14
19
|
return fields.length > 0 ? [{
|
|
15
20
|
title: item.title,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { whenShown } from "../record-mode/record-mode.js";
|
|
1
2
|
//#region src/app/gallery/detail-fields.ts
|
|
2
3
|
/**
|
|
3
4
|
* The fields of a photo's details: those its record page shows in its sections, or without a layout every field but its
|
|
4
|
-
* key and tenant, less sensitive ones and those the gallery already shows: `omit`, such as the photo's file and the
|
|
5
|
+
* key and tenant, less sensitive ones, those meant only for its form and those the gallery already shows: `omit`, such as the photo's file and the
|
|
5
6
|
* field pointing at the gallery's record.
|
|
6
7
|
*/
|
|
7
8
|
const detailFields = (model, view, omit) => {
|
|
8
|
-
const sections = (view?.layout ?? []).flatMap((item) => item.kind === "section" ? item.fields : []);
|
|
9
|
-
return (sections.length > 0 ? [...new Set(sections)] : Object.keys(model.fields).filter((name) => name !== model.tenant && !model.primaryKey.includes(name))).filter((name) => model.fields[name] && !model.fields[name].sensitive && !omit.includes(name));
|
|
9
|
+
const sections = (view?.layout ?? []).flatMap((item) => item.kind === "section" && whenShown(item.when, false) ? item.fields : []);
|
|
10
|
+
return (sections.length > 0 ? [...new Set(sections)] : Object.keys(model.fields).filter((name) => name !== model.tenant && !model.primaryKey.includes(name))).filter((name) => model.fields[name] && !model.fields[name].sensitive && !omit.includes(name) && whenShown(view?.fields[name]?.when, false));
|
|
10
11
|
};
|
|
11
12
|
//#endregion
|
|
12
13
|
export { detailFields };
|
|
@@ -32,5 +32,11 @@ const recordShown = (mode, canUpdate, edit) => {
|
|
|
32
32
|
const helpShown = (own, view, editing) => (own ?? view?.helpWhen ?? "always") === "always" || editing;
|
|
33
33
|
/** A field's help line on the record page, when it shows. */
|
|
34
34
|
const fieldHelp = (hints, view, editing) => hints?.help !== void 0 && helpShown(hints.helpWhen, view, editing) ? hints.help : void 0;
|
|
35
|
+
/** Whether a field or layout item shows: always, unless it says only while editing or only while reading and the page is not. */
|
|
36
|
+
const whenShown = (when, editing) => {
|
|
37
|
+
if (when === "editing") return editing;
|
|
38
|
+
if (when === "reading") return !editing;
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
35
41
|
//#endregion
|
|
36
|
-
export { fieldHelp, helpShown, recordShown };
|
|
42
|
+
export { fieldHelp, helpShown, recordShown, whenShown };
|
package/dist/app/record-page.js
CHANGED
|
@@ -28,6 +28,7 @@ import { MetadataCard, RelatedRecords, SidebarCard } from "../record-view/record
|
|
|
28
28
|
import { RecordHeader } from "../record-view/record-header.js";
|
|
29
29
|
import { SpecTable } from "../record-view/spec-table.js";
|
|
30
30
|
import { KeyFacts } from "../record-view/key-facts.js";
|
|
31
|
+
import { fieldHelp, helpShown, recordShown, whenShown } from "./record-mode/record-mode.js";
|
|
31
32
|
import { FieldEditor } from "./field-editor.js";
|
|
32
33
|
import { namedIcon } from "./named-icon.js";
|
|
33
34
|
import { useDeleteFlow } from "./delete/use-delete-flow.js";
|
|
@@ -41,7 +42,6 @@ import { draftStorageKey } from "./draft-storage.js";
|
|
|
41
42
|
import { useLines } from "./use-lines.js";
|
|
42
43
|
import { useLinesDraft } from "./use-lines-draft.js";
|
|
43
44
|
import { GallerySection } from "./gallery/gallery-section.js";
|
|
44
|
-
import { fieldHelp, helpShown, recordShown } from "./record-mode/record-mode.js";
|
|
45
45
|
import { useRecordEditor } from "./use-record-editor.js";
|
|
46
46
|
import { useRelatedRecords } from "./use-related-records.js";
|
|
47
47
|
import { RelatedSection } from "./related-section.js";
|
|
@@ -148,14 +148,14 @@ const LoadedRecord = ({ model, recordKey, stored }) => {
|
|
|
148
148
|
});
|
|
149
149
|
const related = useRelatedRecords(model, view, meta.resources, meta.views, stored.record, basePath);
|
|
150
150
|
const { fields: fieldTypes } = useProjectUi();
|
|
151
|
-
const layout = layoutFor(model, view, shown === "read");
|
|
151
|
+
const layout = layoutFor(model, view, shown === "read").filter((item) => whenShown(item.when, editing));
|
|
152
152
|
const sidebarFields = layout.flatMap((item) => item.kind === "sidebar" ? item.fields : []);
|
|
153
153
|
const hasStatus = model.fields.status?.type === "enum";
|
|
154
154
|
const statusValue = stored.record.status;
|
|
155
155
|
const status = hasStatus && !sidebarFields.includes("status") && statusValue !== null && statusValue !== void 0 && statusValue !== "" ? String(statusValue) : void 0;
|
|
156
156
|
const updatedAt = auditField(model, "updated");
|
|
157
157
|
const hint = (name) => view?.fields[name];
|
|
158
|
-
const visible = (name) => fieldAccess(stored.permissions, name) !== "hidden";
|
|
158
|
+
const visible = (name) => fieldAccess(stored.permissions, name) !== "hidden" && whenShown(hint(name)?.when, editing);
|
|
159
159
|
const fieldView = (name) => {
|
|
160
160
|
const field = model.fields[name];
|
|
161
161
|
const access = fieldAccess(stored.permissions, name);
|
package/dist/package.js
CHANGED