TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -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 f,html as d,nothing as k}from"lit";import{property as m,state as c,customElement as y}from"lit/decorators.js";import{repeat as h}from"lit/directives/repeat.js";import g from"~labels/core.bookmarks";import u,{BookmarkStoreChangedEvent as b}from"@typo3/backend/bookmark/bookmark-store.js";import"@typo3/backend/bookmark/bookmark-manager.js";var l=function(r,t,e,s){var a=arguments.length,o=a<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,t,e,s);else for(var p=r.length-1;p>=0;p--)(i=r[p])&&(o=(a<3?i(o):a>3?i(t,e,o):i(t,e))||o);return a>3&&o&&Object.defineProperty(t,e,o),o};let n=class extends f{constructor(){super(...arguments),this.limit=0,this.groupId=null,this.groupedBookmarks=new Map,this.groups=[],this.handleStoreUpdate=()=>{this.syncFromStore()}}connectedCallback(){super.connectedCallback(),document.addEventListener(b,this.handleStoreUpdate),this.syncFromStore()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(b,this.handleStoreUpdate)}createRenderRoot(){return this}render(){return this.groupedBookmarks.size===0?d`<p class=dropdown-item-text>${g.get("description")}</p>`:d`<div class=widget-table-wrapper>${h(Array.from(this.groupedBookmarks.entries()),([t])=>t,([t,e])=>this.renderGroup(t,e,this.groupedBookmarks.size>1))}</div>`}async syncFromStore(){this.groupedBookmarks=await u.getGroupedBookmarks({groupId:this.groupId??void 0,limit:this.limit>0?this.limit:void 0,accessibleOnly:!0}),this.groups=await u.getGroups()}renderGroup(t,e,s){const o=this.groups.find(i=>i.id===t)?.label||g.get("notGrouped");return d`<table class="widget-table table table-striped table-hover">${s&&this.groupId===null?d`<thead><tr><th>${o}</th></tr></thead>`:k}<tbody>${h(e,i=>i.id,i=>this.renderBookmarkRow(i))}</tbody></table>`}renderBookmarkRow(t){return d`<tr><td><span class="bookmark-item-column bookmark-item-column-icon" aria-hidden=true> <typo3-backend-icon identifier=${t.iconIdentifier} overlay=${t.iconOverlayIdentifier} size=small></typo3-backend-icon> </span> <a href=${t.href} title=${t.title} @click=${e=>this.handleNavigate(e,t)}><span class="bookmark-item-column bookmark-item-column-title"> ${t.title} </span> </a></td></tr>`}handleNavigate(t,e){t.preventDefault(),u.navigate(e)}};l([m({type:Number})],n.prototype,"limit",void 0),l([m({attribute:"group",converter:{fromAttribute:r=>{if(r===null||r==="")return null;const t=Number(r);return Number.isNaN(t)?r:t},toAttribute:r=>r===null?null:String(r)}})],n.prototype,"groupId",void 0),l([c()],n.prototype,"groupedBookmarks",void 0),l([c()],n.prototype,"groups",void 0),n=l([y("typo3-dashboard-bookmarks-widget")],n);export{n as BookmarksWidgetElement};
|
||||
Reference in New Issue
Block a user