From 6cedafa07578aca8dc6b023b6db5f51d6fc6d98d Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Wed, 24 Apr 2024 17:37:11 +0200
Subject: [PATCH] [BUGFIX] Omit wrong value on inserting record
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When inserting a record via the element
browser, the value argument needs either
to be formatted manually or left empty,
allowing the element browser to format
the identifier automatically.

By omitting the value in the `PageBrowser`
module, the value is now correctly formatted
by the element browser to "pages_<uid>".

This makes the "node-action" usable for
TCA group fields, which allow more than
one record type.

The same logic is also used by the
`BrowseDatabase` module, which also
omits the value argument.

Resolves: #103700
Releases: main, 12.4
Change-Id: I80e2cc696d85b5ec83432c35a263b19f9752b0ef
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84018
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Andreas Kienast <a.fernandez@scripting-base.de>
Reviewed-by: Andreas Kienast <a.fernandez@scripting-base.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 Build/Sources/TypeScript/backend/tree/page-browser.ts           | 2 +-
 .../backend/Resources/Public/JavaScript/tree/page-browser.js    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Build/Sources/TypeScript/backend/tree/page-browser.ts b/Build/Sources/TypeScript/backend/tree/page-browser.ts
index ca8ea44de3f4..5b1910a36cab 100644
--- a/Build/Sources/TypeScript/backend/tree/page-browser.ts
+++ b/Build/Sources/TypeScript/backend/tree/page-browser.ts
@@ -96,7 +96,7 @@ export class PageBrowserTree extends PageTree {
       node.recordType,
       node.identifier,
       node.name,
-      node.identifier,
+      '',
       true
     );
   }
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-browser.js b/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-browser.js
index d7dc19973677..d7a32ccbffe1 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-browser.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-browser.js
@@ -18,7 +18,7 @@ var __decorate=function(e,t,n,o){var r,i=arguments.length,s=i<3?t:null===o?o=Obj
         <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){LinkBrowser.finalizeFunction("t3://page?uid="+e.identifier)}isLinkable(e){return!1===["199","254","255"].includes(String(e.recordType))}selectItem(e){ElementBrowser.insertElement(e.recordType,e.identifier,e.name,e.identifier,!0)}};PageBrowserTree=__decorate([customElement("typo3-backend-component-page-browser-tree")],PageBrowserTree);export{PageBrowserTree};let PageBrowser=class extends LitElement{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((e=>(parseInt(e.identifier,10)===this.activePageId&&(e.checked=!0),e)))},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 AjaxRequest(n).get().then((e=>e.resolve())).then((e=>{document.querySelector(".element-browser-main-content .element-browser-body").innerHTML=e}))},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(null!==this.configuration)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 AjaxRequest(e);return t.length&&(n=n.withQueryArguments("alternativeEntryPoints="+encodeURIComponent(t))),n.get().then((async e=>{const t=await e.resolve("json");return t.actions=this.actions,this.configuration=t,this.mountPointPath=t.temporaryMountPoint||null,t}))}render(){return html`
+      `:super.createNodeContentAction(e)}linkItem(e){LinkBrowser.finalizeFunction("t3://page?uid="+e.identifier)}isLinkable(e){return!1===["199","254","255"].includes(String(e.recordType))}selectItem(e){ElementBrowser.insertElement(e.recordType,e.identifier,e.name,"",!0)}};PageBrowserTree=__decorate([customElement("typo3-backend-component-page-browser-tree")],PageBrowserTree);export{PageBrowserTree};let PageBrowser=class extends LitElement{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((e=>(parseInt(e.identifier,10)===this.activePageId&&(e.checked=!0),e)))},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 AjaxRequest(n).get().then((e=>e.resolve())).then((e=>{document.querySelector(".element-browser-main-content .element-browser-body").innerHTML=e}))},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(null!==this.configuration)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 AjaxRequest(e);return t.length&&(n=n.withQueryArguments("alternativeEntryPoints="+encodeURIComponent(t))),n.get().then((async e=>{const t=await e.resolve("json");return t.actions=this.actions,this.configuration=t,this.mountPointPath=t.temporaryMountPoint||null,t}))}render(){return html`
       <div class="tree">
       ${until(this.renderTree(),"")}
       </div>
-- 
GitLab