@openremote/or-asset-tree 1.8.0-snapshot.20250725120002 → 1.8.0-snapshot.20250728102340
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/README.md +30 -30
- package/custom-elements.json +1 -1
- package/dist/umd/index.bundle.js +1191 -1191
- package/dist/umd/index.bundle.js.map +1 -1
- package/dist/umd/index.js +1191 -1191
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +1250 -1250
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/index.js +99 -1704
- package/lib/or-add-asset-dialog.js +148 -318
- package/lib/style.js +306 -312
- package/package.json +8 -8
|
@@ -1,319 +1,149 @@
|
|
|
1
|
-
var __decorate = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
17
|
-
import { customElement, property, query } from "lit/decorators.js";
|
|
18
|
-
import { AssetModelUtil } from "@openremote/model";
|
|
19
|
-
import "@openremote/or-mwc-components/or-mwc-input";
|
|
20
|
-
import { OrAssetTreeSelectionEvent } from "./index";
|
|
21
|
-
import { createListGroup } from "@openremote/or-mwc-components/or-mwc-list";
|
|
22
|
-
import { i18next } from "@openremote/or-translate";
|
|
23
|
-
import { DefaultColor3, DefaultColor5, Util } from "@openremote/core";
|
|
24
|
-
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
25
|
-
export class OrAddChangedEvent extends CustomEvent {
|
|
26
|
-
constructor(addAssetDetail) {
|
|
27
|
-
super(OrAddChangedEvent.NAME, {
|
|
28
|
-
bubbles: true,
|
|
29
|
-
composed: true,
|
|
30
|
-
detail: addAssetDetail
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
OrAddChangedEvent.NAME = "or-add-asset-changed";
|
|
35
|
-
let OrAddAssetDialog = class OrAddAssetDialog extends LitElement {
|
|
36
|
-
static get styles() {
|
|
37
|
-
// language=CSS
|
|
38
|
-
return css `
|
|
39
|
-
:host{
|
|
40
|
-
border-style: solid;
|
|
41
|
-
border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
|
|
42
|
-
border-width: 1px 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
#name-wrapper {
|
|
46
|
-
display: flex;
|
|
47
|
-
flex-direction: column;
|
|
48
|
-
margin-top: 12px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#toggle-parent-selector,
|
|
52
|
-
#remove-parent {
|
|
53
|
-
flex: 0 0 50px;
|
|
54
|
-
margin: 4px 0 0 5px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#name-input,
|
|
58
|
-
#parent-wrapper {
|
|
59
|
-
margin: 10px 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
#parent-wrapper {
|
|
63
|
-
display: flex;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
#parent {
|
|
67
|
-
flex: 1 1 auto;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
#parent-selector {
|
|
71
|
-
max-width: 250px;
|
|
72
|
-
border-left: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
#mdc-dialog-form-add {
|
|
76
|
-
display: flex;
|
|
77
|
-
height: 100%;
|
|
78
|
-
max-height: 600px;
|
|
79
|
-
width: 1000px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.msg {
|
|
83
|
-
display: flex;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
align-items: center;
|
|
86
|
-
text-align: center;
|
|
87
|
-
height: 100%;
|
|
88
|
-
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
89
|
-
font-size: 14px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#asset-type-option-container {
|
|
93
|
-
padding: 15px;
|
|
94
|
-
flex: 1 1 auto;
|
|
95
|
-
overflow: auto;
|
|
96
|
-
max-width: 100%;
|
|
97
|
-
font-size: 16px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
#type-list {
|
|
101
|
-
width: 260px;
|
|
102
|
-
overflow: auto;
|
|
103
|
-
text-transform: capitalize;
|
|
104
|
-
border-right: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#type-title {
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
margin: 9px 4px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
#type-description {
|
|
114
|
-
text-transform: capitalize;
|
|
115
|
-
color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
|
|
116
|
-
margin-left: 10px;
|
|
117
|
-
font-size: 18px;
|
|
118
|
-
font-weight: bold;
|
|
119
|
-
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.heading,
|
|
123
|
-
.mdc-list-group__subheader {
|
|
124
|
-
text-transform: uppercase;
|
|
125
|
-
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
126
|
-
font-weight: bolder;
|
|
127
|
-
line-height: 1em;
|
|
128
|
-
color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
|
|
129
|
-
letter-spacing: 0.025em;
|
|
130
|
-
font-size: 14px;
|
|
131
|
-
margin: 20px 0 10px;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.mdc-list-group__subheader {
|
|
135
|
-
margin: 20px 0 0 16px;
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
138
|
-
}
|
|
139
|
-
constructor() {
|
|
140
|
-
super();
|
|
141
|
-
this.selectedAttributes = [];
|
|
142
|
-
this.showParentAssetSelector = false;
|
|
143
|
-
this.selectedChildAssetType = "";
|
|
144
|
-
this.name = "New Asset";
|
|
145
|
-
this.addEventListener(OrAssetTreeSelectionEvent.NAME, (event) => {
|
|
146
|
-
this.parent = event.detail.newNodes[0].asset;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
render() {
|
|
150
|
-
const mapDescriptors = (descriptors) => descriptors.map((descriptor) => {
|
|
151
|
-
return {
|
|
152
|
-
styleMap: {
|
|
153
|
-
"--or-icon-fill": descriptor.colour ? "#" + descriptor.colour : "unset"
|
|
154
|
-
},
|
|
155
|
-
icon: descriptor.icon,
|
|
156
|
-
text: Util.getAssetTypeLabel(descriptor),
|
|
157
|
-
value: descriptor.name,
|
|
158
|
-
data: descriptor
|
|
159
|
-
};
|
|
160
|
-
}).sort(Util.sortByString((listItem) => listItem.text));
|
|
161
|
-
const agentItems = mapDescriptors(this.agentTypes);
|
|
162
|
-
const assetItems = mapDescriptors(this.assetTypes);
|
|
163
|
-
const lists = [];
|
|
164
|
-
if (agentItems.length > 0) {
|
|
165
|
-
lists.push({
|
|
166
|
-
heading: i18next.t("agents"),
|
|
167
|
-
list: html `<or-mwc-list @or-mwc-list-changed="${(evt) => { if (evt.detail.length === 1)
|
|
168
|
-
this.onTypeChanged(true, evt.detail[0]); }}" .listItems="${agentItems}" id="agent-list"></or-mwc-list>`
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (assetItems.length > 0) {
|
|
172
|
-
lists.push({
|
|
173
|
-
heading: i18next.t("assets"),
|
|
174
|
-
list: html `<or-mwc-list @or-mwc-list-changed="${(evt) => { if (evt.detail.length === 1)
|
|
175
|
-
this.onTypeChanged(false, evt.detail[0]); }}" .listItems="${assetItems}" id="asset-list"></or-mwc-list>`
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const parentStr = this.parent ? this.parent.name + " (" + this.parent.id + ")" : i18next.t("none");
|
|
179
|
-
return html `
|
|
180
|
-
<div class="col" style="height: 100%;">
|
|
181
|
-
<form id="mdc-dialog-form-add" class="row">
|
|
182
|
-
<div id="type-list" class="col">
|
|
183
|
-
${createListGroup(lists)}
|
|
184
|
-
</div>
|
|
185
|
-
<div id="asset-type-option-container" class="col">
|
|
186
|
-
${!this.selectedType
|
|
187
|
-
? html `<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`
|
|
188
|
-
: this.getTypeTemplate(this.selectedType, parentStr)}
|
|
189
|
-
</div>
|
|
190
|
-
${!this.showParentAssetSelector
|
|
191
|
-
? html ``
|
|
192
|
-
: html `<or-asset-tree id="parent-selector" class="col" .showDeselectBtn="${false}" .showSortBtn="${false}" selectedNodes readonly></or-asset-tree>`}
|
|
193
|
-
</form>
|
|
194
|
-
</div>
|
|
195
|
-
`;
|
|
196
|
-
}
|
|
197
|
-
getTypeTemplate(descriptor, parentStr) {
|
|
198
|
-
var _a, _b;
|
|
199
|
-
if (!descriptor.name) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
const assetTypeInfo = AssetModelUtil.getAssetTypeInfo(descriptor.name), attributes = (_a = assetTypeInfo === null || assetTypeInfo === void 0 ? void 0 : assetTypeInfo.attributeDescriptors) === null || _a === void 0 ? void 0 : _a.filter(e => !e.optional), optionalAttributes = (_b = assetTypeInfo === null || assetTypeInfo === void 0 ? void 0 : assetTypeInfo.attributeDescriptors) === null || _b === void 0 ? void 0 : _b.filter(e => !!e.optional);
|
|
203
|
-
return html `
|
|
204
|
-
<div id="type-title">
|
|
205
|
-
<or-icon style="--or-icon-fill: ${descriptor.colour ? "#" + descriptor.colour : "unset"}" id="type-icon" .icon="${descriptor.icon}"></or-icon>
|
|
206
|
-
<or-translate id="type-description" .value="${Util.getAssetTypeLabel(descriptor)}"></or-translate>
|
|
207
|
-
</div>
|
|
208
|
-
<div id="name-wrapper">
|
|
209
|
-
<or-mwc-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" required .label="${i18next.t("name")}" .value="${this.name}" @or-mwc-input-changed="${(e) => this.onNameChanged(e.detail.value)}"></or-mwc-input>
|
|
210
|
-
<div id="parent-wrapper">
|
|
211
|
-
<or-mwc-input id="parent" .type="${InputType.TEXT}" readonly .label="${i18next.t("parent")}" .value="${parentStr}" @click="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>
|
|
212
|
-
<or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${InputType.BUTTON}" icon="close" @or-mwc-input-changed="${() => this._onDeselectClicked()}"></or-mwc-input>
|
|
213
|
-
<or-mwc-input id="toggle-parent-selector" icon="${this.showParentAssetSelector ? "pencil-off" : "pencil"}" type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>
|
|
214
|
-
</div>
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
${!attributes
|
|
218
|
-
? html ``
|
|
219
|
-
: html `
|
|
220
|
-
<div>
|
|
221
|
-
<div class="heading">${i18next.t("attribute_plural")}</div>
|
|
222
|
-
<div style="display: grid">
|
|
223
|
-
${attributes.sort(Util.sortByString((attribute) => attribute.name))
|
|
224
|
-
.map(attribute => html `
|
|
225
|
-
<or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, undefined, true)}"
|
|
226
|
-
.disabled="${true}" .value="${true}"></or-mwc-input>
|
|
227
|
-
`)}
|
|
228
|
-
</div>
|
|
229
|
-
`}
|
|
230
|
-
|
|
231
|
-
${!optionalAttributes
|
|
232
|
-
? html ``
|
|
233
|
-
: html `
|
|
234
|
-
<div>
|
|
235
|
-
<div class="heading">${i18next.t("optional_attributes")}</div>
|
|
236
|
-
<div style="display: grid">
|
|
237
|
-
${optionalAttributes.sort(Util.sortByString((attribute) => attribute.name))
|
|
238
|
-
.map(attribute => html `
|
|
239
|
-
<or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, undefined, true)}"
|
|
240
|
-
.value="${this.selectedAttributes.find((selected) => selected === attribute)}"
|
|
241
|
-
@or-mwc-input-changed="${(evt) => evt.detail.value ? this.selectedAttributes.push(attribute) : this.selectedAttributes.splice(this.selectedAttributes.findIndex((s) => s === attribute), 1)}"></or-mwc-input>
|
|
242
|
-
`)}
|
|
243
|
-
</div>
|
|
244
|
-
</div>
|
|
245
|
-
`}
|
|
246
|
-
`;
|
|
247
|
-
}
|
|
248
|
-
onNameChanged(name) {
|
|
249
|
-
this.name = name;
|
|
250
|
-
this.onModified();
|
|
251
|
-
}
|
|
252
|
-
onTypeChanged(isAgent, listItem) {
|
|
253
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
yield this.updateComplete;
|
|
255
|
-
this.selectedAttributes = [];
|
|
256
|
-
this.selectedType = listItem.data;
|
|
257
|
-
// Deselect other list selection
|
|
258
|
-
const otherList = isAgent ? this.assetList : this.agentList;
|
|
259
|
-
if (otherList) {
|
|
260
|
-
otherList.values = undefined;
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length,a=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,i);else for(var n=e.length-1;n>=0;n--)(r=e[n])&&(a=(s<3?r(a):s>3?r(t,o,a):r(t,o))||a);return s>3&&a&&Object.defineProperty(t,o,a),a},__awaiter=this&&this.__awaiter||function(e,t,o,i){return new(o||(o=Promise))(function(r,s){function a(e){try{l(i.next(e))}catch(e){s(e)}}function n(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof o?t:new o(function(e){e(t)})).then(a,n)}l((i=i.apply(e,t||[])).next())})};import{css as e,html as t,LitElement as o,unsafeCSS as i}from"lit";import{customElement as r,property as s,query as a}from"lit/decorators.js";import{AssetModelUtil as n}from"@openremote/model";import"@openremote/or-mwc-components/or-mwc-input";import{OrAssetTreeSelectionEvent as l}from"./index";import{createListGroup as d}from"@openremote/or-mwc-components/or-mwc-list";import{i18next as p}from"@openremote/or-translate";import{DefaultColor3 as c,DefaultColor5 as m,Util as h}from"@openremote/core";import{InputType as g}from"@openremote/or-mwc-components/or-mwc-input";export class OrAddChangedEvent extends CustomEvent{constructor(e){super(OrAddChangedEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAddChangedEvent.NAME="or-add-asset-changed";let OrAddAssetDialog=class extends o{static get styles(){return e`
|
|
2
|
+
:host{
|
|
3
|
+
border-style: solid;
|
|
4
|
+
border-color: var(--or-app-color5, ${i(m)});
|
|
5
|
+
border-width: 1px 0;
|
|
261
6
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
7
|
+
|
|
8
|
+
#name-wrapper {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
margin-top: 12px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#toggle-parent-selector,
|
|
15
|
+
#remove-parent {
|
|
16
|
+
flex: 0 0 50px;
|
|
17
|
+
margin: 4px 0 0 5px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#name-input,
|
|
21
|
+
#parent-wrapper {
|
|
22
|
+
margin: 10px 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#parent-wrapper {
|
|
26
|
+
display: flex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#parent {
|
|
30
|
+
flex: 1 1 auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#parent-selector {
|
|
34
|
+
max-width: 250px;
|
|
35
|
+
border-left: 1px solid var(--or-app-color5, ${i(m)});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#mdc-dialog-form-add {
|
|
39
|
+
display: flex;
|
|
40
|
+
height: 100%;
|
|
41
|
+
max-height: 600px;
|
|
42
|
+
width: 1000px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.msg {
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
text-align: center;
|
|
50
|
+
height: 100%;
|
|
51
|
+
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
52
|
+
font-size: 14px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#asset-type-option-container {
|
|
56
|
+
padding: 15px;
|
|
57
|
+
flex: 1 1 auto;
|
|
58
|
+
overflow: auto;
|
|
59
|
+
max-width: 100%;
|
|
60
|
+
font-size: 16px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#type-list {
|
|
64
|
+
width: 260px;
|
|
65
|
+
overflow: auto;
|
|
66
|
+
text-transform: capitalize;
|
|
67
|
+
border-right: 1px solid var(--or-app-color5, ${i(m)});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#type-title {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
margin: 9px 4px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#type-description {
|
|
77
|
+
text-transform: capitalize;
|
|
78
|
+
color: var(--or-app-color3, ${i(c)});
|
|
79
|
+
margin-left: 10px;
|
|
80
|
+
font-size: 18px;
|
|
81
|
+
font-weight: bold;
|
|
82
|
+
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.heading,
|
|
86
|
+
.mdc-list-group__subheader {
|
|
87
|
+
text-transform: uppercase;
|
|
88
|
+
font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
89
|
+
font-weight: bolder;
|
|
90
|
+
line-height: 1em;
|
|
91
|
+
color: var(--or-app-color3, ${i(c)});
|
|
92
|
+
letter-spacing: 0.025em;
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
margin: 20px 0 10px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.mdc-list-group__subheader {
|
|
98
|
+
margin: 20px 0 0 16px;
|
|
99
|
+
}
|
|
100
|
+
`}constructor(){super(),this.selectedAttributes=[],this.showParentAssetSelector=!1,this.selectedChildAssetType="",this.name="New Asset",this.addEventListener(l.NAME,e=>{this.parent=e.detail.newNodes[0].asset})}render(){let e=e=>e.map(e=>({styleMap:{"--or-icon-fill":e.colour?"#"+e.colour:"unset"},icon:e.icon,text:h.getAssetTypeLabel(e),value:e.name,data:e})).sort(h.sortByString(e=>e.text)),o=e(this.agentTypes),i=e(this.assetTypes),r=[];o.length>0&&r.push({heading:p.t("agents"),list:t`<or-mwc-list @or-mwc-list-changed="${e=>{1===e.detail.length&&this.onTypeChanged(!0,e.detail[0])}}" .listItems="${o}" id="agent-list"></or-mwc-list>`}),i.length>0&&r.push({heading:p.t("assets"),list:t`<or-mwc-list @or-mwc-list-changed="${e=>{1===e.detail.length&&this.onTypeChanged(!1,e.detail[0])}}" .listItems="${i}" id="asset-list"></or-mwc-list>`});let s=this.parent?this.parent.name+" ("+this.parent.id+")":p.t("none");return t`
|
|
101
|
+
<div class="col" style="height: 100%;">
|
|
102
|
+
<form id="mdc-dialog-form-add" class="row">
|
|
103
|
+
<div id="type-list" class="col">
|
|
104
|
+
${d(r)}
|
|
105
|
+
</div>
|
|
106
|
+
<div id="asset-type-option-container" class="col">
|
|
107
|
+
${!this.selectedType?t`<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`:this.getTypeTemplate(this.selectedType,s)}
|
|
108
|
+
</div>
|
|
109
|
+
${!this.showParentAssetSelector?t``:t`<or-asset-tree id="parent-selector" class="col" .showDeselectBtn="${!1}" .showSortBtn="${!1}" selectedNodes readonly></or-asset-tree>`}
|
|
110
|
+
</form>
|
|
111
|
+
</div>
|
|
112
|
+
`}getTypeTemplate(e,o){var i,r;if(!e.name)return!1;let s=n.getAssetTypeInfo(e.name),a=null==(i=null==s?void 0:s.attributeDescriptors)?void 0:i.filter(e=>!e.optional),l=null==(r=null==s?void 0:s.attributeDescriptors)?void 0:r.filter(e=>!!e.optional);return t`
|
|
113
|
+
<div id="type-title">
|
|
114
|
+
<or-icon style="--or-icon-fill: ${e.colour?"#"+e.colour:"unset"}" id="type-icon" .icon="${e.icon}"></or-icon>
|
|
115
|
+
<or-translate id="type-description" .value="${h.getAssetTypeLabel(e)}"></or-translate>
|
|
116
|
+
</div>
|
|
117
|
+
<div id="name-wrapper">
|
|
118
|
+
<or-mwc-input id="name-input" .type="${g.TEXT}" min="1" max="1023" required .label="${p.t("name")}" .value="${this.name}" @or-mwc-input-changed="${e=>this.onNameChanged(e.detail.value)}"></or-mwc-input>
|
|
119
|
+
<div id="parent-wrapper">
|
|
120
|
+
<or-mwc-input id="parent" .type="${g.TEXT}" readonly .label="${p.t("parent")}" .value="${o}" @click="${()=>this._onToggleParentAssetSelector()}"></or-mwc-input>
|
|
121
|
+
<or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${g.BUTTON}" icon="close" @or-mwc-input-changed="${()=>this._onDeselectClicked()}"></or-mwc-input>
|
|
122
|
+
<or-mwc-input id="toggle-parent-selector" icon="${this.showParentAssetSelector?"pencil-off":"pencil"}" type="${g.BUTTON}" @or-mwc-input-changed="${()=>this._onToggleParentAssetSelector()}"></or-mwc-input>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
${!a?t``:t`
|
|
127
|
+
<div>
|
|
128
|
+
<div class="heading">${p.t("attribute_plural")}</div>
|
|
129
|
+
<div style="display: grid">
|
|
130
|
+
${a.sort(h.sortByString(e=>e.name)).map(e=>t`
|
|
131
|
+
<or-mwc-input .type="${g.CHECKBOX}" .label="${h.getAttributeLabel(void 0,e,void 0,!0)}"
|
|
132
|
+
.disabled="${!0}" .value="${!0}"></or-mwc-input>
|
|
133
|
+
`)}
|
|
134
|
+
</div>
|
|
135
|
+
`}
|
|
136
|
+
|
|
137
|
+
${!l?t``:t`
|
|
138
|
+
<div>
|
|
139
|
+
<div class="heading">${p.t("optional_attributes")}</div>
|
|
140
|
+
<div style="display: grid">
|
|
141
|
+
${l.sort(h.sortByString(e=>e.name)).map(e=>t`
|
|
142
|
+
<or-mwc-input .type="${g.CHECKBOX}" .label="${h.getAttributeLabel(void 0,e,void 0,!0)}"
|
|
143
|
+
.value="${this.selectedAttributes.find(t=>t===e)}"
|
|
144
|
+
@or-mwc-input-changed="${t=>t.detail.value?this.selectedAttributes.push(e):this.selectedAttributes.splice(this.selectedAttributes.findIndex(t=>t===e),1)}"></or-mwc-input>
|
|
145
|
+
`)}
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
`}
|
|
149
|
+
`}onNameChanged(e){this.name=e,this.onModified()}onTypeChanged(e,t){return __awaiter(this,void 0,void 0,function*(){yield this.updateComplete,this.selectedAttributes=[],this.selectedType=t.data;let o=e?this.assetList:this.agentList;o&&(o.values=void 0),this.onModified()})}onModified(){this.dispatchEvent(new OrAddChangedEvent({name:this.name,descriptor:this.selectedType}))}_onToggleParentAssetSelector(){this.showParentAssetSelector=!this.showParentAssetSelector}_onDeselectClicked(){this.parent=void 0}};__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"config",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"agentTypes",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"assetTypes",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"parent",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"selectedType",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"selectedAttributes",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"showParentAssetSelector",void 0),__decorate([s({attribute:!1})],OrAddAssetDialog.prototype,"selectedChildAssetType",void 0),__decorate([a("#name-input")],OrAddAssetDialog.prototype,"nameInput",void 0),__decorate([a("#agent-list")],OrAddAssetDialog.prototype,"agentList",void 0),__decorate([a("#asset-list")],OrAddAssetDialog.prototype,"assetList",void 0),__decorate([a("#parent-asset-list")],OrAddAssetDialog.prototype,"parentAssetList",void 0),OrAddAssetDialog=__decorate([r("or-add-asset-dialog")],OrAddAssetDialog);export{OrAddAssetDialog};
|