@openremote/or-asset-tree 1.35.0 → 1.35.1
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.
|
@@ -2617,7 +2617,7 @@ var ORAssetTree;(()=>{var e={3260(e){"use strict";let t=(async function(){}).con
|
|
|
2617
2617
|
</ul>
|
|
2618
2618
|
`,"delete","cancel")}
|
|
2619
2619
|
</or-vaadin-confirm-dialog>
|
|
2620
|
-
`)}_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,i;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 n;!e&&this.config.add.typesParent.none?n=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(n=this.config.add.typesParent.assetTypes[e.asset.type]),n||(n=this.config.add.typesParent.default),n&&(t=n.include,i=n.exclude||[])}}return rp.AssetModelUtil.getAssetDescriptors().filter(e=>(!t||t.some(t=>ro.Util.stringMatch(t,e.name)))&&(!i||!i.some(t=>ro.Util.stringMatch(t,e.name))))}_getSortFunction(){return"createdOn"===this.sortBy?ro.Util.sortByNumber(e=>e.asset[this.sortBy]):ro.Util.sortByString(e=>e.asset[this.sortBy])}_getOrderBy(e){switch(e){case"createdOn":return"CREATED_ON";case"type":return"ASSET_TYPE";default:return"NAME"}}_loadAssets(e){return o0(this,arguments,void 0,function*(e,t=0,i){var n;if(console.debug(`Loading assets with ${e?`parent ${e}`:"no parents"}...`),this.assets){console.debug("Assets already pre-loaded using HTML attributes; reusing them to construct the tree UI..."),this._loading=!1,this._buildTreeNodes(this.assets);return}if(!this._connected)throw Error("Not connected to the server; cannot load assets.");if(this._loading)throw Error("Already loading assets for asset tree; ignoring request.");if(this._loading=!0,this.dataProvider)this.dataProvider(t,this.queryLimit,e).then(e=>{this._loading=!1,this._buildTreeNodes(e),this.isFilterEmpty()||this._doFiltering()});else{let r={realm:{name:rs().displayRealm},parents:e?[{id:e}]:[],select:{attributes:[]},orderBy:{property:this._getOrderBy(this.sortBy)},offset:t,limit:Math.max(this.queryLimit,1)};this.assetIds?(r.ids=this.assetIds,r.recursive=!0):this.rootAssets?(r.ids=this.rootAssets.map(e=>e.id),r.recursive=!0):this.rootAssetIds&&(r.ids=this.rootAssetIds,r.recursive=!0);try{let e=null!=(n=this.paginationThreshold)?n:1e3;(yield rs().rest.api.AssetResource.queryCount(Object.assign(Object.assign({},r),{limit:e,parents:void 0}))).data<e&&(r.parents=void 0,r.limit=e)}catch(e){console.warn("Failed to query asset count, falling back to default pagination.",e)}let o=this._sendEventWithReply({eventType:"read-asset-tree",assetQuery:r});return o.then(t=>{var n,
|
|
2620
|
+
`)}_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,i;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 n;!e&&this.config.add.typesParent.none?n=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(n=this.config.add.typesParent.assetTypes[e.asset.type]),n||(n=this.config.add.typesParent.default),n&&(t=n.include,i=n.exclude||[])}}return rp.AssetModelUtil.getAssetDescriptors().filter(e=>(!t||t.some(t=>ro.Util.stringMatch(t,e.name)))&&(!i||!i.some(t=>ro.Util.stringMatch(t,e.name))))}_getSortFunction(){return"createdOn"===this.sortBy?ro.Util.sortByNumber(e=>e.asset[this.sortBy]):ro.Util.sortByString(e=>e.asset[this.sortBy])}_getOrderBy(e){switch(e){case"createdOn":return"CREATED_ON";case"type":return"ASSET_TYPE";default:return"NAME"}}_loadAssets(e){return o0(this,arguments,void 0,function*(e,t=0,i){var n;if(console.debug(`Loading assets with ${e?`parent ${e}`:"no parents"}...`),this.assets){console.debug("Assets already pre-loaded using HTML attributes; reusing them to construct the tree UI..."),this._loading=!1,this._buildTreeNodes(this.assets);return}if(!this._connected)throw Error("Not connected to the server; cannot load assets.");if(this._loading)throw Error("Already loading assets for asset tree; ignoring request.");if(this._loading=!0,this.dataProvider)this.dataProvider(t,this.queryLimit,e).then(e=>{this._loading=!1,this._buildTreeNodes(e),this.isFilterEmpty()||this._doFiltering()});else{let r={realm:{name:rs().displayRealm},parents:e?[{id:e}]:[],select:{attributes:[]},orderBy:{property:this._getOrderBy(this.sortBy)},offset:t,limit:Math.max(this.queryLimit,1)};this.assetIds?(r.ids=this.assetIds,r.recursive=!0):this.rootAssets?(r.ids=this.rootAssets.map(e=>e.id),r.recursive=!0):this.rootAssetIds&&(r.ids=this.rootAssetIds,r.recursive=!0);try{let e=null!=(n=this.paginationThreshold)?n:1e3;(yield rs().rest.api.AssetResource.queryCount(Object.assign(Object.assign({},r),{limit:e,parents:void 0}))).data<e&&(r.parents=void 0,r.limit=e)}catch(e){console.warn("Failed to query asset count, falling back to default pagination.",e)}let o=this._sendEventWithReply({eventType:"read-asset-tree",assetQuery:r});return o.then(t=>{var n,o,s,a,l,d;if((null==(n=r.realm)?void 0:n.name)!==rs().displayRealm){this._loading=!1,this._loadAssets().catch(e=>console.warn("Failed to reload assets after a realm change",e));return}let c=null!=(s=null==(o=t.assetTree)?void 0:o.assets)?s:[],h=null!=(l=null==(a=t.assetTree)?void 0:a.hasMore)&&l;if(e?e&&this._incompleteParentIds.includes(e)&&!h?this._incompleteParentIds=this._incompleteParentIds.filter(t=>t!==e):e&&h&&(this._incompleteParentIds=[...this._incompleteParentIds,e]):this._hasMoreParents=h,console.debug(`Received read-assets-tree event with ${c.length} assets.`),console.debug(`Combining these assets with the cache of ${null!=(d=null==i?void 0:i.length)?d:0} assets...`),this._loading=!1,i){let e=[...i,...c.filter(e=>!i.find(t=>t.id===e.id))];this._buildTreeNodes(e)}else this._buildTreeNodes(c);this.isFilterEmpty()||this._doFiltering()}),o}})}_addEventSubscriptions(){return o0(this,void 0,void 0,function*(){this.disableSubscribe||(this._subscriptionIds=[(yield rs().getEventProvider().subscribeAssetEvents(void 0,!1,e=>this._onEvent(e)))])})}onEventsConnect(){this._connected=!0,this._loadAssets().catch(e=>console.log(e.message))}onEventsDisconnect(){this._connected=!1,this._nodes=void 0}getNodes(){return this._nodes||[]}_onEvent(e){if("assets"===e.eventType)return void this._buildTreeNodes(e.assets);if("asset"===e.eventType){if("READ"===e.cause||"UPDATE"===e.cause&&!(e.updatedProperties.includes("name")||e.updatedProperties.includes("parentId")))return;let t=[];"DELETE"!==e.cause&&t.push(e.asset),this._nodes&&ev._forEachNodeRecursive(this._nodes,i=>{i.asset.id!==e.asset.id&&t.push(i.asset)}),this._buildTreeNodes(t),this.isFilterEmpty()||this._doFiltering(),this.dispatchEvent(new o9(e))}}_buildTreeNodes(e,t=this._getSortFunction()){var i,n;if(console.debug(`Building asset tree nodes for ${e.length} assets...`),e&&0!==e.length){let i,n;rs().isRestrictedUser()&&e.forEach(t=>{if(t.parentId&&t.path&&void 0===e.find(e=>e.id===t.parentId)){let i=null;for(let n=0;n<t.path.length;n++){let r=t.path[n];t.id!==r&&void 0!==e.find(e=>e.id===r)&&(i=r)}t.reparentId=i}}),this.rootAssetIds?i=this.rootAssetIds:this.rootAssets&&(i=this.rootAssets.map(e=>e.id)),n=i?e.filter(e=>i.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}))}),n.sort(t),n.forEach(i=>this._buildChildTreeNodes(i,e,t)),this._nodes=n;let r=[];this._expandedNodes.forEach(e=>{ev._forEachNodeRecursive(this._nodes,t=>{var i,n;if((null==(i=t.asset)?void 0:i.id)&&(null==(n=null==e?void 0:e.asset)?void 0:n.id)&&t.asset.id===e.asset.id&&this.isExpandable(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=[];console.debug(`Asset tree nodes built. Now selecting ${null==(i=this.selectedIds)?void 0:i.length} nodes...`),((null==(n=this.selectedIds)?void 0:n.length)||this._selectedNodes.length)&&this._updateSelectedNodes(),this.expandAllNodes&&ev._forEachNodeRecursive(this._nodes,e=>{e.children&&e.children.length>0&&(e.expanded=!0)})}_buildChildTreeNodes(e,t,i){var n,r;let o=this.assetsChildren[e.asset.id];e.children=o?o.sort(i):[],e.expandable=(null==(n=e.asset)?void 0:n.hasChildren)||(null==(r=e.children)?void 0:r.length),e.children.forEach(n=>{n.parent=e,this._buildChildTreeNodes(n,t,i)})}_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,i=e.y;if(null!==this.shadowRoot){let e=this.shadowRoot.getElementById("list");if(e){let n=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,o=e.getBoundingClientRect().left,s=e.getBoundingClientRect().right;if(t<o||t>s||i>r||i<n)return}}this.selectedIds&&this.dispatchEvent(new o5(!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 i=t.getAttribute("node-asset-id");i&&this.isExpandable(i)&&!this._expandTimer&&(this._expandTimer=window.setTimeout(()=>{this.expandNode(i)},1e3))}expandNode(e){var t;if(this.shadowRoot&&e&&e===this._dragDropParentId){let i=this._findNodeFromAssetId(e),n=null==(t=this.shadowRoot)?void 0:t.querySelector('[node-asset-id="'+e+'"]');n&&i&&!i.expanded&&this._toggleExpander(n.firstElementChild.firstElementChild,i,!0)}}_onDragEnter(e){let t=e.currentTarget;t.classList.add("over");let i=t.getAttribute("node-asset-id");this._dragDropParentId=i}_onDragLeave(e){e.currentTarget.classList.remove("over"),clearTimeout(this._expandTimer),this._expandTimer=void 0}_treeNodeTemplate(e,t){var i;let n,r=rp.AssetModelUtil.getAssetDescriptor(e.asset.type);if(n=e.allChildrenSelected?"checkbox-multiple-marked":e.someChildrenSelected?"checkbox-multiple-marked-outline":"checkbox-multiple-blank-outline",e.hidden)return W``;let o=!1;return e.asset&&e.notMatchingFilter&&(o=!0),e.expanded&&0===e.children.length&&(console.debug("Tree node has no children, collapsing it..."),e.expanded=!1),W`
|
|
2621
2621
|
<li
|
|
2622
2622
|
class="asset-list-element"
|
|
2623
2623
|
?data-selected="${e.selected}"
|
package/build/dist/umd/index.js
CHANGED
|
@@ -2617,7 +2617,7 @@ var ORAssetTree;(()=>{var e={3260(e){"use strict";let t=(async function(){}).con
|
|
|
2617
2617
|
</ul>
|
|
2618
2618
|
`,"delete","cancel")}
|
|
2619
2619
|
</or-vaadin-confirm-dialog>
|
|
2620
|
-
`)}_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,i;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 n;!e&&this.config.add.typesParent.none?n=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(n=this.config.add.typesParent.assetTypes[e.asset.type]),n||(n=this.config.add.typesParent.default),n&&(t=n.include,i=n.exclude||[])}}return rp.AssetModelUtil.getAssetDescriptors().filter(e=>(!t||t.some(t=>ro.Util.stringMatch(t,e.name)))&&(!i||!i.some(t=>ro.Util.stringMatch(t,e.name))))}_getSortFunction(){return"createdOn"===this.sortBy?ro.Util.sortByNumber(e=>e.asset[this.sortBy]):ro.Util.sortByString(e=>e.asset[this.sortBy])}_getOrderBy(e){switch(e){case"createdOn":return"CREATED_ON";case"type":return"ASSET_TYPE";default:return"NAME"}}_loadAssets(e){return o0(this,arguments,void 0,function*(e,t=0,i){var n;if(console.debug(`Loading assets with ${e?`parent ${e}`:"no parents"}...`),this.assets){console.debug("Assets already pre-loaded using HTML attributes; reusing them to construct the tree UI..."),this._loading=!1,this._buildTreeNodes(this.assets);return}if(!this._connected)throw Error("Not connected to the server; cannot load assets.");if(this._loading)throw Error("Already loading assets for asset tree; ignoring request.");if(this._loading=!0,this.dataProvider)this.dataProvider(t,this.queryLimit,e).then(e=>{this._loading=!1,this._buildTreeNodes(e),this.isFilterEmpty()||this._doFiltering()});else{let r={realm:{name:rs().displayRealm},parents:e?[{id:e}]:[],select:{attributes:[]},orderBy:{property:this._getOrderBy(this.sortBy)},offset:t,limit:Math.max(this.queryLimit,1)};this.assetIds?(r.ids=this.assetIds,r.recursive=!0):this.rootAssets?(r.ids=this.rootAssets.map(e=>e.id),r.recursive=!0):this.rootAssetIds&&(r.ids=this.rootAssetIds,r.recursive=!0);try{let e=null!=(n=this.paginationThreshold)?n:1e3;(yield rs().rest.api.AssetResource.queryCount(Object.assign(Object.assign({},r),{limit:e,parents:void 0}))).data<e&&(r.parents=void 0,r.limit=e)}catch(e){console.warn("Failed to query asset count, falling back to default pagination.",e)}let o=this._sendEventWithReply({eventType:"read-asset-tree",assetQuery:r});return o.then(t=>{var n,
|
|
2620
|
+
`)}_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,i;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 n;!e&&this.config.add.typesParent.none?n=this.config.add.typesParent.none:e&&this.config.add.typesParent.assetTypes&&(n=this.config.add.typesParent.assetTypes[e.asset.type]),n||(n=this.config.add.typesParent.default),n&&(t=n.include,i=n.exclude||[])}}return rp.AssetModelUtil.getAssetDescriptors().filter(e=>(!t||t.some(t=>ro.Util.stringMatch(t,e.name)))&&(!i||!i.some(t=>ro.Util.stringMatch(t,e.name))))}_getSortFunction(){return"createdOn"===this.sortBy?ro.Util.sortByNumber(e=>e.asset[this.sortBy]):ro.Util.sortByString(e=>e.asset[this.sortBy])}_getOrderBy(e){switch(e){case"createdOn":return"CREATED_ON";case"type":return"ASSET_TYPE";default:return"NAME"}}_loadAssets(e){return o0(this,arguments,void 0,function*(e,t=0,i){var n;if(console.debug(`Loading assets with ${e?`parent ${e}`:"no parents"}...`),this.assets){console.debug("Assets already pre-loaded using HTML attributes; reusing them to construct the tree UI..."),this._loading=!1,this._buildTreeNodes(this.assets);return}if(!this._connected)throw Error("Not connected to the server; cannot load assets.");if(this._loading)throw Error("Already loading assets for asset tree; ignoring request.");if(this._loading=!0,this.dataProvider)this.dataProvider(t,this.queryLimit,e).then(e=>{this._loading=!1,this._buildTreeNodes(e),this.isFilterEmpty()||this._doFiltering()});else{let r={realm:{name:rs().displayRealm},parents:e?[{id:e}]:[],select:{attributes:[]},orderBy:{property:this._getOrderBy(this.sortBy)},offset:t,limit:Math.max(this.queryLimit,1)};this.assetIds?(r.ids=this.assetIds,r.recursive=!0):this.rootAssets?(r.ids=this.rootAssets.map(e=>e.id),r.recursive=!0):this.rootAssetIds&&(r.ids=this.rootAssetIds,r.recursive=!0);try{let e=null!=(n=this.paginationThreshold)?n:1e3;(yield rs().rest.api.AssetResource.queryCount(Object.assign(Object.assign({},r),{limit:e,parents:void 0}))).data<e&&(r.parents=void 0,r.limit=e)}catch(e){console.warn("Failed to query asset count, falling back to default pagination.",e)}let o=this._sendEventWithReply({eventType:"read-asset-tree",assetQuery:r});return o.then(t=>{var n,o,s,a,l,d;if((null==(n=r.realm)?void 0:n.name)!==rs().displayRealm){this._loading=!1,this._loadAssets().catch(e=>console.warn("Failed to reload assets after a realm change",e));return}let c=null!=(s=null==(o=t.assetTree)?void 0:o.assets)?s:[],h=null!=(l=null==(a=t.assetTree)?void 0:a.hasMore)&&l;if(e?e&&this._incompleteParentIds.includes(e)&&!h?this._incompleteParentIds=this._incompleteParentIds.filter(t=>t!==e):e&&h&&(this._incompleteParentIds=[...this._incompleteParentIds,e]):this._hasMoreParents=h,console.debug(`Received read-assets-tree event with ${c.length} assets.`),console.debug(`Combining these assets with the cache of ${null!=(d=null==i?void 0:i.length)?d:0} assets...`),this._loading=!1,i){let e=[...i,...c.filter(e=>!i.find(t=>t.id===e.id))];this._buildTreeNodes(e)}else this._buildTreeNodes(c);this.isFilterEmpty()||this._doFiltering()}),o}})}_addEventSubscriptions(){return o0(this,void 0,void 0,function*(){this.disableSubscribe||(this._subscriptionIds=[(yield rs().getEventProvider().subscribeAssetEvents(void 0,!1,e=>this._onEvent(e)))])})}onEventsConnect(){this._connected=!0,this._loadAssets().catch(e=>console.log(e.message))}onEventsDisconnect(){this._connected=!1,this._nodes=void 0}getNodes(){return this._nodes||[]}_onEvent(e){if("assets"===e.eventType)return void this._buildTreeNodes(e.assets);if("asset"===e.eventType){if("READ"===e.cause||"UPDATE"===e.cause&&!(e.updatedProperties.includes("name")||e.updatedProperties.includes("parentId")))return;let t=[];"DELETE"!==e.cause&&t.push(e.asset),this._nodes&&ev._forEachNodeRecursive(this._nodes,i=>{i.asset.id!==e.asset.id&&t.push(i.asset)}),this._buildTreeNodes(t),this.isFilterEmpty()||this._doFiltering(),this.dispatchEvent(new o9(e))}}_buildTreeNodes(e,t=this._getSortFunction()){var i,n;if(console.debug(`Building asset tree nodes for ${e.length} assets...`),e&&0!==e.length){let i,n;rs().isRestrictedUser()&&e.forEach(t=>{if(t.parentId&&t.path&&void 0===e.find(e=>e.id===t.parentId)){let i=null;for(let n=0;n<t.path.length;n++){let r=t.path[n];t.id!==r&&void 0!==e.find(e=>e.id===r)&&(i=r)}t.reparentId=i}}),this.rootAssetIds?i=this.rootAssetIds:this.rootAssets&&(i=this.rootAssets.map(e=>e.id)),n=i?e.filter(e=>i.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}))}),n.sort(t),n.forEach(i=>this._buildChildTreeNodes(i,e,t)),this._nodes=n;let r=[];this._expandedNodes.forEach(e=>{ev._forEachNodeRecursive(this._nodes,t=>{var i,n;if((null==(i=t.asset)?void 0:i.id)&&(null==(n=null==e?void 0:e.asset)?void 0:n.id)&&t.asset.id===e.asset.id&&this.isExpandable(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=[];console.debug(`Asset tree nodes built. Now selecting ${null==(i=this.selectedIds)?void 0:i.length} nodes...`),((null==(n=this.selectedIds)?void 0:n.length)||this._selectedNodes.length)&&this._updateSelectedNodes(),this.expandAllNodes&&ev._forEachNodeRecursive(this._nodes,e=>{e.children&&e.children.length>0&&(e.expanded=!0)})}_buildChildTreeNodes(e,t,i){var n,r;let o=this.assetsChildren[e.asset.id];e.children=o?o.sort(i):[],e.expandable=(null==(n=e.asset)?void 0:n.hasChildren)||(null==(r=e.children)?void 0:r.length),e.children.forEach(n=>{n.parent=e,this._buildChildTreeNodes(n,t,i)})}_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,i=e.y;if(null!==this.shadowRoot){let e=this.shadowRoot.getElementById("list");if(e){let n=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,o=e.getBoundingClientRect().left,s=e.getBoundingClientRect().right;if(t<o||t>s||i>r||i<n)return}}this.selectedIds&&this.dispatchEvent(new o5(!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 i=t.getAttribute("node-asset-id");i&&this.isExpandable(i)&&!this._expandTimer&&(this._expandTimer=window.setTimeout(()=>{this.expandNode(i)},1e3))}expandNode(e){var t;if(this.shadowRoot&&e&&e===this._dragDropParentId){let i=this._findNodeFromAssetId(e),n=null==(t=this.shadowRoot)?void 0:t.querySelector('[node-asset-id="'+e+'"]');n&&i&&!i.expanded&&this._toggleExpander(n.firstElementChild.firstElementChild,i,!0)}}_onDragEnter(e){let t=e.currentTarget;t.classList.add("over");let i=t.getAttribute("node-asset-id");this._dragDropParentId=i}_onDragLeave(e){e.currentTarget.classList.remove("over"),clearTimeout(this._expandTimer),this._expandTimer=void 0}_treeNodeTemplate(e,t){var i;let n,r=rp.AssetModelUtil.getAssetDescriptor(e.asset.type);if(n=e.allChildrenSelected?"checkbox-multiple-marked":e.someChildrenSelected?"checkbox-multiple-marked-outline":"checkbox-multiple-blank-outline",e.hidden)return W``;let o=!1;return e.asset&&e.notMatchingFilter&&(o=!0),e.expanded&&0===e.children.length&&(console.debug("Tree node has no children, collapsing it..."),e.expanded=!1),W`
|
|
2621
2621
|
<li
|
|
2622
2622
|
class="asset-list-element"
|
|
2623
2623
|
?data-selected="${e.selected}"
|