TYPO3 v15 dev-main snapshot ()
This commit is contained in:
commit
f9941541b7
1178 files changed
+135377
No files matched your search
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{html as l,LitElement as m}from"lit";import{customElement as f,query as u}from"lit/decorators.js";import h from"@typo3/core/ajax/ajax-request.js";import"@typo3/backend/tree/tree-toolbar.js";import g from"@typo3/backend/element-browser.js";import b from"@typo3/backend/link-browser.js";import"@typo3/backend/element/icon-element.js";import{FileStorageTree as w}from"@typo3/backend/tree/file-storage-tree.js";var d=function(n,e,t,r){var o=arguments.length,i=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(s=n[c])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i};let p=class extends w{createNodeContentAction(e){return this.settings.actions.includes("link")?l`<span class=node-action @click=${()=>this.linkItem(e)}> <typo3-backend-icon identifier=actions-link size=small></typo3-backend-icon> </span>`:this.settings.actions.includes("select")?l`<span class=node-action @click=${()=>this.selectItem(e)}> <typo3-backend-icon identifier=actions-link size=small></typo3-backend-icon> </span>`:super.createNodeContentAction(e)}linkItem(e){b.finalizeFunction("t3://folder?storage="+e.storage+"&identifier="+e.pathIdentifier)}selectItem(e){g.insertElement(e.recordType,e.identifier,e.name,e.identifier,!0)}};p=d([f("typo3-backend-component-filestorage-browser-tree")],p);let a=class extends m{constructor(){super(...arguments),this.activeFolder="",this.actions=[],this.selectActiveNode=e=>{const t=e.detail.nodes;e.detail.nodes=t.map(r=>(decodeURIComponent(r.identifier)===this.activeFolder&&(r.checked=!0),r))},this.loadFolderDetails=e=>{const t=e.detail.node;if(!t.checked)return;const r=document.location.href+"&contentOnly=1&expandFolder="+t.identifier;new h(r).get().then(o=>o.resolve()).then(o=>{const i=document.querySelector(".element-browser-main-content .element-browser-body");i.innerHTML=o})}}firstUpdated(){this.activeFolder=this.getAttribute("active-folder")||""}createRenderRoot(){return this}render(){this.hasAttribute("tree-actions")&&this.getAttribute("tree-actions").length&&(this.actions=JSON.parse(this.getAttribute("tree-actions")));const e={dataUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_data,rootlineUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_rootline,filterUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_filter,showIcons:!0,actions:this.actions},t=()=>{const r=this.querySelector("typo3-backend-tree-toolbar");r.tree=this.tree,this.activeFolder&&this.expandToActiveFolder()};return l`<typo3-backend-tree-toolbar .tree=${this.tree}></typo3-backend-tree-toolbar><typo3-backend-component-filestorage-browser-tree .setup=${e} @tree:initialized=${t} @typo3:tree:node-selected=${this.loadFolderDetails} @typo3:tree:nodes-prepared=${this.selectActiveNode}></typo3-backend-component-filestorage-browser-tree>`}async expandToActiveFolder(){if(!this.activeFolder||!this.tree.settings.rootlineUrl)return;const e=this.tree.nodes.find(t=>decodeURIComponent(t.identifier)===this.activeFolder);if(e){await this.tree.expandNodeParents(e);return}try{const t=new URL(this.tree.settings.rootlineUrl,window.location.origin);t.searchParams.set("identifier",this.activeFolder);const r=await new h(t.toString()).get({cache:"no-cache"}),{rootline:o}=await r.resolve();o&&o.length>0&&(o.pop(),await this.tree.expandParents(o.map(i=>encodeURIComponent(i))))}catch(t){console.debug("Could not expand to active folder:",t)}}};d([u("typo3-backend-component-filestorage-browser-tree")],a.prototype,"tree",void 0),a=d([f("typo3-backend-component-filestorage-browser")],a);export{a as FileStorageBrowser,p as FileStorageBrowserTree};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{LitElement as v,html as E}from"lit";import{customElement as N,query as T}from"lit/decorators.js";import"@typo3/backend/element/icon-element.js";import{SeverityEnum as C}from"@typo3/backend/enum/severity.js";import"@typo3/backend/tree/tree-toolbar.js";import{TreeNodePositionEnum as d}from"@typo3/backend/tree/tree-node.js";import{FileStorageTree as R}from"@typo3/backend/tree/file-storage-tree.js";import{TreeModuleState as I}from"@typo3/backend/tree/tree-module-state.js";import b from"@typo3/backend/context-menu.js";import y from"@typo3/backend/notification.js";import{ModuleStateStorage as F}from"@typo3/backend/storage/module-state-storage.js";import{ModuleUtility as O}from"@typo3/backend/module.js";import{FileListDragDropEvent as U}from"@typo3/filelist/file-list-dragdrop.js";import{Resource as S}from"@typo3/backend/resource/resource.js";import{DataTransferTypes as p}from"@typo3/backend/enum/data-transfer-types.js";import{UrlFactory as w}from"@typo3/core/factory/url-factory.js";import A from"~labels/core.core";import m from"~labels/backend.layout";var h=function(l,e,t,r){var o=arguments.length,n=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(l,e,t,r);else for(var s=l.length-1;s>=0;s--)(i=l[s])&&(n=(o<3?i(n):o>3?i(e,t,n):i(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n};const M="typo3-backend-navigation-component-filestoragetree";let g=class extends R{constructor(){super(...arguments),this.allowNodeDrag=!0}handleNodeMove(e,t,r){if(!this.isDropAllowed(t,e))return;const o=this.getDropCommandDetails(t,e,r);if(o===null)return;const n=f.fromNodePositionOptions(o),i=n.getConflictingOperationsForTreeNode(o.target);if(i.length>0){i.forEach(s=>{y.showMessage(m.get("drop.conflict"),m.get("mess.drop.conflict",[s.resource.name,decodeURIComponent(o.target.identifier)]),C.error)});return}this.initiateDropAction(n)}createDataTransferItemsFromNode(e){return[{type:p.treenode,data:this.getNodeTreeIdentifier(e)},{type:p.falResources,data:JSON.stringify([c.fromTreeNode(e)])}]}handleNodeDragOver(e){if(super.handleNodeDragOver(e))return!0;if(e.dataTransfer.types.includes(p.falResources)){const t=this.getNodeFromDragEvent(e);return t===null?!1:(this.cleanDrag(),this.getElementFromNode(t).classList.add("node-hover"),t.hasChildren&&!t.__expanded?this.openNodeTimeout.targetNode!=t&&(this.openNodeTimeout.targetNode=t,clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.timeout=setTimeout(()=>{this.showChildren(this.openNodeTimeout.targetNode),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null},1e3)):(clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null),e.preventDefault(),!0)}return!1}getTooltipDescription(e){return decodeURIComponent(e.identifier)}handleNodeDrop(e){if(super.handleNodeDrop(e))return!0;if(e.dataTransfer.types.includes(p.falResources)){const t=this.getNodeFromDragEvent(e);if(t===null)return!1;if(t){const r=c.fromTreeNode(t),o=f.fromDataTransfer(e.dataTransfer,r),n=o.getConflictingOperationsForTreeNode(t);return n.length>0?(n.forEach(i=>{y.showMessage(m.get("drop.conflict"),m.get("mess.drop.conflict",[i.resource.name,decodeURIComponent(t.identifier)]),C.error)}),!1):(e.preventDefault(),this.initiateDropAction(o),!0)}}return!1}getDropCommandDetails(e,t,r){const o=this.nodes,n=t.identifier;let i=e;if(n===i.identifier)return null;if(r===d.BEFORE){const s=o.indexOf(e),a=this.setNodePositionAndTarget(s);if(a===null)return null;r=a.position,i=a.target}return{node:t,identifier:n,target:i,position:r}}setNodePositionAndTarget(e){const t=this.nodes,o=t[e].depth;e>0&&e--;const i=t[e].depth,s=this.nodes[e];if(i===o)return{position:d.AFTER,target:s};if(i<o)return{position:d.INSIDE,target:s};for(let a=e;a>=0;a--){if(t[a].depth===o)return{position:d.AFTER,target:this.nodes[a]};if(t[a].depth<o)return{position:d.AFTER,target:t[a]}}return null}isDropAllowed(e,t){return!(e===t||!this.isOverRoot)}initiateDropAction(e){const t={action:"transfer",resources:e.getResources(),target:e.target};top.document.dispatchEvent(new CustomEvent(U.transfer,{detail:t}))}};g=h([N("typo3-backend-navigation-component-filestorage-tree")],g);let u=class extends I(v){constructor(){super(...arguments),this.moduleStateType="media",this.refresh=()=>{this.tree.refreshOrFilterTree()},this.selectFirstNode=()=>{const e=this.tree.nodes[0];e&&this.tree.selectNode(e,!0)},this.loadContent=e=>{const t=e.detail.node;if(!t?.checked||(F.updateWithTreeIdentifier("media",decodeURIComponent(t.identifier),decodeURIComponent(t.__treeIdentifier)),e.detail.propagate===!1))return;const r=top.TYPO3.ModuleMenu.App,o=w.createUrl(O.getFromName(r.getCurrentModule()).link,{id:decodeURIComponent(t.identifier)});top.TYPO3.Backend.ContentContainer.setUrl(o)},this.showContextMenu=e=>{const t=e.detail.node;t&&b.show(t.recordType,decodeURIComponent(t.identifier),"tree","","",this.tree.getElementFromNLine truncated
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{Tree as o}from"@typo3/backend/tree/tree.js";class i extends o{constructor(){super(),this.settings.defaultProperties={hasChildren:!1,nameSourceField:"title",type:"sys_file",prefix:"",suffix:"",locked:!1,loaded:!1,overlayIcon:"",selectable:!0,expanded:!1,checked:!1}}getNodeTitle(e){let t=decodeURIComponent(e.name);const s=this.getNodeLabels(e);s.length&&(t+="; "+s.map(l=>l.label).join("; "));const a=this.getNodeStatusInformation(e);return a.length&&(t+="; "+a.map(l=>l.label).join("; ")),t}}export{i as FileStorageTree};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{html as s,LitElement as m,nothing as g}from"lit";import{customElement as h,property as f,query as P}from"lit/decorators.js";import{until as y}from"lit/directives/until.js";import{PageTree as b}from"@typo3/backend/tree/page-tree.js";import p from"@typo3/core/ajax/ajax-request.js";import"@typo3/backend/tree/tree-toolbar.js";import k from"@typo3/backend/element-browser.js";import v from"@typo3/backend/link-browser.js";import"@typo3/backend/element/icon-element.js";import w from"@typo3/backend/storage/persistent.js";import T from"~labels/core.core";var l=function(r,e,t,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,n);else for(var d=r.length-1;d>=0;d--)(c=r[d])&&(o=(i<3?c(o):i>3?c(e,t,o):c(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o};let u=class extends b{getNodeClasses(e){const t=super.getNodeClasses(e);return this.settings.actions.includes("link")&&(this.isLinkable(e)||t.push("node-disabled")),t}createNodeContentAction(e){return this.settings.actions.includes("link")?this.isLinkable(e)?s`<span class=node-action @click=${()=>this.linkItem(e)}> <typo3-backend-icon identifier=actions-link size=small></typo3-backend-icon> </span>`:super.createNodeContentAction(e):this.settings.actions.includes("select")?s`<span class=node-action @click=${()=>this.selectItem(e)}> <typo3-backend-icon identifier=actions-link size=small></typo3-backend-icon> </span>`:super.createNodeContentAction(e)}linkItem(e){v.finalizeFunction("t3://page?uid="+e.identifier)}isLinkable(e){return!(this.settings.nonViewableDoktypes??[199,254]).includes(e.doktype)}selectItem(e){k.insertElement(e.recordType,e.identifier,e.name,"",!0)}};u=l([h("typo3-backend-component-page-browser-tree")],u);let a=class extends m{constructor(){super(...arguments),this.mountPointPath=null,this.activePageId=0,this.actions=[],this.configuration=null,this.selectActivePageInTree=e=>{const t=e.detail.nodes;e.detail.nodes=t.map(n=>(parseInt(n.identifier,10)===this.activePageId&&(n.checked=!0),n))},this.loadRecordsOfPage=e=>{const t=e.detail.node;if(!t.checked)return;const n=new URL(document.location.href,window.location.origin);n.searchParams.set("contentOnly","1"),n.searchParams.set("expandPage",t.identifier),new p(n).get().then(i=>i.resolve()).then(i=>{const o=document.querySelector(".element-browser-main-content .element-browser-body");o.innerHTML=i})},this.setMountPoint=e=>{this.setTemporaryMountPoint(e.detail.pageId)}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:pagetree:mountPoint",this.setMountPoint)}disconnectedCallback(){document.removeEventListener("typo3:pagetree:mountPoint",this.setMountPoint),super.disconnectedCallback()}firstUpdated(){this.activePageId=parseInt(this.getAttribute("active-page"),10),this.actions=JSON.parse(this.getAttribute("tree-actions")??"[]")}createRenderRoot(){return this}getConfiguration(){if(this.configuration!==null)return Promise.resolve(this.configuration);const e=top.TYPO3.settings.ajaxUrls.page_tree_browser_configuration,t=this.hasAttribute("alternative-entry-points")?JSON.parse(this.getAttribute("alternative-entry-points")):[];let n=new p(e);return t.length&&(n=n.withQueryArguments("alternativeEntryPoints="+encodeURIComponent(t))),n.get().then(async i=>{const o=await i.resolve("json");return o.actions=this.actions,this.configuration=o,this.mountPointPath=o.temporaryMountPoint||null,o})}render(){return s`${y(this.renderTree(),"")}`}renderTree(){return this.getConfiguration().then(e=>{const t=()=>{this.activePageId&&this.tree.ensureActiveNodeLoaded(this.activePageId);const n=this.querySelector("typo3-backend-tree-toolbar");n.tree=this.tree};return s`<typo3-backend-tree-toolbar .tree=${this.tree}></typo3-backend-tree-toolbar>${this.renderMountPoint()}<typo3-backend-component-page-browser-tree id=typo3-pagetree-tree .setup=${e} @tree:initialized=${t} @typo3:tree:node-selected=${this.loadRecordsOfPage} @typo3:tree:nodes-prepared=${this.selectActivePageInTree}></typo3-backend-component-page-browser-tree>`})}unsetTemporaryMountPoint(){w.unset("pageTree_temporaryMountPoint").then(()=>{this.mountPointPath=null})}renderMountPoint(){return this.mountPointPath===null?g:s`<div class=node-mount-point><div class=node-mount-point__icon><typo3-backend-icon identifier=actions-info-circle size=small></typo3-backend-icon></div><div class=node-mount-point__text>${this.mountPointPath}</div><div class="node-mount-point__icon mountpoint-close" @click=${()=>this.unsetTemporaryMountPoint()} title=${T.get("labels.temporaryPageTreeEntryPoints")}><typo3-backend-icon identifier=actions-close size=small></typo3-backend-icon></div></div>`}setTemporaryMountPoint(e){new p(this.configuration.setTemporaryMountPointUrl).post("pid="+e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(t=>t.resolve()).then(t=>{t&&t.hasErrors?(this.tree.errorLine truncated
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{LitElement as b,html as v,nothing as I}from"lit";import{customElement as y,property as u,query as w,state as P}from"lit/decorators.js";import{PageTree as N}from"@typo3/backend/tree/page-tree.js";import A from"@typo3/core/ajax/ajax-request.js";import"@typo3/backend/tree/tree-toolbar.js";import"@typo3/backend/element/icon-element.js";import"@typo3/backend/element/breadcrumb.js";import{TreeNodePositionEnum as g}from"@typo3/backend/tree/tree-node.js";import{cache as S}from"lit/directives/cache.js";import s from"~labels/core.core";var d=function(l,e,t,i){var r=arguments.length,n=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(l,e,t,i);else for(var o=l.length-1;o>=0;o--)(c=l[o])&&(n=(r<3?c(n):r>3?c(e,t,n):c(e,t))||n);return r>3&&n&&Object.defineProperty(e,t,n),n};const _=[{label:s.get("insert_inside"),value:"inside",iconIdentifier:"actions-arrow-end"},{label:s.get("insert_after"),value:"after",iconIdentifier:"actions-arrow-down"}];class p extends CustomEvent{static{this.eventName="typo3:page-position-select-tree:insert-position-change"}constructor(e,t){super(p.eventName,{detail:{pageUid:e,position:t},bubbles:!0,composed:!0})}}class f extends CustomEvent{static{this.eventName="typo3:page-position-select-tree:insert-position-confirm"}constructor(e,t){super(f.eventName,{detail:{pageUid:e,position:t},bubbles:!0,composed:!0})}}let m=class extends N{async handleNodeAdd(e,t,i){this.requestUpdate()}};m=d([y("typo3-backend-component-page-position-select-tree")],m);let a=class extends b{constructor(){super(...arguments),this.activePageId=null,this.actions=["select"],this.insertPosition="inside",this.configuration=null,this.breadcrumbItems=[]}connectedCallback(){super.connectedCallback(),this.loadConfiguration()}createRenderRoot(){return this}loadConfiguration(){const e=top.TYPO3.settings.ajaxUrls.page_tree_browser_configuration,t=this.hasAttribute("alternative-entry-points")?JSON.parse(this.getAttribute("alternative-entry-points")):[];let i=new A(e);t.length&&(i=i.withQueryArguments("alternativeEntryPoints="+encodeURIComponent(t))),i.get().then(async r=>{const n=await r.resolve("json");n.actions=this.actions,this.configuration=n})}render(){return v`<typo3-breadcrumb .nodes=${this.breadcrumbItems}></typo3-breadcrumb>${this.configuration?S(this.renderTree()):I}`}renderTree(){const e=async()=>{const t=this.querySelector("typo3-backend-tree-toolbar");t.tree=this.tree,await this.tree.ensureActiveNodeLoaded(this.activePageId);const i=await this.applyActiveInsertPosition();i&&(await this.tree.updateComplete,this.tree.scrollNodeIntoViewIfNeeded(i),this.tree.focusNode(i))};return v`<typo3-backend-tree-toolbar .tree=${this.tree}></typo3-backend-tree-toolbar><typo3-backend-component-page-position-select-tree id=typo3-pagetree-tree .setup=${this.configuration} @tree:initialized=${e} @typo3:tree:node-selected=${this.handleNodeSelected} @typo3:tree:filter-applied=${()=>this.applyActiveInsertPosition()} @typo3:tree:filter-reset=${()=>this.applyActiveInsertPosition()}></typo3-backend-component-page-position-select-tree>`}async handleNodeSelected(e){const t=e.detail.node;if(this.isActivePagePositionNode(t)){this.dispatchEvent(new f(this.activePageId,this.insertPosition));return}const[i,r]=t.identifier.split("-");this.insertPosition=r??"inside",this.activePageId=Number(i);const n=/^\d+$/.test(t.identifier)?await this.applyActiveInsertPosition():this.syncActiveInsertPositionState();n&&this.tree.focusNode(n),this.dispatchEvent(new p(this.activePageId,this.insertPosition))}async applyActiveInsertPosition(){if(this.activePageId===null||this.activePageId===void 0)return null;let e=this.tree.nodes.find(t=>t.identifier===String(this.activePageId));return!e&&(await this.tree.ensureActiveNodeLoaded(this.activePageId),e=this.tree.nodes.find(t=>t.identifier===String(this.activePageId)),!e)?null:(await this.tree.expandNodeParents(e),await this.toggleDynamicInsertNodes(e),this.syncActiveInsertPositionState())}syncActiveInsertPositionState(){let e=null;return this.tree.nodes.forEach(t=>{t.checked=this.isActivePagePositionNode(t),t.checked&&(e=t)}),this.updateBreadcrumb(this.tree.nodes),this.tree.requestUpdate(),e}async toggleDynamicInsertNodes(e){const t=[];for(const o of this.tree.nodes)["-after","-inside"].some(h=>o.identifier.endsWith(h))&&t.push(o);for(const o of t)await this.tree.removeNode(o);const i={...e,__processed:!1,hasChildren:!1,loaded:!0,identifier:e.identifier+"-inside",parentIdentifier:e.identifier,name:s.get("insert_subpage"),icon:"actions-arrow-end",overlayIcon:"",tooltip:s.get("insert_inside")+" "+e.tooltip},n={...this.tree.nodes.find(o=>o.identifier===e.parentIdentifier),__processed:!1,hasChildren:!1,loaded:!0,identifier:`${e.identifier}-after`,parentIdentifier:e.parentIdentifier,name:s.get("insert_page"),icon:"actions-arrow-end",overlayIcon:"",tooltip:s.get("insert_after")+" "+e.tooltip};let c=[];e.hasChildren&&(c=this.tree.nodes.filLine truncated
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{LitElement as M,html as a,nothing as g}from"lit";import{customElement as v,property as b,query as T,state as E}from"lit/decorators.js";import{until as S}from"lit/directives/until.js";import w from"@typo3/core/ajax/ajax-request.js";import P from"@typo3/backend/storage/persistent.js";import{ModuleUtility as $}from"@typo3/backend/module.js";import x from"@typo3/backend/context-menu.js";import{PageTree as F}from"@typo3/backend/tree/page-tree.js";import{TreeNodePositionEnum as u,TreeNodeCommandEnum as d}from"@typo3/backend/tree/tree-node.js";import{TreeToolbar as U}from"@typo3/backend/tree/tree-toolbar.js";import{TreeModuleState as D}from"@typo3/backend/tree/tree-module-state.js";import _ from"@typo3/backend/modal.js";import I from"@typo3/backend/severity.js";import{UrlFactory as z}from"@typo3/core/factory/url-factory.js";import{ModuleStateStorage as C}from"@typo3/backend/storage/module-state-storage.js";import{DataTransferTypes as f}from"@typo3/backend/enum/data-transfer-types.js";import"@typo3/backend/viewport/content-navigation-toggle.js";import"bootstrap";import r from"~labels/core.core";import O from"~labels/core.common";import R from"~labels/core.mod_web_list";import L from"~labels/backend.pages_new";import{openPageWizardModal as A}from"@typo3/backend/page-wizard/helper/wizard-helper.js";var s=function(p,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(p,e,t,n);else for(var m=p.length-1;m>=0;m--)(l=p[m])&&(i=(o<3?l(i):o>3?l(e,t,i):l(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i};const B="typo3-backend-navigation-component-pagetree";let y=class extends F{constructor(){super(...arguments),this.allowNodeEdit=!0,this.allowNodeDrag=!0,this.allowNodeSorting=!0}sendChangeCommand(e){let t="",n="0";if(e.target)if(n=e.target.identifier,e.position===u.BEFORE){const o=this.getPreviousNode(e.target);n=(o.depth===e.target.depth?"-":"")+o.identifier}else e.position===u.AFTER&&(n="-"+n);if(e.command===d.NEW){const o=e;t="&data[pages]["+e.node.identifier+"][pid]="+encodeURIComponent(n)+"&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(o.title)+"&data[pages]["+e.node.identifier+"][doktype]="+encodeURIComponent(o.doktype)}else if(e.command===d.EDIT)t="&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(e.title);else if(e.command===d.DELETE){const o=C.current("web");e.node.identifier===o.identifier&&this.selectFirstNode(),t="&cmd[pages]["+e.node.identifier+"][delete]=1"}else t="cmd[pages]["+e.node.identifier+"]["+e.command+"]="+n;this.requestTreeUpdate(t).then(o=>{if(o&&o.hasErrors)this.errorNotification(o.messages);else if(e.command===d.NEW){const i=this.getParentNode(e.node);i.loaded=!1,this.loadChildren(i)}else this.refreshOrFilterTree()})}initializeDragForNode(){throw new Error("unused")}async handleNodeEdit(e,t){if(e.__loading=!0,e.identifier.startsWith("NEW")){const n=this.getPreviousNode(e),o=e.depth===n.depth?u.AFTER:u.INSIDE,i={command:d.NEW,node:e,title:t,position:o,target:n,doktype:e.doktype};await this.sendChangeCommand(i)}else{const n={command:d.EDIT,node:e,title:t};await this.sendChangeCommand(n)}e.__loading=!1}createDataTransferItemsFromNode(e){return[{type:f.treenode,data:this.getNodeTreeIdentifier(e)},{type:f.pages,data:JSON.stringify({records:[{identifier:e.identifier,tablename:"pages"}]})}]}async handleNodeAdd(e,t,n){this.updateComplete.then(()=>{this.editNode(e)})}handleNodeDelete(e){const t={node:e,command:d.DELETE};this.settings.displayDeleteConfirmation?_.confirm(r.get("mess.delete.title"),r.get("mess.delete",[t.node.name]),I.warning,[{text:r.get("labels.cancel"),active:!0,btnClass:"btn-default",name:"cancel"},{text:O.get("delete"),btnClass:"btn-warning",name:"delete"}]).addEventListener("button.clicked",o=>{o.target.name==="delete"&&this.sendChangeCommand(t),_.dismiss()}):this.sendChangeCommand(t)}handleNodeMove(e,t,n){const o={node:e,target:t,position:n,command:d.MOVE};let i="";const l=[e.name,t.name];switch(n){case u.BEFORE:i=r.get("mess.move_before",l);break;case u.AFTER:i=r.get("mess.move_after",l);break;default:i=r.get("mess.move_into",l);break}const m=_.confirm(R.get("move_page"),i,I.warning,[{text:r.get("labels.cancel"),active:!0,btnClass:"btn-default",name:"cancel"},{text:r.get("cm.copy"),btnClass:"btn-warning",name:"copy"},{text:r.get("labels.move"),btnClass:"btn-warning",name:"move"}]);m.addEventListener("button.clicked",N=>{const k=N.target;k.name==="move"?(o.command=d.MOVE,this.sendChangeCommand(o)):k.name==="copy"&&(o.command=d.COPY,this.sendChangeCommand(o)),m.hideModal()})}requestTreeUpdate(e){return new w(top.TYPO3.settings.ajaxUrls.record_process).post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(t=>t.resolve()).catch(t=>{this.errorNotification(t),this.loadData()})}};y=s([v("typo3-backend-navigation-component-pagetree-tree")],y);let h=class extends D(M){consLine truncated
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{Tree as l}from"@typo3/backend/tree/tree.js";import{html as a}from"lit";import{DataTransferTypes as i}from"@typo3/backend/enum/data-transfer-types.js";import n from"@typo3/backend/modal.js";import{SeverityEnum as u}from"@typo3/backend/enum/severity.js";import s from"@typo3/backend/utility/drag-drop-utility.js";import p from"@typo3/core/ajax/ajax-request.js";class m extends l{constructor(){super(),this.settings.defaultProperties={hasChildren:!1,nameSourceField:"title",prefix:"",suffix:"",locked:!1,loaded:!1,overlayIcon:"",selectable:!0,expanded:!1,checked:!1,stopPageTree:!1}}getDataUrl(e=null){return e===null?this.settings.dataUrl:this.settings.dataUrl+"&parent="+e.identifier+"&mount="+e.mountPoint+"&depth="+e.depth}ensureActiveNodeLoaded(e){return!e||this.nodes.find(t=>t.checked)?Promise.resolve():new p(TYPO3.settings.ajaxUrls.page_tree_rootline).withQueryArguments({identifier:e}).get({cache:"no-cache"}).then(t=>t.resolve()).then(t=>{const{rootline:r}=t;return r.pop(),this.expandParents(r)})}createNodeToggle(e){return a`${e.stopPageTree&&e.depth!==0?a`<span class=node-stop @click=${t=>{t.preventDefault(),t.stopImmediatePropagation(),document.dispatchEvent(new CustomEvent("typo3:pagetree:mountPoint",{detail:{pageId:parseInt(e.identifier,10)}}))}}> <typo3-backend-icon identifier=actions-caret-end size=small></typo3-backend-icon> </span>`:super.createNodeToggle(e)}`}handleNodeDragOver(e){if(super.handleNodeDragOver(e))return!0;if(e.dataTransfer.types.includes(i.content)){const t=this.getNodeFromDragEvent(e);return t===null?!1:(this.cleanDrag(),this.getElementFromNode(t).classList.add("node-hover"),t.hasChildren&&!t.__expanded?this.openNodeTimeout.targetNode!=t&&(this.openNodeTimeout.targetNode=t,clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.timeout=setTimeout(()=>{this.showChildren(this.openNodeTimeout.targetNode),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null},1e3)):(clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null),e.preventDefault(),s.updateEventAndTooltipToReflectCopyMoveIntention(e),!0)}return!1}handleNodeDrop(e){if(super.handleNodeDrop(e))return!0;if(e.dataTransfer.types.includes(i.content)){const t=this.getNodeFromDragEvent(e);if(t===null)return!1;const r=e.dataTransfer.getData(i.content),d=JSON.parse(r);e.preventDefault();const o=new URL(d.moveElementUrl,window.origin);return o.searchParams.set("expandPage",t.identifier),o.searchParams.set("originalPid",t.identifier),s.isCopyModifierFromEvent(e)&&o.searchParams.set("makeCopy","1"),n.advanced({content:o.toString(),severity:u.notice,size:n.sizes.large,type:n.types.iframe}),!0}return!1}}export{m as PageTree};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import l from"@typo3/core/ajax/ajax-request.js";import{ModuleStateStorage as a}from"@typo3/backend/storage/module-state-storage.js";const u=f=>{class c extends f{constructor(){super(...arguments),this.selectActiveNodeInLoadedNodes=t=>{let e=a.current(this.moduleStateType);if(!e.identifier)return;const{nodes:r}=t.detail,i=this.transformModuleStateIdentifierToNodeIdentifier(e.treeIdentifier),o=this.transformModuleStateIdentifierToNodeIdentifier(e.identifier),n=r.find(s=>e.treeIdentifier!==null&&s.__treeIdentifier===i||e.treeIdentifier===null&&s.identifier===o);if(!n)return;e.treeIdentifier===null&&(e=a.updateWithTreeIdentifier(this.moduleStateType,this.transformNodeIdentifierToModuleStateIdentifier(n.identifier),this.transformNodeIdentifierToModuleStateIdentifier(n.__treeIdentifier))),n.checked=!0;const d=r.find(s=>s.__treeIdentifier===n.__parents.join("_"));d&&!d.__expanded&&this.tree.updateComplete.then(()=>this.tree.expandNodeParents(n))},this.fetchActiveNodeIfMissing=async()=>{const t=a.current(this.moduleStateType);t.identifier&&(this.tree.nodes.find(e=>e.checked)||await this.selectActiveViaRootline(t.identifier))},this.moduleStateUpdated=async t=>{const e=t.detail.state.identifier;if(!this.tree||e&&e===t.detail.oldState.identifier&&this.tree.nodes.find(d=>d.checked))return;if(!e){console.error("invalid identifier",t.detail);return}this.tree.loading&&await this.tree.loadComplete;const r=this.transformModuleStateIdentifierToNodeIdentifier(e),i=this.tree.nodes.find(d=>d.identifier===r),o=this.tree.nodes.find(d=>d.checked);if(i&&i===o){await this.tree.expandNodeParents(i);return}const n=!1;if(i){await this.selectActiveNodeByParents(e,i.__parents,n);return}await this.selectActiveViaRootline(e)}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:module-state-storage:update:"+this.moduleStateType,this.moduleStateUpdated)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("typo3:module-state-storage:update:"+this.moduleStateType,this.moduleStateUpdated)}transformModuleStateIdentifierToNodeIdentifier(t){return t}transformNodeIdentifierToModuleStateIdentifier(t){return t}async selectActiveViaRootline(t){const e=new URL(this.tree.settings.rootlineUrl,window.location.origin);e.searchParams.set("identifier",t);const r=await new l(e.toString()).get({cache:"no-cache"}),{rootline:i}=await r.resolve();i.pop(),await this.selectActiveNodeByParents(t,i.map(n=>this.transformModuleStateIdentifierToNodeIdentifier(n)),!1)}async selectActiveNodeByParents(t,e,r=!0){await this.tree.expandParents(e);const i=this.transformModuleStateIdentifierToNodeIdentifier(t),o=this.tree.nodes.find(n=>n.identifier===i);o&&this.tree.selectNode(o,r)}}return c};export{u as TreeModuleState};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{property as a,customElement as f}from"lit/decorators.js";import{LitElement as u,html as s}from"lit";import"@typo3/backend/element/icon-element.js";var p=function(r,t,o,n){var d=arguments.length,e=d<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,o):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(r,t,o,n);else for(var i=r.length-1;i>=0;i--)(l=r[i])&&(e=(d<3?l(e):d>3?l(t,o,e):l(t,o))||e);return d>3&&e&&Object.defineProperty(t,o,e),e};let c=class extends u{constructor(){super(...arguments),this.expanded="false"}render(){return s`<typo3-backend-icon size=small identifier=${this.expanded==="true"?"actions-chevron-down":"actions-chevron-end"}></typo3-backend-icon>`}};p([a({type:String,reflect:!0,attribute:"aria-expanded"})],c.prototype,"expanded",void 0),c=p([f("typo3-backend-tree-node-toggle")],c);var m=c;export{m as default};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
var t;(function(E){E.COPY="copy",E.EDIT="edit",E.MOVE="move",E.DELETE="delete",E.NEW="new"})(t||(t={}));var f;(function(E){E.INSIDE="inside",E.BEFORE="before",E.AFTER="after"})(f||(f={}));export{t as TreeNodeCommandEnum,f as TreeNodePositionEnum};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{LitElement as u,html as d}from"lit";import{property as m,customElement as b}from"lit/decorators.js";import h from"@typo3/core/event/debounce-event.js";import"@typo3/backend/element/icon-element.js";import"@typo3/backend/viewport/content-navigation-toggle.js";import{Tree as f}from"@typo3/backend/tree/tree.js";import r from"~labels/core.core";import"bootstrap";var p=function(s,e,t,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,n);else for(var c=s.length-1;c>=0;c--)(a=s[c])&&(o=(i<3?a(o):i>3?a(e,t,o):a(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o};let l=class extends u{constructor(){super(...arguments),this.tree=null,this.showRefresh=!0,this.settings={searchInput:".search-input",filterTimeout:450}}createRenderRoot(){return this}firstUpdated(){const e=this.querySelector(this.settings.searchInput);e&&new h("input",t=>{const n=t.target;this.tree.filter(n.value.trim())},this.settings.filterTimeout).bindTo(e)}render(){return d`<div class=tree-toolbar><div class=tree-toolbar__menu><div class=tree-toolbar__search><label for=toolbarSearch class=visually-hidden>${r.get("labels.label.searchString")}</label> <input type=search autocomplete=off id=toolbarSearch class="form-control form-control-sm search-input" placeholder=${this.tree?.setup?.searchPlaceholder||r.get("tree.searchTermInfo")}></div><div class=dropdown><button type=button class="btn btn-sm btn-icon btn-default btn-borderless dropdown-toggle dropdown-toggle-no-chevron" data-bs-toggle=dropdown data-bs-boundary=window aria-expanded=false aria-label=${r.get("labels.openTreeOptionsMenu")}><typo3-backend-icon identifier=actions-menu-alternative size=small></typo3-backend-icon></button><ul class="dropdown-menu dropdown-menu-end">${this.showRefresh?d`<li><button class=dropdown-item @click=${()=>this.refreshTree()}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=actions-refresh size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${r.get("labels.refresh")} </span> </span></button></li>`:""}<li><button class=dropdown-item @click=${e=>this.collapseAll(e)}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=apps-pagetree-category-collapse-all size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${r.get("labels.collapse")} </span> </span></button></li></ul></div><typo3-backend-content-navigation-toggle class="btn btn-sm btn-icon btn-default btn-borderless" action=collapse></typo3-backend-content-navigation-toggle></div></div>`}refreshTree(){this.tree.refreshOrFilterTree()}collapseAll(e){e.preventDefault(),this.tree.nodes.forEach(t=>{t.__parents.length&&this.tree.hideChildren(t)})}};p([m({type:f})],l.prototype,"tree",void 0),p([m({type:Boolean})],l.prototype,"showRefresh",void 0),l=p([b("typo3-backend-tree-toolbar")],l);export{l as TreeToolbar};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import{LitElement as x,html as a,nothing as N}from"lit";import{property as C,state as p,query as $}from"lit/decorators.js";import{repeat as F}from"lit/directives/repeat.js";import{styleMap as b}from"lit/directives/style-map.js";import{ifDefined as D}from"lit/directives/if-defined.js";import{TreeNodePositionEnum as u,TreeNodeCommandEnum as h}from"@typo3/backend/tree/tree-node.js";import w from"@typo3/core/ajax/ajax-request.js";import P from"@typo3/backend/notification.js";import{KeyTypesEnum as l}from"@typo3/backend/enum/key-types.js";import"@typo3/backend/element/icon-element.js";import E from"@typo3/backend/storage/client.js";import{DataTransferTypes as m}from"@typo3/backend/enum/data-transfer-types.js";import k from"@typo3/backend/severity.js";import S from"~labels/core.misc";import R from"~labels/backend.layout";import{openPageWizardModal as O}from"@typo3/backend/page-wizard/helper/wizard-helper.js";var f=function(_,e,t,r){var s=arguments.length,i=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(_,e,t,r);else for(var n=_.length-1;n>=0;n--)(o=_[n])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i};class y{constructor(e){this.treeNodes=e,this.updateIndexes()}get length(){return this.treeNodes.length}toArray(){return this.treeNodes}splice(e,t,...r){this.treeNodes.splice(e,t,...r),this.updateIndexes()}getNodeByTreeIdentifier(e){const t=this.treeIdentifierIndex[e]??null;return this.treeNodes[t]??null}updateIndexes(){this.treeIdentifierIndex=Object.fromEntries(this.treeNodes.map((e,t)=>[e.__treeIdentifier,t]))}}class T extends CustomEvent{static{this.eventName="typo3:tree:filter-applied"}constructor(e,t){super(T.eventName,{detail:{searchTerm:e,resultCount:t},bubbles:!0,composed:!0})}}class v extends Event{static{this.eventName="typo3:tree:filter-reset"}constructor(){super(v.eventName,{bubbles:!0,composed:!0})}}class c extends x{constructor(){super(...arguments),this.setup=null,this.settings={showIcons:!1,width:300,dataUrl:"",filterUrl:"",defaultProperties:{},expandUpToLevel:null,actions:[]},this.nodeMap=new y([]),this.currentScrollPosition=0,this.currentVisibleHeight=0,this.searchTerm=null,this.searchResults=0,this.loading=!1,this.hoveredNode=null,this.nodeDragAllowed=!1,this.isOverRoot=!1,this.nodeDragPosition=null,this.nodeDragMode=null,this.draggingNode=null,this.nodeHeight=32,this.indentWidth=20,this.displayNodes=[],this.focusedNode=null,this.lastFocusedNode=null,this.editingNode=null,this.openNodeTimeout={targetNode:null,timeout:null},this.unfilteredNodes="",this.muteErrorNotifications=!1,this.networkErrorTitle=S.get("tree_networkError"),this.networkErrorMessage=S.get("tree_networkErrorDescription"),this.allowNodeEdit=!1,this.allowNodeDrag=!1,this.allowNodeSorting=!1,this.currentFilterRequest=null,this.__loadPromise=new Promise(e=>this.__loadFinished=e),this.lastRenderScrollPosition=null}get loadComplete(){return this.__loadPromise}get nodes(){return this.nodeMap.toArray()}set nodes(e){this.nodeMap=new y(e)}getNodeFromElement(e){return e===null||!("treeId"in e.dataset)?null:this.getNodeByTreeIdentifier(e.dataset.treeId)}getElementFromNode(e){return this.querySelector('[data-tree-id="'+this.getNodeTreeIdentifier(e)+'"]')}hideChildren(e){e.__expanded=!1,this.saveNodeStatus(e),this.dispatchEvent(new CustomEvent("typo3:tree:expand-toggle",{detail:{node:e}}))}async showChildren(e){e.__expanded=!0,await this.loadChildren(e),this.saveNodeStatus(e),this.dispatchEvent(new CustomEvent("typo3:tree:expand-toggle",{detail:{node:e}}))}getDataUrl(e=null){return e===null?this.settings.dataUrl:this.settings.dataUrl+"&parent="+e.identifier+"&depth="+e.depth}getFilterUrl(){return this.settings.filterUrl+"&q="+this.searchTerm}async loadData(){this.loading=!0,this.nodeMap=new y(this.prepareNodes(await this.fetchData())),this.__loadFinished(),this.__loadPromise=new Promise(e=>this.__loadFinished=e),this.loading=!1}async fetchData(e=null){try{let r=await(await new w(this.getDataUrl(e)).get({cache:"no-cache"})).resolve();return Array.isArray(r)?(e!==null&&(r=r.filter(i=>i.identifier!==e.identifier),r.unshift(e)),r=this.enhanceNodes(r),e!==null&&r.shift(),(await Promise.all(r.map(async i=>{const o=i.__parents.join("_"),n=r.find(g=>g.__treeIdentifier===o)||null,d=n===null||n.__expanded;if(!i.loaded&&i.hasChildren&&i.__expanded&&d){const g=await this.fetchData(i);return i.loaded=!0,[i,...g]}else return[i]}))).flat()):[]}catch(t){return this.errorNotification(t),[]}}async loadChildren(e){try{if(e.loaded){await Promise.all(this.nodes.filter(i=>i.__parents.join("_")===e.__treeIdentifier&&!i.loaded&&i.hasChildren&&i.__expanded).map(i=>this.loadChildren(i)));return}e.__loading=!0;const t=this.prepareNodes(await this.fetchData(e)),r=this.nodes.indexOf(e)+1;let s=0;for(let i=r;i<this.nodes.length&&!(this.nodes[i].depth<=e.depth);++i)s++;this.nodeMap.splice(r,s,...t),e.__loading=!1,e.loaded=!0}catch(t){throw thiLine truncated
|
||||
Reference in new issue
Block a user