@mmlogic/components 0.5.1 → 0.5.3
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/cjs/cell-renderer-7KX9Qbml.js +983 -0
- package/dist/cjs/{client-layout-RZ3Ix-4a.js → client-layout-CqVuJumR.js} +9 -0
- package/dist/cjs/{index-DzRfoAPz.js → index-DVbdkYO3.js} +468 -6
- package/dist/cjs/index.cjs.js +4 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mosterdcomponents.cjs.js +2 -2
- package/dist/cjs/{mrd-boolean-field_23.cjs.entry.js → mrd-boolean-field_25.cjs.entry.js} +3017 -951
- package/dist/cjs/mrd-merge-view.cjs.entry.js +273 -0
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/documents/mrd-document-view/mrd-document-view.js +7 -8
- package/dist/collection/components/email/mrd-email-view/mrd-email-view.css +126 -0
- package/dist/collection/components/email/mrd-email-view/mrd-email-view.js +247 -0
- package/dist/collection/components/fields/file-upload-common.js +23 -7
- package/dist/collection/components/fields/mrd-boolean-field/mrd-boolean-field.js +1 -1
- package/dist/collection/components/fields/mrd-currency-field/mrd-currency-field.js +1 -1
- package/dist/collection/components/fields/mrd-date-field/mrd-date-field.js +1 -1
- package/dist/collection/components/fields/mrd-datetime-field/mrd-datetime-field.js +1 -1
- package/dist/collection/components/fields/mrd-email-field/mrd-email-field.js +1 -1
- package/dist/collection/components/fields/mrd-file-field/mrd-file-field.css +20 -1
- package/dist/collection/components/fields/mrd-file-field/mrd-file-field.js +108 -47
- package/dist/collection/components/fields/mrd-image-field/mrd-image-field.css +44 -0
- package/dist/collection/components/fields/mrd-image-field/mrd-image-field.js +126 -58
- package/dist/collection/components/fields/mrd-longtext-field/mrd-longtext-field.js +1 -1
- package/dist/collection/components/fields/mrd-number-field/mrd-number-field.js +1 -1
- package/dist/collection/components/fields/mrd-secret-field/mrd-secret-field.js +2 -2
- package/dist/collection/components/fields/mrd-text-field/mrd-text-field.js +1 -1
- package/dist/collection/components/fields/mrd-textarea-field/mrd-textarea-field.js +9 -5
- package/dist/collection/components/fields/mrd-time-field/mrd-time-field.js +1 -1
- package/dist/collection/components/form/mrd-field/mrd-field.js +5 -5
- package/dist/collection/components/form/mrd-form/mrd-form.js +55 -6
- package/dist/collection/components/invoice/mrd-invoice-view/mrd-invoice-view.css +145 -0
- package/dist/collection/components/invoice/mrd-invoice-view/mrd-invoice-view.js +281 -0
- package/dist/collection/components/layout/mrd-layout-section/field-value.js +5 -1
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.css +10 -0
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +38 -8
- package/dist/collection/components/merge/mrd-merge-view/merge-diff.js +99 -0
- package/dist/collection/components/merge/mrd-merge-view/merge-parts.js +44 -0
- package/dist/collection/components/merge/mrd-merge-view/mrd-merge-view.css +244 -0
- package/dist/collection/components/merge/mrd-merge-view/mrd-merge-view.js +397 -0
- package/dist/collection/dev/api.js +41 -2
- package/dist/collection/dev/app.js +135 -17
- package/dist/collection/dev/example-data.js +126 -2
- package/dist/collection/types/client-layout.js +6 -0
- package/dist/collection/utils/cell-renderer.js +6 -1
- package/dist/collection/utils/document-attachments.js +27 -14
- package/dist/collection/utils/i18n.js +224 -0
- package/dist/components/cell-renderer.js +1 -0
- package/dist/components/client-layout.js +1 -1
- package/dist/components/document-attachments.js +1 -1
- package/dist/components/file-upload-common.js +1 -1
- package/dist/components/format.js +1 -1
- package/dist/components/i18n.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/mrd-boolean-field2.js +1 -1
- package/dist/components/mrd-currency-field2.js +1 -1
- package/dist/components/mrd-date-field2.js +1 -1
- package/dist/components/mrd-datetime-field2.js +1 -1
- package/dist/components/mrd-document-view2.js +1 -1
- package/dist/components/mrd-email-field2.js +1 -1
- package/dist/components/mrd-email-view.d.ts +11 -0
- package/dist/components/mrd-email-view.js +1 -0
- package/dist/components/mrd-email-view2.js +1 -0
- package/dist/components/mrd-field2.js +1 -1
- package/dist/components/mrd-file-field2.js +1 -1
- package/dist/components/mrd-form.js +1 -1
- package/dist/components/mrd-image-field2.js +1 -1
- package/dist/components/mrd-invoice-view.d.ts +11 -0
- package/dist/components/mrd-invoice-view.js +1 -0
- package/dist/components/mrd-invoice-view2.js +1 -0
- package/dist/components/mrd-layout-section.js +1 -1
- package/dist/components/mrd-longtext-field2.js +1 -1
- package/dist/components/mrd-merge-view.d.ts +11 -0
- package/dist/components/mrd-merge-view.js +1 -0
- package/dist/components/mrd-number-field2.js +1 -1
- package/dist/components/mrd-secret-field2.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/components/mrd-text-field2.js +1 -1
- package/dist/components/mrd-textarea-field2.js +1 -1
- package/dist/components/mrd-time-field2.js +1 -1
- package/dist/components/purify.es.js +2 -0
- package/dist/esm/cell-renderer-DIsNX9D7.js +974 -0
- package/dist/esm/{client-layout-DCOAAH92.js → client-layout-Bc42CfJB.js} +7 -1
- package/dist/esm/{index-DiSe6vjv.js → index-CDiBvvJU.js} +468 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mosterdcomponents.js +3 -3
- package/dist/esm/{mrd-boolean-field_23.entry.js → mrd-boolean-field_25.entry.js} +2949 -885
- package/dist/esm/mrd-merge-view.entry.js +271 -0
- package/dist/mosterdcomponents/index.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-4e061416.entry.js +1 -0
- package/dist/mosterdcomponents/p-910ebfee.entry.js +3 -0
- package/dist/mosterdcomponents/{p-DCOAAH92.js → p-Bc42CfJB.js} +1 -1
- package/dist/mosterdcomponents/p-CDiBvvJU.js +2 -0
- package/dist/mosterdcomponents/p-Ce2QDq0t.js +1 -0
- package/dist/types/components/documents/mrd-document-view/mrd-document-view.d.ts +2 -2
- package/dist/types/components/email/mrd-email-view/mrd-email-view.d.ts +52 -0
- package/dist/types/components/fields/file-upload-common.d.ts +19 -1
- package/dist/types/components/fields/mrd-file-field/mrd-file-field.d.ts +24 -10
- package/dist/types/components/fields/mrd-image-field/mrd-image-field.d.ts +27 -11
- package/dist/types/components/fields/mrd-textarea-field/mrd-textarea-field.d.ts +1 -0
- package/dist/types/components/form/mrd-form/mrd-form.d.ts +16 -1
- package/dist/types/components/invoice/mrd-invoice-view/mrd-invoice-view.d.ts +60 -0
- package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +13 -0
- package/dist/types/components/merge/mrd-merge-view/merge-diff.d.ts +43 -0
- package/dist/types/components/merge/mrd-merge-view/merge-parts.d.ts +37 -0
- package/dist/types/components/merge/mrd-merge-view/mrd-merge-view.d.ts +68 -0
- package/dist/types/components.d.ts +445 -19
- package/dist/types/types/client-layout.d.ts +6 -0
- package/dist/types/utils/document-attachments.d.ts +12 -5
- package/package.json +2 -1
- package/dist/mosterdcomponents/p-DiSe6vjv.js +0 -2
- package/dist/mosterdcomponents/p-cdecc698.entry.js +0 -1
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { diffFields, buildPatch, candidateLabel } from "./merge-diff";
|
|
3
|
+
import { MergeSearchStep, MergeCompareStep, MergeConfirmStep } from "./merge-parts";
|
|
4
|
+
/**
|
|
5
|
+
* Merges two DataObjects of the same basic type (FINDING-0114 / TASK-0177).
|
|
6
|
+
* Never performs network I/O itself: it emits `mrdSearch` (host searches and
|
|
7
|
+
* calls `setSearchResults()`, mirroring mrd-relation-field) and `mrdMerge`
|
|
8
|
+
* (host calls the merge endpoint — `POST {winnerHref}/merge` with
|
|
9
|
+
* `{ loser: loserHref, patch }`, per DataController.merge()).
|
|
10
|
+
*
|
|
11
|
+
* Has no exit/cancel affordance of its own — hosts show this inside their
|
|
12
|
+
* own overlay-page chrome (its close button), the same way mrd-layout-section
|
|
13
|
+
* never renders a page-level close button either.
|
|
14
|
+
*/
|
|
15
|
+
export class MrdMergeView {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.locale = navigator.language;
|
|
18
|
+
/** Dot-notation class, passed through on mrdSearch (host may use it to pick the right search endpoint). */
|
|
19
|
+
this.basicType = '';
|
|
20
|
+
/** URL segment for the search endpoint; falls back to basicType when absent. */
|
|
21
|
+
this.mostSignificantClass = '';
|
|
22
|
+
/** Flat FIELD/RELATION items describing the basic type's schema (host flattens SECTION/GROUP, same as mrd-table's `columns`). */
|
|
23
|
+
this.fields = [];
|
|
24
|
+
/** Href of A (winner) — the object the merge screen was opened from. */
|
|
25
|
+
this.currentHref = '';
|
|
26
|
+
/** A's full raw record: flat fields + `_links`, the same row shape CellRenderer.render expects. */
|
|
27
|
+
this.currentRecord = {};
|
|
28
|
+
/** Display name for A, shown in the compare step's column header. */
|
|
29
|
+
this.currentLabel = '';
|
|
30
|
+
this.step = 'search';
|
|
31
|
+
this.searchQuery = '';
|
|
32
|
+
this.searchResults = [];
|
|
33
|
+
this.isLoading = false;
|
|
34
|
+
this.candidate = null;
|
|
35
|
+
this.resolutions = {};
|
|
36
|
+
/** Which history badge popover is open, keyed e.g. `legalName:A` / `legalName:confirm`. */
|
|
37
|
+
this.openHistoryKey = null;
|
|
38
|
+
this.historyClickOutside = null;
|
|
39
|
+
this.searchDebounce = null;
|
|
40
|
+
this.handleSearchInput = (query) => {
|
|
41
|
+
this.searchQuery = query;
|
|
42
|
+
if (this.searchDebounce)
|
|
43
|
+
clearTimeout(this.searchDebounce);
|
|
44
|
+
if (query.trim().length >= 2) {
|
|
45
|
+
this.isLoading = true;
|
|
46
|
+
this.searchDebounce = setTimeout(() => {
|
|
47
|
+
this.mrdSearch.emit({
|
|
48
|
+
query,
|
|
49
|
+
basicType: this.basicType,
|
|
50
|
+
mostSignificantClass: this.mostSignificantClass || undefined,
|
|
51
|
+
});
|
|
52
|
+
}, 300);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.searchResults = [];
|
|
56
|
+
this.isLoading = false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
this.handleSelect = (record) => {
|
|
60
|
+
this.candidate = record;
|
|
61
|
+
const { conflicts } = diffFields(this.fields, this.currentRecord, record);
|
|
62
|
+
const resolutions = {};
|
|
63
|
+
conflicts.forEach(({ item }) => { var _a; resolutions[(_a = item.name) !== null && _a !== void 0 ? _a : ''] = 'A'; });
|
|
64
|
+
this.resolutions = resolutions;
|
|
65
|
+
this.openHistoryKey = null;
|
|
66
|
+
this.step = 'compare';
|
|
67
|
+
};
|
|
68
|
+
this.handleChangeCandidate = () => {
|
|
69
|
+
this.candidate = null;
|
|
70
|
+
this.resolutions = {};
|
|
71
|
+
this.openHistoryKey = null;
|
|
72
|
+
this.step = 'search';
|
|
73
|
+
};
|
|
74
|
+
this.handleResolve = (name, side) => {
|
|
75
|
+
this.resolutions = Object.assign(Object.assign({}, this.resolutions), { [name]: side });
|
|
76
|
+
};
|
|
77
|
+
this.handleToggleHistory = (key) => {
|
|
78
|
+
this.openHistoryKey = key;
|
|
79
|
+
};
|
|
80
|
+
this.handleContinue = () => {
|
|
81
|
+
this.step = 'confirm';
|
|
82
|
+
};
|
|
83
|
+
this.handleBack = () => {
|
|
84
|
+
this.step = 'compare';
|
|
85
|
+
};
|
|
86
|
+
this.handleConfirm = () => {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
|
+
if (!this.candidate)
|
|
89
|
+
return;
|
|
90
|
+
const diff = diffFields(this.fields, this.currentRecord, this.candidate);
|
|
91
|
+
const patch = buildPatch(diff, this.resolutions);
|
|
92
|
+
const loserHref = (_d = (_c = (_b = (_a = this.candidate) === null || _a === void 0 ? void 0 : _a._links) === null || _b === void 0 ? void 0 : _b.self) === null || _c === void 0 ? void 0 : _c.href) !== null && _d !== void 0 ? _d : '';
|
|
93
|
+
this.mrdMerge.emit({ winnerHref: this.currentHref, loserHref, patch });
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
connectedCallback() {
|
|
97
|
+
this.historyClickOutside = (e) => {
|
|
98
|
+
if (!this.el.contains(e.target))
|
|
99
|
+
this.openHistoryKey = null;
|
|
100
|
+
};
|
|
101
|
+
document.addEventListener('mousedown', this.historyClickOutside);
|
|
102
|
+
}
|
|
103
|
+
disconnectedCallback() {
|
|
104
|
+
if (this.historyClickOutside) {
|
|
105
|
+
document.removeEventListener('mousedown', this.historyClickOutside);
|
|
106
|
+
this.historyClickOutside = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Stores search results, filtering out A itself regardless of what the
|
|
111
|
+
* host's search returns — A must never appear as a mergeable candidate.
|
|
112
|
+
*/
|
|
113
|
+
async setSearchResults(records) {
|
|
114
|
+
this.searchResults = (records !== null && records !== void 0 ? records : []).filter(r => { var _a, _b, _c; return ((_c = (_b = (_a = r === null || r === void 0 ? void 0 : r._links) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.href) !== null && _c !== void 0 ? _c : null) !== this.currentHref; });
|
|
115
|
+
this.isLoading = false;
|
|
116
|
+
}
|
|
117
|
+
async setLoading(loading) {
|
|
118
|
+
this.isLoading = loading;
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
let stepContent;
|
|
123
|
+
if (this.step === 'search') {
|
|
124
|
+
stepContent = (h(MergeSearchStep, { key: '3adb36fb46aa7260641a46a2cf27cc0ef320876f', locale: this.locale, searchQuery: this.searchQuery, searchResults: this.searchResults, isLoading: this.isLoading, onSearchInput: this.handleSearchInput, onSelect: this.handleSelect }));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const diff = diffFields(this.fields, this.currentRecord, this.candidate);
|
|
128
|
+
const bLabel = candidateLabel(this.candidate);
|
|
129
|
+
stepContent = this.step === 'compare' ? (h(MergeCompareStep, { locale: this.locale, currentLabel: this.currentLabel, candidateLabel: bLabel, conflicts: diff.conflicts, autoFilled: diff.autoFilled, recordA: this.currentRecord, recordB: (_a = this.candidate) !== null && _a !== void 0 ? _a : {}, resolutions: this.resolutions, openHistoryKey: this.openHistoryKey, onResolve: this.handleResolve, onToggleHistory: this.handleToggleHistory, onChangeCandidate: this.handleChangeCandidate, onContinue: this.handleContinue })) : (h(MergeConfirmStep, { locale: this.locale, candidateLabel: bLabel, conflicts: diff.conflicts, autoFilled: diff.autoFilled, resolutions: this.resolutions, recordB: (_b = this.candidate) !== null && _b !== void 0 ? _b : {}, openHistoryKey: this.openHistoryKey, onToggleHistory: this.handleToggleHistory, onBack: this.handleBack, onConfirm: this.handleConfirm }));
|
|
130
|
+
}
|
|
131
|
+
return (h(Host, { key: 'e33a6d66a220b28cc9533da78dc274e2d7ec5c4a' }, h("div", { key: 'b5fb1390d86192f9f6f15e3ccb89e2d21d9c7c8b', class: "mrd-merge-view" }, stepContent)));
|
|
132
|
+
}
|
|
133
|
+
static get is() { return "mrd-merge-view"; }
|
|
134
|
+
static get encapsulation() { return "scoped"; }
|
|
135
|
+
static get originalStyleUrls() {
|
|
136
|
+
return {
|
|
137
|
+
"$": ["mrd-merge-view.scss"]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
static get styleUrls() {
|
|
141
|
+
return {
|
|
142
|
+
"$": ["mrd-merge-view.css"]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
static get properties() {
|
|
146
|
+
return {
|
|
147
|
+
"locale": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"mutable": false,
|
|
150
|
+
"complexType": {
|
|
151
|
+
"original": "string",
|
|
152
|
+
"resolved": "string",
|
|
153
|
+
"references": {}
|
|
154
|
+
},
|
|
155
|
+
"required": false,
|
|
156
|
+
"optional": false,
|
|
157
|
+
"docs": {
|
|
158
|
+
"tags": [],
|
|
159
|
+
"text": ""
|
|
160
|
+
},
|
|
161
|
+
"getter": false,
|
|
162
|
+
"setter": false,
|
|
163
|
+
"reflect": false,
|
|
164
|
+
"attribute": "locale",
|
|
165
|
+
"defaultValue": "navigator.language"
|
|
166
|
+
},
|
|
167
|
+
"basicType": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"mutable": false,
|
|
170
|
+
"complexType": {
|
|
171
|
+
"original": "string",
|
|
172
|
+
"resolved": "string",
|
|
173
|
+
"references": {}
|
|
174
|
+
},
|
|
175
|
+
"required": false,
|
|
176
|
+
"optional": false,
|
|
177
|
+
"docs": {
|
|
178
|
+
"tags": [],
|
|
179
|
+
"text": "Dot-notation class, passed through on mrdSearch (host may use it to pick the right search endpoint)."
|
|
180
|
+
},
|
|
181
|
+
"getter": false,
|
|
182
|
+
"setter": false,
|
|
183
|
+
"reflect": false,
|
|
184
|
+
"attribute": "basic-type",
|
|
185
|
+
"defaultValue": "''"
|
|
186
|
+
},
|
|
187
|
+
"mostSignificantClass": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"mutable": false,
|
|
190
|
+
"complexType": {
|
|
191
|
+
"original": "string",
|
|
192
|
+
"resolved": "string",
|
|
193
|
+
"references": {}
|
|
194
|
+
},
|
|
195
|
+
"required": false,
|
|
196
|
+
"optional": false,
|
|
197
|
+
"docs": {
|
|
198
|
+
"tags": [],
|
|
199
|
+
"text": "URL segment for the search endpoint; falls back to basicType when absent."
|
|
200
|
+
},
|
|
201
|
+
"getter": false,
|
|
202
|
+
"setter": false,
|
|
203
|
+
"reflect": false,
|
|
204
|
+
"attribute": "most-significant-class",
|
|
205
|
+
"defaultValue": "''"
|
|
206
|
+
},
|
|
207
|
+
"fields": {
|
|
208
|
+
"type": "unknown",
|
|
209
|
+
"mutable": false,
|
|
210
|
+
"complexType": {
|
|
211
|
+
"original": "ClientLayoutItem[]",
|
|
212
|
+
"resolved": "ClientLayoutItem[]",
|
|
213
|
+
"references": {
|
|
214
|
+
"ClientLayoutItem": {
|
|
215
|
+
"location": "import",
|
|
216
|
+
"path": "../../../types/client-layout",
|
|
217
|
+
"id": "src/types/client-layout.ts::ClientLayoutItem",
|
|
218
|
+
"referenceLocation": "ClientLayoutItem"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"required": false,
|
|
223
|
+
"optional": false,
|
|
224
|
+
"docs": {
|
|
225
|
+
"tags": [],
|
|
226
|
+
"text": "Flat FIELD/RELATION items describing the basic type's schema (host flattens SECTION/GROUP, same as mrd-table's `columns`)."
|
|
227
|
+
},
|
|
228
|
+
"getter": false,
|
|
229
|
+
"setter": false,
|
|
230
|
+
"defaultValue": "[]"
|
|
231
|
+
},
|
|
232
|
+
"currentHref": {
|
|
233
|
+
"type": "string",
|
|
234
|
+
"mutable": false,
|
|
235
|
+
"complexType": {
|
|
236
|
+
"original": "string",
|
|
237
|
+
"resolved": "string",
|
|
238
|
+
"references": {}
|
|
239
|
+
},
|
|
240
|
+
"required": false,
|
|
241
|
+
"optional": false,
|
|
242
|
+
"docs": {
|
|
243
|
+
"tags": [],
|
|
244
|
+
"text": "Href of A (winner) \u2014 the object the merge screen was opened from."
|
|
245
|
+
},
|
|
246
|
+
"getter": false,
|
|
247
|
+
"setter": false,
|
|
248
|
+
"reflect": false,
|
|
249
|
+
"attribute": "current-href",
|
|
250
|
+
"defaultValue": "''"
|
|
251
|
+
},
|
|
252
|
+
"currentRecord": {
|
|
253
|
+
"type": "unknown",
|
|
254
|
+
"mutable": false,
|
|
255
|
+
"complexType": {
|
|
256
|
+
"original": "Record<string, any>",
|
|
257
|
+
"resolved": "any | string",
|
|
258
|
+
"references": {
|
|
259
|
+
"Record": {
|
|
260
|
+
"location": "global",
|
|
261
|
+
"id": "global::Record"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"required": false,
|
|
266
|
+
"optional": false,
|
|
267
|
+
"docs": {
|
|
268
|
+
"tags": [],
|
|
269
|
+
"text": "A's full raw record: flat fields + `_links`, the same row shape CellRenderer.render expects."
|
|
270
|
+
},
|
|
271
|
+
"getter": false,
|
|
272
|
+
"setter": false,
|
|
273
|
+
"defaultValue": "{}"
|
|
274
|
+
},
|
|
275
|
+
"currentLabel": {
|
|
276
|
+
"type": "string",
|
|
277
|
+
"mutable": false,
|
|
278
|
+
"complexType": {
|
|
279
|
+
"original": "string",
|
|
280
|
+
"resolved": "string",
|
|
281
|
+
"references": {}
|
|
282
|
+
},
|
|
283
|
+
"required": false,
|
|
284
|
+
"optional": false,
|
|
285
|
+
"docs": {
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": "Display name for A, shown in the compare step's column header."
|
|
288
|
+
},
|
|
289
|
+
"getter": false,
|
|
290
|
+
"setter": false,
|
|
291
|
+
"reflect": false,
|
|
292
|
+
"attribute": "current-label",
|
|
293
|
+
"defaultValue": "''"
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
static get states() {
|
|
298
|
+
return {
|
|
299
|
+
"step": {},
|
|
300
|
+
"searchQuery": {},
|
|
301
|
+
"searchResults": {},
|
|
302
|
+
"isLoading": {},
|
|
303
|
+
"candidate": {},
|
|
304
|
+
"resolutions": {},
|
|
305
|
+
"openHistoryKey": {}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
static get events() {
|
|
309
|
+
return [{
|
|
310
|
+
"method": "mrdSearch",
|
|
311
|
+
"name": "mrdSearch",
|
|
312
|
+
"bubbles": true,
|
|
313
|
+
"cancelable": true,
|
|
314
|
+
"composed": true,
|
|
315
|
+
"docs": {
|
|
316
|
+
"tags": [],
|
|
317
|
+
"text": ""
|
|
318
|
+
},
|
|
319
|
+
"complexType": {
|
|
320
|
+
"original": "{ query: string; basicType: string; mostSignificantClass?: string }",
|
|
321
|
+
"resolved": "{ query: string; basicType: string; mostSignificantClass?: string | undefined; }",
|
|
322
|
+
"references": {}
|
|
323
|
+
}
|
|
324
|
+
}, {
|
|
325
|
+
"method": "mrdMerge",
|
|
326
|
+
"name": "mrdMerge",
|
|
327
|
+
"bubbles": true,
|
|
328
|
+
"cancelable": true,
|
|
329
|
+
"composed": true,
|
|
330
|
+
"docs": {
|
|
331
|
+
"tags": [],
|
|
332
|
+
"text": ""
|
|
333
|
+
},
|
|
334
|
+
"complexType": {
|
|
335
|
+
"original": "{ winnerHref: string; loserHref: string; patch: Record<string, unknown> }",
|
|
336
|
+
"resolved": "{ winnerHref: string; loserHref: string; patch: Record<string, unknown>; }",
|
|
337
|
+
"references": {
|
|
338
|
+
"Record": {
|
|
339
|
+
"location": "global",
|
|
340
|
+
"id": "global::Record"
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}];
|
|
345
|
+
}
|
|
346
|
+
static get methods() {
|
|
347
|
+
return {
|
|
348
|
+
"setSearchResults": {
|
|
349
|
+
"complexType": {
|
|
350
|
+
"signature": "(records: Record<string, any>[]) => Promise<void>",
|
|
351
|
+
"parameters": [{
|
|
352
|
+
"name": "records",
|
|
353
|
+
"type": "Record<string, any>[]",
|
|
354
|
+
"docs": ""
|
|
355
|
+
}],
|
|
356
|
+
"references": {
|
|
357
|
+
"Promise": {
|
|
358
|
+
"location": "global",
|
|
359
|
+
"id": "global::Promise"
|
|
360
|
+
},
|
|
361
|
+
"Record": {
|
|
362
|
+
"location": "global",
|
|
363
|
+
"id": "global::Record"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
"return": "Promise<void>"
|
|
367
|
+
},
|
|
368
|
+
"docs": {
|
|
369
|
+
"text": "Stores search results, filtering out A itself regardless of what the\nhost's search returns \u2014 A must never appear as a mergeable candidate.",
|
|
370
|
+
"tags": []
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"setLoading": {
|
|
374
|
+
"complexType": {
|
|
375
|
+
"signature": "(loading: boolean) => Promise<void>",
|
|
376
|
+
"parameters": [{
|
|
377
|
+
"name": "loading",
|
|
378
|
+
"type": "boolean",
|
|
379
|
+
"docs": ""
|
|
380
|
+
}],
|
|
381
|
+
"references": {
|
|
382
|
+
"Promise": {
|
|
383
|
+
"location": "global",
|
|
384
|
+
"id": "global::Promise"
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
"return": "Promise<void>"
|
|
388
|
+
},
|
|
389
|
+
"docs": {
|
|
390
|
+
"text": "",
|
|
391
|
+
"tags": []
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
static get elementRef() { return "el"; }
|
|
397
|
+
}
|
|
@@ -19,7 +19,21 @@ async function apiRequest(method, path, token, body) {
|
|
|
19
19
|
const text = await resp.text();
|
|
20
20
|
let json;
|
|
21
21
|
try { json = JSON.parse(text); } catch (_) { json = text; }
|
|
22
|
-
return { status: resp.status, ok: resp.ok, body: json };
|
|
22
|
+
return { status: resp.status, ok: resp.ok, body: json, location: resp.headers.get('Location') };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Write (POST/PATCH) that returns no body — only a Location header
|
|
27
|
+
* (create/patch/merge on /data/**, per TASK-0203). Follows the Location
|
|
28
|
+
* header with a GET to hand callers the current record, mirroring
|
|
29
|
+
* content-app's ApiClientService create/update methods.
|
|
30
|
+
*/
|
|
31
|
+
async function apiWriteAndFetch(method, path, token, payload) {
|
|
32
|
+
const write = await apiRequest(method, path, token, payload);
|
|
33
|
+
if (!write.ok) return write;
|
|
34
|
+
const href = write.location || path;
|
|
35
|
+
const { body } = await apiRequest('GET', href, token);
|
|
36
|
+
return { ...write, body };
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
/** Resolve a file/image reference href to a signed, directly-usable URL.
|
|
@@ -95,7 +109,7 @@ async function apiFetchPage(token, baseHref, pageNumber, sort = '') {
|
|
|
95
109
|
}
|
|
96
110
|
|
|
97
111
|
async function apiSubmitForm(token, tenantCode, pluralName, values) {
|
|
98
|
-
const { status, ok, body } = await
|
|
112
|
+
const { status, ok, body } = await apiWriteAndFetch('POST', `/data/${tenantCode}/${pluralName}`, token, values);
|
|
99
113
|
return { status, ok, body };
|
|
100
114
|
}
|
|
101
115
|
|
|
@@ -135,6 +149,31 @@ async function apiSearchRelation(token, tenantCode, mostSignificantClass, query)
|
|
|
135
149
|
}));
|
|
136
150
|
}
|
|
137
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Search for merge candidates. Unlike apiSearchRelation, this does NOT map
|
|
154
|
+
* results down to {id, label} — mrd-merge-view needs the full raw records
|
|
155
|
+
* (fields + _links) up front so it can diff without a second fetch per
|
|
156
|
+
* candidate once one is selected.
|
|
157
|
+
*/
|
|
158
|
+
async function apiSearchMergeCandidates(token, tenantCode, mostSignificantClass, query) {
|
|
159
|
+
const q = encodeURIComponent(query);
|
|
160
|
+
const { ok, status, body } = await apiRequest('GET', `/data/${tenantCode}/${mostSignificantClass}?q=${q}`, token);
|
|
161
|
+
if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
|
|
162
|
+
return (body._embedded && body._embedded[mostSignificantClass]) || [];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Merge two DataObjects of the same basic type. Mirrors DataController.merge():
|
|
167
|
+
* POST {winnerHref}/merge with { loser: loserHref, patch }. Returns no body
|
|
168
|
+
* (204 + Location, per TASK-0203) — follows Location with a GET for the
|
|
169
|
+
* patched winner record.
|
|
170
|
+
*/
|
|
171
|
+
async function apiMerge(token, winnerHref, loserHref, patch) {
|
|
172
|
+
const { ok, status, body } = await apiWriteAndFetch('POST', `${winnerHref}/merge`, token, { loser: loserHref, patch });
|
|
173
|
+
if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
|
|
174
|
+
return body;
|
|
175
|
+
}
|
|
176
|
+
|
|
138
177
|
/* =====================================================================
|
|
139
178
|
LAYOUT MAPPERS
|
|
140
179
|
mrd-form and mrd-field now accept the flat API format directly.
|