[TASK] Deprecate legacy FormEngine functions 72/61872/10
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 2 Oct 2019 06:24:58 +0000 (08:24 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 7 Oct 2019 07:47:28 +0000 (09:47 +0200)
This patch deprecates the last remaining legacy functions in FormEngine:

- setFormValueOpenBrowser()
- setFormValueFromBrowseWin()
- setHiddenFromList()
- setFormValueManipulate()
- setFormValue_getFObj()

Additionally, a call to the undefined function `group_change` has been
removed.

Resolves: #89331
Releases: master
Change-Id: Ie7419ed0581b92c37afd0614ca78287ffe286016
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61872
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
12 files changed:
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/FormEngine/Container/InlineControlContainer.ts
Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ElementBrowser.ts
Build/Sources/TypeScript/scheduler/Resources/Public/TypeScript/PageBrowser.ts [deleted file]
Build/Sources/TypeScript/scheduler/Resources/Public/TypeScript/Scheduler.ts
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine/Container/InlineControlContainer.js
typo3/sysext/core/Documentation/Changelog/master/Deprecation-89331-FormEngineLegacyFunctions.rst [new file with mode: 0644]
typo3/sysext/form/Resources/Public/JavaScript/Backend/FormEditor/InspectorComponent.js
typo3/sysext/recordlist/Resources/Public/JavaScript/ElementBrowser.js
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Resources/Public/JavaScript/PageBrowser.js [deleted file]
typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js

index 4d09bce..9dfe559 100644 (file)
@@ -377,21 +377,23 @@ class InlineControlContainer {
       throw 'Denied message sent by ' + e.origin;
     }
 
-    if (typeof e.data.objectGroup === 'undefined') {
-      throw 'No object group defined for message';
-    }
+    if (e.data.actionName === 'typo3:elementBrowser:elementInserted') {
+      if (typeof e.data.objectGroup === 'undefined') {
+        throw 'No object group defined for message';
+      }
 
-    if (e.data.objectGroup !== this.container.dataset.objectGroup) {
-      // Received message isn't provisioned for current InlineControlContainer instance
-      return;
-    }
+      if (e.data.objectGroup !== this.container.dataset.objectGroup) {
+        // Received message isn't provisioned for current InlineControlContainer instance
+        return;
+      }
 
-    if (this.isUniqueElementUsed(parseInt(e.data.uid, 10), e.data.table)) {
-      Notification.error('There is already a relation to the selected element');
-      return;
-    }
+      if (this.isUniqueElementUsed(parseInt(e.data.uid, 10), e.data.table)) {
+        Notification.error('There is already a relation to the selected element');
+        return;
+      }
 
-    this.importRecord([e.data.objectGroup, e.data.uid]);
+      this.importRecord([e.data.objectGroup, e.data.uid]);
+    }
   }
 
   /**
index ac6a826..342be6c 100644 (file)
@@ -32,7 +32,6 @@ declare global {
     setFormValueFromBrowseWin: Function;
     editform: any;
     content: any;
-    group_change: any;
   }
 }
 
@@ -142,6 +141,7 @@ class ElementBrowser {
     if (this.irre.objectId) {
       if (this.getParent()) {
         const message = {
+          actionName: 'typo3:elementBrowser:elementInserted',
           objectGroup: this.irre.objectId,
           table: table,
           uid: uid,
@@ -161,32 +161,25 @@ class ElementBrowser {
 
     if (this.fieldReference && !this.rte.parameters && !this.rte.configuration) {
       this.addElement(filename, table + '_' + uid, fp, close);
-    } else {
-      if (
-        this.getParent() && this.getParent().content && this.getParent().content.document.editform
-        && this.getParent().content.document.editform[this.formFieldName]
-      ) {
-        this.getParent().group_change(
-          'add',
-          this.fieldReference,
-          this.rte.parameters,
-          this.rte.configuration,
-          this.targetDoc.editform[this.formFieldName],
-          this.getParent().content.document,
-        );
-      } else {
-        alert('Error - reference to main window is not set properly!');
-      }
-      if (close) {
-        this.focusOpenerAndClose();
-      }
     }
     return false;
   }
 
   public addElement(elName: string, elValue: string, altElValue: string, close: boolean): void {
-    if (this.getParent() && this.getParent().setFormValueFromBrowseWin) {
-      this.getParent().setFormValueFromBrowseWin(this.fieldReference, altElValue ? altElValue : elValue, elName);
+    if (this.getParent()) {
+      if (this.getParent().setFormValueFromBrowseWin) {
+        console.warn('setFormValueFromBrowseWin has been marked as deprecated. Listen to message events instead.');
+        this.getParent().setFormValueFromBrowseWin(this.fieldReference, altElValue ? altElValue : elValue, elName);
+      }
+
+      const message = {
+        actionName: 'typo3:elementBrowser:elementAdded',
+        fieldName: this.fieldReference,
+        value: altElValue ? altElValue : elValue,
+        label: elName
+      };
+      MessageUtility.send(message, this.getParent());
+
       if (close) {
         this.focusOpenerAndClose();
       }
diff --git a/Build/Sources/TypeScript/scheduler/Resources/Public/TypeScript/PageBrowser.ts b/Build/Sources/TypeScript/scheduler/Resources/Public/TypeScript/PageBrowser.ts
deleted file mode 100644 (file)
index 1fb41a6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 * as $ from 'jquery';
-
-/**
- * Module: TYPO3/CMS/Scheduler/PageBrowser
- * Javascript for adding links for calling the page browser pop up
- */
-class PageBrowser {
-  constructor() {
-    $(document).on('click', '.t3js-pageBrowser', (evt: JQueryEventObject): void => {
-      let browserWin: Window;
-      let pageUrl: string = $(evt.currentTarget).data('url');
-      browserWin = window.open(pageUrl, 'Typo3WinBrowser', 'height=650,width=800,status=0,menubar=0,resizable=1,scrollbars=1');
-      browserWin.focus();
-    });
-  }
-}
-
-export = new PageBrowser();
index 2e24d74..ac8d43e 100644 (file)
@@ -14,6 +14,8 @@
 import * as $ from 'jquery';
 import 'datatables';
 import DocumentSaveActions = require('TYPO3/CMS/Backend/DocumentSaveActions');
+import Modal = require('TYPO3/CMS/Backend/Modal');
+import MessageUtility = require('TYPO3/CMS/Backend/Utility/MessageUtility');
 
 interface TableNumberMapping {
   [s: string]: number;
@@ -27,6 +29,15 @@ declare let defaultNumberOfDays: TableNumberMapping;
 class Scheduler {
   private allCheckedStatus: boolean = false;
 
+  private static updateElementBrowserTriggers(): void {
+    const triggers = document.querySelectorAll('.t3js-element-browser');
+
+    triggers.forEach((el: HTMLAnchorElement): void => {
+      const triggerField = <HTMLInputElement>document.getElementById(el.dataset.triggerFor);
+      el.dataset.params = triggerField.name + '|||pages';
+    });
+  }
+
   constructor() {
     this.initializeEvents();
     this.initializeDefaultStates();
@@ -160,6 +171,19 @@ class Scheduler {
       'paging': false,
       'searching': false,
     });
+
+    $(document).on('click', '.t3js-element-browser', (e: JQueryEventObject): void => {
+      e.preventDefault();
+
+      const el = <HTMLAnchorElement>e.currentTarget;
+      Modal.advanced({
+        type: Modal.types.iframe,
+        content: el.href + '&mode=' + el.dataset.mode + '&bparams=' + el.dataset.params,
+        size: Modal.sizes.large
+      });
+    });
+
+    window.addEventListener('message', this.listenOnElementBrowser);
   }
 
   /**
@@ -173,6 +197,27 @@ class Scheduler {
     let $taskClass = $('#task_class');
     if ($taskClass.length) {
       this.actOnChangedTaskClass($taskClass);
+      Scheduler.updateElementBrowserTriggers();
+    }
+  }
+
+  private listenOnElementBrowser = (e: MessageEvent): void => {
+    if (!MessageUtility.MessageUtility.verifyOrigin(e.origin)) {
+      throw 'Denied message sent by ' + e.origin;
+    }
+
+    if (e.data.actionName === 'typo3:elementBrowser:elementAdded') {
+      if (typeof e.data.fieldName === 'undefined') {
+        throw 'fieldName not defined in message';
+      }
+
+      if (typeof e.data.value === 'undefined') {
+        throw 'value not defined in message';
+      }
+
+      const result = e.data.value.split('_');
+      const field = <HTMLInputElement>document.querySelector('input[name="' + e.data.fieldName + '"]');
+      field.value = result[1];
     }
   }
 }
index 1965566..0a42edf 100644 (file)
  */
 
 // add legacy functions to be accessible in the global scope
-var setFormValueOpenBrowser,
-  setFormValueFromBrowseWin,
-  setHiddenFromList,
-  setFormValueManipulate,
-  setFormValue_getFObj;
+var setFormValueOpenBrowser, // @deprecated
+  setFormValueFromBrowseWin, // @deprecated
+  setHiddenFromList, // @deprecated
+  setFormValueManipulate, // @deprecated
+  setFormValue_getFObj; // @deprecated
 
 /**
  * Module: TYPO3/CMS/Backend/FormEngine
@@ -34,10 +34,11 @@ define(['jquery',
   'TYPO3/CMS/Backend/FormEngineValidation',
   'TYPO3/CMS/Backend/DocumentSaveActions',
   'TYPO3/CMS/Backend/Modal',
+  'TYPO3/CMS/Backend/Utility/MessageUtility',
   'TYPO3/CMS/Backend/Severity',
   'TYPO3/CMS/Backend/BackendException',
   'TYPO3/CMS/Backend/Event/InteractionRequestMap'
-], function($, FormEngineValidation, DocumentSaveActions, Modal, Severity, BackendException, InteractionRequestMap) {
+], function($, FormEngineValidation, DocumentSaveActions, Modal, MessageUtility, Severity, BackendException, InteractionRequestMap) {
 
   /**
    * @param {InteractionRequest} interactionRequest
@@ -66,15 +67,25 @@ define(['jquery',
     browserUrl: ''
   };
 
-  // functions to connect the db/file browser with this document and the formfields on it!
+  /**
+   * Opens a popup window with the element browser (browser.php)
+   *
+   * @param {string} mode can be "db" or "file"
+   * @param {string} params additional params for the browser window
+   * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11.0. Use FormEngine.openPopupWindow() instead.
+   */
+  setFormValueOpenBrowser = function(mode, params) {
+    console.warn('setFormValueOpenBrowser() has been marked as deprecated and will be removed in TYPO3 v11. Use FormEngine.openPopupWindow instead.');
+    return FormEngine.openPopupWindow(mode, params);
+  };
 
   /**
    * Opens a popup window with the element browser (browser.php)
    *
-   * @param {String} mode can be "db" or "file"
-   * @param {String} params additional params for the browser window
+   * @param {string} mode can be "db" or "file"
+   * @param {string} params additional params for the browser window
    */
-  FormEngine.openPopupWindow = setFormValueOpenBrowser = function(mode, params) {
+  FormEngine.openPopupWindow = function(mode, params) {
     return Modal.advanced({
       type: Modal.types.iframe,
       content: FormEngine.browserUrl + '&mode=' + mode + '&bparams=' + params,
@@ -87,14 +98,35 @@ define(['jquery',
    * or from a multi-select (two selects side-by-side)
    * previously known as "setFormValueFromBrowseWin"
    *
-   * @param {String} fieldName Formerly known as "fName" name of the field, like [tt_content][2387][header]
-   * @param {(String|Number)} value The value to fill in (could be an integer)
-   * @param {String} label The visible name in the selector
-   * @param {String} title The title when hovering over it
-   * @param {String} exclusiveValues If the select field has exclusive options that are not combine-able
+   * @param {string} fieldName Formerly known as "fsetFormValueFromBrowseWinName" name of the field, like [tt_content][2387][header]
+   * @param {string|number} value The value to fill in (could be an integer)
+   * @param {string} label The visible name in the selector
+   * @param {string} title The title when hovering over it
+   * @param {string} exclusiveValues If the select field has exclusive options that are not combine-able
+   * @param {$} $optionEl The jQuery object of the selected <option> tag
+   * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11.0. Use FormEngine.setSelectOptionFromExternalSource() instead.
+   */
+  setFormValueFromBrowseWin = function(fieldName, value, label, title, exclusiveValues, $optionEl) {
+    console.warn(
+      'setFormValueFromBrowseWin() has been marked as deprecated and will be removed in TYPO3 v11. '
+      + 'Use FormEngine.setSelectOptionFromExternalSource() or send a message instead.'
+    );
+    FormEngine.setSelectOptionFromExternalSource(fieldName, value, label, title, exclusiveValues, $optionEl);
+  };
+
+  /**
+   * properly fills the select field from the popup window (element browser, link browser)
+   * or from a multi-select (two selects side-by-side)
+   * previously known as "setFormValueFromBrowseWin"
+   *
+   * @param {string} fieldName Formerly known as "fsetFormValueFromBrowseWinName" name of the field, like [tt_content][2387][header]
+   * @param {string|number} value The value to fill in (could be an integer)
+   * @param {string} label The visible name in the selector
+   * @param {string} title The title when hovering over it
+   * @param {string} exclusiveValues If the select field has exclusive options that are not combine-able
    * @param {$} $optionEl The jQuery object of the selected <option> tag
    */
-  FormEngine.setSelectOptionFromExternalSource = setFormValueFromBrowseWin = function(fieldName, value, label, title, exclusiveValues, $optionEl) {
+  FormEngine.setSelectOptionFromExternalSource = function(fieldName, value, label, title, exclusiveValues, $optionEl) {
     exclusiveValues = String(exclusiveValues);
 
     var $fieldEl,
@@ -226,8 +258,21 @@ define(['jquery',
    *
    * @param {HTMLElement} selectFieldEl the select field
    * @param {HTMLElement} originalFieldEl the hidden form field
+   * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11.0. Use FormEngine.updateHiddenFieldValueFromSelect() instead.
    */
-  FormEngine.updateHiddenFieldValueFromSelect = setHiddenFromList = function(selectFieldEl, originalFieldEl) {
+  setHiddenFromList = function(selectFieldEl, originalFieldEl) {
+    console.warn('setHiddenFromList() has been marked as deprecated and will be removed in TYPO3 v11. Use FormEngine.updateHiddenFieldValueFromSelect() instead.');
+    FormEngine.updateHiddenFieldValueFromSelect(selectFieldEl, originalFieldEl);
+  };
+
+  /**
+   * sets the value of the hidden field, from the select list, always executed after the select field was updated
+   * previously known as global function setHiddenFromList()
+   *
+   * @param {HTMLElement} selectFieldEl the select field
+   * @param {HTMLElement} originalFieldEl the hidden form field
+   */
+  FormEngine.updateHiddenFieldValueFromSelect = function(selectFieldEl, originalFieldEl) {
     var selectedValues = [];
     $(selectFieldEl).find('option').each(function() {
       selectedValues.push($(this).prop('value'));
@@ -244,8 +289,10 @@ define(['jquery',
    * @param {String} fName
    * @param {String} type
    * @param {Number} maxLength
+   * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11.0.
    */
   setFormValueManipulate = function(fName, type, maxLength) {
+    console.warn('setFormValueManipulate() has been marked as deprecated and will be removed in TYPO3 v11.');
     var $formEl = FormEngine.getFormElement(fName);
     if ($formEl.length > 0) {
       var formObj = $formEl.get(0);
@@ -419,8 +466,10 @@ define(['jquery',
    *
    * @param {String} fieldName the name of the field name
    * @returns {*|HTMLElement}
+   * @deprecated since TYPO3 v10.2, will be removed in TYPO3 v11.0. Use FormEngine.getFormElement() instead.
    */
   setFormValue_getFObj = function(fieldName) {
+    console.warn('setFormValue_getFObj() has been marked as deprecated and will be removed in TYPO3 v11. Use FormEngine.getFormElement() instead.');
     var $formEl = FormEngine.getFormElement(fieldName);
     if ($formEl.length > 0) {
       // return the DOM element of the form object
@@ -548,6 +597,8 @@ define(['jquery',
 
       FormEngine.openPopupWindow(mode, params);
     });
+
+    window.addEventListener('message', FormEngine.handlePostMessage);
   };
 
   /**
@@ -589,6 +640,28 @@ define(['jquery',
     }
   };
 
+  FormEngine.handlePostMessage = function (e) {
+    if (!MessageUtility.MessageUtility.verifyOrigin(e.origin)) {
+      throw 'Denied message sent by ' + e.origin;
+    }
+
+    if (e.data.actionName === 'typo3:elementBrowser:elementAdded') {
+      if (typeof e.data.fieldName === 'undefined') {
+        throw 'fieldName not defined in message';
+      }
+
+      if (typeof e.data.value === 'undefined') {
+        throw 'value not defined in message';
+      }
+
+      const label = e.data.label || e.data.value;
+      const title = e.data.title || label;
+      const exclusiveValues = e.data.exclusiveValues || '';
+
+      FormEngine.setSelectOptionFromExternalSource(e.data.fieldName, e.data.value, label, title, exclusiveValues);
+    }
+  };
+
   /**
    * Initializes the remaining character views based on the fields' maxlength attribute
    */
index 6b58a1b..80ccbf2 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./../InlineRelation/AjaxDispatcher","../../Utility/MessageUtility","jquery","TYPO3/CMS/Backend/FormEngine","TYPO3/CMS/Backend/FormEngineValidation","../../Icons","../../InfoWindow","../../Modal","../../Notification","nprogress","../../Severity","Sortable","../../Utility"],function(e,t,n,i,o,r,a,s,l,c,d,u,g,h,p){"use strict";var m,f,b,v;!function(e){e.toggleSelector='[data-toggle="formengine-inline"]',e.controlSectionSelector=".t3js-formengine-irre-control",e.createNewRecordButtonSelector=".t3js-create-new-button",e.createNewRecordBySelectorSelector=".t3js-create-new-selector",e.deleteRecordButtonSelector=".t3js-editform-delete-inline-record",e.enableDisableRecordButtonSelector=".t3js-toggle-visibility-button",e.infoWindowButton='[data-action="infowindow"]',e.synchronizeLocalizeRecordButtonSelector=".t3js-synchronizelocalize-button",e.uniqueValueSelectors="select.t3js-inline-unique",e.revertUniqueness=".t3js-revert-unique",e.controlContainerButtons=".t3js-inline-controls"}(m||(m={})),function(e){e.new="inlineIsNewRecord",e.visible="panel-visible",e.collapsed="panel-collapsed"}(f||(f={})),function(e){e.structureSeparator="-"}(b||(b={})),function(e){e.DOWN="down",e.UP="up"}(v||(v={}));class S{constructor(e){this.container=null,this.ajaxDispatcher=null,this.appearance=null,this.xhrQueue={},this.progessQueue={},this.noTitleString=TYPO3.lang?TYPO3.lang["FormEngine.noRecordTitle"]:"[No title]",this.handlePostMessage=(e=>{if(!i.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if(void 0===e.data.objectGroup)throw"No object group defined for message";e.data.objectGroup===this.container.dataset.objectGroup&&(this.isUniqueElementUsed(parseInt(e.data.uid,10),e.data.table)?d.error("There is already a relation to the selected element"):this.importRecord([e.data.objectGroup,e.data.uid]))}),o(()=>{this.container=document.querySelector("#"+e),this.ajaxDispatcher=new n.AjaxDispatcher(this.container.dataset.objectGroup),this.registerEvents()})}static getDelegatedEventTarget(e,t){let n;return null===(n=e.closest(t))&&e.matches(t)&&(n=e),n}static getInlineRecordContainer(e){return document.querySelector('[data-object-id="'+e+'"]')}static registerInfoButton(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.infoWindowButton))&&(e.preventDefault(),e.stopImmediatePropagation(),l.showItem(t.dataset.infoTable,t.dataset.infoUid))}static toggleElement(e){const t=S.getInlineRecordContainer(e);t.classList.contains(f.collapsed)?(t.classList.remove(f.collapsed),t.classList.add(f.visible)):(t.classList.remove(f.visible),t.classList.add(f.collapsed))}static isNewRecord(e){return S.getInlineRecordContainer(e).classList.contains(f.new)}static updateExpandedCollapsedStateLocally(e,t){const n=S.getInlineRecordContainer(e),i="uc[inlineView]["+n.dataset.topmostParentTable+"]["+n.dataset.topmostParentUid+"]"+n.dataset.fieldName,o=document.getElementsByName(i);o.length&&(o[0].value=t?"1":"0")}static getValuesFromHashMap(e){return Object.keys(e).map(t=>e[t])}static selectOptionValueExists(e,t){return null!==e.querySelector('option[value="'+t+'"]')}static removeSelectOptionByValue(e,t){const n=e.querySelector('option[value="'+t+'"]');null!==n&&n.remove()}static reAddSelectOption(e,t,n){if(S.selectOptionValueExists(e,t))return;const i=e.querySelectorAll("option");let o=-1;for(let e of Object.keys(n.possible)){if(e===t)break;for(let t=0;t<i.length;++t){if(i[t].value===e){o=t;break}}}-1===o?o=0:o<i.length&&o++;const r=document.createElement("option");r.text=n.possible[t],r.value=t,e.insertBefore(r,e.options[o])}registerEvents(){if(this.container.addEventListener("click",e=>{this.registerToggle(e),this.registerSort(e),this.registerCreateRecordButton(e),this.registerEnableDisableButton(e),S.registerInfoButton(e),this.registerDeleteButton(e),this.registerSynchronizeLocalize(e),this.registerRevertUniquenessAction(e)}),this.container.addEventListener("change",e=>{this.registerCreateRecordBySelector(e),this.registerUniqueSelectFieldChanged(e)}),window.addEventListener("message",this.handlePostMessage),this.getAppearance().useSortable){const e=document.querySelector("#"+this.container.getAttribute("id")+"_records");new h(e,{group:e.getAttribute("id"),handle:".sortableHandle",onSort:()=>{this.updateSorting()}})}}registerToggle(e){if(S.getDelegatedEventTarget(e.target,m.controlSectionSelector))return;let t;null!==(t=S.getDelegatedEventTarget(e.target,m.toggleSelector))&&(e.preventDefault(),e.stopImmediatePropagation(),this.loadRecordDetails(t.parentElement.dataset.objectId))}registerSort(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.controlSectionSelector+' [data-action="sort"]'))&&(e.preventDefault(),e.stopImmediatePropagation(),this.changeSortingByButton(t.closest("[data-object-id]").dataset.objectId,t.dataset.direction))}registerCreateRecordButton(e){let t;if(null!==(t=S.getDelegatedEventTarget(e.target,m.createNewRecordButtonSelector))&&(e.preventDefault(),e.stopImmediatePropagation(),this.isBelowMax())){let e=this.container.dataset.objectGroup;void 0!==t.dataset.recordUid&&(e+=b.structureSeparator+t.dataset.recordUid),this.importRecord([e],t.dataset.recordUid)}}registerCreateRecordBySelector(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.createNewRecordBySelectorSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=t,i=n.options[n.selectedIndex].getAttribute("value");this.importRecord([this.container.dataset.objectGroup,i])}createRecord(e,t,n=null,i=null){let o=this.container.dataset.objectGroup;null!==n&&(o+=b.structureSeparator+n),null!==n?(S.getInlineRecordContainer(o).insertAdjacentHTML("afterend",t),this.memorizeAddRecord(e,n,i)):(document.querySelector("#"+this.container.getAttribute("id")+"_records").insertAdjacentHTML("beforeend",t),this.memorizeAddRecord(e,null,i))}importRecord(e,t){this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_create")).withContext().withParams(e)).done(e=>{this.isBelowMax()&&(this.createRecord(e.compilerInput.uid,e.data,void 0!==t?t:null,void 0!==e.compilerInput.childChildUid?e.compilerInput.childChildUid:null),r.reinitialize(),r.Validation.initializeInputFields(),r.Validation.validate())})}registerEnableDisableButton(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.enableDisableRecordButtonSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=t.closest("[data-object-id]").dataset.objectId,i=S.getInlineRecordContainer(n),o="data"+i.dataset.fieldName+"["+t.dataset.hiddenField+"]",r=document.querySelector('[data-formengine-input-name="'+o+'"'),a=document.querySelector('[name="'+o+'"');null!==r&&null!==a&&(r.checked=!r.checked,a.value=r.checked?"1":"0",TBE_EDITOR.fieldChanged_fName(o,o));const l="t3-form-field-container-inline-hidden";let c="";i.classList.contains(l)?(c="actions-edit-hide",i.classList.remove(l)):(c="actions-edit-unhide",i.classList.add(l)),s.getIcon(c,s.sizes.small).done(e=>{t.replaceChild(document.createRange().createContextualFragment(e),t.querySelector(".t3js-icon"))})}registerDeleteButton(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.deleteRecordButtonSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?",i=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";c.confirm(n,i,g.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",active:!0,btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes"}]).on("button.clicked",e=>{if("yes"===e.target.name){const e=t.closest("[data-object-id]").dataset.objectId;this.deleteRecord(e)}c.dismiss()})}registerSynchronizeLocalize(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.synchronizeLocalizeRecordButtonSelector)))return;this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_synchronizelocalize")).withContext().withParams([this.container.dataset.objectGroup,t.dataset.type])).done(e=>{document.querySelector("#"+this.container.getAttribute("id")+"_records").insertAdjacentHTML("beforeend",e.data);const t=this.container.dataset.objectGroup+b.structureSeparator;for(let n of e.compilerInput.delete)this.deleteRecord(t+n,!0);for(let n of e.compilerInput.localize){if(void 0!==n.remove){const e=S.getInlineRecordContainer(t+n.remove);e.parentElement.removeChild(e)}this.memorizeAddRecord(n.uid,null,n.selectedValue)}})}registerUniqueSelectFieldChanged(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.uniqueValueSelectors)))return;const n=t.closest("[data-object-id]");if(null!==n){const e=n.dataset.objectId,i=n.dataset.objectUid;this.handleChangedField(t,e);const o=this.getFormFieldForElements();if(null===o)return;this.updateUnique(t,o,i)}}registerRevertUniquenessAction(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.revertUniqueness))&&this.revertUnique(t.dataset.uid)}loadRecordDetails(e){const t=document.querySelector("#"+e+"_fields"),n=void 0!==this.xhrQueue[e];if(null!==t&&"\x3c!--notloaded--\x3e"!==t.innerHTML.substr(0,16))this.collapseExpandRecord(e);else{const i=this.getProgress(e);if(n)this.xhrQueue[e].abort(),delete this.xhrQueue[e],delete this.progessQueue[e],i.done();else{const n=this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_details")).withContext().withParams([e]));n.done(n=>{if(delete this.xhrQueue[e],delete this.progessQueue[e],t.innerHTML=n.data,this.collapseExpandRecord(e),i.done(),r.reinitialize(),r.Validation.initializeInputFields(),r.Validation.validate(),this.hasObjectGroupDefinedUniqueConstraints()){const t=S.getInlineRecordContainer(e);this.removeUsed(t)}}),this.xhrQueue[e]=n,i.start()}}}collapseExpandRecord(e){const t=S.getInlineRecordContainer(e),n=!0===this.getAppearance().expandSingle,i=t.classList.contains(f.collapsed);let o=[];const r=[];n&&i&&(o=this.collapseAllRecords(t.dataset.objectUid)),S.toggleElement(e),S.isNewRecord(e)?S.updateExpandedCollapsedStateLocally(e,i):i?r.push(t.dataset.objectUid):i||o.push(t.dataset.objectUid),this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_expandcollapse")).withContext().withParams([e,r.join(","),o.join(",")]))}memorizeAddRecord(e,t=null,n=null){const i=this.getFormFieldForElements();if(null===i)return;let r=p.trimExplode(",",i.value);if(t){const n=[];for(let i=0;i<r.length;i++)r[i].length&&n.push(r[i]),t===r[i]&&n.push(e);r=n}else r.push(e);i.value=r.join(","),i.classList.add("has-change"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,r),this.setUnique(e,n),this.isBelowMax()||this.toggleContainerControls(!1),TBE_EDITOR.fieldChanged_fName(i.name,i)}memorizeRemoveRecord(e){const t=this.getFormFieldForElements();if(null===t)return[];let n=p.trimExplode(",",t.value);const i=n.indexOf(e);return i>-1&&(delete n[i],t.value=n.join(","),t.classList.add("has-change"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,n)),n}changeSortingByButton(e,t){const n=S.getInlineRecordContainer(e),i=n.dataset.objectUid,o=document.querySelector("#"+this.container.getAttribute("id")+"_records"),r=Array.from(o.children).map(e=>e.dataset.objectUid);let a=r.indexOf(i),s=!1;if(t===v.UP&&a>0?(r[a]=r[a-1],r[a-1]=i,s=!0):t===v.DOWN&&a<r.length-1&&(r[a]=r[a+1],r[a+1]=i,s=!0),s){const e=this.container.dataset.objectGroup+b.structureSeparator,i=t===v.UP?1:0;n.parentElement.insertBefore(S.getInlineRecordContainer(e+r[a-i]),S.getInlineRecordContainer(e+r[a+1-i])),this.updateSorting()}}updateSorting(){const e=this.getFormFieldForElements();if(null===e)return;const t=document.querySelector("#"+this.container.getAttribute("id")+"_records"),n=Array.from(t.children).map(e=>e.dataset.objectUid);e.value=n.join(","),e.classList.add("has-change"),o(document).trigger("inline:sorting-changed"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,n)}deleteRecord(e,t=!1){const n=S.getInlineRecordContainer(e),i=n.dataset.objectUid;if(n.classList.add("t3js-inline-record-deleted"),!S.isNewRecord(e)&&!t){const e=this.container.querySelector('[name="cmd'+n.dataset.fieldName+'[delete]"]');e.removeAttribute("disabled"),n.parentElement.insertAdjacentElement("afterbegin",e)}n.addEventListener("transitionend",()=>{n.parentElement.removeChild(n),a.validate()}),this.revertUnique(i),this.memorizeRemoveRecord(i),n.classList.add("form-irre-object--deleted"),this.isBelowMax()&&this.toggleContainerControls(!0)}toggleContainerControls(e){this.container.querySelectorAll(m.controlContainerButtons+" a").forEach(t=>{t.style.display=e?null:"none"})}getProgress(e){const t="#"+e+"_header";let n;return void 0!==this.progessQueue[e]?n=this.progessQueue[e]:((n=u).configure({parent:t,showSpinner:!1}),this.progessQueue[e]=n),n}collapseAllRecords(e){const t=this.getFormFieldForElements(),n=[];if(null!==t){const i=p.trimExplode(",",t.value);for(let t of i){if(t===e)continue;const i=this.container.dataset.objectGroup+b.structureSeparator+t,o=S.getInlineRecordContainer(i);o.classList.contains(f.visible)&&(o.classList.remove(f.visible),o.classList.add(f.collapsed),S.isNewRecord(i)?S.updateExpandedCollapsedStateLocally(i,!1):n.push(t))}}return n}getFormFieldForElements(){const e=document.getElementsByName(this.container.dataset.formField);return e.length>0?e[0]:null}redrawSortingButtons(e,t=[]){if(0===t.length){const e=this.getFormFieldForElements();null!==e&&(t=p.trimExplode(",",e.value))}0!==t.length&&t.forEach((n,i)=>{const o="#"+e+b.structureSeparator+n+"_header",r=document.querySelector(o),a=r.querySelector('[data-action="sort"][data-direction="'+v.UP+'"]');if(null!==a){let e="actions-move-up";0===i?(a.classList.add("disabled"),e="empty-empty"):a.classList.remove("disabled"),s.getIcon(e,s.sizes.small).done(e=>{a.replaceChild(document.createRange().createContextualFragment(e),a.querySelector(".t3js-icon"))})}const l=r.querySelector('[data-action="sort"][data-direction="'+v.DOWN+'"]');if(null!==l){let e="actions-move-down";i===t.length-1?(l.classList.add("disabled"),e="empty-empty"):l.classList.remove("disabled"),s.getIcon(e,s.sizes.small).done(e=>{l.replaceChild(document.createRange().createContextualFragment(e),l.querySelector(".t3js-icon"))})}})}isBelowMax(){const e=this.getFormFieldForElements();if(null===e)return!0;if(void 0!==TYPO3.settings.FormEngineInline.config[this.container.dataset.objectGroup]){if(p.trimExplode(",",e.value).length>=TYPO3.settings.FormEngineInline.config[this.container.dataset.objectGroup].max)return!1;if(this.hasObjectGroupDefinedUniqueConstraints()){const e=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if(e.used.length>=e.max&&e.max>=0)return!1}}return!0}isUniqueElementUsed(e,t){if(!this.hasObjectGroupDefinedUniqueConstraints())return!1;const n=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],i=S.getValuesFromHashMap(n.used);if("select"===n.type&&-1!==i.indexOf(e))return!0;if("groupdb"===n.type)for(let n=i.length-1;n>=0;n--)if(i[n].table===t&&i[n].uid===e)return!0;return!1}removeUsed(e){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const t=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if("select"!==t.type)return;let n=e.querySelector('[name="data['+t.table+"]["+e.dataset.objectUid+"]["+t.field+']"]');const i=S.getValuesFromHashMap(t.used);if(null!==n){const e=n.options[n.selectedIndex].value;for(let t of i)t!==e&&S.removeSelectOptionByValue(n,t)}}setUnique(e,t){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const n=document.querySelector("#"+this.container.dataset.objectGroup+"_selector"),i=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if("select"===i.type){if(!i.selector||-1!==i.max){const o=this.getFormFieldForElements(),r=this.container.dataset.objectGroup+b.structureSeparator+e;let a=S.getInlineRecordContainer(r).querySelector('[name="data['+i.table+"]["+e+"]["+i.field+']"]');const s=S.getValuesFromHashMap(i.used);if(null!==n){if(null!==a){for(let e of s)S.removeSelectOptionByValue(a,e);i.selector||(t=a.options[0].value,a.options[0].selected=!0,this.updateUnique(a,o,e),this.handleChangedField(a,this.container.dataset.objectGroup+"["+e+"]"))}for(let e of s)S.removeSelectOptionByValue(a,e);void 0!==i.used.length&&(i.used={}),i.used[e]={table:i.elTable,uid:t}}if(null!==o&&S.selectOptionValueExists(n,t)){const n=p.trimExplode(",",o.value);for(let o of n)null!==(a=document.querySelector('[name="data['+i.table+"]["+o+"]["+i.field+']"]'))&&o!==e&&S.removeSelectOptionByValue(a,t)}}}else"groupdb"===i.type&&(i.used[e]={table:i.elTable,uid:t});"select"===i.selector&&S.selectOptionValueExists(n,t)&&(S.removeSelectOptionByValue(n,t),i.used[e]={table:i.elTable,uid:t})}updateUnique(e,t,n){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const i=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],o=i.used[n];if("select"===i.selector){const t=document.querySelector("#"+this.container.dataset.objectGroup+"_selector");S.removeSelectOptionByValue(t,e.value),void 0!==o&&S.reAddSelectOption(t,o,i)}if(i.selector&&-1===i.max)return;if(!i||null===t)return;const r=p.trimExplode(",",t.value);let a;for(let t of r)null!==(a=document.querySelector('[name="data['+i.table+"]["+t+"]["+i.field+']"]'))&&a!==e&&(S.removeSelectOptionByValue(a,e.value),void 0!==o&&S.reAddSelectOption(a,o,i));i.used[n]=e.value}revertUnique(e){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const t=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],n=this.container.dataset.objectGroup+b.structureSeparator+e,i=S.getInlineRecordContainer(n);let o=i.querySelector('[name="data['+t.table+"]["+i.dataset.objectUid+"]["+t.field+']"]');if("select"===t.type){let n;if(null!==o)n=o.value;else{if(""===i.dataset.tableUniqueOriginalValue)return;n=i.dataset.tableUniqueOriginalValue}if("select"===t.selector&&!isNaN(parseInt(n,10))){const e=document.querySelector("#"+this.container.dataset.objectGroup+"_selector");S.reAddSelectOption(e,n,t)}if(t.selector&&-1===t.max)return;const r=this.getFormFieldForElements();if(null===r)return;const a=p.trimExplode(",",r.value);let s;for(let e=0;e<a.length;e++)null!==(s=document.querySelector('[name="data['+t.table+"]["+a[e]+"]["+t.field+']"]'))&&S.reAddSelectOption(s,n,t);delete t.used[e]}else"groupdb"===t.type&&delete t.used[e]}hasObjectGroupDefinedUniqueConstraints(){return void 0!==TYPO3.settings.FormEngineInline.unique&&void 0!==TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup]}handleChangedField(e,t){let n;n=e instanceof HTMLSelectElement?e.options[e.selectedIndex].text:e.value,document.querySelector("#"+t+"_label").textContent=n.length?n:this.noTitleString}getAppearance(){if(null===this.appearance&&(this.appearance={},"string"==typeof this.container.dataset.appearance))try{this.appearance=JSON.parse(this.container.dataset.appearance)}catch(e){console.error(e)}return this.appearance}}return S});
\ No newline at end of file
+define(["require","exports","./../InlineRelation/AjaxDispatcher","../../Utility/MessageUtility","jquery","TYPO3/CMS/Backend/FormEngine","TYPO3/CMS/Backend/FormEngineValidation","../../Icons","../../InfoWindow","../../Modal","../../Notification","nprogress","../../Severity","Sortable","../../Utility"],function(e,t,n,i,o,r,a,s,l,c,d,u,g,h,p){"use strict";var m,f,b,v;!function(e){e.toggleSelector='[data-toggle="formengine-inline"]',e.controlSectionSelector=".t3js-formengine-irre-control",e.createNewRecordButtonSelector=".t3js-create-new-button",e.createNewRecordBySelectorSelector=".t3js-create-new-selector",e.deleteRecordButtonSelector=".t3js-editform-delete-inline-record",e.enableDisableRecordButtonSelector=".t3js-toggle-visibility-button",e.infoWindowButton='[data-action="infowindow"]',e.synchronizeLocalizeRecordButtonSelector=".t3js-synchronizelocalize-button",e.uniqueValueSelectors="select.t3js-inline-unique",e.revertUniqueness=".t3js-revert-unique",e.controlContainerButtons=".t3js-inline-controls"}(m||(m={})),function(e){e.new="inlineIsNewRecord",e.visible="panel-visible",e.collapsed="panel-collapsed"}(f||(f={})),function(e){e.structureSeparator="-"}(b||(b={})),function(e){e.DOWN="down",e.UP="up"}(v||(v={}));class S{constructor(e){this.container=null,this.ajaxDispatcher=null,this.appearance=null,this.xhrQueue={},this.progessQueue={},this.noTitleString=TYPO3.lang?TYPO3.lang["FormEngine.noRecordTitle"]:"[No title]",this.handlePostMessage=(e=>{if(!i.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementInserted"===e.data.actionName){if(void 0===e.data.objectGroup)throw"No object group defined for message";if(e.data.objectGroup!==this.container.dataset.objectGroup)return;if(this.isUniqueElementUsed(parseInt(e.data.uid,10),e.data.table))return void d.error("There is already a relation to the selected element");this.importRecord([e.data.objectGroup,e.data.uid])}}),o(()=>{this.container=document.querySelector("#"+e),this.ajaxDispatcher=new n.AjaxDispatcher(this.container.dataset.objectGroup),this.registerEvents()})}static getDelegatedEventTarget(e,t){let n;return null===(n=e.closest(t))&&e.matches(t)&&(n=e),n}static getInlineRecordContainer(e){return document.querySelector('[data-object-id="'+e+'"]')}static registerInfoButton(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.infoWindowButton))&&(e.preventDefault(),e.stopImmediatePropagation(),l.showItem(t.dataset.infoTable,t.dataset.infoUid))}static toggleElement(e){const t=S.getInlineRecordContainer(e);t.classList.contains(f.collapsed)?(t.classList.remove(f.collapsed),t.classList.add(f.visible)):(t.classList.remove(f.visible),t.classList.add(f.collapsed))}static isNewRecord(e){return S.getInlineRecordContainer(e).classList.contains(f.new)}static updateExpandedCollapsedStateLocally(e,t){const n=S.getInlineRecordContainer(e),i="uc[inlineView]["+n.dataset.topmostParentTable+"]["+n.dataset.topmostParentUid+"]"+n.dataset.fieldName,o=document.getElementsByName(i);o.length&&(o[0].value=t?"1":"0")}static getValuesFromHashMap(e){return Object.keys(e).map(t=>e[t])}static selectOptionValueExists(e,t){return null!==e.querySelector('option[value="'+t+'"]')}static removeSelectOptionByValue(e,t){const n=e.querySelector('option[value="'+t+'"]');null!==n&&n.remove()}static reAddSelectOption(e,t,n){if(S.selectOptionValueExists(e,t))return;const i=e.querySelectorAll("option");let o=-1;for(let e of Object.keys(n.possible)){if(e===t)break;for(let t=0;t<i.length;++t){if(i[t].value===e){o=t;break}}}-1===o?o=0:o<i.length&&o++;const r=document.createElement("option");r.text=n.possible[t],r.value=t,e.insertBefore(r,e.options[o])}registerEvents(){if(this.container.addEventListener("click",e=>{this.registerToggle(e),this.registerSort(e),this.registerCreateRecordButton(e),this.registerEnableDisableButton(e),S.registerInfoButton(e),this.registerDeleteButton(e),this.registerSynchronizeLocalize(e),this.registerRevertUniquenessAction(e)}),this.container.addEventListener("change",e=>{this.registerCreateRecordBySelector(e),this.registerUniqueSelectFieldChanged(e)}),window.addEventListener("message",this.handlePostMessage),this.getAppearance().useSortable){const e=document.querySelector("#"+this.container.getAttribute("id")+"_records");new h(e,{group:e.getAttribute("id"),handle:".sortableHandle",onSort:()=>{this.updateSorting()}})}}registerToggle(e){if(S.getDelegatedEventTarget(e.target,m.controlSectionSelector))return;let t;null!==(t=S.getDelegatedEventTarget(e.target,m.toggleSelector))&&(e.preventDefault(),e.stopImmediatePropagation(),this.loadRecordDetails(t.parentElement.dataset.objectId))}registerSort(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.controlSectionSelector+' [data-action="sort"]'))&&(e.preventDefault(),e.stopImmediatePropagation(),this.changeSortingByButton(t.closest("[data-object-id]").dataset.objectId,t.dataset.direction))}registerCreateRecordButton(e){let t;if(null!==(t=S.getDelegatedEventTarget(e.target,m.createNewRecordButtonSelector))&&(e.preventDefault(),e.stopImmediatePropagation(),this.isBelowMax())){let e=this.container.dataset.objectGroup;void 0!==t.dataset.recordUid&&(e+=b.structureSeparator+t.dataset.recordUid),this.importRecord([e],t.dataset.recordUid)}}registerCreateRecordBySelector(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.createNewRecordBySelectorSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=t,i=n.options[n.selectedIndex].getAttribute("value");this.importRecord([this.container.dataset.objectGroup,i])}createRecord(e,t,n=null,i=null){let o=this.container.dataset.objectGroup;null!==n&&(o+=b.structureSeparator+n),null!==n?(S.getInlineRecordContainer(o).insertAdjacentHTML("afterend",t),this.memorizeAddRecord(e,n,i)):(document.querySelector("#"+this.container.getAttribute("id")+"_records").insertAdjacentHTML("beforeend",t),this.memorizeAddRecord(e,null,i))}importRecord(e,t){this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_create")).withContext().withParams(e)).done(e=>{this.isBelowMax()&&(this.createRecord(e.compilerInput.uid,e.data,void 0!==t?t:null,void 0!==e.compilerInput.childChildUid?e.compilerInput.childChildUid:null),r.reinitialize(),r.Validation.initializeInputFields(),r.Validation.validate())})}registerEnableDisableButton(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.enableDisableRecordButtonSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=t.closest("[data-object-id]").dataset.objectId,i=S.getInlineRecordContainer(n),o="data"+i.dataset.fieldName+"["+t.dataset.hiddenField+"]",r=document.querySelector('[data-formengine-input-name="'+o+'"'),a=document.querySelector('[name="'+o+'"');null!==r&&null!==a&&(r.checked=!r.checked,a.value=r.checked?"1":"0",TBE_EDITOR.fieldChanged_fName(o,o));const l="t3-form-field-container-inline-hidden";let c="";i.classList.contains(l)?(c="actions-edit-hide",i.classList.remove(l)):(c="actions-edit-unhide",i.classList.add(l)),s.getIcon(c,s.sizes.small).done(e=>{t.replaceChild(document.createRange().createContextualFragment(e),t.querySelector(".t3js-icon"))})}registerDeleteButton(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.deleteRecordButtonSelector)))return;e.preventDefault(),e.stopImmediatePropagation();const n=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?",i=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";c.confirm(n,i,g.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",active:!0,btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes"}]).on("button.clicked",e=>{if("yes"===e.target.name){const e=t.closest("[data-object-id]").dataset.objectId;this.deleteRecord(e)}c.dismiss()})}registerSynchronizeLocalize(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.synchronizeLocalizeRecordButtonSelector)))return;this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_synchronizelocalize")).withContext().withParams([this.container.dataset.objectGroup,t.dataset.type])).done(e=>{document.querySelector("#"+this.container.getAttribute("id")+"_records").insertAdjacentHTML("beforeend",e.data);const t=this.container.dataset.objectGroup+b.structureSeparator;for(let n of e.compilerInput.delete)this.deleteRecord(t+n,!0);for(let n of e.compilerInput.localize){if(void 0!==n.remove){const e=S.getInlineRecordContainer(t+n.remove);e.parentElement.removeChild(e)}this.memorizeAddRecord(n.uid,null,n.selectedValue)}})}registerUniqueSelectFieldChanged(e){let t;if(null===(t=S.getDelegatedEventTarget(e.target,m.uniqueValueSelectors)))return;const n=t.closest("[data-object-id]");if(null!==n){const e=n.dataset.objectId,i=n.dataset.objectUid;this.handleChangedField(t,e);const o=this.getFormFieldForElements();if(null===o)return;this.updateUnique(t,o,i)}}registerRevertUniquenessAction(e){let t;null!==(t=S.getDelegatedEventTarget(e.target,m.revertUniqueness))&&this.revertUnique(t.dataset.uid)}loadRecordDetails(e){const t=document.querySelector("#"+e+"_fields"),n=void 0!==this.xhrQueue[e];if(null!==t&&"\x3c!--notloaded--\x3e"!==t.innerHTML.substr(0,16))this.collapseExpandRecord(e);else{const i=this.getProgress(e);if(n)this.xhrQueue[e].abort(),delete this.xhrQueue[e],delete this.progessQueue[e],i.done();else{const n=this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_details")).withContext().withParams([e]));n.done(n=>{if(delete this.xhrQueue[e],delete this.progessQueue[e],t.innerHTML=n.data,this.collapseExpandRecord(e),i.done(),r.reinitialize(),r.Validation.initializeInputFields(),r.Validation.validate(),this.hasObjectGroupDefinedUniqueConstraints()){const t=S.getInlineRecordContainer(e);this.removeUsed(t)}}),this.xhrQueue[e]=n,i.start()}}}collapseExpandRecord(e){const t=S.getInlineRecordContainer(e),n=!0===this.getAppearance().expandSingle,i=t.classList.contains(f.collapsed);let o=[];const r=[];n&&i&&(o=this.collapseAllRecords(t.dataset.objectUid)),S.toggleElement(e),S.isNewRecord(e)?S.updateExpandedCollapsedStateLocally(e,i):i?r.push(t.dataset.objectUid):i||o.push(t.dataset.objectUid),this.ajaxDispatcher.send(this.ajaxDispatcher.newRequest(this.ajaxDispatcher.getEndpoint("record_inline_expandcollapse")).withContext().withParams([e,r.join(","),o.join(",")]))}memorizeAddRecord(e,t=null,n=null){const i=this.getFormFieldForElements();if(null===i)return;let r=p.trimExplode(",",i.value);if(t){const n=[];for(let i=0;i<r.length;i++)r[i].length&&n.push(r[i]),t===r[i]&&n.push(e);r=n}else r.push(e);i.value=r.join(","),i.classList.add("has-change"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,r),this.setUnique(e,n),this.isBelowMax()||this.toggleContainerControls(!1),TBE_EDITOR.fieldChanged_fName(i.name,i)}memorizeRemoveRecord(e){const t=this.getFormFieldForElements();if(null===t)return[];let n=p.trimExplode(",",t.value);const i=n.indexOf(e);return i>-1&&(delete n[i],t.value=n.join(","),t.classList.add("has-change"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,n)),n}changeSortingByButton(e,t){const n=S.getInlineRecordContainer(e),i=n.dataset.objectUid,o=document.querySelector("#"+this.container.getAttribute("id")+"_records"),r=Array.from(o.children).map(e=>e.dataset.objectUid);let a=r.indexOf(i),s=!1;if(t===v.UP&&a>0?(r[a]=r[a-1],r[a-1]=i,s=!0):t===v.DOWN&&a<r.length-1&&(r[a]=r[a+1],r[a+1]=i,s=!0),s){const e=this.container.dataset.objectGroup+b.structureSeparator,i=t===v.UP?1:0;n.parentElement.insertBefore(S.getInlineRecordContainer(e+r[a-i]),S.getInlineRecordContainer(e+r[a+1-i])),this.updateSorting()}}updateSorting(){const e=this.getFormFieldForElements();if(null===e)return;const t=document.querySelector("#"+this.container.getAttribute("id")+"_records"),n=Array.from(t.children).map(e=>e.dataset.objectUid);e.value=n.join(","),e.classList.add("has-change"),o(document).trigger("inline:sorting-changed"),o(document).trigger("change"),this.redrawSortingButtons(this.container.dataset.objectGroup,n)}deleteRecord(e,t=!1){const n=S.getInlineRecordContainer(e),i=n.dataset.objectUid;if(n.classList.add("t3js-inline-record-deleted"),!S.isNewRecord(e)&&!t){const e=this.container.querySelector('[name="cmd'+n.dataset.fieldName+'[delete]"]');e.removeAttribute("disabled"),n.parentElement.insertAdjacentElement("afterbegin",e)}n.addEventListener("transitionend",()=>{n.parentElement.removeChild(n),a.validate()}),this.revertUnique(i),this.memorizeRemoveRecord(i),n.classList.add("form-irre-object--deleted"),this.isBelowMax()&&this.toggleContainerControls(!0)}toggleContainerControls(e){this.container.querySelectorAll(m.controlContainerButtons+" a").forEach(t=>{t.style.display=e?null:"none"})}getProgress(e){const t="#"+e+"_header";let n;return void 0!==this.progessQueue[e]?n=this.progessQueue[e]:((n=u).configure({parent:t,showSpinner:!1}),this.progessQueue[e]=n),n}collapseAllRecords(e){const t=this.getFormFieldForElements(),n=[];if(null!==t){const i=p.trimExplode(",",t.value);for(let t of i){if(t===e)continue;const i=this.container.dataset.objectGroup+b.structureSeparator+t,o=S.getInlineRecordContainer(i);o.classList.contains(f.visible)&&(o.classList.remove(f.visible),o.classList.add(f.collapsed),S.isNewRecord(i)?S.updateExpandedCollapsedStateLocally(i,!1):n.push(t))}}return n}getFormFieldForElements(){const e=document.getElementsByName(this.container.dataset.formField);return e.length>0?e[0]:null}redrawSortingButtons(e,t=[]){if(0===t.length){const e=this.getFormFieldForElements();null!==e&&(t=p.trimExplode(",",e.value))}0!==t.length&&t.forEach((n,i)=>{const o="#"+e+b.structureSeparator+n+"_header",r=document.querySelector(o),a=r.querySelector('[data-action="sort"][data-direction="'+v.UP+'"]');if(null!==a){let e="actions-move-up";0===i?(a.classList.add("disabled"),e="empty-empty"):a.classList.remove("disabled"),s.getIcon(e,s.sizes.small).done(e=>{a.replaceChild(document.createRange().createContextualFragment(e),a.querySelector(".t3js-icon"))})}const l=r.querySelector('[data-action="sort"][data-direction="'+v.DOWN+'"]');if(null!==l){let e="actions-move-down";i===t.length-1?(l.classList.add("disabled"),e="empty-empty"):l.classList.remove("disabled"),s.getIcon(e,s.sizes.small).done(e=>{l.replaceChild(document.createRange().createContextualFragment(e),l.querySelector(".t3js-icon"))})}})}isBelowMax(){const e=this.getFormFieldForElements();if(null===e)return!0;if(void 0!==TYPO3.settings.FormEngineInline.config[this.container.dataset.objectGroup]){if(p.trimExplode(",",e.value).length>=TYPO3.settings.FormEngineInline.config[this.container.dataset.objectGroup].max)return!1;if(this.hasObjectGroupDefinedUniqueConstraints()){const e=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if(e.used.length>=e.max&&e.max>=0)return!1}}return!0}isUniqueElementUsed(e,t){if(!this.hasObjectGroupDefinedUniqueConstraints())return!1;const n=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],i=S.getValuesFromHashMap(n.used);if("select"===n.type&&-1!==i.indexOf(e))return!0;if("groupdb"===n.type)for(let n=i.length-1;n>=0;n--)if(i[n].table===t&&i[n].uid===e)return!0;return!1}removeUsed(e){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const t=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if("select"!==t.type)return;let n=e.querySelector('[name="data['+t.table+"]["+e.dataset.objectUid+"]["+t.field+']"]');const i=S.getValuesFromHashMap(t.used);if(null!==n){const e=n.options[n.selectedIndex].value;for(let t of i)t!==e&&S.removeSelectOptionByValue(n,t)}}setUnique(e,t){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const n=document.querySelector("#"+this.container.dataset.objectGroup+"_selector"),i=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup];if("select"===i.type){if(!i.selector||-1!==i.max){const o=this.getFormFieldForElements(),r=this.container.dataset.objectGroup+b.structureSeparator+e;let a=S.getInlineRecordContainer(r).querySelector('[name="data['+i.table+"]["+e+"]["+i.field+']"]');const s=S.getValuesFromHashMap(i.used);if(null!==n){if(null!==a){for(let e of s)S.removeSelectOptionByValue(a,e);i.selector||(t=a.options[0].value,a.options[0].selected=!0,this.updateUnique(a,o,e),this.handleChangedField(a,this.container.dataset.objectGroup+"["+e+"]"))}for(let e of s)S.removeSelectOptionByValue(a,e);void 0!==i.used.length&&(i.used={}),i.used[e]={table:i.elTable,uid:t}}if(null!==o&&S.selectOptionValueExists(n,t)){const n=p.trimExplode(",",o.value);for(let o of n)null!==(a=document.querySelector('[name="data['+i.table+"]["+o+"]["+i.field+']"]'))&&o!==e&&S.removeSelectOptionByValue(a,t)}}}else"groupdb"===i.type&&(i.used[e]={table:i.elTable,uid:t});"select"===i.selector&&S.selectOptionValueExists(n,t)&&(S.removeSelectOptionByValue(n,t),i.used[e]={table:i.elTable,uid:t})}updateUnique(e,t,n){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const i=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],o=i.used[n];if("select"===i.selector){const t=document.querySelector("#"+this.container.dataset.objectGroup+"_selector");S.removeSelectOptionByValue(t,e.value),void 0!==o&&S.reAddSelectOption(t,o,i)}if(i.selector&&-1===i.max)return;if(!i||null===t)return;const r=p.trimExplode(",",t.value);let a;for(let t of r)null!==(a=document.querySelector('[name="data['+i.table+"]["+t+"]["+i.field+']"]'))&&a!==e&&(S.removeSelectOptionByValue(a,e.value),void 0!==o&&S.reAddSelectOption(a,o,i));i.used[n]=e.value}revertUnique(e){if(!this.hasObjectGroupDefinedUniqueConstraints())return;const t=TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup],n=this.container.dataset.objectGroup+b.structureSeparator+e,i=S.getInlineRecordContainer(n);let o=i.querySelector('[name="data['+t.table+"]["+i.dataset.objectUid+"]["+t.field+']"]');if("select"===t.type){let n;if(null!==o)n=o.value;else{if(""===i.dataset.tableUniqueOriginalValue)return;n=i.dataset.tableUniqueOriginalValue}if("select"===t.selector&&!isNaN(parseInt(n,10))){const e=document.querySelector("#"+this.container.dataset.objectGroup+"_selector");S.reAddSelectOption(e,n,t)}if(t.selector&&-1===t.max)return;const r=this.getFormFieldForElements();if(null===r)return;const a=p.trimExplode(",",r.value);let s;for(let e=0;e<a.length;e++)null!==(s=document.querySelector('[name="data['+t.table+"]["+a[e]+"]["+t.field+']"]'))&&S.reAddSelectOption(s,n,t);delete t.used[e]}else"groupdb"===t.type&&delete t.used[e]}hasObjectGroupDefinedUniqueConstraints(){return void 0!==TYPO3.settings.FormEngineInline.unique&&void 0!==TYPO3.settings.FormEngineInline.unique[this.container.dataset.objectGroup]}handleChangedField(e,t){let n;n=e instanceof HTMLSelectElement?e.options[e.selectedIndex].text:e.value,document.querySelector("#"+t+"_label").textContent=n.length?n:this.noTitleString}getAppearance(){if(null===this.appearance&&(this.appearance={},"string"==typeof this.container.dataset.appearance))try{this.appearance=JSON.parse(this.container.dataset.appearance)}catch(e){console.error(e)}return this.appearance}}return S});
\ No newline at end of file
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89331-FormEngineLegacyFunctions.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89331-FormEngineLegacyFunctions.rst
new file mode 100644 (file)
index 0000000..d3ca397
--- /dev/null
@@ -0,0 +1,79 @@
+.. include:: ../../Includes.txt
+
+=================================================
+Deprecation: #89331 - FormEngine legacy functions
+=================================================
+
+See :issue:`89331`
+
+Description
+===========
+
+The FormEngine supports global callback functions executed on certain interactions. Such functions were overridden and
+spread through some extensions which are not related to FormEngine at all.
+
+These functions have been marked as deprecated:
+
+* :js:`setFormValueOpenBrowser()`
+* :js:`setFormValueFromBrowseWin()`
+* :js:`setHiddenFromList()`
+* :js:`setFormValueManipulate()`
+* :js:`setFormValue_getFObj()`
+
+The function :js:`setFormValueFromBrowseWin()` is also called by `ElementBrowser`. Extensions not related to FormEngine
+are able to override this function and inject custom handling. This approach has been marked as deprecated as well.
+
+
+Impact
+======
+
+Calling a deprecated function will trigger a warning in the browser console.
+
+
+Affected Installations
+======================
+
+All installations using 3rd party extensions calling any of these deprecated functions are affected.
+
+
+Migration
+=========
+
+Some functions can be used in FormEngine context only from now on. Load the module `TYPO3/CMS/Backend/FormEngine` and
+use the according replacements:
+
+* :js:`setFormValueOpenBrowser()` - use :js:`FormEngine.openPopupWindow()` instead
+* :js:`setFormValueFromBrowseWin()` - use :js:`FormEngine.setSelectOptionFromExternalSource()` instead
+* :js:`setHiddenFromList()` - use :js:`FormEngine.updateHiddenFieldValueFromSelect()` instead
+* :js:`setFormValueManipulate()` - no replacement, this is interal logic for form controls separated into according modules
+* :js:`setFormValue_getFObj()` - use :js:`FormEngine.getFormElement()` instead
+
+If :js:`setFormValueFromBrowseWin()` is not used within a FormEngine context, it is possible to listen to the
+:js:`message` event.
+
+Example code:
+
+.. code-block:: js
+
+   require(['TYPO3/CMS/Backend/Utility/MessageUtility'], function (MessageUtility) {
+     window.addEventListener('message', function (e) {
+       // MessageUtility.MessageUtility is correct as this is not an AMD module
+       if (!MessageUtility.MessageUtility.verifyOrigin(e.origin)) {
+         throw 'Denied message sent by ' + e.origin;
+       }
+
+       if (typeof e.data.fieldName === 'undefined') {
+         throw 'fieldName not defined in message';
+       }
+
+       if (typeof e.data.value === 'undefined') {
+         throw 'value not defined in message';
+       }
+
+       const result = e.data.value.split('_');
+       const field = <HTMLInputElement>document.querySelector('input[name="' + e.data.fieldName + '"]');
+       field.value = result[1];
+     });
+   }
+
+.. index:: Backend, JavaScript, NotScanned, ext:backend
index aa36efa..3215e5c 100644 (file)
  * Module: TYPO3/CMS/Form/Backend/FormEditor/InspectorComponent
  */
 
-/**
- * Add legacy functions to be accessible in the global scope.
- * This is needed by TYPO3/CMS/Recordlist/ElementBrowser
- */
-var setFormValueFromBrowseWin;
-
 define(['jquery',
   'TYPO3/CMS/Form/Backend/FormEditor/Helper',
   'TYPO3/CMS/Backend/Icons',
   'TYPO3/CMS/Backend/Notification',
   'TYPO3/CMS/Backend/Modal',
+  'TYPO3/CMS/Backend/Utility/MessageUtility',
   'TYPO3/CMS/Form/Backend/Contrib/jquery.mjs.nestedSortable'
-], function($, Helper, Icons, Notification, Modal) {
+], function($, Helper, Icons, Notification, Modal, MessageUtility) {
   'use strict';
 
   return (function($, Helper, Icons, Notification) {
@@ -393,6 +388,34 @@ define(['jquery',
     /**
      * @private
      *
+     * Listens on messages sent by ElementBrowser
+     */
+    function _listenOnElementBrowser() {
+      window.addEventListener('message', function (e) {
+        if (!MessageUtility.MessageUtility.verifyOrigin(e.origin)) {
+          throw 'Denied message sent by ' + e.origin;
+        }
+
+        if (e.data.actionName === 'typo3:elementBrowser:elementAdded') {
+          if (typeof e.data.fieldName === 'undefined') {
+            throw 'fieldName not defined in message';
+          }
+
+          if (typeof e.data.value === 'undefined') {
+            throw 'value not defined in message';
+          }
+
+          var result = e.data.value.split('_');
+          $(getHelper().getDomElementDataAttribute('contentElementSelectorTarget', 'bracesWithKeyValue', [e.data.fieldName]))
+            .val(result.pop())
+            .trigger('paste');
+        }
+      });
+    }
+
+    /**
+     * @private
+     *
      * @param string
      * @param string
      * @return object
@@ -754,25 +777,6 @@ define(['jquery',
     /**
      * @public
      *
-     * callback from TYPO3/CMS/Recordlist/ElementBrowser
-     *
-     * @param string fieldReference
-     * @param string elValue
-     * @param string elName
-     * @return void
-     */
-    setFormValueFromBrowseWin = function(fieldReference, elValue, elName) {
-      var result;
-      result = elValue.split('_');
-
-      $(getHelper().getDomElementDataAttribute('contentElementSelectorTarget', 'bracesWithKeyValue', [fieldReference]))
-        .val(result.pop())
-        .trigger('paste');
-    };
-
-    /**
-     * @public
-     *
      * @return object
      */
     function getInspectorDomElement() {
@@ -2410,6 +2414,8 @@ define(['jquery',
         _openTypo3WinBrowser('db', randomIdentifier + '|||' + editorConfiguration['browsableType']);
       });
 
+      _listenOnElementBrowser();
+
       propertyPath = getFormEditorApp().buildPropertyPath(editorConfiguration['propertyPath'], collectionElementIdentifier, collectionName);
       propertyData = getCurrentlySelectedFormElement().get(propertyPath);
 
index 6171c87..80706d7 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","TYPO3/CMS/Backend/Utility/MessageUtility","jquery","TYPO3/CMS/Backend/Modal"],function(e,t,r,i,n){"use strict";return new class{constructor(){this.opener=null,this.thisScriptUrl="",this.mode="",this.formFieldName="",this.fieldReference="",this.fieldReferenceSlashed="",this.rte={parameters:"",configuration:""},this.irre={objectId:0},this.focusOpenerAndClose=(()=>{this.getParent()&&this.getParent().focus(),n.dismiss(),close()}),i(()=>{const e=i("body").data();this.thisScriptUrl=e.thisScriptUrl,this.mode=e.mode,this.formFieldName=e.formFieldName,this.fieldReference=e.fieldReference,this.fieldReferenceSlashed=e.fieldReferenceSlashed,this.rte.parameters=e.rteParameters,this.rte.configuration=e.rteConfiguration,this.irre.objectId=e.irreObjectId})}setReferences(){return!!(this.getParent()&&this.getParent().content&&this.getParent().content.document.editform&&this.getParent().content.document.editform[this.formFieldName])&&(this.targetDoc=this.getParent().content.document,this.elRef=this.targetDoc.editform[this.formFieldName],!0)}executeFunctionByName(e,t,...r){const i=e.split("."),n=i.pop();for(let e of i)t=t[e];return t[n].apply(t,r)}getParent(){return null===this.opener&&(void 0!==window.parent&&void 0!==window.parent.document.list_frame&&null!==window.parent.document.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.document.list_frame:void 0!==window.parent&&void 0!==window.parent.frames.list_frame&&null!==window.parent.frames.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.frames.list_frame:void 0!==window.frames&&void 0!==window.frames.frameElement&&null!==window.frames.frameElement&&window.frames.frameElement.classList.contains("t3js-modal-iframe")?this.opener=window.frames.frameElement.contentWindow.parent:window.opener&&(this.opener=window.opener)),this.opener}insertElement(e,t,i,n,s,o,a,d,m){if(this.irre.objectId){if(this.getParent()){const i={objectGroup:this.irre.objectId,table:e,uid:t};r.MessageUtility.send(i,this.getParent())}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose();return m&&this.focusOpenerAndClose(),!0}return!this.fieldReference||this.rte.parameters||this.rte.configuration?(this.getParent()&&this.getParent().content&&this.getParent().content.document.editform&&this.getParent().content.document.editform[this.formFieldName]?this.getParent().group_change("add",this.fieldReference,this.rte.parameters,this.rte.configuration,this.targetDoc.editform[this.formFieldName],this.getParent().content.document):alert("Error - reference to main window is not set properly!"),m&&this.focusOpenerAndClose()):this.addElement(n,e+"_"+t,s,m),!1}addElement(e,t,r,i){this.getParent()&&this.getParent().setFormValueFromBrowseWin?(this.getParent().setFormValueFromBrowseWin(this.fieldReference,r||t,e),i&&this.focusOpenerAndClose()):(alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose())}}});
\ No newline at end of file
+define(["require","exports","TYPO3/CMS/Backend/Utility/MessageUtility","jquery","TYPO3/CMS/Backend/Modal"],function(e,t,r,i,n){"use strict";return new class{constructor(){this.opener=null,this.thisScriptUrl="",this.mode="",this.formFieldName="",this.fieldReference="",this.fieldReferenceSlashed="",this.rte={parameters:"",configuration:""},this.irre={objectId:0},this.focusOpenerAndClose=(()=>{this.getParent()&&this.getParent().focus(),n.dismiss(),close()}),i(()=>{const e=i("body").data();this.thisScriptUrl=e.thisScriptUrl,this.mode=e.mode,this.formFieldName=e.formFieldName,this.fieldReference=e.fieldReference,this.fieldReferenceSlashed=e.fieldReferenceSlashed,this.rte.parameters=e.rteParameters,this.rte.configuration=e.rteConfiguration,this.irre.objectId=e.irreObjectId})}setReferences(){return!!(this.getParent()&&this.getParent().content&&this.getParent().content.document.editform&&this.getParent().content.document.editform[this.formFieldName])&&(this.targetDoc=this.getParent().content.document,this.elRef=this.targetDoc.editform[this.formFieldName],!0)}executeFunctionByName(e,t,...r){const i=e.split("."),n=i.pop();for(let e of i)t=t[e];return t[n].apply(t,r)}getParent(){return null===this.opener&&(void 0!==window.parent&&void 0!==window.parent.document.list_frame&&null!==window.parent.document.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.document.list_frame:void 0!==window.parent&&void 0!==window.parent.frames.list_frame&&null!==window.parent.frames.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.frames.list_frame:void 0!==window.frames&&void 0!==window.frames.frameElement&&null!==window.frames.frameElement&&window.frames.frameElement.classList.contains("t3js-modal-iframe")?this.opener=window.frames.frameElement.contentWindow.parent:window.opener&&(this.opener=window.opener)),this.opener}insertElement(e,t,i,n,s,o,a,d,l){if(this.irre.objectId){if(this.getParent()){const i={actionName:"typo3:elementBrowser:elementInserted",objectGroup:this.irre.objectId,table:e,uid:t};r.MessageUtility.send(i,this.getParent())}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose();return l&&this.focusOpenerAndClose(),!0}return!this.fieldReference||this.rte.parameters||this.rte.configuration||this.addElement(n,e+"_"+t,s,l),!1}addElement(e,t,i,n){if(this.getParent()){this.getParent().setFormValueFromBrowseWin&&(console.warn("setFormValueFromBrowseWin has been marked as deprecated. Listen to message events instead."),this.getParent().setFormValueFromBrowseWin(this.fieldReference,i||t,e));const s={actionName:"typo3:elementBrowser:elementAdded",fieldName:this.fieldReference,value:i||t,label:e};r.MessageUtility.send(s,this.getParent()),n&&this.focusOpenerAndClose()}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose()}}});
\ No newline at end of file
index 0a923e6..99f5135 100644 (file)
@@ -610,14 +610,6 @@ class SchedulerModuleController
         // Load necessary JavaScript
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Scheduler/Scheduler');
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker');
-        $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Scheduler/PageBrowser');
-        $this->getPageRenderer()->addJsInlineCode('browse-button', '
-            function setFormValueFromBrowseWin(fieldReference, elValue, elName) {
-                var res = elValue.split("_");
-                var element = document.getElementById(fieldReference);
-                element.value = res[1];
-            }
-        ');
 
         // Start rendering the add/edit form
         $this->view->assign('uid', htmlspecialchars((string)$this->submittedData['uid']));
@@ -727,13 +719,11 @@ class SchedulerModuleController
     {
         if (isset($fieldInfo['browser']) && ($fieldInfo['browser'] === 'page')) {
             $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
-            $url = (string)$uriBuilder->buildUriFromRoute(
-                'wizard_element_browser',
-                ['mode' => 'db', 'bparams' => $fieldID . '|||pages|']
-            );
+            $url = (string)$uriBuilder->buildUriFromRoute('wizard_element_browser');
+
             $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_db'));
             return '
-                <div><a href="#" data-url=' . htmlspecialchars($url) . ' class="btn btn-default t3js-pageBrowser" title="' . $title . '">
+                <div><a href="' . htmlspecialchars($url) . '" data-trigger-for="' . htmlspecialchars($fieldID) . '" data-mode="db" data-params="" class="btn btn-default t3js-element-browser" title="' . $title . '">
                     <span class="t3js-icon icon icon-size-small icon-state-default icon-actions-insert-record" data-identifier="actions-insert-record">
                         <span class="icon-markup">' . $this->iconFactory->getIcon(
                 'actions-insert-record',
diff --git a/typo3/sysext/scheduler/Resources/Public/JavaScript/PageBrowser.js b/typo3/sysext/scheduler/Resources/Public/JavaScript/PageBrowser.js
deleted file mode 100644 (file)
index 70c2be6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * 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!
- */
-define(["require","exports","jquery"],function(e,r,t){"use strict";return new class{constructor(){t(document).on("click",".t3js-pageBrowser",e=>{let r,s=t(e.currentTarget).data("url");(r=window.open(s,"Typo3WinBrowser","height=650,width=800,status=0,menubar=0,resizable=1,scrollbars=1")).focus()})}}});
\ No newline at end of file
index 057fd9b..db53336 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","TYPO3/CMS/Backend/DocumentSaveActions","datatables"],function(e,a,t,l){"use strict";return new class{constructor(){this.allCheckedStatus=!1,this.actOnChangedTaskClass=(e=>{let a=e.val();a=a.toLowerCase().replace(/\\/g,"-"),t(".extraFields").hide(),t(".extra_fields_"+a).show()}),this.actOnChangedTaskType=(e=>{this.toggleFieldsByTaskType(t(e.currentTarget).val())}),this.actOnChangeSchedulerTableGarbageCollectionAllTables=(e=>{let a=t("#task_tableGarbageCollection_numberOfDays"),l=t("#task_tableGarbageCollection_table");if(e.prop("checked"))l.prop("disabled",!0),a.prop("disabled",!0);else{let e=parseInt(a.val(),10);if(e<1){let a=l.val();void 0!==defaultNumberOfDays[a]&&(e=defaultNumberOfDays[a])}l.prop("disabled",!1),e>0&&a.prop("disabled",!1)}}),this.actOnChangeSchedulerTableGarbageCollectionTable=(e=>{let a=t("#task_tableGarbageCollection_numberOfDays");defaultNumberOfDays[e.val()]>0?(a.prop("disabled",!1),a.val(defaultNumberOfDays[e.val()])):(a.prop("disabled",!0),a.val(0))}),this.checkOrUncheckAllCheckboxes=(e=>(e.parents(".tx_scheduler_mod1_table").find(":checkbox").prop("checked",!this.allCheckedStatus),this.allCheckedStatus=!this.allCheckedStatus,!1)),this.toggleFieldsByTaskType=(e=>{e=parseInt(e+"",10),t("#task_end_col").toggle(2===e),t("#task_frequency_row").toggle(2===e)}),this.toggleTaskGroups=(e=>{let a=e.data("task-group-id");t("#recordlist-task-group-"+a).collapse("toggle")}),this.initializeEvents=(()=>{t(".checkall").on("click",e=>{this.checkOrUncheckAllCheckboxes(t(e.currentTarget))}),t("#task_class").change(e=>{this.actOnChangedTaskClass(t(e.currentTarget))}),t("#task_type").change(this.actOnChangedTaskType),t("#task_tableGarbageCollection_allTables").change(e=>{this.actOnChangeSchedulerTableGarbageCollectionAllTables(t(e.currentTarget))}),t("#task_tableGarbageCollection_table").change(e=>{this.actOnChangeSchedulerTableGarbageCollectionTable(t(e.currentTarget))}),t(".taskGroup").on("click",e=>{this.toggleTaskGroups(t(e.currentTarget))}),t("table.taskGroup-table").DataTable({paging:!1,searching:!1})}),this.initializeDefaultStates=(()=>{let e=t("#task_type");e.length&&this.toggleFieldsByTaskType(e.val());let a=t("#task_class");a.length&&this.actOnChangedTaskClass(a)}),this.initializeEvents(),this.initializeDefaultStates(),l.getInstance().addPreSubmitCallback(()=>{let e=t("#task_class").val();e=e.toLowerCase().replace(/\\/g,"-"),t(".extraFields").appendTo(t("#extraFieldsHidden")),t(".extra_fields_"+e).appendTo(t("#extraFieldsSection"))})}}});
\ No newline at end of file
+define(["require","exports","jquery","TYPO3/CMS/Backend/DocumentSaveActions","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Utility/MessageUtility","datatables"],function(e,a,t,l,s,i){"use strict";class r{constructor(){this.allCheckedStatus=!1,this.actOnChangedTaskClass=(e=>{let a=e.val();a=a.toLowerCase().replace(/\\/g,"-"),t(".extraFields").hide(),t(".extra_fields_"+a).show()}),this.actOnChangedTaskType=(e=>{this.toggleFieldsByTaskType(t(e.currentTarget).val())}),this.actOnChangeSchedulerTableGarbageCollectionAllTables=(e=>{let a=t("#task_tableGarbageCollection_numberOfDays"),l=t("#task_tableGarbageCollection_table");if(e.prop("checked"))l.prop("disabled",!0),a.prop("disabled",!0);else{let e=parseInt(a.val(),10);if(e<1){let a=l.val();void 0!==defaultNumberOfDays[a]&&(e=defaultNumberOfDays[a])}l.prop("disabled",!1),e>0&&a.prop("disabled",!1)}}),this.actOnChangeSchedulerTableGarbageCollectionTable=(e=>{let a=t("#task_tableGarbageCollection_numberOfDays");defaultNumberOfDays[e.val()]>0?(a.prop("disabled",!1),a.val(defaultNumberOfDays[e.val()])):(a.prop("disabled",!0),a.val(0))}),this.checkOrUncheckAllCheckboxes=(e=>(e.parents(".tx_scheduler_mod1_table").find(":checkbox").prop("checked",!this.allCheckedStatus),this.allCheckedStatus=!this.allCheckedStatus,!1)),this.toggleFieldsByTaskType=(e=>{e=parseInt(e+"",10),t("#task_end_col").toggle(2===e),t("#task_frequency_row").toggle(2===e)}),this.toggleTaskGroups=(e=>{let a=e.data("task-group-id");t("#recordlist-task-group-"+a).collapse("toggle")}),this.initializeEvents=(()=>{t(".checkall").on("click",e=>{this.checkOrUncheckAllCheckboxes(t(e.currentTarget))}),t("#task_class").change(e=>{this.actOnChangedTaskClass(t(e.currentTarget))}),t("#task_type").change(this.actOnChangedTaskType),t("#task_tableGarbageCollection_allTables").change(e=>{this.actOnChangeSchedulerTableGarbageCollectionAllTables(t(e.currentTarget))}),t("#task_tableGarbageCollection_table").change(e=>{this.actOnChangeSchedulerTableGarbageCollectionTable(t(e.currentTarget))}),t(".taskGroup").on("click",e=>{this.toggleTaskGroups(t(e.currentTarget))}),t("table.taskGroup-table").DataTable({paging:!1,searching:!1}),t(document).on("click",".t3js-element-browser",e=>{e.preventDefault();const a=e.currentTarget;s.advanced({type:s.types.iframe,content:a.href+"&mode="+a.dataset.mode+"&bparams="+a.dataset.params,size:s.sizes.large})}),window.addEventListener("message",this.listenOnElementBrowser)}),this.initializeDefaultStates=(()=>{let e=t("#task_type");e.length&&this.toggleFieldsByTaskType(e.val());let a=t("#task_class");a.length&&(this.actOnChangedTaskClass(a),r.updateElementBrowserTriggers())}),this.listenOnElementBrowser=(e=>{if(!i.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementAdded"===e.data.actionName){if(void 0===e.data.fieldName)throw"fieldName not defined in message";if(void 0===e.data.value)throw"value not defined in message";const a=e.data.value.split("_");document.querySelector('input[name="'+e.data.fieldName+'"]').value=a[1]}}),this.initializeEvents(),this.initializeDefaultStates(),l.getInstance().addPreSubmitCallback(()=>{let e=t("#task_class").val();e=e.toLowerCase().replace(/\\/g,"-"),t(".extraFields").appendTo(t("#extraFieldsHidden")),t(".extra_fields_"+e).appendTo(t("#extraFieldsSection"))})}static updateElementBrowserTriggers(){document.querySelectorAll(".t3js-element-browser").forEach(e=>{const a=document.getElementById(e.dataset.triggerFor);e.dataset.params=a.name+"|||pages"})}}return new r});
\ No newline at end of file