@formicoidea/labre-core-database 0.49.0 → 0.51.0
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/database-page/view-menu-commands.js +4 -3
- package/dist/properties-panel/properties-panel.d.ts +6 -5
- package/dist/properties-panel/properties-panel.js +7 -5
- package/dist/translations.d.ts +13 -1
- package/dist/translations.js +16 -5
- package/dist/view-transfer/remap-view.d.ts +11 -2
- package/dist/view-transfer/remap-view.js +38 -12
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSourcePickerProvider, } from '@formicoidea/labre-core/shared/services';
|
|
2
|
-
import { PROPERTIES_PANEL_TITLE, VIEW_MENU_GROUP, VIEW_MENU_IMPORT, VIEW_MENU_LAYOUT, VIEW_MENU_OPEN_IN, VIEW_MENU_SAVE_TEMPLATE, } from '../translations.js';
|
|
2
|
+
import { PROPERTIES_PANEL_TITLE, VIEW_MENU_COLOR_RULES, VIEW_MENU_GROUP, VIEW_MENU_IMPORT, VIEW_MENU_LAYOUT, VIEW_MENU_OPEN_IN, VIEW_MENU_SAVE_TEMPLATE, } from '../translations.js';
|
|
3
3
|
import { canImportView, currentViewTemplate, requestViewImport, } from '../view-transfer/import-view.js';
|
|
4
4
|
/** The current view's options button on the page: what knows the view. */
|
|
5
5
|
function viewOptions(std, hostBlockId) {
|
|
@@ -36,6 +36,7 @@ export function databasePageViewCommands(hostBlockId) {
|
|
|
36
36
|
setting(hostBlockId, 'group', VIEW_MENU_GROUP, 1),
|
|
37
37
|
setting(hostBlockId, 'open-in', VIEW_MENU_OPEN_IN, 2),
|
|
38
38
|
setting(hostBlockId, 'properties', PROPERTIES_PANEL_TITLE, 3),
|
|
39
|
+
setting(hostBlockId, 'color-rules', VIEW_MENU_COLOR_RULES, 4),
|
|
39
40
|
{
|
|
40
41
|
id: 'database.view.save-template',
|
|
41
42
|
owner: 'core',
|
|
@@ -44,7 +45,7 @@ export function databasePageViewCommands(hostBlockId) {
|
|
|
44
45
|
labelFallback: VIEW_MENU_SAVE_TEMPLATE[1],
|
|
45
46
|
category: 'view',
|
|
46
47
|
surfaces: ['view-menu'],
|
|
47
|
-
order:
|
|
48
|
+
order: 5,
|
|
48
49
|
scope: 'page',
|
|
49
50
|
defaultKeys: { mac: [], other: [] },
|
|
50
51
|
when: std => {
|
|
@@ -71,7 +72,7 @@ export function databasePageViewCommands(hostBlockId) {
|
|
|
71
72
|
labelFallback: VIEW_MENU_IMPORT[1],
|
|
72
73
|
category: 'transfer',
|
|
73
74
|
surfaces: ['view-menu'],
|
|
74
|
-
order:
|
|
75
|
+
order: 6,
|
|
75
76
|
scope: 'page',
|
|
76
77
|
defaultKeys: { mac: [], other: [] },
|
|
77
78
|
when: std => {
|
|
@@ -18,16 +18,16 @@ declare const DatabasePropertiesPanel_base: typeof ShadowlessElement & import("@
|
|
|
18
18
|
* request). It draws nothing of its own beyond the shared side-panel header:
|
|
19
19
|
* the list is the data-view's own `data-view-properties-setting`, the very
|
|
20
20
|
* list the view options' "Properties" pops, so hiding, showing and
|
|
21
|
-
* reordering write through the same `Property` methods, once.
|
|
21
|
+
* reordering write through the same `Property` methods, once. A row's click
|
|
22
|
+
* opens the property's menu (the table header's: rename, type, duplicate,
|
|
23
|
+
* delete) and "New property" adds one, both from that list.
|
|
22
24
|
*
|
|
23
25
|
* A host mounts it with `std` (the editor that shows the database) and
|
|
24
26
|
* `request`; it follows the block as it mounts and unmounts. Read-only, the
|
|
25
27
|
* list is drawn and inert.
|
|
26
28
|
*
|
|
27
|
-
* ponytail: the
|
|
28
|
-
*
|
|
29
|
-
* the host-panels verbs of §10 (for a host that draws its own panel) are not
|
|
30
|
-
* written: the Labre app mounts this element. Add them to
|
|
29
|
+
* ponytail: the host-panels verbs of §10 (for a host that draws its own
|
|
30
|
+
* panel) are not written: the Labre app mounts this element. Add them to
|
|
31
31
|
* `@labre/affine/host-panels` when a host draws its own.
|
|
32
32
|
*/
|
|
33
33
|
export declare class DatabasePropertiesPanel extends DatabasePropertiesPanel_base {
|
|
@@ -36,6 +36,7 @@ export declare class DatabasePropertiesPanel extends DatabasePropertiesPanel_bas
|
|
|
36
36
|
private readonly _mounts$;
|
|
37
37
|
connectedCallback(): void;
|
|
38
38
|
private _t;
|
|
39
|
+
private readonly _wording;
|
|
39
40
|
private readonly _close;
|
|
40
41
|
private _renderHeader;
|
|
41
42
|
private _renderBody;
|
|
@@ -65,16 +65,16 @@ export function propertiesPanelView(std, request) {
|
|
|
65
65
|
* request). It draws nothing of its own beyond the shared side-panel header:
|
|
66
66
|
* the list is the data-view's own `data-view-properties-setting`, the very
|
|
67
67
|
* list the view options' "Properties" pops, so hiding, showing and
|
|
68
|
-
* reordering write through the same `Property` methods, once.
|
|
68
|
+
* reordering write through the same `Property` methods, once. A row's click
|
|
69
|
+
* opens the property's menu (the table header's: rename, type, duplicate,
|
|
70
|
+
* delete) and "New property" adds one, both from that list.
|
|
69
71
|
*
|
|
70
72
|
* A host mounts it with `std` (the editor that shows the database) and
|
|
71
73
|
* `request`; it follows the block as it mounts and unmounts. Read-only, the
|
|
72
74
|
* list is drawn and inert.
|
|
73
75
|
*
|
|
74
|
-
* ponytail: the
|
|
75
|
-
*
|
|
76
|
-
* the host-panels verbs of §10 (for a host that draws its own panel) are not
|
|
77
|
-
* written: the Labre app mounts this element. Add them to
|
|
76
|
+
* ponytail: the host-panels verbs of §10 (for a host that draws its own
|
|
77
|
+
* panel) are not written: the Labre app mounts this element. Add them to
|
|
78
78
|
* `@labre/affine/host-panels` when a host draws its own.
|
|
79
79
|
*/
|
|
80
80
|
let DatabasePropertiesPanel = (() => {
|
|
@@ -222,6 +222,7 @@ let DatabasePropertiesPanel = (() => {
|
|
|
222
222
|
<div class="affine-database-properties-panel-list" ?inert=${readonly}>
|
|
223
223
|
<data-view-properties-setting
|
|
224
224
|
.view=${view}
|
|
225
|
+
.wording=${this._wording}
|
|
225
226
|
></data-view-properties-setting>
|
|
226
227
|
</div>`;
|
|
227
228
|
}
|
|
@@ -248,6 +249,7 @@ let DatabasePropertiesPanel = (() => {
|
|
|
248
249
|
super(...arguments);
|
|
249
250
|
/** Bumped when a block mounts or unmounts, so the view is looked up again. */
|
|
250
251
|
this._mounts$ = signal(0);
|
|
252
|
+
this._wording = (wording) => this._t(wording);
|
|
251
253
|
this._close = () => {
|
|
252
254
|
this.std.getOptional(PropertiesPanelProvider)?.close();
|
|
253
255
|
};
|
package/dist/translations.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChromeWording } from '@formicoidea/labre-core/shared/services';
|
|
2
2
|
import type { TranslationKeyManifestEntry } from '@formicoidea/labre-core/std';
|
|
3
3
|
/** The entry that lists the sources the database's views already read. */
|
|
4
4
|
export declare const DATABASE_ADD_VIEW_EXISTING_SOURCE: ChromeWording;
|
|
@@ -18,8 +18,20 @@ export declare const VIEW_MENU_GROUP: ChromeWording;
|
|
|
18
18
|
* is the panel title for the same reason (`PROPERTIES_PANEL_TITLE`).
|
|
19
19
|
*/
|
|
20
20
|
export declare const VIEW_MENU_OPEN_IN: ChromeWording;
|
|
21
|
+
/**
|
|
22
|
+
* "Conditional colors" (ADR 0036): the view settings' own entry
|
|
23
|
+
* (`DATA_VIEW_COLOR_RULES`), one chrome word, one key, declared once by
|
|
24
|
+
* `@labre/data-view`, so not listed below.
|
|
25
|
+
*/
|
|
26
|
+
export declare const VIEW_MENU_COLOR_RULES: ChromeWording;
|
|
27
|
+
/** Shared with the frame toolbar: one chrome word, one key (`SAVE_AS_TEMPLATE`). */
|
|
21
28
|
export declare const VIEW_MENU_SAVE_TEMPLATE: ChromeWording;
|
|
22
29
|
export declare const VIEW_MENU_IMPORT: ChromeWording;
|
|
30
|
+
/**
|
|
31
|
+
* Declared once by `@labre/data-view` (`DATA_VIEW_PROPERTIES`, the list's own
|
|
32
|
+
* title, in its view options popover too), so not listed below. Restated, not
|
|
33
|
+
* imported: this bundle imports core alone (`core-database-boundary`).
|
|
34
|
+
*/
|
|
23
35
|
export declare const PROPERTIES_PANEL_TITLE: ChromeWording;
|
|
24
36
|
/** The panel's "Show all" over the view's hidden properties. */
|
|
25
37
|
export declare const PROPERTIES_PANEL_SHOW_ALL: ChromeWording;
|
package/dist/translations.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SAVE_AS_TEMPLATE, } from '@formicoidea/labre-core/shared/services';
|
|
1
2
|
/* ── "+ view" (ADR 0035 §1, §9c, B11; labre ADR-0046 §5) ──────────────── */
|
|
2
3
|
/** The entry that lists the sources the database's views already read. */
|
|
3
4
|
export const DATABASE_ADD_VIEW_EXISTING_SOURCE = [
|
|
@@ -43,15 +44,27 @@ export const VIEW_MENU_OPEN_IN = [
|
|
|
43
44
|
'com.labre.data-view.open-in',
|
|
44
45
|
'Open pages in',
|
|
45
46
|
];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* "Conditional colors" (ADR 0036): the view settings' own entry
|
|
49
|
+
* (`DATA_VIEW_COLOR_RULES`), one chrome word, one key, declared once by
|
|
50
|
+
* `@labre/data-view`, so not listed below.
|
|
51
|
+
*/
|
|
52
|
+
export const VIEW_MENU_COLOR_RULES = [
|
|
53
|
+
'com.labre.data-view.color-rules',
|
|
54
|
+
'Conditional colors',
|
|
49
55
|
];
|
|
56
|
+
/** Shared with the frame toolbar: one chrome word, one key (`SAVE_AS_TEMPLATE`). */
|
|
57
|
+
export const VIEW_MENU_SAVE_TEMPLATE = SAVE_AS_TEMPLATE;
|
|
50
58
|
export const VIEW_MENU_IMPORT = [
|
|
51
59
|
'com.labre.database.view-menu.import',
|
|
52
60
|
'Import a view…',
|
|
53
61
|
];
|
|
54
62
|
/* ── The properties panel (ADR 0035 §9b, issue B10) ────────────────────── */
|
|
63
|
+
/**
|
|
64
|
+
* Declared once by `@labre/data-view` (`DATA_VIEW_PROPERTIES`, the list's own
|
|
65
|
+
* title, in its view options popover too), so not listed below. Restated, not
|
|
66
|
+
* imported: this bundle imports core alone (`core-database-boundary`).
|
|
67
|
+
*/
|
|
55
68
|
export const PROPERTIES_PANEL_TITLE = [
|
|
56
69
|
'com.labre.database.properties-panel.title',
|
|
57
70
|
'Properties',
|
|
@@ -117,14 +130,12 @@ const DATABASE_EDITOR_WORDINGS = [
|
|
|
117
130
|
PICKER_TITLE,
|
|
118
131
|
PROPERTIES_PANEL_HIDE_ALL,
|
|
119
132
|
PROPERTIES_PANEL_SHOW_ALL,
|
|
120
|
-
PROPERTIES_PANEL_TITLE,
|
|
121
133
|
PROPERTIES_PANEL_UNAVAILABLE,
|
|
122
134
|
SLASH_LINKED_VIEW,
|
|
123
135
|
SLASH_LINKED_VIEW_DESCRIPTION,
|
|
124
136
|
VIEW_MENU_GROUP,
|
|
125
137
|
VIEW_MENU_IMPORT,
|
|
126
138
|
VIEW_MENU_LAYOUT,
|
|
127
|
-
VIEW_MENU_SAVE_TEMPLATE,
|
|
128
139
|
];
|
|
129
140
|
/**
|
|
130
141
|
* This package's `com.labre.database.*` wordings, exported from the package
|
|
@@ -2,14 +2,17 @@ import type { DataSourcePickerProperty } from '@formicoidea/labre-core/shared/se
|
|
|
2
2
|
/**
|
|
3
3
|
* What a copied view lost on the way (labre PRD REQ-DB-2: "the dialog says
|
|
4
4
|
* so"): conditions of its filter and keys of its sort that pointed at an
|
|
5
|
-
* ignored property, the grouping by one,
|
|
6
|
-
* properties
|
|
5
|
+
* ignored property, the grouping by one, the columns of the ignored
|
|
6
|
+
* properties, and its colour rules that read one (ADR 0036; `colorRules`
|
|
7
|
+
* arrived in 0.50, a field a 0.49 reader of this type never reads).
|
|
8
|
+
* Held by `remap-dropped-signature.unit.spec.ts`.
|
|
7
9
|
*/
|
|
8
10
|
export interface RemapDropped {
|
|
9
11
|
filters: number;
|
|
10
12
|
sorts: number;
|
|
11
13
|
group: boolean;
|
|
12
14
|
properties: number;
|
|
15
|
+
colorRules: number;
|
|
13
16
|
}
|
|
14
17
|
export interface RemappedView {
|
|
15
18
|
/** The view's data for this database, without `id`, `name` or `sourceId`. */
|
|
@@ -35,6 +38,10 @@ type Json = Record<string, unknown>;
|
|
|
35
38
|
* kept its id;
|
|
36
39
|
* - a manual order of rows (`sort.manuallySort`, a group's
|
|
37
40
|
* `manuallyCardSort`) names rows of the other database: emptied;
|
|
41
|
+
* - a colour rule (`colorRules`, ADR 0036) is rewritten as a filter is,
|
|
42
|
+
* but a rule that loses any condition is removed whole and counted: a
|
|
43
|
+
* rule with fewer conditions would colour rows its author never meant;
|
|
44
|
+
* its colour is the shared palette's and is kept as is;
|
|
38
45
|
* - `id`, `name` and `sourceId` are left to the caller; any other key is
|
|
39
46
|
* copied as is.
|
|
40
47
|
*
|
|
@@ -50,6 +57,8 @@ export declare function defaultMapping(from: readonly DataSourcePickerProperty[]
|
|
|
50
57
|
/**
|
|
51
58
|
* What a view template keeps of a view (labre PRD REQ-DB-4): everything but
|
|
52
59
|
* its filters, its sorts and its manual orders, which belong to one view.
|
|
60
|
+
* Its colour rules (`colorRules`, ADR 0036) are kept, conditions included:
|
|
61
|
+
* REQ-DB-4 names them part of a template.
|
|
53
62
|
*/
|
|
54
63
|
export declare function viewTemplateData(view: Readonly<Json>): Json;
|
|
55
64
|
export {};
|
|
@@ -22,6 +22,10 @@ function isRecord(value) {
|
|
|
22
22
|
* kept its id;
|
|
23
23
|
* - a manual order of rows (`sort.manuallySort`, a group's
|
|
24
24
|
* `manuallyCardSort`) names rows of the other database: emptied;
|
|
25
|
+
* - a colour rule (`colorRules`, ADR 0036) is rewritten as a filter is,
|
|
26
|
+
* but a rule that loses any condition is removed whole and counted: a
|
|
27
|
+
* rule with fewer conditions would colour rows its author never meant;
|
|
28
|
+
* its colour is the shared palette's and is kept as is;
|
|
25
29
|
* - `id`, `name` and `sourceId` are left to the caller; any other key is
|
|
26
30
|
* copied as is.
|
|
27
31
|
*
|
|
@@ -37,6 +41,7 @@ export function remapView(view, from, to, mapping) {
|
|
|
37
41
|
sorts: 0,
|
|
38
42
|
group: false,
|
|
39
43
|
properties: 0,
|
|
44
|
+
colorRules: 0,
|
|
40
45
|
};
|
|
41
46
|
const fromById = new Map(from.map(p => [p.id, p]));
|
|
42
47
|
const toById = new Map(to.map(p => [p.id, p]));
|
|
@@ -99,7 +104,7 @@ export function remapView(view, from, to, mapping) {
|
|
|
99
104
|
}
|
|
100
105
|
return { value, empty: false };
|
|
101
106
|
};
|
|
102
|
-
const remapFilter = (filter) => {
|
|
107
|
+
const remapFilter = (filter, onDrop) => {
|
|
103
108
|
if (filter.type === 'group') {
|
|
104
109
|
const conditions = Array.isArray(filter.conditions)
|
|
105
110
|
? filter.conditions
|
|
@@ -108,7 +113,7 @@ export function remapView(view, from, to, mapping) {
|
|
|
108
113
|
for (const condition of conditions) {
|
|
109
114
|
if (!isRecord(condition))
|
|
110
115
|
continue;
|
|
111
|
-
const next = remapFilter(condition);
|
|
116
|
+
const next = remapFilter(condition, onDrop);
|
|
112
117
|
if (next)
|
|
113
118
|
kept.push(next);
|
|
114
119
|
}
|
|
@@ -118,7 +123,7 @@ export function remapView(view, from, to, mapping) {
|
|
|
118
123
|
const sourceId = typeof left?.name === 'string' ? left.name : undefined;
|
|
119
124
|
const id = target(sourceId);
|
|
120
125
|
if (!sourceId || !id) {
|
|
121
|
-
|
|
126
|
+
onDrop();
|
|
122
127
|
return null;
|
|
123
128
|
}
|
|
124
129
|
let empty = false;
|
|
@@ -132,24 +137,43 @@ export function remapView(view, from, to, mapping) {
|
|
|
132
137
|
})
|
|
133
138
|
: filter.args;
|
|
134
139
|
if (empty) {
|
|
135
|
-
|
|
140
|
+
onDrop();
|
|
136
141
|
return null;
|
|
137
142
|
}
|
|
138
143
|
return { ...filter, left: { ...left, name: id }, args };
|
|
139
144
|
};
|
|
145
|
+
// A nested group left empty is dropped with its conditions; the root
|
|
146
|
+
// stays, an empty group being "no filter".
|
|
147
|
+
const prune = (group) => ({
|
|
148
|
+
...group,
|
|
149
|
+
conditions: group.conditions
|
|
150
|
+
.map(c => (c.type === 'group' ? prune(c) : c))
|
|
151
|
+
.filter(c => c.type !== 'group' || c.conditions.length > 0),
|
|
152
|
+
});
|
|
140
153
|
if (isRecord(data.filter)) {
|
|
141
|
-
const root = remapFilter(data.filter)
|
|
142
|
-
|
|
143
|
-
// stays, an empty group being "no filter".
|
|
144
|
-
const prune = (group) => ({
|
|
145
|
-
...group,
|
|
146
|
-
conditions: group.conditions
|
|
147
|
-
.map(c => (c.type === 'group' ? prune(c) : c))
|
|
148
|
-
.filter(c => c.type !== 'group' || c.conditions.length > 0),
|
|
154
|
+
const root = remapFilter(data.filter, () => {
|
|
155
|
+
dropped.filters += 1;
|
|
149
156
|
});
|
|
150
157
|
if (root)
|
|
151
158
|
data.filter = prune(root);
|
|
152
159
|
}
|
|
160
|
+
if (Array.isArray(data.colorRules)) {
|
|
161
|
+
const kept = [];
|
|
162
|
+
for (const rule of data.colorRules) {
|
|
163
|
+
if (!isRecord(rule) || !isRecord(rule.filter))
|
|
164
|
+
continue;
|
|
165
|
+
let lost = false;
|
|
166
|
+
const filter = remapFilter(rule.filter, () => {
|
|
167
|
+
lost = true;
|
|
168
|
+
});
|
|
169
|
+
if (lost || !filter) {
|
|
170
|
+
dropped.colorRules += 1;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
kept.push({ ...rule, filter: prune(filter) });
|
|
174
|
+
}
|
|
175
|
+
data.colorRules = kept;
|
|
176
|
+
}
|
|
153
177
|
if (isRecord(data.sort)) {
|
|
154
178
|
const sortBy = Array.isArray(data.sort.sortBy) ? data.sort.sortBy : [];
|
|
155
179
|
const kept = [];
|
|
@@ -211,6 +235,8 @@ export function defaultMapping(from, to) {
|
|
|
211
235
|
/**
|
|
212
236
|
* What a view template keeps of a view (labre PRD REQ-DB-4): everything but
|
|
213
237
|
* its filters, its sorts and its manual orders, which belong to one view.
|
|
238
|
+
* Its colour rules (`colorRules`, ADR 0036) are kept, conditions included:
|
|
239
|
+
* REQ-DB-4 names them part of a template.
|
|
214
240
|
*/
|
|
215
241
|
export function viewTemplateData(view) {
|
|
216
242
|
const data = structuredClone(view);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-core-database",
|
|
3
3
|
"description": "Labre core-database editing chrome for @formicoidea/labre-core.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.51.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@formicoidea/labre-core": "0.
|
|
30
|
+
"@formicoidea/labre-core": "0.51.0",
|
|
31
31
|
"@blocksuite/icons": "^2.2.12",
|
|
32
32
|
"@preact/signals-core": "^1.8.0",
|
|
33
33
|
"lit": "^3.2.0"
|