@openremote/or-asset-tree 1.8.0-snapshot.20250723203453 → 1.8.0-snapshot.20250725070921

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/lib/index.d.ts CHANGED
@@ -114,9 +114,9 @@ declare global {
114
114
  export declare const getAssetTypes: () => Promise<string[] | undefined>;
115
115
  declare const OrAssetTree_base: (new (...args: any[]) => {
116
116
  _connectRequested: boolean;
117
- _subscriptionIds?: string[] | undefined;
118
- _assetIds?: string[] | undefined;
119
- _attributeRefs?: import("@openremote/model").AttributeRef[] | undefined;
117
+ _subscriptionIds?: string[];
118
+ _assetIds?: string[];
119
+ _attributeRefs?: import("@openremote/model").AttributeRef[];
120
120
  _status: import("@openremote/core").EventProviderStatus;
121
121
  _statusCallback: (status: import("@openremote/core").EventProviderStatus) => void;
122
122
  connectedCallback(): void;
@@ -138,7 +138,7 @@ declare const OrAssetTree_base: (new (...args: any[]) => {
138
138
  onEventsConnect(): void;
139
139
  onEventsDisconnect(): void;
140
140
  _onEvent(event: SharedEvent): void;
141
- requestUpdate(name?: PropertyKey | undefined, oldValue?: unknown): void;
141
+ requestUpdate(name?: PropertyKey, oldValue?: unknown): void;
142
142
  readonly isConnected: boolean;
143
143
  }) & typeof LitElement;
144
144
  export declare class OrAssetTree extends OrAssetTree_base {
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var __decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length,n=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,i);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(a<3?r(n):a>3?r(t,s,n):r(t,s))||n);return a>3&&n&&Object.defineProperty(t,s,n),n},__awaiter=this&&this.__awaiter||function(e,t,s,i){return new(s||(s=Promise))((function(r,a){function n(e){try{d(i.next(e))}catch(e){a(e)}}function o(e){try{d(i.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(n,o)}d((i=i.apply(e,t||[])).next())}))},OrAssetTree_1,FilterElementType;import{html,LitElement}from"lit";import{customElement,property,query,state}from"lit/decorators.js";import"@openremote/or-mwc-components/or-mwc-input";import{InputType}from"@openremote/or-mwc-components/or-mwc-input";import"@openremote/or-icon";import{AssetModelUtil}from"@openremote/model";import"@openremote/or-translate";import{style}from"./style";import manager,{subscribe,Util}from"@openremote/core";import Qs from"qs";import{getAssetDescriptorIconTemplate}from"@openremote/or-icon";import"@openremote/or-mwc-components/or-mwc-menu";import{getContentWithMenuTemplate}from"@openremote/or-mwc-components/or-mwc-menu";import"@openremote/or-mwc-components/or-mwc-list";import{i18next}from"@openremote/or-translate";import"@openremote/or-mwc-components/or-mwc-dialog";import{OrMwcDialog,showDialog,showErrorDialog,showOkCancelDialog}from"@openremote/or-mwc-components/or-mwc-dialog";import"./or-add-asset-dialog";import{showSnackbar}from"@openremote/or-mwc-components/or-mwc-snackbar";import{when}from"lit/directives/when.js";export{style};export class OrAssetTreeRequestSelectionEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestSelectionEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestSelectionEvent.NAME="or-asset-tree-request-selection";export class OrAssetTreeSelectionEvent extends CustomEvent{constructor(e){super(OrAssetTreeSelectionEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeSelectionEvent.NAME="or-asset-tree-selection";export class OrAssetTreeChangeParentEvent extends CustomEvent{constructor(e,t){super(OrAssetTreeChangeParentEvent.NAME,{bubbles:!0,composed:!0,detail:{parentId:e,assetIds:t}})}}OrAssetTreeChangeParentEvent.NAME="or-asset-tree-change-parent";export class OrAssetTreeToggleExpandEvent extends CustomEvent{constructor(e){super(OrAssetTreeToggleExpandEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeToggleExpandEvent.NAME="or-asset-tree-expand",function(e){e[e.SEARCH_FILTER=0]="SEARCH_FILTER",e[e.ASSET_TYPE=1]="ASSET_TYPE",e[e.ATTRIBUTE_NAME=2]="ATTRIBUTE_NAME",e[e.ATTRIBUTE_VALUE=3]="ATTRIBUTE_VALUE"}(FilterElementType||(FilterElementType={}));export class OrAssetTreeRequestAddEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestAddEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestAddEvent.NAME="or-asset-tree-request-add";export class OrAssetTreeAddEvent extends CustomEvent{constructor(e){super(OrAssetTreeAddEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeAddEvent.NAME="or-asset-tree-add";export class OrAssetTreeRequestDeleteEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestDeleteEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestDeleteEvent.NAME="or-asset-tree-request-delete";export class OrAssetTreeAssetEvent extends CustomEvent{constructor(e){super(OrAssetTreeAssetEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeAssetEvent.NAME="or-asset-tree-asset-event";export class OrAssetTreeFilter{constructor(){this.asset=void 0,this.assetType=[],this.attribute=[],this.attributeValue=[]}}export const getAssetTypes=()=>__awaiter(void 0,void 0,void 0,(function*(){const e=yield manager.rest.api.AssetResource.queryAssets({select:{attributes:[]},recursive:!0});if(e&&e.data)return e.data.map((e=>e.type))}));let OrAssetTree=OrAssetTree_1=class OrAssetTree extends(subscribe(manager)(LitElement)){constructor(){super(...arguments),this.readonly=!1,this.disabled=!1,this.disableSubscribe=!1,this.showDeselectBtn=!0,this.showSortBtn=!0,this.showFilter=!0,this.sortBy="name",this.expandAllNodes=!1,this.expandedIds=[],this.checkboxes=!1,this._loading=!1,this._connected=!1,this._selectedNodes=[],this._expandedNodes=[],this._filter=new OrAssetTreeFilter,this._searchInputTimer=void 0,this._filterSettingOpen=!1,this._assetTypes=[],this._uniqueAssetTypes=[],this._dragDropParentId=null,this._expandTimer=void 0,this._latestSelected=void 0,this.assetsChildren={}}static get styles(){return[style]}get selectedNodes(){return this._selectedNodes?[...this._selectedNodes]:[]}set selectedNodes(e){this.selectedIds=e.map((e=>e.asset.id))}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.requestUpdate()}refresh(){this._nodes=void 0}isAncestorSelected(e){if(!this.selectedIds||!e.parent)return!1;for(;e.parent;)if(e=e.parent,this.selectedIds.includes(e.asset.id))return!0;return!1}mapDescriptors(e,t){let s=e.map((e=>({styleMap:{"--or-icon-fill":e.colour?"#"+e.colour:"unset"},icon:e.icon,text:Util.getAssetTypeLabel(e),value:e.name,data:e}))).sort(Util.sortByString((e=>e.text)));return t&&s.splice(0,0,t),s}getSelectHeader(){return html`<or-mwc-input style="width:100%;" ?disabled="${this._loading}" type="${InputType.TEXT}" .label="${i18next.t("filter.assetTypeLabel")}" iconTrailing="menu-down" iconColor="rgba(0, 0, 0, 0.87)" icon="selection-ellipse" value="${i18next.t("filter.assetTypeNone")}"></or-mwc-input>`}getSelectedHeader(e){return html`<or-mwc-input style="width:100%;" ?disabled="${this._loading}" type="${InputType.TEXT}" .label="${i18next.t("filter.assetTypeLabel")}" .iconColor="${e.colour}" iconTrailing="menu-down" icon="${e.icon}" value="${Util.getAssetTypeLabel(e)}"></or-mwc-input>`}assetTypeSelect(){if(this._assetTypeFilter){const e=this._assetTypes.find((e=>e.name===this._assetTypeFilter));return e?this.getSelectedHeader(e):this.getSelectHeader()}return this.getSelectHeader()}atLeastOneNodeToBeShown(){var e;let t=!1;return null===(e=this._nodes)||void 0===e||e.forEach((e=>{e.hidden||(t=!0)})),t}render(){const e=this._canAdd();return html`
1
+ var OrAssetTree_1,FilterElementType,__decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length,d=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,t,s,i);else for(var n=e.length-1;n>=0;n--)(r=e[n])&&(d=(a<3?r(d):a>3?r(t,s,d):r(t,s))||d);return a>3&&d&&Object.defineProperty(t,s,d),d},__awaiter=this&&this.__awaiter||function(e,t,s,i){function r(e){return e instanceof s?e:new s(function(t){t(e)})}return new(s||(s=Promise))(function(s,a){function d(e){try{o(i.next(e))}catch(e){a(e)}}function n(e){try{o(i.throw(e))}catch(e){a(e)}}function o(e){e.done?s(e.value):r(e.value).then(d,n)}o((i=i.apply(e,t||[])).next())})};import{html,LitElement}from"lit";import{customElement,property,query,state}from"lit/decorators.js";import"@openremote/or-mwc-components/or-mwc-input";import{InputType}from"@openremote/or-mwc-components/or-mwc-input";import"@openremote/or-icon";import{AssetModelUtil}from"@openremote/model";import"@openremote/or-translate";import{style}from"./style";import manager,{subscribe,Util}from"@openremote/core";import Qs from"qs";import{getAssetDescriptorIconTemplate}from"@openremote/or-icon";import"@openremote/or-mwc-components/or-mwc-menu";import{getContentWithMenuTemplate}from"@openremote/or-mwc-components/or-mwc-menu";import"@openremote/or-mwc-components/or-mwc-list";import{i18next}from"@openremote/or-translate";import"@openremote/or-mwc-components/or-mwc-dialog";import{OrMwcDialog,showDialog,showErrorDialog,showOkCancelDialog}from"@openremote/or-mwc-components/or-mwc-dialog";import"./or-add-asset-dialog";import{showSnackbar}from"@openremote/or-mwc-components/or-mwc-snackbar";import{when}from"lit/directives/when.js";export class OrAssetTreeRequestSelectionEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestSelectionEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestSelectionEvent.NAME="or-asset-tree-request-selection";export class OrAssetTreeSelectionEvent extends CustomEvent{constructor(e){super(OrAssetTreeSelectionEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeSelectionEvent.NAME="or-asset-tree-selection";export class OrAssetTreeChangeParentEvent extends CustomEvent{constructor(e,t){super(OrAssetTreeChangeParentEvent.NAME,{bubbles:!0,composed:!0,detail:{parentId:e,assetIds:t}})}}OrAssetTreeChangeParentEvent.NAME="or-asset-tree-change-parent";export class OrAssetTreeToggleExpandEvent extends CustomEvent{constructor(e){super(OrAssetTreeToggleExpandEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeToggleExpandEvent.NAME="or-asset-tree-expand",function(e){e[e.SEARCH_FILTER=0]="SEARCH_FILTER",e[e.ASSET_TYPE=1]="ASSET_TYPE",e[e.ATTRIBUTE_NAME=2]="ATTRIBUTE_NAME",e[e.ATTRIBUTE_VALUE=3]="ATTRIBUTE_VALUE"}(FilterElementType||(FilterElementType={}));export class OrAssetTreeRequestAddEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestAddEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestAddEvent.NAME="or-asset-tree-request-add";export class OrAssetTreeAddEvent extends CustomEvent{constructor(e){super(OrAssetTreeAddEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeAddEvent.NAME="or-asset-tree-add";export class OrAssetTreeRequestDeleteEvent extends CustomEvent{constructor(e){super(OrAssetTreeRequestDeleteEvent.NAME,{bubbles:!0,composed:!0,detail:{allow:!0,detail:e}})}}OrAssetTreeRequestDeleteEvent.NAME="or-asset-tree-request-delete";export class OrAssetTreeAssetEvent extends CustomEvent{constructor(e){super(OrAssetTreeAssetEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}OrAssetTreeAssetEvent.NAME="or-asset-tree-asset-event";export class OrAssetTreeFilter{constructor(){this.asset=void 0,this.assetType=[],this.attribute=[],this.attributeValue=[]}}export const getAssetTypes=()=>__awaiter(void 0,void 0,void 0,function*(){let e=yield manager.rest.api.AssetResource.queryAssets({select:{attributes:[]},recursive:!0});if(e&&e.data)return e.data.map(e=>e.type)});let OrAssetTree=OrAssetTree_1=class OrAssetTree extends subscribe(manager)(LitElement){constructor(){super(...arguments),this.readonly=!1,this.disabled=!1,this.disableSubscribe=!1,this.showDeselectBtn=!0,this.showSortBtn=!0,this.showFilter=!0,this.sortBy="name",this.expandAllNodes=!1,this.expandedIds=[],this.checkboxes=!1,this._loading=!1,this._connected=!1,this._selectedNodes=[],this._expandedNodes=[],this._filter=new OrAssetTreeFilter,this._searchInputTimer=void 0,this._filterSettingOpen=!1,this._assetTypes=[],this._uniqueAssetTypes=[],this._dragDropParentId=null,this._expandTimer=void 0,this._latestSelected=void 0,this.assetsChildren={}}static get styles(){return[style]}get selectedNodes(){return this._selectedNodes?[...this._selectedNodes]:[]}set selectedNodes(e){this.selectedIds=e.map(e=>e.asset.id)}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.requestUpdate()}refresh(){this._nodes=void 0}isAncestorSelected(e){if(!this.selectedIds||!e.parent)return!1;for(;e.parent;)if(e=e.parent,this.selectedIds.includes(e.asset.id))return!0;return!1}mapDescriptors(e,t){let s=e.map(e=>({styleMap:{"--or-icon-fill":e.colour?"#"+e.colour:"unset"},icon:e.icon,text:Util.getAssetTypeLabel(e),value:e.name,data:e})).sort(Util.sortByString(e=>e.text));return t&&s.splice(0,0,t),s}getSelectHeader(){return html`<or-mwc-input style="width:100%;" ?disabled="${this._loading}" type="${InputType.TEXT}" .label="${i18next.t("filter.assetTypeLabel")}" iconTrailing="menu-down" iconColor="rgba(0, 0, 0, 0.87)" icon="selection-ellipse" value="${i18next.t("filter.assetTypeNone")}"></or-mwc-input>`}getSelectedHeader(e){return html`<or-mwc-input style="width:100%;" ?disabled="${this._loading}" type="${InputType.TEXT}" .label="${i18next.t("filter.assetTypeLabel")}" .iconColor="${e.colour}" iconTrailing="menu-down" icon="${e.icon}" value="${Util.getAssetTypeLabel(e)}"></or-mwc-input>`}assetTypeSelect(){if(!this._assetTypeFilter)return this.getSelectHeader();{let e=this._assetTypes.find(e=>e.name===this._assetTypeFilter);return e?this.getSelectedHeader(e):this.getSelectHeader()}}atLeastOneNodeToBeShown(){var e;let t=!1;return null==(e=this._nodes)||e.forEach(e=>{e.hidden||(t=!0)}),t}render(){let e=this._canAdd();return html`
2
2
  <div id="header">
3
3
  <div id="title-container">
4
4
  <or-translate id="title" value="asset_plural"></or-translate>
@@ -10,11 +10,11 @@ var __decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length
10
10
  <or-mwc-input ?hidden="${this._isReadonly()||!this.selectedIds||0===this.selectedIds.length||this._gatewayDescendantIsSelected()}" type="${InputType.BUTTON}" icon="delete" title="${i18next.t("delete")}" @or-mwc-input-changed="${()=>this._onDeleteClicked()}"></or-mwc-input>
11
11
  <or-mwc-input ?hidden="${this._isReadonly()||!e}" type="${InputType.BUTTON}" icon="plus" title="${i18next.t("addAsset")}" @or-mwc-input-changed="${()=>this._onAddClicked()}"></or-mwc-input>
12
12
 
13
- ${getContentWithMenuTemplate(html`<or-mwc-input type="${InputType.BUTTON}" ?hidden="${!this.showSortBtn}" icon="sort-variant" title="${i18next.t("sort")}" ></or-mwc-input>`,["name","type","createdOn"].map((e=>({value:e,text:i18next.t(e)}))),this.sortBy,(e=>this._onSortClicked(e)))}
13
+ ${getContentWithMenuTemplate(html`<or-mwc-input type="${InputType.BUTTON}" ?hidden="${!this.showSortBtn}" icon="sort-variant" title="${i18next.t("sort")}" ></or-mwc-input>`,["name","type","createdOn"].map(e=>({value:e,text:i18next.t(e)})),this.sortBy,e=>this._onSortClicked(e))}
14
14
  </div>
15
15
  </div>
16
16
 
17
- ${when(this.showFilter,(()=>html`
17
+ ${when(this.showFilter,()=>html`
18
18
  <div id="asset-tree-filter">
19
19
  <or-mwc-input id="filterInput"
20
20
  ?disabled="${this._loading}"
@@ -26,11 +26,11 @@ var __decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length
26
26
  @input="${e=>{this._onFilterInputEvent(e)}}"
27
27
  @or-mwc-input-changed="${e=>{this._onFilterInput(e.detail.value||void 0,!0)}}">
28
28
  </or-mwc-input>
29
- <or-icon id="filterSettingsIcon" icon="${this._filterSettingOpen?"window-close":"tune"}" title="${i18next.t(this._filterSettingOpen?"filter.close":"filter.open")}" @click="${()=>{if(this._filterSettingOpen)this._filterSettingOpen=!1;else{if(this._filterSettingOpen=!0,0===this._assetTypes.length){const e=this._getAllowedChildTypes(this._selectedNodes[0]);this._assetTypes=e.filter((e=>"asset"===e.descriptorType))}this._filter.attribute.length>0&&(this._attributeNameFilter.value=this._filter.attribute[0]),this._filter.attributeValue.length>0&&this._filter.attribute.length>0&&(this._attributeValueFilter.disabled=!1,this._attributeValueFilter.value=this._filter.attributeValue[0]),this._filter.assetType.length>0?this._assetTypeFilter=this._filter.assetType[0]:this._assetTypeFilter=""}}}"></or-icon>
29
+ <or-icon id="filterSettingsIcon" icon="${this._filterSettingOpen?"window-close":"tune"}" title="${i18next.t(this._filterSettingOpen?"filter.close":"filter.open")}" @click="${()=>{if(this._filterSettingOpen)this._filterSettingOpen=!1;else{if(this._filterSettingOpen=!0,0===this._assetTypes.length){let e=this._getAllowedChildTypes(this._selectedNodes[0]);this._assetTypes=e.filter(e=>"asset"===e.descriptorType)}this._filter.attribute.length>0&&(this._attributeNameFilter.value=this._filter.attribute[0]),this._filter.attributeValue.length>0&&this._filter.attribute.length>0&&(this._attributeValueFilter.disabled=!1,this._attributeValueFilter.value=this._filter.attributeValue[0]),this._filter.assetType.length>0?this._assetTypeFilter=this._filter.assetType[0]:this._assetTypeFilter=""}}}"></or-icon>
30
30
  </div>
31
31
  <div id="asset-tree-filter-setting" class="${this._filterSettingOpen?"visible":""}">
32
32
  <div class="advanced-filter">
33
- ${this._assetTypes.length>0?getContentWithMenuTemplate(this.assetTypeSelect(),this.mapDescriptors(this._assetTypes,{text:i18next.t("filter.assetTypeMenuNone"),value:"",icon:"selection-ellipse"}),void 0,(e=>{this._assetTypeFilter=e}),void 0,!1,!0,!0):html``}
33
+ ${this._assetTypes.length>0?getContentWithMenuTemplate(this.assetTypeSelect(),this.mapDescriptors(this._assetTypes,{text:i18next.t("filter.assetTypeMenuNone"),value:"",icon:"selection-ellipse"}),void 0,e=>{this._assetTypeFilter=e},void 0,!1,!0,!0):html``}
34
34
  <or-mwc-input id="attributeNameFilter" .label="${i18next.t("filter.attributeLabel")}"
35
35
 
36
36
  .type="${InputType.TEXT}"
@@ -49,43 +49,43 @@ var __decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length
49
49
  </div>
50
50
  </div>
51
51
  </div>
52
- `))}
52
+ `)}
53
53
 
54
- ${this._nodes?0!==this._nodes.length&&this.atLeastOneNodeToBeShown()?html`
54
+ ${!this._nodes?html`
55
+ <span id="loading"><or-translate value="loading"></or-translate></span>`:0===this._nodes.length||!this.atLeastOneNodeToBeShown()?html`<span id="noAssetsFound"><or-translate value="noAssetsFound"></or-translate></span>`:html`
55
56
  <div id="list-container">
56
57
  <ol id="list">
57
- ${this._nodes.map((e=>this._treeNodeTemplate(e,0))).filter((e=>!!e))}
58
+ ${this._nodes.map(e=>this._treeNodeTemplate(e,0)).filter(e=>!!e)}
58
59
  <li class="asset-list-element">
59
60
  <div class="end-element" node-asset-id="${""}" @dragleave=${e=>{this._onDragLeave(e)}} @dragenter="${e=>this._onDragEnter(e)}" @dragend="${e=>this._onDragEnd(e)}" @dragover="${e=>this._onDragOver(e)}"></div>
60
61
  </li>
61
62
  </ol>
62
63
  </div>
63
- `:html`<span id="noAssetsFound"><or-translate value="noAssetsFound"></or-translate></span>`:html`
64
- <span id="loading"><or-translate value="loading"></or-translate></span>`}
64
+ `}
65
65
 
66
66
  <div id="footer">
67
67
 
68
68
  </div>
69
- `}_isReadonly(){return this.readonly||!manager.hasRole("write:assets")}shouldUpdate(e){const t=super.shouldUpdate(e);return(e.has("assets")||e.has("rootAssets")||e.has("rootAssetIds"))&&(this._nodes=void 0),this._nodes?(e.has("selectedIds")&&(Util.objectsEqual(e.get("selectedIds"),this.selectedIds)||this._updateSelectedNodes()),e.has("sortBy")&&this._updateSort(this._nodes,this._getSortFunction()),e.has("disabledSubscribe")&&this.disableSubscribe&&this._removeEventSubscriptions(),t):(this._loadAssets(),!0)}_updateSelectedNodes(){const e=[],t=[];OrAssetTree_1._forEachNodeRecursive(this._nodes,(s=>{if(this.selectedIds&&this.selectedIds.indexOf(s.asset.id)>=0){e.push(s.asset.id),t.push(s),s.selected=!0;let i=s.parent;for(;i;)i.expanded=!0,i=i.parent}else s.selected=!1;if(this.checkboxes){let t=s.parent;for(;t;){const s=[];OrAssetTree_1._forEachNodeRecursive(t.children,(e=>{s.push(e)})),t.someChildrenSelected=!1,t.allChildrenSelected=!1,s.every((t=>e.includes(t.asset.id)))?t.allChildrenSelected=!0:s.some((t=>e.includes(t.asset.id)))&&(t.someChildrenSelected=!0),t=t.parent}}})),this.selectedIds=e;const s=this._selectedNodes;this._selectedNodes=t,this.dispatchEvent(new OrAssetTreeSelectionEvent({oldNodes:s,newNodes:t}))}_updateSort(e,t){e&&(e.sort(t),e.forEach((e=>this._updateSort(e.children,t))))}_toggleExpander(e,t,s=!1){t&&t.expandable&&(t.expanded=!t.expanded,t.expanded?this._expandedNodes.push(t):this._expandedNodes=this._expandedNodes.filter((e=>e!==t)),e.parentElement.parentElement.parentElement.toggleAttribute("data-expanded"),s||this.dispatchEvent(new OrAssetTreeToggleExpandEvent({node:t})),this.requestUpdate())}_buildPaths(e){let t=[];return e.asset&&e.asset.id?(t.push(e.asset.id),e.children.length>0&&e.expanded&&e.children.forEach((e=>{t=t.concat(this._buildPaths(e))})),t):[]}_findNode(e,t){if(e.asset&&e.asset.id){if(e.asset.id===t)return e;if(e.children.length>0&&e.expanded){let s;return e.children.forEach((e=>{s||(s=this._findNode(e,t))})),s}}}_findNodeFromAssetId(e){if(this._nodes){let t;return this._nodes.forEach((s=>{t||(t=this._findNode(s,e))})),t}}_onNodeClicked(e,t){var s,i,r,a;if(e&&e.defaultPrevented)return;e&&e.preventDefault();const n=e&&e.target.className.indexOf("expander")>=0,o=e&&(null===(i=null===(s=e.target)||void 0===s?void 0:s.icon)||void 0===i?void 0:i.includes("checkbox-multiple"));if(n)this._toggleExpander(e.target,t);else{let s=!0;if(t&&this.config&&(null===(r=this.config.select)||void 0===r?void 0:r.types)&&(s=this.config.select.types.indexOf(t.asset.type)>=0),!s&&!o)return;let i=[];if(t){const s=this.selectedNodes.indexOf(t);let r=!0,n=!0;const d=!(this._isReadonly()||this.config&&this.config.select&&this.config.select.multiSelect);if((this.checkboxes||d&&e&&(e.ctrlKey||e.shiftKey||e.metaKey))&&(n=!1,s>=0&&this.selectedIds&&this.selectedIds.length>1&&(r=!1)),o){i=[...this.selectedNodes];const e=[];OrAssetTree_1._forEachNodeRecursive(t.children,(t=>{var s,i;let r=!0;t&&(null===(i=null===(s=this.config)||void 0===s?void 0:s.select)||void 0===i?void 0:i.types)&&(r=this.config.select.types.indexOf(t.asset.type)>=0),r&&e.push(t)})),i=t.allChildrenSelected?i.filter((t=>!e.map((e=>e.asset.id)).includes(t.asset.id))):i.concat(e)}else if(n)this._latestSelected=Object.assign({},t),i=[t];else if(r){if(s<0){if(e&&e.shiftKey){let e=[];if(null===(a=this._nodes)||void 0===a||a.forEach((t=>{e=e.concat(this._buildPaths(t))})),this._latestSelected&&this._latestSelected.asset&&this._latestSelected.asset.id&&t.asset&&t.asset.id){let s=this._latestSelected.asset.id,r=t.asset.id,a=e.findIndex((e=>e.includes(s))),n=e.findIndex((e=>e.includes(r))),o=-1,d=-1;a>n?(o=n,d=a):(o=a,d=n);let l=e.slice(o,d+1),c=[];l.forEach((e=>{let t=this._findNodeFromAssetId(e);t&&c.push(t)})),i=[...this.selectedNodes],i=i.concat(c)}}else i=[...this.selectedNodes],i.push(t);this._latestSelected=Object.assign({},t)}}else s>=0&&(i=[...this.selectedNodes],1===i.length&&(this._latestSelected=void 0),i.splice(s,1))}Util.dispatchCancellableEvent(this,new OrAssetTreeRequestSelectionEvent({oldNodes:this.selectedNodes,newNodes:i})).then((e=>{e.allow&&(this.selectedNodes=e.detail.newNodes)}))}}_onDeselectClicked(){this._onNodeClicked(null,null)}parseFromInputFilter(e){let t=this._filterInput.value;e&&(t=e);let s=new OrAssetTreeFilter;if(t){let e=t,i=t.match(/(attribute\:)(\"[^"]+\")\S*/g);i&&(i.length>0&&i.forEach(((t,i)=>{e=e.replace(t,"");const r=t.toString().indexOf("attribute:"),a=t.toString().substring(r+10+1,t.toString().length-1);s.attribute.push(a),s.attributeValue.push("")})),this._attributeValueFilter.disabled=!1),i=t.match(/(type\:)\S+/g),i&&i.length>0&&i.forEach(((t,i)=>{e=e.replace(t,"");const r=t.toString().indexOf("type:"),a=t.toString().substring(r+5);s.assetType.push(a)})),i=t.match(/(\"[^\"]+\")\:(([^\"\s]+)|(\"[^\"]+\"))/g),i&&i.length>0&&i.forEach(((t,i)=>{e=e.replace(t,"");const r=t.toString().indexOf('":');let a=t.toString().substring(r+2);const n=t.toString().substring(1,r);'"'===a[0]&&'"'===a[a.length-1]&&(a=a.substring(1,a.length-1)),s.attribute.push(n),s.attributeValue.push(a)})),s.asset=e&&e.length>0?e.trim():void 0}return s}formatFilter(e){let t=e.asset?e.asset:"",s=e.asset?" ":"",i=[];return e.assetType.length>0&&e.assetType.forEach((e=>{t+=s+"type:"+e,s=" "})),e.attribute.length>0&&e.attributeValue.length>0&&e.attributeValue.forEach(((r,a)=>{i.push(e.attribute[a]),t+=s+'"'+e.attribute[a]+'":'+r,s=" "})),e.attribute.length>0&&0===e.attributeValue.length&&e.attribute.forEach((e=>{i.includes(e)||(t+=s+'attribute:"'+e+'"',s=" ")})),t}_shouldEnableAttrTypeEvent(e){let t;e.composedPath()&&(t=e.composedPath()[0].value||void 0),this._shouldEnableAttrType(t)}_shouldEnableAttrType(e){this._attributeValueFilter.disabled=!e}applySettingFields(e){if(this._assetTypeFilter?e.assetType=[this._assetTypeFilter]:e.assetType=[],this._attributeNameFilter.value?e.attribute=[this._attributeNameFilter.value]:e.attribute=[],this._attributeNameFilter.value&&this._attributeValueFilter.value){let t=this._attributeValueFilter.value;t.includes(" ")&&(t='"'+t+'"'),e.attributeValue=[t]}else e.attributeValue=[];return e}_filterFromSettings(){let e=this.parseFromInputFilter(),t=this.applySettingFields(e);this._filter=t;let s=this.formatFilter(this._filter);this._filterInput.value=s,this._filterSettingOpen=!1,this._doFiltering()}_onFilterInputEvent(e){let t;e.composedPath()&&(t=e.composedPath()[0].value||void 0),this._onFilterInput(t,!1)}_onFilterInput(e,t){let s=this.parseFromInputFilter(e);Util.objectsEqual(this._filter,s,!0)||(this._filter=s,this._searchInputTimer&&clearTimeout(this._searchInputTimer),t?this._doFiltering():this._searchInputTimer=window.setTimeout((()=>{this._doFiltering()}),350))}_doFiltering(){return __awaiter(this,void 0,void 0,(function*(){if(this._searchInputTimer&&(clearTimeout(this._searchInputTimer),this._searchInputTimer=void 0),this.isConnected&&this._nodes){if(!(this._filter.asset||this._filter.attribute||this._filter.assetType||this._filter.attributeValue))return OrAssetTree_1._forEachNodeRecursive(this._nodes,(e=>{e.notMatchingFilter=!1,e.hidden=!1})),void this.requestUpdate("_nodes");if(this.disabled=!0,this._filter.asset||this._filter.assetType||this._filter.attribute){let e=!1;this._filter.attribute&&(e=!0),this.getMatcher(e).then((e=>{this._nodes&&(this._nodes.forEach((t=>{this.filterTreeNode(t,e)})),this.disabled=!1)}))}}}))}getMatcher(e){return e?this.getMatcherFromQuery():this.getSimpleNameMatcher()}getSimpleNameMatcher(){return __awaiter(this,void 0,void 0,(function*(){return e=>{let t=!0;return this._filter.asset&&(t=t&&e.name.toLowerCase().includes(this._filter.asset.toLowerCase())),this._filter.assetType.length>0&&(t=t&&e.type.toLowerCase()===this._filter.assetType[0].toLowerCase()),t}}))}getMatcherFromQuery(){return __awaiter(this,void 0,void 0,(function*(){let assetCond,attributeCond,assetTypeCond;this._filter.asset&&(assetCond=[{predicateType:"string",match:"CONTAINS",value:this._filter.asset,caseSensitive:!1}]),this._filter.assetType.length>0&&(assetTypeCond=this._filter.assetType),this._filter.attribute.length>0&&(attributeCond={operator:"AND",items:this._filter.attribute.map((e=>({name:{predicateType:"string",match:"EXACT",value:Util.sentenceCaseToCamelCase(e),caseSensitive:!1}})))});const query={select:{attributes:attributeCond?void 0:[]},names:assetCond,types:assetTypeCond,attributes:attributeCond};let response,foundAssetIds;try{response=yield manager.rest.api.AssetResource.queryAssets(query),foundAssetIds=response.data.map((e=>e.id))}catch(e){this._filter.assetType.forEach((e=>{-1===this._assetTypes.findIndex((t=>t.name===e))&&showSnackbar(void 0,"filter.assetTypeDoesNotExist","dismiss")})),foundAssetIds=[]}return asset=>{let attrValueCheck=!0;if(this._filter.attribute.length>0&&this._filter.attributeValue.length>0&&foundAssetIds.includes(asset.id)){let attributeVal=[];this._filter.attributeValue.forEach(((e,t)=>{e.length>0&&attributeVal.push([this._filter.attribute[t],e])}));let matchingAsset=response.data.find((e=>e.id===asset.id));if(matchingAsset&&matchingAsset.attributes)for(let attributeValIndex=0;attributeValIndex<attributeVal.length;attributeValIndex++){let currentAttributeVal=attributeVal[attributeValIndex],atLeastOneAttributeMatchValue=!1;Object.keys(matchingAsset.attributes).forEach((key=>{let attr=matchingAsset.attributes[key];if(attr.name.toLowerCase()===currentAttributeVal[0].toLowerCase()&&attr.value)switch(attr.type){case"number":case"integer":case"long":case"bigInteger":case"bigNumber":case"positiveInteger":case"negativeInteger":case"positiveNumber":case"negativeNumber":let value=currentAttributeVal[1];currentAttributeVal[1].startsWith("=")&&"="!==currentAttributeVal[1][1]&&(value="="+value),/^[0-9]+$/.test(currentAttributeVal[1])&&(value="=="+value);const resultNumberEval=eval(attr.value+value);resultNumberEval&&(atLeastOneAttributeMatchValue=!0);break;case"text":if(attr.value){let e=currentAttributeVal[1];const t="*";let s=e.replace(t,".*");s=s.replace(/"/g,"");let i=attr.value;-1!=i.toLowerCase().indexOf(s.toLowerCase())&&(atLeastOneAttributeMatchValue=!0)}}})),attrValueCheck=atLeastOneAttributeMatchValue}}return foundAssetIds.includes(asset.id)&&attrValueCheck}}))}isAnyFilter(){return void 0!==this._filter.asset||this._filter.assetType.length>0||this._filter.attribute.length>0}filterTreeNode(e,t,s=!1){let i=t(e.asset);e.notMatchingFilter=!i;let r=e.children.map((e=>this.filterTreeNode(e,t,i))).some((e=>e));return i=i||r,e.expanded=r&&e.children.length>0&&this.isAnyFilter(),e.hidden=!i&&!s,i}_onCopyClicked(){return __awaiter(this,void 0,void 0,(function*(){if(1===this._selectedNodes.length)try{const e=yield manager.rest.api.AssetResource.get(this._selectedNodes[0].asset.id);if(!e.data)throw new Error("API returned an invalid response when retrieving the source asset");const t=JSON.parse(JSON.stringify(e.data));t.name+=" copy",delete t.id,delete t.path,delete t.createdOn,delete t.version,Util.dispatchCancellableEvent(this,new OrAssetTreeRequestAddEvent({sourceAsset:this._selectedNodes[0].asset,asset:t})).then((e=>{e.allow&&this.dispatchEvent(new OrAssetTreeAddEvent(e.detail))}))}catch(e){console.error("Failed to copy asset",e),showErrorDialog("Failed to copy asset")}}))}_onAddClicked(){const e=this._getAllowedChildTypes(this._selectedNodes[0]),t=e.filter((e=>"agent"===e.descriptorType)),s=e.filter((e=>"asset"===e.descriptorType)),i=this._selectedNodes&&1===this._selectedNodes.length?this._selectedNodes[0].asset:void 0;let r;r=showDialog((new OrMwcDialog).setHeading(i18next.t("addAsset")).setContent(html`
70
- <or-add-asset-dialog id="add-panel" .config="${this.config}" .agentTypes="${t}" .assetTypes="${s}" .parent="${i}" @or-add-asset-changed="${e=>{const t=!!e.detail.name&&e.detail.name.trim().length>0&&e.detail.name.trim().length<1024;r.shadowRoot.getElementById("add-btn").disabled=!e.detail.descriptor||!t}}"></or-add-asset-dialog>
71
- `).setActions([{actionName:"cancel",content:"cancel"},{actionName:"add",content:html`<or-mwc-input id="add-btn" class="button" .type="${InputType.BUTTON}" label="add" disabled></or-mwc-input>`,action:()=>{const e=r.shadowRoot.getElementById("add-panel"),t=e.selectedType,s=e.selectedAttributes,i=e.name.trim(),a=e.parent;if(!t)return;const n={name:i,type:t.name,realm:manager.displayRealm},o=AssetModelUtil.getAssetTypeInfo(t.name);if(!o)return;o.attributeDescriptors&&(n.attributes={},o.attributeDescriptors.filter((e=>!e.optional)).forEach((e=>{n.attributes[e.name]={name:e.name,type:e.type,meta:e.meta?Object.assign({},e.meta):void 0}}))),s&&(null==s||s.forEach((e=>{n.attributes[e.name]={name:e.name,type:e.type,meta:e.meta?Object.assign({},e.meta):void 0}}))),this.selectedIds&&(n.parentId=a?a.id:void 0);const d={asset:n};Util.dispatchCancellableEvent(this,new OrAssetTreeRequestAddEvent(d)).then((e=>{e.allow&&this.dispatchEvent(new OrAssetTreeAddEvent(e.detail))}))}}]).setStyles(html`
69
+ `}_isReadonly(){return this.readonly||!manager.hasRole("write:assets")}shouldUpdate(e){let t=super.shouldUpdate(e);return((e.has("assets")||e.has("rootAssets")||e.has("rootAssetIds"))&&(this._nodes=void 0),this._nodes)?(e.has("selectedIds")&&!Util.objectsEqual(e.get("selectedIds"),this.selectedIds)&&this._updateSelectedNodes(),e.has("sortBy")&&this._updateSort(this._nodes,this._getSortFunction()),e.has("disabledSubscribe")&&this.disableSubscribe&&this._removeEventSubscriptions(),t):(this._loadAssets(),!0)}_updateSelectedNodes(){let e=[],t=[];OrAssetTree_1._forEachNodeRecursive(this._nodes,s=>{if(this.selectedIds&&this.selectedIds.indexOf(s.asset.id)>=0){e.push(s.asset.id),t.push(s),s.selected=!0;let i=s.parent;for(;i;)i.expanded=!0,i=i.parent}else s.selected=!1;if(this.checkboxes){let t=s.parent;for(;t;){let s=[];OrAssetTree_1._forEachNodeRecursive(t.children,e=>{s.push(e)}),t.someChildrenSelected=!1,t.allChildrenSelected=!1,s.every(t=>e.includes(t.asset.id))?t.allChildrenSelected=!0:s.some(t=>e.includes(t.asset.id))&&(t.someChildrenSelected=!0),t=t.parent}}}),this.selectedIds=e;let s=this._selectedNodes;this._selectedNodes=t,this.dispatchEvent(new OrAssetTreeSelectionEvent({oldNodes:s,newNodes:t}))}_updateSort(e,t){e&&(e.sort(t),e.forEach(e=>this._updateSort(e.children,t)))}_toggleExpander(e,t,s=!1){t&&t.expandable&&(t.expanded=!t.expanded,t.expanded?this._expandedNodes.push(t):this._expandedNodes=this._expandedNodes.filter(e=>e!==t),e.parentElement.parentElement.parentElement.toggleAttribute("data-expanded"),s||this.dispatchEvent(new OrAssetTreeToggleExpandEvent({node:t})),this.requestUpdate())}_buildPaths(e){let t=[];return e.asset&&e.asset.id?(t.push(e.asset.id),e.children.length>0&&e.expanded&&e.children.forEach(e=>{t=t.concat(this._buildPaths(e))}),t):[]}_findNode(e,t){if(e.asset&&e.asset.id){if(e.asset.id===t)return e;if(e.children.length>0&&e.expanded){let s;return e.children.forEach(e=>{s||(s=this._findNode(e,t))}),s}return}}_findNodeFromAssetId(e){if(this._nodes){let t;return this._nodes.forEach(s=>{t||(t=this._findNode(s,e))}),t}}_onNodeClicked(e,t){var s,i,r,a;if(e&&e.defaultPrevented)return;e&&e.preventDefault();let d=e&&e.target.className.indexOf("expander")>=0,n=e&&(null==(i=null==(s=e.target)?void 0:s.icon)?void 0:i.includes("checkbox-multiple"));if(d)this._toggleExpander(e.target,t);else{let s=!0;if(t&&this.config&&(null==(r=this.config.select)?void 0:r.types)&&(s=this.config.select.types.indexOf(t.asset.type)>=0),!s&&!n)return;let i=[];if(t){let s=this.selectedNodes.indexOf(t),r=!0,d=!0,o=!this._isReadonly()&&(!this.config||!this.config.select||!this.config.select.multiSelect);if((this.checkboxes||o&&e&&(e.ctrlKey||e.shiftKey||e.metaKey))&&(d=!1,s>=0&&this.selectedIds&&this.selectedIds.length>1&&(r=!1)),n){i=[...this.selectedNodes];let e=[];OrAssetTree_1._forEachNodeRecursive(t.children,t=>{var s,i;let r=!0;t&&(null==(i=null==(s=this.config)?void 0:s.select)?void 0:i.types)&&(r=this.config.select.types.indexOf(t.asset.type)>=0),r&&e.push(t)}),i=t.allChildrenSelected?i.filter(t=>!e.map(e=>e.asset.id).includes(t.asset.id)):i.concat(e)}else if(d)this._latestSelected=Object.assign({},t),i=[t];else if(r){if(s<0){if(e&&e.shiftKey){let e=[];if(null==(a=this._nodes)||a.forEach(t=>{e=e.concat(this._buildPaths(t))}),this._latestSelected&&this._latestSelected.asset&&this._latestSelected.asset.id&&t.asset&&t.asset.id){let s=this._latestSelected.asset.id,r=t.asset.id,a=e.findIndex(e=>e.includes(s)),d=e.findIndex(e=>e.includes(r)),n=-1,o=-1;a>d?(n=d,o=a):(n=a,o=d);let l=e.slice(n,o+1),h=[];l.forEach(e=>{let t=this._findNodeFromAssetId(e);t&&h.push(t)}),i=(i=[...this.selectedNodes]).concat(h)}}else(i=[...this.selectedNodes]).push(t);this._latestSelected=Object.assign({},t)}}else s>=0&&(1===(i=[...this.selectedNodes]).length&&(this._latestSelected=void 0),i.splice(s,1))}Util.dispatchCancellableEvent(this,new OrAssetTreeRequestSelectionEvent({oldNodes:this.selectedNodes,newNodes:i})).then(e=>{e.allow&&(this.selectedNodes=e.detail.newNodes)})}}_onDeselectClicked(){this._onNodeClicked(null,null)}parseFromInputFilter(e){let t=this._filterInput.value;e&&(t=e);let s=new OrAssetTreeFilter;if(t){let e=t,i=t.match(/(attribute\:)(\"[^"]+\")\S*/g);i&&(i.length>0&&i.forEach((t,i)=>{e=e.replace(t,"");let r=t.toString().indexOf("attribute:"),a=t.toString().substring(r+10+1,t.toString().length-1);s.attribute.push(a),s.attributeValue.push("")}),this._attributeValueFilter.disabled=!1),(i=t.match(/(type\:)\S+/g))&&i.length>0&&i.forEach((t,i)=>{e=e.replace(t,"");let r=t.toString().indexOf("type:"),a=t.toString().substring(r+5);s.assetType.push(a)}),(i=t.match(/(\"[^\"]+\")\:(([^\"\s]+)|(\"[^\"]+\"))/g))&&i.length>0&&i.forEach((t,i)=>{e=e.replace(t,"");let r=t.toString().indexOf('":'),a=t.toString().substring(r+2),d=t.toString().substring(1,r);'"'===a[0]&&'"'===a[a.length-1]&&(a=a.substring(1,a.length-1)),s.attribute.push(d),s.attributeValue.push(a)}),s.asset=e&&e.length>0?e.trim():void 0}return s}formatFilter(e){let t=e.asset?e.asset:"",s=e.asset?" ":"",i=[];return e.assetType.length>0&&e.assetType.forEach(e=>{t+=s+"type:"+e,s=" "}),e.attribute.length>0&&e.attributeValue.length>0&&e.attributeValue.forEach((r,a)=>{i.push(e.attribute[a]),t+=s+'"'+e.attribute[a]+'":'+r,s=" "}),e.attribute.length>0&&0===e.attributeValue.length&&e.attribute.forEach(e=>{i.includes(e)||(t+=s+'attribute:"'+e+'"',s=" ")}),t}_shouldEnableAttrTypeEvent(e){let t;e.composedPath()&&(t=e.composedPath()[0].value||void 0),this._shouldEnableAttrType(t)}_shouldEnableAttrType(e){e?this._attributeValueFilter.disabled=!1:this._attributeValueFilter.disabled=!0}applySettingFields(e){if(this._assetTypeFilter?e.assetType=[this._assetTypeFilter]:e.assetType=[],this._attributeNameFilter.value?e.attribute=[this._attributeNameFilter.value]:e.attribute=[],this._attributeNameFilter.value&&this._attributeValueFilter.value){let t=this._attributeValueFilter.value;t.includes(" ")&&(t='"'+t+'"'),e.attributeValue=[t]}else e.attributeValue=[];return e}_filterFromSettings(){let e=this.parseFromInputFilter(),t=this.applySettingFields(e);this._filter=t;let s=this.formatFilter(this._filter);this._filterInput.value=s,this._filterSettingOpen=!1,this._doFiltering()}_onFilterInputEvent(e){let t;e.composedPath()&&(t=e.composedPath()[0].value||void 0),this._onFilterInput(t,!1)}_onFilterInput(e,t){let s=this.parseFromInputFilter(e);Util.objectsEqual(this._filter,s,!0)||(this._filter=s,this._searchInputTimer&&clearTimeout(this._searchInputTimer),t?this._doFiltering():this._searchInputTimer=window.setTimeout(()=>{this._doFiltering()},350))}_doFiltering(){return __awaiter(this,void 0,void 0,function*(){if(this._searchInputTimer&&(clearTimeout(this._searchInputTimer),this._searchInputTimer=void 0),this.isConnected&&this._nodes){if(!this._filter.asset&&!this._filter.attribute&&!this._filter.assetType&&!this._filter.attributeValue){OrAssetTree_1._forEachNodeRecursive(this._nodes,e=>{e.notMatchingFilter=!1,e.hidden=!1}),this.requestUpdate("_nodes");return}if(this.disabled=!0,this._filter.asset||this._filter.assetType||this._filter.attribute){let e=!1;this._filter.attribute&&(e=!0),this.getMatcher(e).then(e=>{this._nodes&&(this._nodes.forEach(t=>{this.filterTreeNode(t,e)}),this.disabled=!1)})}}})}getMatcher(e){return e?this.getMatcherFromQuery():this.getSimpleNameMatcher()}getSimpleNameMatcher(){return __awaiter(this,void 0,void 0,function*(){return e=>{let t=!0;return this._filter.asset&&(t=t&&e.name.toLowerCase().includes(this._filter.asset.toLowerCase())),this._filter.assetType.length>0&&(t=t&&e.type.toLowerCase()===this._filter.assetType[0].toLowerCase()),t}})}getMatcherFromQuery(){return __awaiter(this,void 0,void 0,function*(){let response,foundAssetIds,assetCond,attributeCond,assetTypeCond;this._filter.asset&&(assetCond=[{predicateType:"string",match:"CONTAINS",value:this._filter.asset,caseSensitive:!1}]),this._filter.assetType.length>0&&(assetTypeCond=this._filter.assetType),this._filter.attribute.length>0&&(attributeCond={operator:"AND",items:this._filter.attribute.map(e=>({name:{predicateType:"string",match:"EXACT",value:Util.sentenceCaseToCamelCase(e),caseSensitive:!1}}))});let query={select:{attributes:attributeCond?void 0:[]},names:assetCond,types:assetTypeCond,attributes:attributeCond};try{foundAssetIds=(response=yield manager.rest.api.AssetResource.queryAssets(query)).data.map(e=>e.id)}catch(e){this._filter.assetType.forEach(e=>{-1===this._assetTypes.findIndex(t=>t.name===e)&&showSnackbar(void 0,"filter.assetTypeDoesNotExist","dismiss")}),foundAssetIds=[]}return asset=>{let attrValueCheck=!0;if(this._filter.attribute.length>0&&this._filter.attributeValue.length>0&&foundAssetIds.includes(asset.id)){let attributeVal=[];this._filter.attributeValue.forEach((e,t)=>{e.length>0&&attributeVal.push([this._filter.attribute[t],e])});let matchingAsset=response.data.find(e=>e.id===asset.id);if(matchingAsset&&matchingAsset.attributes)for(let attributeValIndex=0;attributeValIndex<attributeVal.length;attributeValIndex++){let currentAttributeVal=attributeVal[attributeValIndex],atLeastOneAttributeMatchValue=!1;Object.keys(matchingAsset.attributes).forEach(key=>{let attr=matchingAsset.attributes[key];if(attr.name.toLowerCase()===currentAttributeVal[0].toLowerCase()&&attr.value)switch(attr.type){case"number":case"integer":case"long":case"bigInteger":case"bigNumber":case"positiveInteger":case"negativeInteger":case"positiveNumber":case"negativeNumber":let value=currentAttributeVal[1];currentAttributeVal[1].startsWith("=")&&"="!==currentAttributeVal[1][1]&&(value="="+value),/^[0-9]+$/.test(currentAttributeVal[1])&&(value="=="+value);let resultNumberEval=eval(attr.value+value);resultNumberEval&&(atLeastOneAttributeMatchValue=!0);break;case"text":if(attr.value){let unparsedValue=currentAttributeVal[1],multicharString="*",parsedValue=unparsedValue.replace(multicharString,".*");parsedValue=parsedValue.replace(/"/g,""),-1!=attr.value.toLowerCase().indexOf(parsedValue.toLowerCase())&&(atLeastOneAttributeMatchValue=!0)}}}),attrValueCheck=atLeastOneAttributeMatchValue}}return foundAssetIds.includes(asset.id)&&attrValueCheck}})}isAnyFilter(){return void 0!==this._filter.asset||this._filter.assetType.length>0||this._filter.attribute.length>0}filterTreeNode(e,t,s=!1){let i=t(e.asset);e.notMatchingFilter=!i;let r=e.children.map(e=>this.filterTreeNode(e,t,i)).some(e=>e);return i=i||r,e.expanded=r&&e.children.length>0&&this.isAnyFilter(),e.hidden=!i&&!s,i}_onCopyClicked(){return __awaiter(this,void 0,void 0,function*(){if(1===this._selectedNodes.length)try{let e=yield manager.rest.api.AssetResource.get(this._selectedNodes[0].asset.id);if(!e.data)throw Error("API returned an invalid response when retrieving the source asset");let t=JSON.parse(JSON.stringify(e.data));t.name+=" copy",delete t.id,delete t.path,delete t.createdOn,delete t.version,Util.dispatchCancellableEvent(this,new OrAssetTreeRequestAddEvent({sourceAsset:this._selectedNodes[0].asset,asset:t})).then(e=>{e.allow&&this.dispatchEvent(new OrAssetTreeAddEvent(e.detail))})}catch(e){console.error("Failed to copy asset",e),showErrorDialog("Failed to copy asset")}})}_onAddClicked(){let e,t=this._getAllowedChildTypes(this._selectedNodes[0]),s=t.filter(e=>"agent"===e.descriptorType),i=t.filter(e=>"asset"===e.descriptorType),r=this._selectedNodes&&1===this._selectedNodes.length?this._selectedNodes[0].asset:void 0,a=t=>{let s=!!t.detail.name&&t.detail.name.trim().length>0&&t.detail.name.trim().length<1024;e.shadowRoot.getElementById("add-btn").disabled=!t.detail.descriptor||!s};e=showDialog(new OrMwcDialog().setHeading(i18next.t("addAsset")).setContent(html`
70
+ <or-add-asset-dialog id="add-panel" .config="${this.config}" .agentTypes="${s}" .assetTypes="${i}" .parent="${r}" @or-add-asset-changed="${a}"></or-add-asset-dialog>
71
+ `).setActions([{actionName:"cancel",content:"cancel"},{actionName:"add",content:html`<or-mwc-input id="add-btn" class="button" .type="${InputType.BUTTON}" label="add" disabled></or-mwc-input>`,action:()=>{let t=e.shadowRoot.getElementById("add-panel"),s=t.selectedType,i=t.selectedAttributes,r=t.name.trim(),a=t.parent;if(!s)return;let d={name:r,type:s.name,realm:manager.displayRealm},n=AssetModelUtil.getAssetTypeInfo(s.name);if(!n)return;n.attributeDescriptors&&(d.attributes={},n.attributeDescriptors.filter(e=>!e.optional).forEach(e=>{d.attributes[e.name]={name:e.name,type:e.type,meta:e.meta?Object.assign({},e.meta):void 0}})),i&&(null==i||i.forEach(e=>{d.attributes[e.name]={name:e.name,type:e.type,meta:e.meta?Object.assign({},e.meta):void 0}})),this.selectedIds&&(d.parentId=a?a.id:void 0);let o={asset:d};Util.dispatchCancellableEvent(this,new OrAssetTreeRequestAddEvent(o)).then(e=>{e.allow&&this.dispatchEvent(new OrAssetTreeAddEvent(e.detail))})}}]).setStyles(html`
72
72
  <style>
73
73
  .mdc-dialog__content {
74
74
  padding: 0 !important;
75
75
  }
76
76
  </style>
77
- `).setDismissAction(null))}_gatewayDescendantIsSelected(){return this._selectedNodes.some((e=>{var t;let s=null==e?void 0:e.parent;for(;s;){if("GatewayAsset"===(null===(t=s.asset)||void 0===t?void 0:t.type))return!0;s=s.parent}return!1}))}_onDeleteClicked(){this._selectedNodes.length>0&&Util.dispatchCancellableEvent(this,new OrAssetTreeRequestDeleteEvent(this._selectedNodes)).then((e=>{e.allow&&this._doDelete()}))}_onSortClicked(e){this.sortBy=e}_doDelete(){if(!this._selectedNodes||0===this._selectedNodes.length)return;const e=new Set,t=this._selectedNodes.filter((t=>{var s;return"GatewayAsset"!==(null===(s=t.asset)||void 0===s?void 0:s.type)||(e.add(t.asset),!1)}));OrAssetTree_1._forEachNodeRecursive(t,(t=>{var s;let i=t.parent,r=!0;for(;i&&r;)"GatewayAsset"===(null===(s=null==i?void 0:i.asset)||void 0===s?void 0:s.type)&&(r=!1),i=i.parent;r&&e.add(t.asset)}));const s=Array.from(e).map((e=>e.id)),i=Array.from(e).map((e=>e.name)),r=()=>{this.disabled=!0,manager.rest.api.AssetResource.delete({assetId:s},{paramsSerializer:e=>Qs.stringify(e,{arrayFormat:"repeat"})}).then((e=>{this.refresh(),this.disabled=!1,204!==e.status&&showErrorDialog(i18next.t("deleteAssetsFailed"))})).catch((e=>{this.refresh(),this.disabled=!1,showErrorDialog(i18next.t("deleteAssetsFailed"))}))};showOkCancelDialog(i18next.t("deleteAssets"),i18next.t("deleteAssetsConfirm",{assetNames:i.join(",\n- ")}),i18next.t("delete")).then((e=>{e&&r()}))}_canAdd(){var e;if(this._selectedNodes&&this._selectedNodes.length>1)return!1;const t=this._selectedNodes?this._selectedNodes[0]:void 0;return"GatewayAsset"!==(null===(e=null==t?void 0:t.asset)||void 0===e?void 0:e.type)&&!this._gatewayDescendantIsSelected()&&this._getAllowedChildTypes(t).length>0}_getAllowedChildTypes(e){let t,s;if(this.config&&this.config.add){if(this.config.add.typesProvider){const t=this.config.add.typesProvider(e);if(t)return t}if(this.config.add.typesParent){let i;!e&&this.config.add.typesParent.none?i=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(i=this.config.add.typesParent.assetTypes[e.asset.type]),i||(i=this.config.add.typesParent.default),i&&(t=i.include,s=i.exclude||[])}}return AssetModelUtil.getAssetDescriptors().filter((e=>(!t||t.some((t=>Util.stringMatch(t,e.name))))&&(!s||!s.some((t=>Util.stringMatch(t,e.name))))))}_getSortFunction(){return"createdOn"===this.sortBy?Util.sortByNumber((e=>e.asset[this.sortBy])):Util.sortByString((e=>e.asset[this.sortBy]))}_loadAssets(){const e=this._getSortFunction();if(this.assets)this._loading=!1,this._buildTreeNodes(this.assets,e);else{if(!this._connected)return;if(this._loading)return;if(this._loading=!0,this.dataProvider)this.dataProvider().then((t=>{this._loading=!1,this._buildTreeNodes(t,e)}));else{const t={realm:{name:manager.displayRealm},select:{attributes:[]}};this.assetIds?(t.ids=this.assetIds,t.recursive=!0):this.rootAssets?(t.ids=this.rootAssets.map((e=>e.id)),t.recursive=!0):this.rootAssetIds&&(t.ids=this.rootAssetIds,t.recursive=!0),this._sendEventWithReply({eventType:"read-assets",assetQuery:t}).then((t=>{this._loading=!1,this._buildTreeNodes(t.assets,e)}))}}}_addEventSubscriptions(){return __awaiter(this,void 0,void 0,(function*(){this.disableSubscribe||(this._subscriptionIds=[yield manager.getEventProvider().subscribeAssetEvents(void 0,!1,(e=>this._onEvent(e)))])}))}onEventsConnect(){this._connected=!0,this._loadAssets()}onEventsDisconnect(){this._connected=!1,this._nodes=void 0}getNodes(){return this._nodes||[]}_onEvent(e){if("assets"!==e.eventType){if("asset"===e.eventType){const t=e;if("READ"===t.cause)return;if("UPDATE"===t.cause&&!t.updatedProperties.includes("name")&&!t.updatedProperties.includes("parentId"))return;const s=[];"DELETE"!==t.cause&&s.push(t.asset),this._nodes&&OrAssetTree_1._forEachNodeRecursive(this._nodes,(e=>{e.asset.id!==t.asset.id&&s.push(e.asset)})),this._buildTreeNodes(s,this._getSortFunction()),this._filterInput.value&&this._doFiltering(),this.dispatchEvent(new OrAssetTreeAssetEvent(t))}}else{const t=e;this._buildTreeNodes(t.assets,this._getSortFunction())}}_buildTreeNodes(e,t){if(e&&0!==e.length){let s,i;manager.isRestrictedUser()&&e.forEach((t=>{if(t.parentId&&t.path&&void 0===e.find((e=>e.id===t.parentId))){let s=null;for(let i=0;i<t.path.length;i++){const r=t.path[i];t.id!==r&&void 0!==e.find((e=>e.id===r))&&(s=r)}t.reparentId=s}})),this.rootAssetIds?s=this.rootAssetIds:this.rootAssets&&(s=this.rootAssets.map((e=>e.id))),i=s?e.filter((e=>s.indexOf(e.id)>=0||null===e.reparentId)).map((e=>({asset:e}))):e.filter((e=>!e.parentId||null===e.reparentId)).map((e=>({asset:e}))),this.assetsChildren={},e.forEach((e=>{e.parentId&&(this.assetsChildren[e.parentId]||(this.assetsChildren[e.parentId]=[]),this.assetsChildren[e.parentId].push({asset:e})),e.reparentId&&(this.assetsChildren[e.reparentId]||(this.assetsChildren[e.reparentId]=[]),this.assetsChildren[e.reparentId].push({asset:e}))})),i.sort(t),i.forEach((s=>this._buildChildTreeNodes(s,e,t))),this._nodes=i;const r=[];this._expandedNodes.forEach((e=>{OrAssetTree_1._forEachNodeRecursive(this._nodes,(t=>{if(t.asset&&e&&e.asset&&t.asset.id===e.asset.id){t.expanded=!0,r.push(t);let e=t.parent;for(;e;)e.expanded=!0,e=e.parent,r.indexOf(e)<0&&r.push(e)}}))})),this._expandedNodes=r}else this._nodes=[];this.selectedIds&&this.selectedIds.length>0&&this._updateSelectedNodes(),this.expandAllNodes&&OrAssetTree_1._forEachNodeRecursive(this._nodes,(e=>{e.children&&e.children.length>0&&(e.expanded=!0)}))}_buildChildTreeNodes(e,t,s){let i=this.assetsChildren[e.asset.id];e.children=i?i.sort(s):[],e.children.length>0&&(e.expandable=!0),e.children.forEach((i=>{i.parent=e,this._buildChildTreeNodes(i,t,s)}))}_onDragStart(e){this._dragDropParentId=null;let t=e.currentTarget.getAttribute("node-asset-id");this.selectedIds||(this.selectedIds=[]),t&&this.selectedIds&&!this.selectedIds.includes(t)&&(e.ctrlKey||e.shiftKey||(this.selectedIds=[]),this.selectedIds.push(t))}_onDragEnd(e){const t=e.x,s=e.y;if(null!==this.shadowRoot){let e=this.shadowRoot.getElementById("list");if(e){const i=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,a=e.getBoundingClientRect().left,n=e.getBoundingClientRect().right;if(t<a||t>n||s>r||s<i)return}}this.selectedIds&&this.dispatchEvent(new OrAssetTreeChangeParentEvent(this._dragDropParentId?this._dragDropParentId:void 0,this.selectedIds))}isExpandable(e){return!(!this._nodes||!this.shadowRoot)&&!!this.shadowRoot.querySelector('[node-asset-id="'+e+'"] > .node-name > [data-expandable]')}_onDragOver(e){let t=e.currentTarget;t.classList.add("over");let s=t.getAttribute("node-asset-id");s&&this.isExpandable(s)&&!this._expandTimer&&(this._expandTimer=window.setTimeout((()=>{this.expandNode(s)}),1e3))}expandNode(e){var t;if(this.shadowRoot&&e&&e===this._dragDropParentId){const s=this._findNodeFromAssetId(e);let i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[node-asset-id="'+e+'"]');i&&s&&!s.expanded&&this._toggleExpander(i.firstElementChild.firstElementChild,s,!0)}}_onDragEnter(e){let t=e.currentTarget;t.classList.add("over");let s=t.getAttribute("node-asset-id");this._dragDropParentId=s}_onDragLeave(e){e.currentTarget.classList.remove("over"),clearTimeout(this._expandTimer),this._expandTimer=void 0}_treeNodeTemplate(e,t){const s=AssetModelUtil.getAssetDescriptor(e.asset.type);let i;if(i=e.allChildrenSelected?"checkbox-multiple-marked":e.someChildrenSelected?"checkbox-multiple-marked-outline":"checkbox-multiple-blank-outline",e.hidden)return html``;let r=!1;return e.asset&&e.notMatchingFilter&&(r=!0),e.expanded&&0===e.children.length&&(e.expanded=!1),this.expandedIds&&-1!==this.expandedIds.findIndex((t=>t===e.asset.id))&&(e.expanded=!0),html`
77
+ `).setDismissAction(null))}_gatewayDescendantIsSelected(){return this._selectedNodes.some(e=>{var t;let s=null==e?void 0:e.parent;for(;s;){if((null==(t=s.asset)?void 0:t.type)==="GatewayAsset")return!0;s=s.parent}return!1})}_onDeleteClicked(){this._selectedNodes.length>0&&Util.dispatchCancellableEvent(this,new OrAssetTreeRequestDeleteEvent(this._selectedNodes)).then(e=>{e.allow&&this._doDelete()})}_onSortClicked(e){this.sortBy=e}_doDelete(){if(!this._selectedNodes||0===this._selectedNodes.length)return;let e=new Set,t=this._selectedNodes.filter(t=>{var s;return(null==(s=t.asset)?void 0:s.type)!=="GatewayAsset"||(e.add(t.asset),!1)});OrAssetTree_1._forEachNodeRecursive(t,t=>{var s;let i=t.parent,r=!0;for(;i&&r;)"GatewayAsset"===(null==(s=null==i?void 0:i.asset)?void 0:s.type)&&(r=!1),i=i.parent;r&&e.add(t.asset)});let s=Array.from(e).map(e=>e.id),i=Array.from(e).map(e=>e.name),r=()=>{this.disabled=!0,manager.rest.api.AssetResource.delete({assetId:s},{paramsSerializer:e=>Qs.stringify(e,{arrayFormat:"repeat"})}).then(e=>{this.refresh(),this.disabled=!1,204!==e.status&&showErrorDialog(i18next.t("deleteAssetsFailed"))}).catch(e=>{this.refresh(),this.disabled=!1,showErrorDialog(i18next.t("deleteAssetsFailed"))})};showOkCancelDialog(i18next.t("deleteAssets"),i18next.t("deleteAssetsConfirm",{assetNames:i.join(",\n- ")}),i18next.t("delete")).then(e=>{e&&r()})}_canAdd(){var e;if(this._selectedNodes&&this._selectedNodes.length>1)return!1;let t=this._selectedNodes?this._selectedNodes[0]:void 0;return!((null==(e=null==t?void 0:t.asset)?void 0:e.type)==="GatewayAsset"||this._gatewayDescendantIsSelected())&&this._getAllowedChildTypes(t).length>0}_getAllowedChildTypes(e){let t,s;if(this.config&&this.config.add){if(this.config.add.typesProvider){let t=this.config.add.typesProvider(e);if(t)return t}if(this.config.add.typesParent){let i;!e&&this.config.add.typesParent.none?i=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(i=this.config.add.typesParent.assetTypes[e.asset.type]),i||(i=this.config.add.typesParent.default),i&&(t=i.include,s=i.exclude||[])}}return AssetModelUtil.getAssetDescriptors().filter(e=>(!t||t.some(t=>Util.stringMatch(t,e.name)))&&(!s||!s.some(t=>Util.stringMatch(t,e.name))))}_getSortFunction(){return"createdOn"===this.sortBy?Util.sortByNumber(e=>e.asset[this.sortBy]):Util.sortByString(e=>e.asset[this.sortBy])}_loadAssets(){let e=this._getSortFunction();if(this.assets)this._loading=!1,this._buildTreeNodes(this.assets,e);else{if(!this._connected||this._loading)return;if(this._loading=!0,this.dataProvider)this.dataProvider().then(t=>{this._loading=!1,this._buildTreeNodes(t,e)});else{let t={realm:{name:manager.displayRealm},select:{attributes:[]}};this.assetIds?(t.ids=this.assetIds,t.recursive=!0):this.rootAssets?(t.ids=this.rootAssets.map(e=>e.id),t.recursive=!0):this.rootAssetIds&&(t.ids=this.rootAssetIds,t.recursive=!0),this._sendEventWithReply({eventType:"read-assets",assetQuery:t}).then(t=>{this._loading=!1,this._buildTreeNodes(t.assets,e)})}}}_addEventSubscriptions(){return __awaiter(this,void 0,void 0,function*(){this.disableSubscribe||(this._subscriptionIds=[(yield manager.getEventProvider().subscribeAssetEvents(void 0,!1,e=>this._onEvent(e)))])})}onEventsConnect(){this._connected=!0,this._loadAssets()}onEventsDisconnect(){this._connected=!1,this._nodes=void 0}getNodes(){return this._nodes||[]}_onEvent(e){if("assets"===e.eventType){let t=e;this._buildTreeNodes(t.assets,this._getSortFunction());return}if("asset"===e.eventType){let t=e;if("READ"===t.cause||"UPDATE"===t.cause&&!(t.updatedProperties.includes("name")||t.updatedProperties.includes("parentId")))return;let s=[];"DELETE"!==t.cause&&s.push(t.asset),this._nodes&&OrAssetTree_1._forEachNodeRecursive(this._nodes,e=>{e.asset.id!==t.asset.id&&s.push(e.asset)}),this._buildTreeNodes(s,this._getSortFunction()),this._filterInput.value&&this._doFiltering(),this.dispatchEvent(new OrAssetTreeAssetEvent(t))}}_buildTreeNodes(e,t){if(e&&0!==e.length){let s,i;manager.isRestrictedUser()&&e.forEach(t=>{if(t.parentId&&t.path&&void 0===e.find(e=>e.id===t.parentId)){let s=null;for(let i=0;i<t.path.length;i++){let r=t.path[i];t.id!==r&&void 0!==e.find(e=>e.id===r)&&(s=r)}t.reparentId=s}}),this.rootAssetIds?s=this.rootAssetIds:this.rootAssets&&(s=this.rootAssets.map(e=>e.id)),i=s?e.filter(e=>s.indexOf(e.id)>=0||null===e.reparentId).map(e=>({asset:e})):e.filter(e=>!e.parentId||null===e.reparentId).map(e=>({asset:e})),this.assetsChildren={},e.forEach(e=>{e.parentId&&(this.assetsChildren[e.parentId]||(this.assetsChildren[e.parentId]=[]),this.assetsChildren[e.parentId].push({asset:e})),e.reparentId&&(this.assetsChildren[e.reparentId]||(this.assetsChildren[e.reparentId]=[]),this.assetsChildren[e.reparentId].push({asset:e}))}),i.sort(t),i.forEach(s=>this._buildChildTreeNodes(s,e,t)),this._nodes=i;let r=[];this._expandedNodes.forEach(e=>{OrAssetTree_1._forEachNodeRecursive(this._nodes,t=>{if(t.asset&&e&&e.asset&&t.asset.id===e.asset.id){t.expanded=!0,r.push(t);let e=t.parent;for(;e;)e.expanded=!0,e=e.parent,0>r.indexOf(e)&&r.push(e)}})}),this._expandedNodes=r}else this._nodes=[];this.selectedIds&&this.selectedIds.length>0&&this._updateSelectedNodes(),this.expandAllNodes&&OrAssetTree_1._forEachNodeRecursive(this._nodes,e=>{e.children&&e.children.length>0&&(e.expanded=!0)})}_buildChildTreeNodes(e,t,s){let i=this.assetsChildren[e.asset.id];e.children=i?i.sort(s):[],e.children.length>0&&(e.expandable=!0),e.children.forEach(i=>{i.parent=e,this._buildChildTreeNodes(i,t,s)})}_onDragStart(e){this._dragDropParentId=null;let t=e.currentTarget.getAttribute("node-asset-id");this.selectedIds||(this.selectedIds=[]),t&&this.selectedIds&&!this.selectedIds.includes(t)&&(e.ctrlKey||e.shiftKey||(this.selectedIds=[]),this.selectedIds.push(t))}_onDragEnd(e){let t=e.x,s=e.y;if(null!==this.shadowRoot){let e=this.shadowRoot.getElementById("list");if(e){let i=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,a=e.getBoundingClientRect().left,d=e.getBoundingClientRect().right;if(t<a||t>d||s>r||s<i)return}}this.selectedIds&&this.dispatchEvent(new OrAssetTreeChangeParentEvent(!this._dragDropParentId?void 0:this._dragDropParentId,this.selectedIds))}isExpandable(e){return!!(this._nodes&&this.shadowRoot&&this.shadowRoot.querySelector('[node-asset-id="'+e+'"] > .node-name > [data-expandable]'))||!1}_onDragOver(e){let t=e.currentTarget;t.classList.add("over");let s=t.getAttribute("node-asset-id");s&&this.isExpandable(s)&&!this._expandTimer&&(this._expandTimer=window.setTimeout(()=>{this.expandNode(s)},1e3))}expandNode(e){var t;if(this.shadowRoot&&e&&e===this._dragDropParentId){let s=this._findNodeFromAssetId(e),i=null==(t=this.shadowRoot)?void 0:t.querySelector('[node-asset-id="'+e+'"]');i&&s&&!s.expanded&&this._toggleExpander(i.firstElementChild.firstElementChild,s,!0)}}_onDragEnter(e){let t=e.currentTarget;t.classList.add("over");let s=t.getAttribute("node-asset-id");this._dragDropParentId=s}_onDragLeave(e){e.currentTarget.classList.remove("over"),clearTimeout(this._expandTimer),this._expandTimer=void 0}_treeNodeTemplate(e,t){let s,i=AssetModelUtil.getAssetDescriptor(e.asset.type);if(s=e.allChildrenSelected?"checkbox-multiple-marked":e.someChildrenSelected?"checkbox-multiple-marked-outline":"checkbox-multiple-blank-outline",e.hidden)return html``;let r=!1;return e.asset&&e.notMatchingFilter&&(r=!0),e.expanded&&0===e.children.length&&(e.expanded=!1),this.expandedIds&&-1!==this.expandedIds.findIndex(t=>t===e.asset.id)&&(e.expanded=!0),html`
78
78
  <li class="asset-list-element" ?data-selected="${e.selected}" ?data-expanded="${e.expanded}" @click="${t=>this._onNodeClicked(t,e)}">
79
79
  <div class="in-between-element" node-asset-id="${e.parent?e.parent.asset?e.parent.asset.id:"":void 0}" @dragleave=${e=>{this._onDragLeave(e)}} @dragenter="${e=>this._onDragEnter(e)}" @dragend="${e=>this._onDragEnd(e)}" @dragover="${e=>this._onDragOver(e)}"></div>
80
80
  <div class="node-container draggable" node-asset-id="${e.asset?e.asset.id:""}" draggable="${!this._isReadonly()}" @dragleave=${e=>{this._onDragLeave(e)}} @dragenter="${e=>this._onDragEnter(e)}" @dragstart="${e=>this._onDragStart(e)}" @dragend="${e=>this._onDragEnd(e)}" @dragover="${e=>this._onDragOver(e)}" style="padding-left: ${22*t}px">
81
81
  <div class="node-name">
82
82
  <div class="expander" ?data-expandable="${e.expandable}"></div>
83
- ${getAssetDescriptorIconTemplate(s,void 0,void 0,r?"d3d3d3":void 0)}
83
+ ${getAssetDescriptorIconTemplate(i,void 0,void 0,r?"d3d3d3":void 0)}
84
84
  <span style="color: ${r?"#d3d3d3;":""}">${e.asset.name}</span>
85
85
  ${this.checkboxes?html`
86
86
  <span class="mdc-list-item__graphic">
87
87
  ${e.expandable?html`<div class="mdc-checkbox">
88
- <or-icon class="mdc-checkbox--parent" icon="${i}"></or-icon>
88
+ <or-icon class="mdc-checkbox--parent" icon="${s}"></or-icon>
89
89
  </div>`:""}
90
90
  <div class="mdc-checkbox">
91
91
  ${e.selected?html`<or-icon icon="checkbox-marked"></or-icon>`:html`<or-icon icon="checkbox-blank-outline"></or-icon>`}
@@ -94,7 +94,7 @@ var __decorate=this&&this.__decorate||function(e,t,s,i){var r,a=arguments.length
94
94
  </div>
95
95
  </div>
96
96
  <ol>
97
- ${!e.children||e.expandable&&!e.expanded?"":e.children.map((e=>this._treeNodeTemplate(e,t+1))).filter((e=>!!e))}
97
+ ${!e.children||e.expandable&&!e.expanded?"":e.children.map(e=>this._treeNodeTemplate(e,t+1)).filter(e=>!!e)}
98
98
  </ol>
99
99
  </li>
100
- `}static _forEachNodeRecursive(e,t){e&&e.forEach((e=>{t(e),this._forEachNodeRecursive(e.children,t)}))}};__decorate([property({type:Array,reflect:!1})],OrAssetTree.prototype,"assets",void 0),__decorate([property({type:Object})],OrAssetTree.prototype,"assetInfos",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"_assetIdsOverride",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"rootAssets",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"rootAssetIds",void 0),__decorate([property({type:Object})],OrAssetTree.prototype,"dataProvider",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"readonly",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"disabled",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"disableSubscribe",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"selectedIds",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showDeselectBtn",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showSortBtn",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showFilter",void 0),__decorate([property({type:String})],OrAssetTree.prototype,"sortBy",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"expandAllNodes",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"expandedIds",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"checkboxes",void 0),__decorate([property({attribute:!1})],OrAssetTree.prototype,"_nodes",void 0),__decorate([state()],OrAssetTree.prototype,"_filter",void 0),__decorate([query("#clearIconContainer")],OrAssetTree.prototype,"_clearIconContainer",void 0),__decorate([query("#filterInput")],OrAssetTree.prototype,"_filterInput",void 0),__decorate([state()],OrAssetTree.prototype,"_filterSettingOpen",void 0),__decorate([state()],OrAssetTree.prototype,"_assetTypes",void 0),__decorate([query("#attributeNameFilter")],OrAssetTree.prototype,"_attributeNameFilter",void 0),__decorate([query("#attributeValueFilter")],OrAssetTree.prototype,"_attributeValueFilter",void 0),__decorate([state()],OrAssetTree.prototype,"_assetTypeFilter",void 0),OrAssetTree=OrAssetTree_1=__decorate([customElement("or-asset-tree")],OrAssetTree);export{OrAssetTree};
100
+ `}static _forEachNodeRecursive(e,t){e&&e.forEach(e=>{t(e),this._forEachNodeRecursive(e.children,t)})}};__decorate([property({type:Array,reflect:!1})],OrAssetTree.prototype,"assets",void 0),__decorate([property({type:Object})],OrAssetTree.prototype,"assetInfos",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"_assetIdsOverride",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"rootAssets",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"rootAssetIds",void 0),__decorate([property({type:Object})],OrAssetTree.prototype,"dataProvider",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"readonly",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"disabled",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"disableSubscribe",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"selectedIds",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showDeselectBtn",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showSortBtn",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"showFilter",void 0),__decorate([property({type:String})],OrAssetTree.prototype,"sortBy",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"expandAllNodes",void 0),__decorate([property({type:Array})],OrAssetTree.prototype,"expandedIds",void 0),__decorate([property({type:Boolean})],OrAssetTree.prototype,"checkboxes",void 0),__decorate([property({attribute:!1})],OrAssetTree.prototype,"_nodes",void 0),__decorate([state()],OrAssetTree.prototype,"_filter",void 0),__decorate([query("#clearIconContainer")],OrAssetTree.prototype,"_clearIconContainer",void 0),__decorate([query("#filterInput")],OrAssetTree.prototype,"_filterInput",void 0),__decorate([state()],OrAssetTree.prototype,"_filterSettingOpen",void 0),__decorate([state()],OrAssetTree.prototype,"_assetTypes",void 0),__decorate([query("#attributeNameFilter")],OrAssetTree.prototype,"_attributeNameFilter",void 0),__decorate([query("#attributeValueFilter")],OrAssetTree.prototype,"_attributeValueFilter",void 0),__decorate([state()],OrAssetTree.prototype,"_assetTypeFilter",void 0),OrAssetTree=OrAssetTree_1=__decorate([customElement("or-asset-tree")],OrAssetTree);export{style,OrAssetTree};
@@ -33,8 +33,8 @@ export declare class OrAddAssetDialog extends LitElement {
33
33
  protected parentAssetList?: OrMwcList;
34
34
  static get styles(): import("lit").CSSResult;
35
35
  constructor();
36
- protected render(): import("lit-html").TemplateResult<1>;
37
- protected getTypeTemplate(descriptor: AgentDescriptor | AssetDescriptor, parentStr: string): false | import("lit-html").TemplateResult<1>;
36
+ protected render(): import("lit").TemplateResult<1>;
37
+ protected getTypeTemplate(descriptor: AgentDescriptor | AssetDescriptor, parentStr: string): false | import("lit").TemplateResult<1>;
38
38
  protected onNameChanged(name: string): void;
39
39
  protected onTypeChanged(isAgent: boolean, listItem: ListItem): Promise<void>;
40
40
  protected onModified(): void;
@@ -1,7 +1,7 @@
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,t instanceof o?t:new o((function(e){e(t)}))).then(a,n)}l((i=i.apply(e,t||[])).next())}))};import{css,html,LitElement,unsafeCSS}from"lit";import{customElement,property,query}from"lit/decorators.js";import{AssetModelUtil}from"@openremote/model";import"@openremote/or-mwc-components/or-mwc-input";import{OrAssetTreeSelectionEvent}from"./index";import{createListGroup}from"@openremote/or-mwc-components/or-mwc-list";import{i18next}from"@openremote/or-translate";import{DefaultColor3,DefaultColor5,Util}from"@openremote/core";import{InputType}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 LitElement{static get styles(){return css`
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
2
  :host{
3
3
  border-style: solid;
4
- border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
4
+ border-color: var(--or-app-color5, ${i(m)});
5
5
  border-width: 1px 0;
6
6
  }
7
7
 
@@ -32,7 +32,7 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length
32
32
 
33
33
  #parent-selector {
34
34
  max-width: 250px;
35
- border-left: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
35
+ border-left: 1px solid var(--or-app-color5, ${i(m)});
36
36
  }
37
37
 
38
38
  #mdc-dialog-form-add {
@@ -64,7 +64,7 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length
64
64
  width: 260px;
65
65
  overflow: auto;
66
66
  text-transform: capitalize;
67
- border-right: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
67
+ border-right: 1px solid var(--or-app-color5, ${i(m)});
68
68
  }
69
69
 
70
70
  #type-title {
@@ -75,7 +75,7 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length
75
75
 
76
76
  #type-description {
77
77
  text-transform: capitalize;
78
- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
78
+ color: var(--or-app-color3, ${i(c)});
79
79
  margin-left: 10px;
80
80
  font-size: 18px;
81
81
  font-weight: bold;
@@ -88,7 +88,7 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length
88
88
  font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
89
89
  font-weight: bolder;
90
90
  line-height: 1em;
91
- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
91
+ color: var(--or-app-color3, ${i(c)});
92
92
  letter-spacing: 0.025em;
93
93
  font-size: 14px;
94
94
  margin: 20px 0 10px;
@@ -97,53 +97,53 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,s=arguments.length
97
97
  .mdc-list-group__subheader {
98
98
  margin: 20px 0 0 16px;
99
99
  }
100
- `}constructor(){super(),this.selectedAttributes=[],this.showParentAssetSelector=!1,this.selectedChildAssetType="",this.name="New Asset",this.addEventListener(OrAssetTreeSelectionEvent.NAME,(e=>{this.parent=e.detail.newNodes[0].asset}))}render(){const e=e=>e.map((e=>({styleMap:{"--or-icon-fill":e.colour?"#"+e.colour:"unset"},icon:e.icon,text:Util.getAssetTypeLabel(e),value:e.name,data:e}))).sort(Util.sortByString((e=>e.text))),t=e(this.agentTypes),o=e(this.assetTypes),i=[];t.length>0&&i.push({heading:i18next.t("agents"),list:html`<or-mwc-list @or-mwc-list-changed="${e=>{1===e.detail.length&&this.onTypeChanged(!0,e.detail[0])}}" .listItems="${t}" id="agent-list"></or-mwc-list>`}),o.length>0&&i.push({heading:i18next.t("assets"),list:html`<or-mwc-list @or-mwc-list-changed="${e=>{1===e.detail.length&&this.onTypeChanged(!1,e.detail[0])}}" .listItems="${o}" id="asset-list"></or-mwc-list>`});const r=this.parent?this.parent.name+" ("+this.parent.id+")":i18next.t("none");return html`
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
101
  <div class="col" style="height: 100%;">
102
102
  <form id="mdc-dialog-form-add" class="row">
103
103
  <div id="type-list" class="col">
104
- ${createListGroup(i)}
104
+ ${d(r)}
105
105
  </div>
106
106
  <div id="asset-type-option-container" class="col">
107
- ${this.selectedType?this.getTypeTemplate(this.selectedType,r):html`<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`}
107
+ ${!this.selectedType?t`<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`:this.getTypeTemplate(this.selectedType,s)}
108
108
  </div>
109
- ${this.showParentAssetSelector?html`<or-asset-tree id="parent-selector" class="col" .showDeselectBtn="${!1}" .showSortBtn="${!1}" selectedNodes readonly></or-asset-tree>`:html``}
109
+ ${!this.showParentAssetSelector?t``:t`<or-asset-tree id="parent-selector" class="col" .showDeselectBtn="${!1}" .showSortBtn="${!1}" selectedNodes readonly></or-asset-tree>`}
110
110
  </form>
111
111
  </div>
112
- `}getTypeTemplate(e,t){var o,i;if(!e.name)return!1;const r=AssetModelUtil.getAssetTypeInfo(e.name),s=null===(o=null==r?void 0:r.attributeDescriptors)||void 0===o?void 0:o.filter((e=>!e.optional)),a=null===(i=null==r?void 0:r.attributeDescriptors)||void 0===i?void 0:i.filter((e=>!!e.optional));return html`
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
113
  <div id="type-title">
114
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="${Util.getAssetTypeLabel(e)}"></or-translate>
115
+ <or-translate id="type-description" .value="${h.getAssetTypeLabel(e)}"></or-translate>
116
116
  </div>
117
117
  <div id="name-wrapper">
118
- <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>
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
119
  <div id="parent-wrapper">
120
- <or-mwc-input id="parent" .type="${InputType.TEXT}" readonly .label="${i18next.t("parent")}" .value="${t}" @click="${()=>this._onToggleParentAssetSelector()}"></or-mwc-input>
121
- <or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${InputType.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="${InputType.BUTTON}" @or-mwc-input-changed="${()=>this._onToggleParentAssetSelector()}"></or-mwc-input>
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
123
  </div>
124
124
  </div>
125
125
 
126
- ${s?html`
126
+ ${!a?t``:t`
127
127
  <div>
128
- <div class="heading">${i18next.t("attribute_plural")}</div>
128
+ <div class="heading">${p.t("attribute_plural")}</div>
129
129
  <div style="display: grid">
130
- ${s.sort(Util.sortByString((e=>e.name))).map((e=>html`
131
- <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(void 0,e,void 0,!0)}"
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
132
  .disabled="${!0}" .value="${!0}"></or-mwc-input>
133
- `))}
133
+ `)}
134
134
  </div>
135
- `:html``}
135
+ `}
136
136
 
137
- ${a?html`
137
+ ${!l?t``:t`
138
138
  <div>
139
- <div class="heading">${i18next.t("optional_attributes")}</div>
139
+ <div class="heading">${p.t("optional_attributes")}</div>
140
140
  <div style="display: grid">
141
- ${a.sort(Util.sortByString((e=>e.name))).map((e=>html`
142
- <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.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
- `))}
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
146
  </div>
147
147
  </div>
148
- `:html``}
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;const 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([property({attribute:!1})],OrAddAssetDialog.prototype,"config",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"agentTypes",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"assetTypes",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"parent",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"selectedType",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"selectedAttributes",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"showParentAssetSelector",void 0),__decorate([property({attribute:!1})],OrAddAssetDialog.prototype,"selectedChildAssetType",void 0),__decorate([query("#name-input")],OrAddAssetDialog.prototype,"nameInput",void 0),__decorate([query("#agent-list")],OrAddAssetDialog.prototype,"agentList",void 0),__decorate([query("#asset-list")],OrAddAssetDialog.prototype,"assetList",void 0),__decorate([query("#parent-asset-list")],OrAddAssetDialog.prototype,"parentAssetList",void 0),OrAddAssetDialog=__decorate([customElement("or-add-asset-dialog")],OrAddAssetDialog);export{OrAddAssetDialog};
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};
package/lib/style.js CHANGED
@@ -1,19 +1,19 @@
1
- import{css,unsafeCSS}from"lit";import{DefaultColor1,DefaultColor2,DefaultColor4,DefaultColor5,DefaultColor8}from"@openremote/core";import{mdiChevronRight}from"@mdi/js";import{mdiChevronDown}from"@mdi/js";export const style=css`
1
+ import{css as e,unsafeCSS as r}from"lit";import{DefaultColor1 as t,DefaultColor2 as o,DefaultColor4 as a,DefaultColor5 as n,DefaultColor8 as i}from"@openremote/core";import{mdiChevronRight as l}from"@mdi/js";import{mdiChevronDown as s}from"@mdi/js";export const style=e`
2
2
 
3
3
  :host {
4
- --internal-or-asset-tree-header-color: var(--or-asset-tree-header-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
5
- --internal-or-asset-tree-header-text-color: var(--or-asset-tree-header-text-color, var(--or-app-color8, ${unsafeCSS(DefaultColor8)}));
4
+ --internal-or-asset-tree-header-color: var(--or-asset-tree-header-color, var(--or-app-color4, ${r(a)}));
5
+ --internal-or-asset-tree-header-text-color: var(--or-asset-tree-header-text-color, var(--or-app-color8, ${r(i)}));
6
6
  --internal-or-asset-tree-header-menu-background-color: var(--or-asset-tree-header-menu-background-color, var(--internal-or-asset-tree-header-text-color));
7
7
  --internal-or-asset-tree-header-menu-text-color: var(--or-asset-tree-header-menu-text-color, inherit);
8
8
  --internal-or-asset-tree-header-height: var(--or-asset-tree-header-height, 48px);
9
- --internal-or-asset-tree-background-color: var(--or-asset-tree-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
9
+ --internal-or-asset-tree-background-color: var(--or-asset-tree-background-color, var(--or-app-color1, ${r(t)}));
10
10
  --internal-or-asset-tree-text-color: var(--or-asset-tree-text-color, inherit);
11
11
  --internal-or-asset-tree-item-height: var(--or-asset-tree-item-height, 24px);
12
12
  --internal-or-asset-tree-item-padding: var(--or-asset-tree-item-padding, 10px);
13
- --internal-or-asset-tree-selected-background-color: var(--or-asset-tree-selected-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
14
- --internal-or-asset-tree-selected-color: var(--or-asset-tree-selected-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
15
- --internal-or-asset-tree-button-color: var(--or-asset-tree-button-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
16
- --internal-or-asset-tree-line-color: var(--or-asset-tree-line-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
13
+ --internal-or-asset-tree-selected-background-color: var(--or-asset-tree-selected-background-color, var(--or-app-color2, ${r(o)}));
14
+ --internal-or-asset-tree-selected-color: var(--or-asset-tree-selected-color, var(--or-app-color4, ${r(a)}));
15
+ --internal-or-asset-tree-button-color: var(--or-asset-tree-button-color, var(--or-app-color4, ${r(a)}));
16
+ --internal-or-asset-tree-line-color: var(--or-asset-tree-line-color, var(--or-app-color5, ${r(n)}));
17
17
 
18
18
  display: flex;
19
19
  flex-direction: column;
@@ -50,7 +50,7 @@ import{css,unsafeCSS}from"lit";import{DefaultColor1,DefaultColor2,DefaultColor4,
50
50
  align-items: center;
51
51
  width: 100%;
52
52
  height: var(--internal-or-asset-tree-header-height);
53
- border-bottom: 1px solid ${unsafeCSS(DefaultColor5)};
53
+ border-bottom: 1px solid ${r(n)};
54
54
  z-index: 1000;
55
55
  line-height: var(--internal-or-asset-tree-header-height);
56
56
  color: var(--internal-or-asset-tree-header-text-color);
@@ -115,7 +115,7 @@ import{css,unsafeCSS}from"lit";import{DefaultColor1,DefaultColor2,DefaultColor4,
115
115
  }
116
116
 
117
117
  .asset-list-element .over {
118
- background-color: ${unsafeCSS(DefaultColor5)};
118
+ background-color: ${r(n)};
119
119
  }
120
120
 
121
121
  .in-between-element {
@@ -158,15 +158,15 @@ import{css,unsafeCSS}from"lit";import{DefaultColor1,DefaultColor2,DefaultColor4,
158
158
  }
159
159
 
160
160
  .expander[data-expandable] {
161
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='rgb(204, 204, 204)' viewBox='0 0 24 24'%3E%3Cpath d='${unsafeCSS(mdiChevronRight)}'/%3E%3C/svg%3E");
161
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='rgb(204, 204, 204)' viewBox='0 0 24 24'%3E%3Cpath d='${r(l)}'/%3E%3C/svg%3E");
162
162
  }
163
163
 
164
164
  .expander[data-expandable]:hover {
165
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${unsafeCSS(mdiChevronRight)}'/%3E%3C/svg%3E");
165
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${r(l)}'/%3E%3C/svg%3E");
166
166
  }
167
167
 
168
168
  li[data-expanded] > .node-container .expander {
169
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${unsafeCSS(mdiChevronDown)}'/%3E%3C/svg%3E") !important;
169
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${r(s)}'/%3E%3C/svg%3E") !important;
170
170
  }
171
171
 
172
172
  .node-name {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openremote/or-asset-tree",
3
- "version": "1.8.0-snapshot.20250723203453",
3
+ "version": "1.8.0-snapshot.20250725070921",
4
4
  "description": "OpenRemote Asset Tree",
5
5
  "customElements": "custom-elements.json",
6
6
  "main": "dist/umd/index.bundle.js",
@@ -13,23 +13,23 @@
13
13
  "scripts": {
14
14
  "analyze": "npx cem analyze --config ../custom-elements-manifest.config.mjs",
15
15
  "test": "echo \"No tests\" && exit 0",
16
- "prepack": "npx webpack"
16
+ "prepack": "npx rspack"
17
17
  },
18
18
  "author": "OpenRemote",
19
19
  "license": "AGPL-3.0-or-later",
20
20
  "dependencies": {
21
21
  "@mdi/js": "^5.9.55",
22
- "@openremote/core": "1.8.0-snapshot.20250723203453",
23
- "@openremote/model": "1.8.0-snapshot.20250723203453",
24
- "@openremote/or-icon": "1.8.0-snapshot.20250723203453",
25
- "@openremote/or-mwc-components": "1.8.0-snapshot.20250723203453",
26
- "@openremote/or-translate": "1.8.0-snapshot.20250723203453",
27
- "@openremote/rest": "1.8.0-snapshot.20250723203453",
22
+ "@openremote/core": "1.8.0-snapshot.20250725070921",
23
+ "@openremote/model": "1.8.0-snapshot.20250725070921",
24
+ "@openremote/or-icon": "1.8.0-snapshot.20250725070921",
25
+ "@openremote/or-mwc-components": "1.8.0-snapshot.20250725070921",
26
+ "@openremote/or-translate": "1.8.0-snapshot.20250725070921",
27
+ "@openremote/rest": "1.8.0-snapshot.20250725070921",
28
28
  "lit": "^2.0.2",
29
29
  "moment": "^2.29.4"
30
30
  },
31
31
  "devDependencies": {
32
- "@openremote/util": "1.8.0-snapshot.20250723203453"
32
+ "@openremote/util": "1.8.0-snapshot.20250725070921"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"