[TASK] Improve loops in TypeScript 53/61653/6
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 10 Sep 2019 06:41:24 +0000 (08:41 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 25 Sep 2019 10:01:33 +0000 (12:01 +0200)
This patch improves the loops in TypeScript by using `for (... of ...)`
and incorporating ES7 features as `Object.entries()` and
`Object.values()`.

Resolves: #89262
Releases: master
Change-Id: I4f4300a2e241bcd34494ae0b0d400e589ad702da
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61653
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
26 files changed:
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenu.ts
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DocumentSaveActions.ts
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/FormEngine/Container/InlineControlContainer.ts
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Utility.ts
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Wizard.ts
Build/Sources/TypeScript/extensionmanager/Resources/Public/TypeScript/Main.ts
Build/Sources/TypeScript/install/Resources/Public/TypeScript/Module/Maintenance/LanguagePacks.ts
Build/Sources/TypeScript/install/Resources/Public/TypeScript/Module/Upgrade/UpgradeDocs.ts
Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/BrowseFiles.ts
Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ElementBrowser.ts
Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/LinkBrowser.ts
Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Backend.ts
Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Workspaces.ts
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js
typo3/sysext/backend/Resources/Public/JavaScript/DocumentSaveActions.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine/Container/InlineControlContainer.js
typo3/sysext/backend/Resources/Public/JavaScript/Utility.js
typo3/sysext/backend/Resources/Public/JavaScript/Wizard.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js
typo3/sysext/install/Resources/Public/JavaScript/Module/Maintenance/LanguagePacks.js
typo3/sysext/install/Resources/Public/JavaScript/Module/Upgrade/UpgradeDocs.js
typo3/sysext/recordlist/Resources/Public/JavaScript/BrowseFiles.js
typo3/sysext/recordlist/Resources/Public/JavaScript/ElementBrowser.js
typo3/sysext/recordlist/Resources/Public/JavaScript/LinkBrowser.js
typo3/sysext/workspaces/Resources/Public/JavaScript/Backend.js
typo3/sysext/workspaces/Resources/Public/JavaScript/Workspaces.js

index 6707fd5..7c4b23e 100644 (file)
@@ -53,10 +53,9 @@ class ContextMenu {
   private static drawActionItem(item: MenuItem): string {
     const attributes: { [key: string]: string } = item.additionalAttributes || {};
     let attributesString = '';
-    for (let attribute in attributes) {
-      if (attributes.hasOwnProperty(attribute)) {
-        attributesString += ' ' + attribute + '="' + attributes[attribute] + '"';
-      }
+    for (const attribute of Object.entries(attributes)) {
+      const [k, v] = attribute;
+      attributesString += ' ' + k + '="' + v + '"';
     }
 
     return '<a class="list-group-item"'
@@ -273,24 +272,21 @@ class ContextMenu {
    */
   private drawMenu(items: MenuItems, level: number): string {
     let elements: string = '';
-    for (let key in items) {
-      if (items.hasOwnProperty(key)) {
-        const item = items[key];
-        if (item.type === 'item') {
-          elements += ContextMenu.drawActionItem(item);
-        } else if (item.type === 'divider') {
-          elements += '<a class="list-group-item list-group-item-divider"></a>';
-        } else if (item.type === 'submenu' || item.childItems) {
-          elements += '<a class="list-group-item list-group-item-submenu">'
-            + '<span class="list-group-item-icon">' + item.icon + '</span> '
-            + item.label + '&nbsp;&nbsp;<span class="fa fa-caret-right"></span>'
-            + '</a>';
-
-          const childElements = this.drawMenu(item.childItems, 1);
-          elements += '<div class="context-menu contentMenu' + (level + 1) + '" style="display:none;">'
-            + '<div class="list-group">' + childElements + '</div>'
-            + '</div>';
-        }
+    for (let item of Object.values(items)) {
+      if (item.type === 'item') {
+        elements += ContextMenu.drawActionItem(item);
+      } else if (item.type === 'divider') {
+        elements += '<a class="list-group-item list-group-item-divider"></a>';
+      } else if (item.type === 'submenu' || item.childItems) {
+        elements += '<a class="list-group-item list-group-item-submenu">'
+          + '<span class="list-group-item-icon">' + item.icon + '</span> '
+          + item.label + '&nbsp;&nbsp;<span class="fa fa-caret-right"></span>'
+          + '</a>';
+
+        const childElements = this.drawMenu(item.childItems, 1);
+        elements += '<div class="context-menu contentMenu' + (level + 1) + '" style="display:none;">'
+          + '<div class="list-group">' + childElements + '</div>'
+          + '</div>';
       }
     }
     return elements;
index 04c3ea3..db937d9 100644 (file)
@@ -71,8 +71,8 @@ class DocumentSaveActions {
         const $elem = $('<input />').attr('type', 'hidden').attr('name', name).attr('value', value);
 
         // Run any preSubmit callbacks
-        for (let i = 0; i < this.preSubmitCallbacks.length; ++i) {
-          this.preSubmitCallbacks[i](e);
+        for (let callback of this.preSubmitCallbacks) {
+          callback(e);
 
           if (e.isPropagationStopped()) {
             preventExec = false;
index 0effa32..081447e 100644 (file)
@@ -1028,9 +1028,9 @@ class InlineControlContainer {
 
     if (uniqueValueField !== null) {
       const selectedValue = uniqueValueField.options[uniqueValueField.selectedIndex].value;
-      for (let i = 0; i < values.length; i++) {
-        if (values[i] !== selectedValue) {
-          InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[i]);
+      for (let value of values) {
+        if (value !== selectedValue) {
+          InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
         }
       }
     }
@@ -1060,8 +1060,8 @@ class InlineControlContainer {
         if (selectorElement !== null) {
           // remove all items from the new select-item which are already used in other children
           if (uniqueValueField !== null) {
-            for (let i = 0; i < values.length; i++) {
-              InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[i]);
+            for (let value of values) {
+              InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
             }
             // set the selected item automatically to the first of the remaining items if no selector is used
             if (!unique.selector) {
@@ -1071,8 +1071,8 @@ class InlineControlContainer {
               this.handleChangedField(uniqueValueField, this.container.dataset.objectGroup + '[' + recordUid + ']');
             }
           }
-          for (let j = 0; j < values.length; j++) {
-            InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[j]);
+          for (let value of values) {
+            InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
           }
           if (typeof unique.used.length !== 'undefined') {
             unique.used = {};
@@ -1085,11 +1085,11 @@ class InlineControlContainer {
         // remove the newly used item from each select-field of the child records
         if (formField !== null && InlineControlContainer.selectOptionValueExists(selectorElement, selectedValue)) {
           const records = Utility.trimExplode(',', (<HTMLInputElement>formField).value);
-          for (let k = 0; k < records.length; k++) {
+          for (let record of records) {
             uniqueValueField = <HTMLSelectElement>document.querySelector(
-              '[name="data[' + unique.table + '][' + records[k] + '][' + unique.field + ']"]',
+              '[name="data[' + unique.table + '][' + record + '][' + unique.field + ']"]',
             );
-            if (uniqueValueField !== null && records[k] !== recordUid) {
+            if (uniqueValueField !== null && record !== recordUid) {
               InlineControlContainer.removeSelectOptionByValue(uniqueValueField, selectedValue);
             }
           }
@@ -1145,9 +1145,9 @@ class InlineControlContainer {
 
     const records = Utility.trimExplode(',', formField.value);
     let uniqueValueField;
-    for (let i = 0; i < records.length; i++) {
+    for (let record of records) {
       uniqueValueField = <HTMLSelectElement>document.querySelector(
-        '[name="data[' + unique.table + '][' + records[i] + '][' + unique.field + ']"]',
+        '[name="data[' + unique.table + '][' + record + '][' + unique.field + ']"]',
       );
       if (uniqueValueField !== null && uniqueValueField !== srcElement) {
         InlineControlContainer.removeSelectOptionByValue(uniqueValueField, srcElement.value);
index 4b923db..cb5530e 100644 (file)
@@ -104,16 +104,14 @@ class Utility {
 
   public static convertFormToObject(form: HTMLFormElement): { [key: string]: any } {
     const obj: { [key: string]: any } = {};
-    const elements = form.querySelectorAll('input, select, textarea');
-    for (let i = 0; i < elements.length; ++i ) {
-      const element = <HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement>(elements[i]);
+    form.querySelectorAll('input, select, textarea').forEach((element: HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement): void => {
       const name = element.name;
       const value = element.value;
 
       if (name) {
         obj[name] = value;
       }
-    }
+    });
 
     return obj;
   }
index 13ce963..2ace00f 100644 (file)
@@ -273,8 +273,7 @@ class Wizard {
     let slides = '<div class="carousel slide" data-ride="carousel" data-interval="false">'
       + '<div class="carousel-inner" role="listbox">';
 
-    for (let i = 0; i < this.setup.slides.length; ++i) {
-      let currentSlide: Slide = this.setup.slides[i];
+    for (let currentSlide of Object.values(this.setup.slides)) {
       let slideContent = currentSlide.content;
 
       if (typeof slideContent === 'object') {
index b56d549..6ed0fb2 100644 (file)
@@ -45,12 +45,11 @@ class ExtensionManager {
 
   private static getUrlVars(): any {
     let vars: any = [];
-    let hash: Array<string>;
     let hashes: Array<string> = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
-    for (let i = 0; i < hashes.length; i++) {
-      hash = hashes[i].split('=');
-      vars.push(hash[0]);
-      vars[hash[0]] = hash[1];
+    for (let hash of hashes) {
+      const [k, v] = hash.split('=');
+      vars.push(k);
+      vars[k] = v;
     }
     return vars;
   }
index 6e3e09a..63cc3c2 100644 (file)
@@ -510,8 +510,8 @@ class LanguagePacks extends AbstractInteractableModule {
 
   private renderNotifications(): void {
     const $notificationBox: JQuery = this.getNotificationBox();
-    for (let i = 0; i < this.notifications.length; ++i) {
-      $notificationBox.append(this.notifications[i]);
+    for (let notification of this.notifications) {
+      $notificationBox.append(notification);
     }
     this.notifications = [];
   }
index 227c7e8..0232ed2 100644 (file)
@@ -220,8 +220,8 @@ class UpgradeDocs extends AbstractInteractableModule {
       const andString = andTags.join('');
       const tags = [];
       if (orTags.length) {
-        for (let i = 0; i < orTags.length; i++) {
-          tags.push(andString + orTags[i]);
+        for (let orTag of orTags) {
+          tags.push(andString + orTag);
         }
       } else {
         tags.push(andString);
index 29532b4..4419c65 100644 (file)
@@ -116,8 +116,8 @@ class Selector {
         }
       });
       if (selectedItems.length > 0) {
-        for (let i = 0; i < selectedItems.length; i++) {
-          BrowseFiles.File.insertElement(selectedItems[i]);
+        for (let selectedItem of selectedItems) {
+          BrowseFiles.File.insertElement(selectedItem);
         }
       }
       ElementBrowser.focusOpenerAndClose();
index ebb6787..ac6a826 100644 (file)
@@ -89,8 +89,8 @@ class ElementBrowser {
   public executeFunctionByName(functionName: string, context: any, ...args: Array<any>): any {
     const namespaces = functionName.split('.');
     const func = namespaces.pop();
-    for (let i = 0; i < namespaces.length; i++) {
-      context = context[namespaces[i]];
+    for (let namespace of namespaces) {
+      context = context[namespace];
     }
     return context[func].apply(context, args);
   }
index a7b3252..0d6cab2 100644 (file)
@@ -70,17 +70,15 @@ class LinkBrowser {
    */
   public encodeGetParameters(obj: LinkAttributes, prefix: string, url: string): string {
     const str = [];
-    for (let p in obj) {
-      if (obj.hasOwnProperty(p)) {
-        const k: string = prefix ? prefix + '[' + p + ']' : p;
-        const v: any = obj[p];
-        if (!url.includes(k + '=')) {
-          str.push(
-            typeof v === 'object'
-              ? this.encodeGetParameters(v, k, url)
-              : encodeURIComponent(k) + '=' + encodeURIComponent(v),
-          );
-        }
+    for (const entry of Object.entries(obj)) {
+      const [p, v] = entry;
+      const k: string = prefix ? prefix + '[' + p + ']' : p;
+      if (!url.includes(k + '=')) {
+        str.push(
+          typeof v === 'object'
+            ? this.encodeGetParameters(v, k, url)
+            : encodeURIComponent(k) + '=' + encodeURIComponent(v),
+        );
       }
     }
     return '&' + str.join('&');
index 3f14702..4cda624 100644 (file)
@@ -81,11 +81,11 @@ class Backend extends Workspaces {
   private static generateDiffView(diff: Array<any>): JQuery {
     const $diff = $('<div />', {class: 'diff'});
 
-    for (let i = 0; i < diff.length; ++i) {
+    for (let currentDiff of diff) {
       $diff.append(
         $('<div />', {class: 'diff-item'}).append(
-          $('<div />', {class: 'diff-item-title'}).text(diff[i].label),
-          $('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(diff[i].content),
+          $('<div />', {class: 'diff-item-title'}).text(currentDiff.label),
+          $('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(currentDiff.content),
         ),
       );
     }
@@ -101,26 +101,26 @@ class Backend extends Workspaces {
   private static generateCommentView(comments: Array<any>): JQuery {
     const $comments = $('<div />');
 
-    for (let i = 0; i < comments.length; ++i) {
+    for (let comment of comments) {
       const $panel = $('<div />', {class: 'panel panel-default'});
 
-      if (comments[i].user_comment.length > 0) {
+      if (comment.user_comment.length > 0) {
         $panel.append(
-          $('<div />', {class: 'panel-body'}).html(comments[i].user_comment),
+          $('<div />', {class: 'panel-body'}).html(comment.user_comment),
         );
       }
 
       $panel.append(
         $('<div />', {class: 'panel-footer'}).append(
-          $('<span />', {class: 'label label-success'}).text(comments[i].stage_title),
-          $('<span />', {class: 'label label-info'}).text(comments[i].tstamp),
+          $('<span />', {class: 'label label-success'}).text(comment.stage_title),
+          $('<span />', {class: 'label label-info'}).text(comment.tstamp),
         ),
       );
 
       $comments.append(
         $('<div />', {class: 'media'}).append(
-          $('<div />', {class: 'media-left text-center'}).text(comments[i].user_username).prepend(
-            $('<div />').html(comments[i].user_avatar),
+          $('<div />', {class: 'media-left text-center'}).text(comment.user_username).prepend(
+            $('<div />').html(comment.user_avatar),
           ),
           $('<div />', {class: 'media-body'}).append($panel),
         ),
@@ -139,22 +139,22 @@ class Backend extends Workspaces {
   private static generateHistoryView(data: Array<any>): JQuery {
     const $history = $('<div />');
 
-    for (let i = 0; i < data.length; ++i) {
+    for (let currentData of data) {
       const $panel = $('<div />', {class: 'panel panel-default'});
       let $diff;
 
-      if (typeof data[i].differences === 'object') {
-        if (data[i].differences.length === 0) {
+      if (typeof currentData.differences === 'object') {
+        if (currentData.differences.length === 0) {
           // Somehow here are no differences. What a pity, skip that record
           continue;
         }
         $diff = $('<div />', {class: 'diff'});
 
-        for (let j = 0; j < data[i].differences.length; ++j) {
+        for (let j = 0; j < currentData.differences.length; ++j) {
           $diff.append(
             $('<div />', {class: 'diff-item'}).append(
-              $('<div />', {class: 'diff-item-title'}).text(data[i].differences[j].label),
-              $('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(data[i].differences[j].html),
+              $('<div />', {class: 'diff-item-title'}).text(currentData.differences[j].label),
+              $('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(currentData.differences[j].html),
             ),
           );
         }
@@ -164,19 +164,19 @@ class Backend extends Workspaces {
         );
       } else {
         $panel.append(
-          $('<div />', {class: 'panel-body'}).text(data[i].differences),
+          $('<div />', {class: 'panel-body'}).text(currentData.differences),
         );
       }
       $panel.append(
         $('<div />', {class: 'panel-footer'}).append(
-          $('<span />', {class: 'label label-info'}).text(data[i].datetime),
+          $('<span />', {class: 'label label-info'}).text(currentData.datetime),
         ),
       );
 
       $history.append(
         $('<div />', {class: 'media'}).append(
-          $('<div />', {class: 'media-left text-center'}).text(data[i].user).prepend(
-            $('<div />').html(data[i].user_avatar),
+          $('<div />', {class: 'media-left text-center'}).text(currentData.user).prepend(
+            $('<div />').html(currentData.user_avatar),
           ),
           $('<div />', {class: 'media-body'}).append($panel),
         ),
index 578977a..9bb6400 100644 (file)
@@ -41,9 +41,7 @@ export default class Workspaces {
         ),
       );
 
-      for (let i = 0; i < result.sendMailTo.length; ++i) {
-        const recipient = result.sendMailTo[i];
-
+      for (const recipient of result.sendMailTo) {
         $form.append(
           $('<div />', {class: 'checkbox'}).append(
             $('<label />').text(recipient.label).prepend(
index 6b79661..431bbb3 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./ContextMenuActions"],function(t,e,i,n){"use strict";class s{constructor(){this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=(t=>{this.mousePos={X:t.pageX,Y:t.pageY},this.mouseOutFromMenu("#contentMenu0"),this.mouseOutFromMenu("#contentMenu1")}),this.initializeEvents()}static drawActionItem(t){const e=t.additionalAttributes||{};let i="";for(let t in e)e.hasOwnProperty(t)&&(i+=" "+t+'="'+e[t]+'"');return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+i+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"}static within(t,e,i){const n=t.offset();return i>=n.top&&i<n.top+t.height()&&e>=n.left&&e<n.left+t.width()}static initializeContextMenuContainer(){if(0===i("#contentMenu0").length){const t='<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>';i("body").append(t)}}initializeEvents(){i(document).on("click contextmenu",".t3js-contextmenutrigger",t=>{const e=i(t.currentTarget);e.prop("onclick")&&"click"===t.type||(t.preventDefault(),this.show(e.data("table"),e.data("uid"),e.data("context"),e.data("iteminfo"),e.data("parameters")))}),i(document).on("mousemove",this.storeMousePositionEvent)}show(t,e,i,n,s){this.record={table:t,uid:e};let o="";void 0!==t&&(o+="table="+encodeURIComponent(t)),void 0!==e&&(o+=(o.length>0?"&":"")+"uid="+e),void 0!==i&&(o+=(o.length>0?"&":"")+"context="+i),void 0!==n&&(o+=(o.length>0?"&":"")+"enDisItems="+n),void 0!==s&&(o+=(o.length>0?"&":"")+"addParams="+s),this.fetch(o)}fetch(t){let e=TYPO3.settings.ajaxUrls.contextmenu;t&&(e+=(e.includes("?")?"&":"?")+t),i.ajax(e).done(t=>{void 0!==t&&Object.keys(t).length>0&&this.populateData(t,0)})}populateData(e,o){s.initializeContextMenuContainer();const l=i("#contentMenu"+o);if(l.length&&(0===o||i("#contentMenu"+(o-1)).is(":visible"))){const s=this.drawMenu(e,o);l.html('<div class="list-group">'+s+"</div>"),i("a.list-group-item",l).click(e=>{e.preventDefault();const s=i(e.currentTarget);if(s.hasClass("list-group-item-submenu"))return void this.openSubmenu(o,s);const l=s.data("callback-action"),a=s.data("callback-module");s.data("callback-module")?t([a],t=>{t[l].bind(s)(this.record.table,this.record.uid)}):n&&"function"==typeof n[l]?n[l].bind(s)(this.record.table,this.record.uid):console.log("action: "+l+" not found"),this.hideAll()}),l.css(this.getPosition(l)).show()}}openSubmenu(t,e){const n=i("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(n),n.css(this.getPosition(n)).show()}getPosition(t){let e=this.mousePos.X,n=this.mousePos.Y;const s=i(window).width()-20,o=i(window).height(),l=t.width(),a=t.height(),c=this.mousePos.X-i(document).scrollLeft(),u=this.mousePos.Y-i(document).scrollTop();return o-a<u&&(u>a?n-=a-10:n+=o-a-u),s-l<c&&(c>l?e-=l-10:s-l-c<i(document).scrollLeft()?e=i(document).scrollLeft():e+=s-l-c),{left:e+"px",top:n+"px"}}drawMenu(t,e){let i="";for(let n in t)if(t.hasOwnProperty(n)){const o=t[n];if("item"===o.type)i+=s.drawActionItem(o);else if("divider"===o.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===o.type||o.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+o.icon+"</span> "+o.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(e+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(o.childItems,1)+"</div></div>"}}return i}mouseOutFromMenu(t){const e=i(t);e.length>0&&e.is(":visible")&&!s.within(e,this.mousePos.X,this.mousePos.Y)?this.hide(t):e.length>0&&e.is(":visible")&&(this.delayContextMenuHide=!0)}hide(t){this.delayContextMenuHide=!1,window.setTimeout(()=>{this.delayContextMenuHide||i(t).hide()},500)}hideAll(){this.hide("#contentMenu0"),this.hide("#contentMenu1")}}return new s});
\ No newline at end of file
+define(["require","exports","jquery","./ContextMenuActions"],function(t,e,i,n){"use strict";class s{constructor(){this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=(t=>{this.mousePos={X:t.pageX,Y:t.pageY},this.mouseOutFromMenu("#contentMenu0"),this.mouseOutFromMenu("#contentMenu1")}),this.initializeEvents()}static drawActionItem(t){const e=t.additionalAttributes||{};let i="";for(const t of Object.entries(e)){const[e,n]=t;i+=" "+e+'="'+n+'"'}return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+i+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"}static within(t,e,i){const n=t.offset();return i>=n.top&&i<n.top+t.height()&&e>=n.left&&e<n.left+t.width()}static initializeContextMenuContainer(){if(0===i("#contentMenu0").length){const t='<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>';i("body").append(t)}}initializeEvents(){i(document).on("click contextmenu",".t3js-contextmenutrigger",t=>{const e=i(t.currentTarget);e.prop("onclick")&&"click"===t.type||(t.preventDefault(),this.show(e.data("table"),e.data("uid"),e.data("context"),e.data("iteminfo"),e.data("parameters")))}),i(document).on("mousemove",this.storeMousePositionEvent)}show(t,e,i,n,s){this.record={table:t,uid:e};let o="";void 0!==t&&(o+="table="+encodeURIComponent(t)),void 0!==e&&(o+=(o.length>0?"&":"")+"uid="+e),void 0!==i&&(o+=(o.length>0?"&":"")+"context="+i),void 0!==n&&(o+=(o.length>0?"&":"")+"enDisItems="+n),void 0!==s&&(o+=(o.length>0?"&":"")+"addParams="+s),this.fetch(o)}fetch(t){let e=TYPO3.settings.ajaxUrls.contextmenu;t&&(e+=(e.includes("?")?"&":"?")+t),i.ajax(e).done(t=>{void 0!==t&&Object.keys(t).length>0&&this.populateData(t,0)})}populateData(e,o){s.initializeContextMenuContainer();const l=i("#contentMenu"+o);if(l.length&&(0===o||i("#contentMenu"+(o-1)).is(":visible"))){const s=this.drawMenu(e,o);l.html('<div class="list-group">'+s+"</div>"),i("a.list-group-item",l).click(e=>{e.preventDefault();const s=i(e.currentTarget);if(s.hasClass("list-group-item-submenu"))return void this.openSubmenu(o,s);const l=s.data("callback-action"),a=s.data("callback-module");s.data("callback-module")?t([a],t=>{t[l].bind(s)(this.record.table,this.record.uid)}):n&&"function"==typeof n[l]?n[l].bind(s)(this.record.table,this.record.uid):console.log("action: "+l+" not found"),this.hideAll()}),l.css(this.getPosition(l)).show()}}openSubmenu(t,e){const n=i("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(n),n.css(this.getPosition(n)).show()}getPosition(t){let e=this.mousePos.X,n=this.mousePos.Y;const s=i(window).width()-20,o=i(window).height(),l=t.width(),a=t.height(),c=this.mousePos.X-i(document).scrollLeft(),u=this.mousePos.Y-i(document).scrollTop();return o-a<u&&(u>a?n-=a-10:n+=o-a-u),s-l<c&&(c>l?e-=l-10:s-l-c<i(document).scrollLeft()?e=i(document).scrollLeft():e+=s-l-c),{left:e+"px",top:n+"px"}}drawMenu(t,e){let i="";for(let n of Object.values(t))if("item"===n.type)i+=s.drawActionItem(n);else if("divider"===n.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===n.type||n.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+n.icon+"</span> "+n.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(e+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(n.childItems,1)+"</div></div>"}return i}mouseOutFromMenu(t){const e=i(t);e.length>0&&e.is(":visible")&&!s.within(e,this.mousePos.X,this.mousePos.Y)?this.hide(t):e.length>0&&e.is(":visible")&&(this.delayContextMenuHide=!0)}hide(t){this.delayContextMenuHide=!1,window.setTimeout(()=>{this.delayContextMenuHide||i(t).hide()},500)}hideAll(){this.hide("#contentMenu0"),this.hide("#contentMenu1")}}return new s});
\ No newline at end of file
index f7b308b..2a76b05 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./Icons"],function(t,e,a,n){"use strict";class r{constructor(){this.preSubmitCallbacks=[],a(()=>{this.initializeSaveHandling()})}static getInstance(){return null===r.instance&&(r.instance=new r),r.instance}addPreSubmitCallback(t){if("function"!=typeof t)throw"callback must be a function.";this.preSubmitCallbacks.push(t)}initializeSaveHandling(){let t=!1;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(",");a(".t3js-module-docheader").on("click",e,e=>{if(!t){t=!0;const r=a(e.currentTarget),i=r.attr("form")||r.attr("data-form")||null,s=i?a("#"+i):r.closest("form"),l=r.data("name")||e.currentTarget.getAttribute("name"),u=r.data("value")||e.currentTarget.getAttribute("value"),o=a("<input />").attr("type","hidden").attr("name",l).attr("value",u);for(let a=0;a<this.preSubmitCallbacks.length;++a)if(this.preSubmitCallbacks[a](e),e.isPropagationStopped())return t=!1,!1;s.append(o),s.on("submit",()=>{if(s.find(".has-error").length>0)return t=!1,!1;let e;const a=r.closest(".t3js-splitbutton");return a.length>0?(a.find("button").prop("disabled",!0),e=a.children().first()):(r.prop("disabled",!0),e=r),n.getIcon("spinner-circle-dark",n.sizes.small).done(t=>{e.find(".t3js-icon").replaceWith(t)}),!0}),"A"!==e.currentTarget.tagName&&!r.attr("form")||e.isDefaultPrevented()||(s.find('[name="doSave"]').val("1"),s.submit(),e.preventDefault())}return!0})}}return r.instance=null,r});
\ No newline at end of file
+define(["require","exports","jquery","./Icons"],function(t,e,a,n){"use strict";class r{constructor(){this.preSubmitCallbacks=[],a(()=>{this.initializeSaveHandling()})}static getInstance(){return null===r.instance&&(r.instance=new r),r.instance}addPreSubmitCallback(t){if("function"!=typeof t)throw"callback must be a function.";this.preSubmitCallbacks.push(t)}initializeSaveHandling(){let t=!1;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(",");a(".t3js-module-docheader").on("click",e,e=>{if(!t){t=!0;const r=a(e.currentTarget),i=r.attr("form")||r.attr("data-form")||null,s=i?a("#"+i):r.closest("form"),l=r.data("name")||e.currentTarget.getAttribute("name"),u=r.data("value")||e.currentTarget.getAttribute("value"),o=a("<input />").attr("type","hidden").attr("name",l).attr("value",u);for(let a of this.preSubmitCallbacks)if(a(e),e.isPropagationStopped())return t=!1,!1;s.append(o),s.on("submit",()=>{if(s.find(".has-error").length>0)return t=!1,!1;let e;const a=r.closest(".t3js-splitbutton");return a.length>0?(a.find("button").prop("disabled",!0),e=a.children().first()):(r.prop("disabled",!0),e=r),n.getIcon("spinner-circle-dark",n.sizes.small).done(t=>{e.find(".t3js-icon").replaceWith(t)}),!0}),"A"!==e.currentTarget.tagName&&!r.attr("form")||e.isDefaultPrevented()||(s.find('[name="doSave"]').val("1"),s.submit(),e.preventDefault())}return!0})}}return r.instance=null,r});
\ No newline at end of file
index 6fff5a8..c6d91df 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){const t=this.container.querySelector(m.controlContainerButtons);null!==t&&(t.style.display=e?"block":"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=0;t<i.length;t++)i[t]!==e&&S.removeSelectOptionByValue(n,i[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=0;e<s.length;e++)S.removeSelectOptionByValue(a,s[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=0;e<s.length;e++)S.removeSelectOptionByValue(a,s[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=0;o<n.length;o++)null!==(a=document.querySelector('[name="data['+i.table+"]["+n[o]+"]["+i.field+']"]'))&&n[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=0;t<r.length;t++)null!==(a=document.querySelector('[name="data['+i.table+"]["+r[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(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){const t=this.container.querySelector(m.controlContainerButtons);null!==t&&(t.style.display=e?"block":"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
index b21b578..f32fef8 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports"],function(t,e){"use strict";return class{static trimExplode(t,e){return e.split(t).map(t=>t.trim()).filter(t=>""!==t)}static intExplode(t,e,r=!1){return e.split(t).map(t=>parseInt(t,10)).filter(t=>!isNaN(t)||r&&0===t)}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static getParameterFromUrl(t,e){if("function"!=typeof t.split)return"";const r=t.split("?");let i="";if(r.length>=2){const t=r.join("?"),n=encodeURIComponent(e)+"=",s=t.split(/[&;]/g);for(let t=s.length;t-- >0;)if(-1!==s[t].lastIndexOf(n,0)){i=s[t].split("=")[1];break}}return i}static updateQueryStringParameter(t,e,r){const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),n=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+n+e+"="+r}static convertFormToObject(t){const e={},r=t.querySelectorAll("input, select, textarea");for(let t=0;t<r.length;++t){const i=r[t],n=i.name,s=i.value;n&&(e[n]=s)}return e}}});
\ No newline at end of file
+define(["require","exports"],function(t,e){"use strict";return class{static trimExplode(t,e){return e.split(t).map(t=>t.trim()).filter(t=>""!==t)}static intExplode(t,e,r=!1){return e.split(t).map(t=>parseInt(t,10)).filter(t=>!isNaN(t)||r&&0===t)}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static getParameterFromUrl(t,e){if("function"!=typeof t.split)return"";const r=t.split("?");let i="";if(r.length>=2){const t=r.join("?"),n=encodeURIComponent(e)+"=",s=t.split(/[&;]/g);for(let t=s.length;t-- >0;)if(-1!==s[t].lastIndexOf(n,0)){i=s[t].split("=")[1];break}}return i}static updateQueryStringParameter(t,e,r){const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),n=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+n+e+"="+r}static convertFormToObject(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const r=t.name,i=t.value;r&&(e[r]=i)}),e}}});
\ No newline at end of file
index a94bf7e..4b9ee7f 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./Enum/Severity","jquery","./Modal","./Severity","./Icons"],function(e,t,s,i,a,r,l){"use strict";class n{constructor(){this.setup={slides:[],settings:{},forceSelection:!0,$carousel:null},this.originalSetup=i.extend(!0,{},this.setup)}set(e,t){return this.setup.settings[e]=t,this}addSlide(e,t,i="",a=s.SeverityEnum.info,r){const l={identifier:e,title:t,content:i,severity:a,callback:r};return this.setup.slides.push(l),this}addFinalProcessingSlide(e){return e||(e=(()=>{this.dismiss()})),l.getIcon("spinner-circle-dark",l.sizes.large,null,null).done(t=>{let s=i("<div />",{class:"text-center"}).append(t);this.addSlide("final-processing-slide",top.TYPO3.lang["wizard.processing.title"],s[0].outerHTML,r.info,e)})}show(){let e=this.generateSlides(),t=this.setup.slides[0];a.confirm(t.title,e,t.severity,[{text:top.TYPO3.lang["wizard.button.cancel"],active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{this.getComponent().trigger("wizard-dismiss")}},{text:top.TYPO3.lang["wizard.button.next"],btnClass:"btn-"+r.getCssClass(t.severity),name:"next"}]),this.setup.forceSelection&&this.lockNextStep(),this.addProgressBar(),this.initializeEvents(),this.getComponent().on("wizard-visible",()=>{this.runSlideCallback(t,this.setup.$carousel.find(".item").first())}).on("wizard-dismissed",()=>{this.setup=i.extend(!0,{},this.originalSetup)})}getComponent(){return null===this.setup.$carousel&&this.generateSlides(),this.setup.$carousel}dismiss(){a.dismiss()}lockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!0),e}unlockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!1),e}setForceSelection(e){this.setup.forceSelection=e}initializeEvents(){let e=this.setup.$carousel.closest(".modal"),t=e.find(".modal-title"),s=e.find(".modal-footer"),l=s.find('button[name="next"]');l.on("click",()=>{this.setup.$carousel.carousel("next")}),this.setup.$carousel.on("slide.bs.carousel",()=>{let i=this.setup.$carousel.data("currentSlide")+1,a=this.setup.$carousel.data("currentIndex")+1;t.text(this.setup.slides[a].title),this.setup.$carousel.data("currentSlide",i),this.setup.$carousel.data("currentIndex",a),i>=this.setup.$carousel.data("realSlideCount")?(e.find(".modal-header .close").remove(),s.slideUp()):s.find(".progress-bar").width(this.setup.$carousel.data("initialStep")*i+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}",i).replace("{1}",this.setup.$carousel.data("slideCount"))),l.removeClass("btn-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("btn-"+r.getCssClass(this.setup.slides[a].severity)),e.removeClass("modal-severity-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("modal-severity-"+r.getCssClass(this.setup.slides[a].severity))}).on("slid.bs.carousel",e=>{let t=this.setup.$carousel.data("currentIndex"),s=this.setup.slides[t];this.runSlideCallback(s,i(e.relatedTarget)),this.setup.forceSelection&&this.lockNextStep()});let n=this.getComponent();n.on("wizard-dismiss",this.dismiss),a.currentModal.on("hidden.bs.modal",()=>{n.trigger("wizard-dismissed")}).on("shown.bs.modal",()=>{n.trigger("wizard-visible")})}runSlideCallback(e,t){"function"==typeof e.callback&&e.callback(t,this.setup.settings,e.identifier)}addProgressBar(){let e,t=this.setup.$carousel.find(".item").length,s=Math.max(1,t),a=this.setup.$carousel.closest(".modal").find(".modal-footer");e=Math.round(100/s),this.setup.$carousel.data("initialStep",e).data("slideCount",s).data("realSlideCount",t).data("currentIndex",0).data("currentSlide",1),s>1&&a.prepend(i("<div />",{class:"progress"}).append(i("<div />",{role:"progressbar",class:"progress-bar","aria-valuemin":0,"aria-valuenow":e,"aria-valuemax":100}).width(e+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}","1").replace("{1}",s))))}generateSlides(){if(null!==this.setup.$carousel)return this.setup.$carousel;let e='<div class="carousel slide" data-ride="carousel" data-interval="false"><div class="carousel-inner" role="listbox">';for(let t=0;t<this.setup.slides.length;++t){let s=this.setup.slides[t],i=s.content;"object"==typeof i&&(i=i.html()),e+='<div class="item" data-slide="'+s.identifier+'">'+i+"</div>"}return e+="</div></div>",this.setup.$carousel=i(e),this.setup.$carousel.find(".item").first().addClass("active"),this.setup.$carousel}}let d;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.Wizard&&(d=window.opener.TYPO3.Wizard),parent&&parent.window.TYPO3&&parent.window.TYPO3.Wizard&&(d=parent.window.TYPO3.Wizard),top&&top.TYPO3&&top.TYPO3.Wizard&&(d=top.TYPO3.Wizard)}catch(e){}return d||(d=new n,"undefined"!=typeof TYPO3&&(TYPO3.Wizard=d)),d});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","jquery","./Modal","./Severity","./Icons"],function(e,t,s,i,a,r,l){"use strict";class n{constructor(){this.setup={slides:[],settings:{},forceSelection:!0,$carousel:null},this.originalSetup=i.extend(!0,{},this.setup)}set(e,t){return this.setup.settings[e]=t,this}addSlide(e,t,i="",a=s.SeverityEnum.info,r){const l={identifier:e,title:t,content:i,severity:a,callback:r};return this.setup.slides.push(l),this}addFinalProcessingSlide(e){return e||(e=(()=>{this.dismiss()})),l.getIcon("spinner-circle-dark",l.sizes.large,null,null).done(t=>{let s=i("<div />",{class:"text-center"}).append(t);this.addSlide("final-processing-slide",top.TYPO3.lang["wizard.processing.title"],s[0].outerHTML,r.info,e)})}show(){let e=this.generateSlides(),t=this.setup.slides[0];a.confirm(t.title,e,t.severity,[{text:top.TYPO3.lang["wizard.button.cancel"],active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{this.getComponent().trigger("wizard-dismiss")}},{text:top.TYPO3.lang["wizard.button.next"],btnClass:"btn-"+r.getCssClass(t.severity),name:"next"}]),this.setup.forceSelection&&this.lockNextStep(),this.addProgressBar(),this.initializeEvents(),this.getComponent().on("wizard-visible",()=>{this.runSlideCallback(t,this.setup.$carousel.find(".item").first())}).on("wizard-dismissed",()=>{this.setup=i.extend(!0,{},this.originalSetup)})}getComponent(){return null===this.setup.$carousel&&this.generateSlides(),this.setup.$carousel}dismiss(){a.dismiss()}lockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!0),e}unlockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!1),e}setForceSelection(e){this.setup.forceSelection=e}initializeEvents(){let e=this.setup.$carousel.closest(".modal"),t=e.find(".modal-title"),s=e.find(".modal-footer"),l=s.find('button[name="next"]');l.on("click",()=>{this.setup.$carousel.carousel("next")}),this.setup.$carousel.on("slide.bs.carousel",()=>{let i=this.setup.$carousel.data("currentSlide")+1,a=this.setup.$carousel.data("currentIndex")+1;t.text(this.setup.slides[a].title),this.setup.$carousel.data("currentSlide",i),this.setup.$carousel.data("currentIndex",a),i>=this.setup.$carousel.data("realSlideCount")?(e.find(".modal-header .close").remove(),s.slideUp()):s.find(".progress-bar").width(this.setup.$carousel.data("initialStep")*i+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}",i).replace("{1}",this.setup.$carousel.data("slideCount"))),l.removeClass("btn-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("btn-"+r.getCssClass(this.setup.slides[a].severity)),e.removeClass("modal-severity-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("modal-severity-"+r.getCssClass(this.setup.slides[a].severity))}).on("slid.bs.carousel",e=>{let t=this.setup.$carousel.data("currentIndex"),s=this.setup.slides[t];this.runSlideCallback(s,i(e.relatedTarget)),this.setup.forceSelection&&this.lockNextStep()});let n=this.getComponent();n.on("wizard-dismiss",this.dismiss),a.currentModal.on("hidden.bs.modal",()=>{n.trigger("wizard-dismissed")}).on("shown.bs.modal",()=>{n.trigger("wizard-visible")})}runSlideCallback(e,t){"function"==typeof e.callback&&e.callback(t,this.setup.settings,e.identifier)}addProgressBar(){let e,t=this.setup.$carousel.find(".item").length,s=Math.max(1,t),a=this.setup.$carousel.closest(".modal").find(".modal-footer");e=Math.round(100/s),this.setup.$carousel.data("initialStep",e).data("slideCount",s).data("realSlideCount",t).data("currentIndex",0).data("currentSlide",1),s>1&&a.prepend(i("<div />",{class:"progress"}).append(i("<div />",{role:"progressbar",class:"progress-bar","aria-valuemin":0,"aria-valuenow":e,"aria-valuemax":100}).width(e+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}","1").replace("{1}",s))))}generateSlides(){if(null!==this.setup.$carousel)return this.setup.$carousel;let e='<div class="carousel slide" data-ride="carousel" data-interval="false"><div class="carousel-inner" role="listbox">';for(let t of Object.values(this.setup.slides)){let s=t.content;"object"==typeof s&&(s=s.html()),e+='<div class="item" data-slide="'+t.identifier+'">'+s+"</div>"}return e+="</div></div>",this.setup.$carousel=i(e),this.setup.$carousel.find(".item").first().addClass("active"),this.setup.$carousel}}let d;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.Wizard&&(d=window.opener.TYPO3.Wizard),parent&&parent.window.TYPO3&&parent.window.TYPO3.Wizard&&(d=parent.window.TYPO3.Wizard),top&&top.TYPO3&&top.TYPO3.Wizard&&(d=top.TYPO3.Wizard)}catch(e){}return d||(d=new n,"undefined"!=typeof TYPO3&&(TYPO3.Wizard=d)),d});
\ No newline at end of file
index 84e232c..621f612 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","nprogress","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Core/SecurityUtility","./Repository","./Update","./UploadForm","datatables","TYPO3/CMS/Backend/Input/Clearable"],function(e,t,n,a,i,o,r,s,l,c,d){"use strict";const p=new s;var u;!function(e){e.extensionlist="#typo3-extension-list",e.searchField="#Tx_Extensionmanager_extensionkey"}(u||(u={}));class m{constructor(){this.bindExtensionListActions=(()=>{n(".removeExtension").not(".transformed").each((e,t)=>{const a=n(t);a.data("href",a.attr("href")),a.attr("href","#"),a.addClass("transformed"),a.click(()=>{i.confirm(TYPO3.lang["extensionList.removalConfirmation.title"],TYPO3.lang["extensionList.removalConfirmation.question"],r.error,[{text:TYPO3.lang["button.cancel"],active:!0,btnClass:"btn-default",trigger:()=>{i.dismiss()}},{text:TYPO3.lang["button.remove"],btnClass:"btn-danger",trigger:()=>{this.removeExtensionFromDisk(a),i.dismiss()}}])})})}),n(()=>{n.fn.dataTableExt.oSort["extension-asc"]=((e,t)=>m.extensionCompare(e,t)),n.fn.dataTableExt.oSort["extension-desc"]=((e,t)=>{return-1*m.extensionCompare(e,t)}),n.fn.dataTableExt.oSort["version-asc"]=((e,t)=>{return-1*m.versionCompare(e,t)}),n.fn.dataTableExt.oSort["version-desc"]=((e,t)=>m.versionCompare(e,t)),this.Update=new c,this.UploadForm=new d,this.Repository=new l;const e=this.manageExtensionListing();let t;n(document).on("click",".onClickMaskExtensionManager",()=>{a.start()}).on("click","a[data-action=update-extension]",e=>{e.preventDefault(),n.ajax({url:n(this).attr("href"),dataType:"json",beforeSend:()=>{a.start()},success:this.updateExtension})}).on("change","input[name=unlockDependencyIgnoreButton]",e=>{n(".t3js-dependencies").toggleClass("disabled",!n(e.currentTarget).prop("checked"))}),null!==(t=document.querySelector(u.searchField))&&t.clearable({onClear:()=>{e.search("").draw()}}),n(document).on("click",".t3-button-action-installdistribution",()=>{a.start()}),this.Repository.initDom(),this.Update.initializeEvents(),this.UploadForm.initializeEvents(),o.initialize("#typo3-extension-list [title]",{delay:{show:500,hide:100},trigger:"hover",container:"body"})})}static getUrlVars(){let e,t=[],n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(let a=0;a<n.length;a++)e=n[a].split("="),t.push(e[0]),t[e[0]]=e[1];return t}static versionCompare(e,t){if(e===t)return 0;const n=e.split("."),a=t.split("."),i=Math.min(n.length,a.length);for(let e=0;e<i;e++){if(parseInt(n[e],10)>parseInt(a[e],10))return 1;if(parseInt(n[e],10)<parseInt(a[e],10))return-1}return n.length>a.length?1:n.length<a.length?-1:0}static extensionCompare(e,t){const n=document.createElement("div");n.innerHTML=e;const a=n.textContent||n.innerText||e;n.innerHTML=t;const i=n.textContent||n.innerText||t;return a.trim().localeCompare(i.trim())}manageExtensionListing(){const e=n(u.searchField),t=n(u.extensionlist).DataTable({paging:!1,dom:"lrtip",lengthChange:!1,pageLength:15,stateSave:!0,drawCallback:this.bindExtensionListActions,columns:[null,null,{type:"extension"},null,{type:"version"},{orderable:!1},null,null]});e.parents("form").on("submit",()=>!1);const a=m.getUrlVars(),i=a.search?a.search:t.search();return e.val(i),e.on("input",e=>{t.search(n(e.currentTarget).val()).draw()}),t}removeExtensionFromDisk(e){n.ajax({url:e.data("href"),beforeSend:()=>{a.start()},success:()=>{location.reload()},complete:()=>{a.done()}})}updateExtension(e){let t=0;const o=n("<form>");n.each(e.updateComments,(e,a)=>{const i=n("<input>").attr({type:"radio",name:"version"}).val(e);0===t&&i.attr("checked","checked"),o.append([n("<h3>").append([i," "+p.encodeHtml(e)]),n("<div>").append(a.replace(/(\r\n|\n\r|\r|\n)/g,"\n").split(/\n/).map(e=>p.encodeHtml(e)).join("<br>"))]),t++});const s=n("<div>").append([n("<h1>").text(TYPO3.lang["extensionList.updateConfirmation.title"]),n("<h2>").text(TYPO3.lang["extensionList.updateConfirmation.message"]),o]);a.done(),i.confirm(TYPO3.lang["extensionList.updateConfirmation.questionVersionComments"],s,r.warning,[{text:TYPO3.lang["button.cancel"],active:!0,btnClass:"btn-default",trigger:()=>{i.dismiss()}},{text:TYPO3.lang["button.updateExtension"],btnClass:"btn-warning",trigger:()=>{n.ajax({url:e.url,data:{tx_extensionmanager_tools_extensionmanagerextensionmanager:{version:n("input:radio[name=version]:checked",i.currentModal).val()}},dataType:"json",beforeSend:()=>{a.start()},complete:()=>{location.reload()}}),i.dismiss()}}])}}let g=new m;return void 0===TYPO3.ExtensionManager&&(TYPO3.ExtensionManager=g),g});
\ No newline at end of file
+define(["require","exports","jquery","nprogress","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Core/SecurityUtility","./Repository","./Update","./UploadForm","datatables","TYPO3/CMS/Backend/Input/Clearable"],function(e,t,n,a,o,i,r,s,l,c,d){"use strict";const p=new s;var u;!function(e){e.extensionlist="#typo3-extension-list",e.searchField="#Tx_Extensionmanager_extensionkey"}(u||(u={}));class m{constructor(){this.bindExtensionListActions=(()=>{n(".removeExtension").not(".transformed").each((e,t)=>{const a=n(t);a.data("href",a.attr("href")),a.attr("href","#"),a.addClass("transformed"),a.click(()=>{o.confirm(TYPO3.lang["extensionList.removalConfirmation.title"],TYPO3.lang["extensionList.removalConfirmation.question"],r.error,[{text:TYPO3.lang["button.cancel"],active:!0,btnClass:"btn-default",trigger:()=>{o.dismiss()}},{text:TYPO3.lang["button.remove"],btnClass:"btn-danger",trigger:()=>{this.removeExtensionFromDisk(a),o.dismiss()}}])})})}),n(()=>{n.fn.dataTableExt.oSort["extension-asc"]=((e,t)=>m.extensionCompare(e,t)),n.fn.dataTableExt.oSort["extension-desc"]=((e,t)=>{return-1*m.extensionCompare(e,t)}),n.fn.dataTableExt.oSort["version-asc"]=((e,t)=>{return-1*m.versionCompare(e,t)}),n.fn.dataTableExt.oSort["version-desc"]=((e,t)=>m.versionCompare(e,t)),this.Update=new c,this.UploadForm=new d,this.Repository=new l;const e=this.manageExtensionListing();let t;n(document).on("click",".onClickMaskExtensionManager",()=>{a.start()}).on("click","a[data-action=update-extension]",e=>{e.preventDefault(),n.ajax({url:n(this).attr("href"),dataType:"json",beforeSend:()=>{a.start()},success:this.updateExtension})}).on("change","input[name=unlockDependencyIgnoreButton]",e=>{n(".t3js-dependencies").toggleClass("disabled",!n(e.currentTarget).prop("checked"))}),null!==(t=document.querySelector(u.searchField))&&t.clearable({onClear:()=>{e.search("").draw()}}),n(document).on("click",".t3-button-action-installdistribution",()=>{a.start()}),this.Repository.initDom(),this.Update.initializeEvents(),this.UploadForm.initializeEvents(),i.initialize("#typo3-extension-list [title]",{delay:{show:500,hide:100},trigger:"hover",container:"body"})})}static getUrlVars(){let e=[],t=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(let n of t){const[t,a]=n.split("=");e.push(t),e[t]=a}return e}static versionCompare(e,t){if(e===t)return 0;const n=e.split("."),a=t.split("."),o=Math.min(n.length,a.length);for(let e=0;e<o;e++){if(parseInt(n[e],10)>parseInt(a[e],10))return 1;if(parseInt(n[e],10)<parseInt(a[e],10))return-1}return n.length>a.length?1:n.length<a.length?-1:0}static extensionCompare(e,t){const n=document.createElement("div");n.innerHTML=e;const a=n.textContent||n.innerText||e;n.innerHTML=t;const o=n.textContent||n.innerText||t;return a.trim().localeCompare(o.trim())}manageExtensionListing(){const e=n(u.searchField),t=n(u.extensionlist).DataTable({paging:!1,dom:"lrtip",lengthChange:!1,pageLength:15,stateSave:!0,drawCallback:this.bindExtensionListActions,columns:[null,null,{type:"extension"},null,{type:"version"},{orderable:!1},null,null]});e.parents("form").on("submit",()=>!1);const a=m.getUrlVars(),o=a.search?a.search:t.search();return e.val(o),e.on("input",e=>{t.search(n(e.currentTarget).val()).draw()}),t}removeExtensionFromDisk(e){n.ajax({url:e.data("href"),beforeSend:()=>{a.start()},success:()=>{location.reload()},complete:()=>{a.done()}})}updateExtension(e){let t=0;const i=n("<form>");n.each(e.updateComments,(e,a)=>{const o=n("<input>").attr({type:"radio",name:"version"}).val(e);0===t&&o.attr("checked","checked"),i.append([n("<h3>").append([o," "+p.encodeHtml(e)]),n("<div>").append(a.replace(/(\r\n|\n\r|\r|\n)/g,"\n").split(/\n/).map(e=>p.encodeHtml(e)).join("<br>"))]),t++});const s=n("<div>").append([n("<h1>").text(TYPO3.lang["extensionList.updateConfirmation.title"]),n("<h2>").text(TYPO3.lang["extensionList.updateConfirmation.message"]),i]);a.done(),o.confirm(TYPO3.lang["extensionList.updateConfirmation.questionVersionComments"],s,r.warning,[{text:TYPO3.lang["button.cancel"],active:!0,btnClass:"btn-default",trigger:()=>{o.dismiss()}},{text:TYPO3.lang["button.updateExtension"],btnClass:"btn-warning",trigger:()=>{n.ajax({url:e.url,data:{tx_extensionmanager_tools_extensionmanagerextensionmanager:{version:n("input:radio[name=version]:checked",o.currentModal).val()}},dataType:"json",beforeSend:()=>{a.start()},complete:()=>{location.reload()}}),o.dismiss()}}])}}let g=new m;return void 0===TYPO3.ExtensionManager&&(TYPO3.ExtensionManager=g),g});
\ No newline at end of file
index a54be3e..917d80d 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","../AbstractInteractableModule","jquery","../../Router","../../Renderable/FlashMessage","../../Renderable/ProgressBar","../../Renderable/InfoBox","../../Renderable/Severity","bootstrap"],function(t,a,e,s,n,i,o,d,l){"use strict";return new class extends e.AbstractInteractableModule{constructor(){super(...arguments),this.selectorOutputContainer=".t3js-languagePacks-output",this.selectorContentContainer=".t3js-languagePacks-mainContent",this.selectorActivateLanguage=".t3js-languagePacks-activateLanguage",this.selectorActivateLanguageIcon="#t3js-languagePacks-activate-icon",this.selectorAddLanguageToggle=".t3js-languagePacks-addLanguage-toggle",this.selectorLanguageInactive=".t3js-languagePacks-inactive",this.selectorDeactivateLanguage=".t3js-languagePacks-deactivateLanguage",this.selectorDeactivateLanguageIcon="#t3js-languagePacks-deactivate-icon",this.selectorUpdate=".t3js-languagePacks-update",this.selectorLanguageUpdateIcon="#t3js-languagePacks-languageUpdate-icon",this.selectorExtensionPackMissesIcon="#t3js-languagePacks-extensionPack-misses-icon",this.selectorNotifications=".t3js-languagePacks-notifications",this.activeLanguages=[],this.activeExtensions=[],this.packsUpdateDetails={toHandle:0,handled:0,updated:0,new:0,failed:0},this.notifications=[]}initialize(t){this.currentModal=t,this.getData(),t.on("click",this.selectorAddLanguageToggle,()=>{t.find(this.selectorContentContainer+" "+this.selectorLanguageInactive).toggle()}),t.on("click",this.selectorActivateLanguage,t=>{const a=s(t.target).closest(this.selectorActivateLanguage).data("iso");t.preventDefault(),this.activateLanguage(a)}),t.on("click",this.selectorDeactivateLanguage,t=>{const a=s(t.target).closest(this.selectorDeactivateLanguage).data("iso");t.preventDefault(),this.deactivateLanguage(a)}),t.on("click",this.selectorUpdate,t=>{const a=s(t.target).closest(this.selectorUpdate).data("iso"),e=s(t.target).closest(this.selectorUpdate).data("extension");t.preventDefault(),this.updatePacks(a,e)})}getData(){const t=this.getModalBody();s.ajax({url:n.getUrl("languagePacksGetData"),cache:!1,success:a=>{if(!0===a.success){this.activeLanguages=a.activeLanguages,this.activeExtensions=a.activeExtensions,t.empty().append(a.html);const e=t.parent().find(this.selectorContentContainer);e.empty(),e.append(this.languageMatrixHtml(a)),e.append(this.extensionMatrixHtml(a)),s('[data-toggle="tooltip"]').tooltip({container:e})}else{const t=d.render(l.error,"Something went wrong","");this.addNotification(t)}this.renderNotifications()},error:a=>{n.handleAjaxError(a,t)}})}activateLanguage(t){const a=this.getModalBody(),e=this.findInModal(this.selectorOutputContainer),c=o.render(l.loading,"Loading...","");e.empty().append(c),s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksActivateLanguage",token:this.getModuleContent().data("language-packs-activate-language-token"),iso:t}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{if(e.empty(),!0===t.success&&Array.isArray(t.status))t.status.forEach(t=>{const a=d.render(t.severity,t.title,t.message);this.addNotification(a)});else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}this.getData()},error:t=>{n.handleAjaxError(t,a)}})}deactivateLanguage(t){const a=this.getModalBody(),e=this.findInModal(this.selectorOutputContainer),c=o.render(l.loading,"Loading...","");e.empty().append(c),s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksDeactivateLanguage",token:this.getModuleContent().data("language-packs-deactivate-language-token"),iso:t}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{if(e.empty(),!0===t.success&&Array.isArray(t.status))t.status.forEach(t=>{const a=d.render(t.severity,t.title,t.message);this.addNotification(a)});else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}this.getData()},error:t=>{n.handleAjaxError(t,a)}})}updatePacks(t,a){const e=this.findInModal(this.selectorOutputContainer),i=this.findInModal(this.selectorContentContainer),o=void 0===t?this.activeLanguages:[t];let d=!0,l=this.activeExtensions;void 0!==a&&(l=[a],d=!1),this.packsUpdateDetails={toHandle:o.length*l.length,handled:0,updated:0,new:0,failed:0},e.empty().append(s("<div>",{class:"progress"}).append(s("<div>",{class:"progress-bar progress-bar-info",role:"progressbar","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100,style:"width: 0;"}).append(s("<span>",{class:"text-nowrap"}).text("0 of "+this.packsUpdateDetails.toHandle+" language packs updated")))),i.empty(),o.forEach(t=>{l.forEach(a=>{s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksUpdatePack",token:this.getModuleContent().data("language-packs-update-pack-token"),iso:t,extension:a}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{!0===t.success?(this.packsUpdateDetails.handled++,"new"===t.packResult?this.packsUpdateDetails.new++:"update"===t.packResult?this.packsUpdateDetails.updated++:this.packsUpdateDetails.failed++,this.packUpdateDone(d,o)):(this.packsUpdateDetails.handled++,this.packsUpdateDetails.failed++,this.packUpdateDone(d,o))},error:()=>{this.packsUpdateDetails.handled++,this.packsUpdateDetails.failed++,this.packUpdateDone(d,o)}})})})}packUpdateDone(t,a){const e=this.getModalBody(),o=this.findInModal(this.selectorOutputContainer);if(this.packsUpdateDetails.handled===this.packsUpdateDetails.toHandle){const o=d.render(l.ok,"Language packs updated",this.packsUpdateDetails.new+" new language packs downloaded, "+this.packsUpdateDetails.updated+" language packs updated, "+this.packsUpdateDetails.failed+" language packs not available");this.addNotification(o),!0===t?s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksUpdateIsoTimes",token:this.getModuleContent().data("language-packs-update-iso-times-token"),isos:a}},cache:!1,success:t=>{if(!0===t.success)this.getData();else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}},error:t=>{n.handleAjaxError(t,e)}}):this.getData()}else{const t=this.packsUpdateDetails.handled/this.packsUpdateDetails.toHandle*100;o.find(".progress-bar").css("width",t+"%").attr("aria-valuenow",t).find("span").text(this.packsUpdateDetails.handled+" of "+this.packsUpdateDetails.toHandle+" language packs updated")}}languageMatrixHtml(t){const a=this.findInModal(this.selectorActivateLanguageIcon).html(),e=this.findInModal(this.selectorDeactivateLanguageIcon).html(),n=this.findInModal(this.selectorLanguageUpdateIcon).html(),i=s("<div>"),o=s("<tbody>");return t.languages.forEach(t=>{const i=t.active,d=s("<tr>");i?o.append(d.append(s("<td>").text(" "+t.name).prepend(s("<div />",{class:"btn-group"}).append(s("<a>",{class:"btn btn-default t3js-languagePacks-deactivateLanguage","data-iso":t.iso,"data-toggle":"tooltip",title:"Deactivate"}).append(e),s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-iso":t.iso,"data-toggle":"tooltip",title:"Download language packs"}).append(n))))):o.append(d.addClass("t3-languagePacks-inactive t3js-languagePacks-inactive").css({display:"none"}).append(s("<td>").text(" "+t.name).prepend(s("<div />",{class:"btn-group"}).append(s("<a>",{class:"btn btn-default t3js-languagePacks-activateLanguage","data-iso":t.iso,"data-toggle":"tooltip",title:"Activate"}).append(a))))),d.append(s("<td>").text(t.iso),s("<td>").text(t.dependencies.join(", ")),s("<td>").text(null===t.lastUpdate?"":t.lastUpdate)),o.append(d)}),i.append(s("<h3>").text("Active languages"),s("<table>",{class:"table table-striped table-bordered"}).append(s("<thead>").append(s("<tr>").append(s("<th>").append(s("<div />",{class:"btn-group"}).append(s("<button>",{class:"btn btn-default t3js-languagePacks-addLanguage-toggle",type:"button"}).append(s("<span>").append(a)," Add language"),s("<button>",{class:"btn btn-default t3js-languagePacks-update",type:"button"}).append(s("<span>").append(n)," Update all"))),s("<th>").text("Locale"),s("<th>").text("Dependencies"),s("<th>").text("Last update"))),o)),i.html()}extensionMatrixHtml(t){const a=this.findInModal(this.selectorExtensionPackMissesIcon).html(),e=this.findInModal(this.selectorLanguageUpdateIcon).html();let n,i="",o=!0,c=0;const p=s("<div>"),g=s("<tr>");g.append(s("<th>").text("Extension"),s("<th>").text("Key")),t.activeLanguages.forEach(t=>{g.append(s("<th>").append(s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-iso":t,"data-toggle":"tooltip",title:"Download and update all language packs"}).append(s("<span>").append(e)," "+t)))});const r=s("<tbody>");return t.extensions.forEach(t=>{if(o=!0,t.packs.forEach(t=>{!1===t.exists&&(o=!1)}),!0===o)return;c++,n=""!==t.icon?s("<span>").append(s("<img>",{style:"max-height: 16px; max-width: 16px;",src:"../"+t.icon,alt:t.title}),s("<span>").text(" "+t.title)):s("<span>").text(t.title);const e=s("<tr>");e.append(s("<td>").html(n.html()),s("<td>").text(t.key)),t.packs.forEach(n=>{!0!==n.exists&&(i=null!==n.lastUpdate?"No language pack available when tried at "+n.lastUpdate+". Click to re-try.":"Language pack not downloaded. Click to download",e.append(s("<td>").append(s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-extension":t.key,"data-iso":n.iso,"data-toggle":"tooltip",title:i}).append(a))))}),r.append(e)}),p.append(s("<h3>").text("Translation status"),s("<table>",{class:"table table-striped table-bordered"}).append(s("<thead>").append(g),r)),0===c?d.render(l.ok,"Language packs have been found for every installed extension.","To download the latest changes, use the refresh button in the list above."):p.html()}getNotificationBox(){return this.findInModal(this.selectorNotifications)}addNotification(t){this.notifications.push(t)}renderNotifications(){const t=this.getNotificationBox();for(let a=0;a<this.notifications.length;++a)t.append(this.notifications[a]);this.notifications=[]}}});
\ No newline at end of file
+define(["require","exports","../AbstractInteractableModule","jquery","../../Router","../../Renderable/FlashMessage","../../Renderable/ProgressBar","../../Renderable/InfoBox","../../Renderable/Severity","bootstrap"],function(t,a,e,s,n,i,o,d,l){"use strict";return new class extends e.AbstractInteractableModule{constructor(){super(...arguments),this.selectorOutputContainer=".t3js-languagePacks-output",this.selectorContentContainer=".t3js-languagePacks-mainContent",this.selectorActivateLanguage=".t3js-languagePacks-activateLanguage",this.selectorActivateLanguageIcon="#t3js-languagePacks-activate-icon",this.selectorAddLanguageToggle=".t3js-languagePacks-addLanguage-toggle",this.selectorLanguageInactive=".t3js-languagePacks-inactive",this.selectorDeactivateLanguage=".t3js-languagePacks-deactivateLanguage",this.selectorDeactivateLanguageIcon="#t3js-languagePacks-deactivate-icon",this.selectorUpdate=".t3js-languagePacks-update",this.selectorLanguageUpdateIcon="#t3js-languagePacks-languageUpdate-icon",this.selectorExtensionPackMissesIcon="#t3js-languagePacks-extensionPack-misses-icon",this.selectorNotifications=".t3js-languagePacks-notifications",this.activeLanguages=[],this.activeExtensions=[],this.packsUpdateDetails={toHandle:0,handled:0,updated:0,new:0,failed:0},this.notifications=[]}initialize(t){this.currentModal=t,this.getData(),t.on("click",this.selectorAddLanguageToggle,()=>{t.find(this.selectorContentContainer+" "+this.selectorLanguageInactive).toggle()}),t.on("click",this.selectorActivateLanguage,t=>{const a=s(t.target).closest(this.selectorActivateLanguage).data("iso");t.preventDefault(),this.activateLanguage(a)}),t.on("click",this.selectorDeactivateLanguage,t=>{const a=s(t.target).closest(this.selectorDeactivateLanguage).data("iso");t.preventDefault(),this.deactivateLanguage(a)}),t.on("click",this.selectorUpdate,t=>{const a=s(t.target).closest(this.selectorUpdate).data("iso"),e=s(t.target).closest(this.selectorUpdate).data("extension");t.preventDefault(),this.updatePacks(a,e)})}getData(){const t=this.getModalBody();s.ajax({url:n.getUrl("languagePacksGetData"),cache:!1,success:a=>{if(!0===a.success){this.activeLanguages=a.activeLanguages,this.activeExtensions=a.activeExtensions,t.empty().append(a.html);const e=t.parent().find(this.selectorContentContainer);e.empty(),e.append(this.languageMatrixHtml(a)),e.append(this.extensionMatrixHtml(a)),s('[data-toggle="tooltip"]').tooltip({container:e})}else{const t=d.render(l.error,"Something went wrong","");this.addNotification(t)}this.renderNotifications()},error:a=>{n.handleAjaxError(a,t)}})}activateLanguage(t){const a=this.getModalBody(),e=this.findInModal(this.selectorOutputContainer),c=o.render(l.loading,"Loading...","");e.empty().append(c),s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksActivateLanguage",token:this.getModuleContent().data("language-packs-activate-language-token"),iso:t}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{if(e.empty(),!0===t.success&&Array.isArray(t.status))t.status.forEach(t=>{const a=d.render(t.severity,t.title,t.message);this.addNotification(a)});else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}this.getData()},error:t=>{n.handleAjaxError(t,a)}})}deactivateLanguage(t){const a=this.getModalBody(),e=this.findInModal(this.selectorOutputContainer),c=o.render(l.loading,"Loading...","");e.empty().append(c),s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksDeactivateLanguage",token:this.getModuleContent().data("language-packs-deactivate-language-token"),iso:t}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{if(e.empty(),!0===t.success&&Array.isArray(t.status))t.status.forEach(t=>{const a=d.render(t.severity,t.title,t.message);this.addNotification(a)});else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}this.getData()},error:t=>{n.handleAjaxError(t,a)}})}updatePacks(t,a){const e=this.findInModal(this.selectorOutputContainer),i=this.findInModal(this.selectorContentContainer),o=void 0===t?this.activeLanguages:[t];let d=!0,l=this.activeExtensions;void 0!==a&&(l=[a],d=!1),this.packsUpdateDetails={toHandle:o.length*l.length,handled:0,updated:0,new:0,failed:0},e.empty().append(s("<div>",{class:"progress"}).append(s("<div>",{class:"progress-bar progress-bar-info",role:"progressbar","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100,style:"width: 0;"}).append(s("<span>",{class:"text-nowrap"}).text("0 of "+this.packsUpdateDetails.toHandle+" language packs updated")))),i.empty(),o.forEach(t=>{l.forEach(a=>{s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksUpdatePack",token:this.getModuleContent().data("language-packs-update-pack-token"),iso:t,extension:a}},cache:!1,beforeSend:()=>{this.getNotificationBox().empty()},success:t=>{!0===t.success?(this.packsUpdateDetails.handled++,"new"===t.packResult?this.packsUpdateDetails.new++:"update"===t.packResult?this.packsUpdateDetails.updated++:this.packsUpdateDetails.failed++,this.packUpdateDone(d,o)):(this.packsUpdateDetails.handled++,this.packsUpdateDetails.failed++,this.packUpdateDone(d,o))},error:()=>{this.packsUpdateDetails.handled++,this.packsUpdateDetails.failed++,this.packUpdateDone(d,o)}})})})}packUpdateDone(t,a){const e=this.getModalBody(),o=this.findInModal(this.selectorOutputContainer);if(this.packsUpdateDetails.handled===this.packsUpdateDetails.toHandle){const o=d.render(l.ok,"Language packs updated",this.packsUpdateDetails.new+" new language packs downloaded, "+this.packsUpdateDetails.updated+" language packs updated, "+this.packsUpdateDetails.failed+" language packs not available");this.addNotification(o),!0===t?s.ajax({url:n.getUrl(),method:"POST",context:this,data:{install:{action:"languagePacksUpdateIsoTimes",token:this.getModuleContent().data("language-packs-update-iso-times-token"),isos:a}},cache:!1,success:t=>{if(!0===t.success)this.getData();else{const t=i.render(l.error,"Something went wrong","");this.addNotification(t)}},error:t=>{n.handleAjaxError(t,e)}}):this.getData()}else{const t=this.packsUpdateDetails.handled/this.packsUpdateDetails.toHandle*100;o.find(".progress-bar").css("width",t+"%").attr("aria-valuenow",t).find("span").text(this.packsUpdateDetails.handled+" of "+this.packsUpdateDetails.toHandle+" language packs updated")}}languageMatrixHtml(t){const a=this.findInModal(this.selectorActivateLanguageIcon).html(),e=this.findInModal(this.selectorDeactivateLanguageIcon).html(),n=this.findInModal(this.selectorLanguageUpdateIcon).html(),i=s("<div>"),o=s("<tbody>");return t.languages.forEach(t=>{const i=t.active,d=s("<tr>");i?o.append(d.append(s("<td>").text(" "+t.name).prepend(s("<div />",{class:"btn-group"}).append(s("<a>",{class:"btn btn-default t3js-languagePacks-deactivateLanguage","data-iso":t.iso,"data-toggle":"tooltip",title:"Deactivate"}).append(e),s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-iso":t.iso,"data-toggle":"tooltip",title:"Download language packs"}).append(n))))):o.append(d.addClass("t3-languagePacks-inactive t3js-languagePacks-inactive").css({display:"none"}).append(s("<td>").text(" "+t.name).prepend(s("<div />",{class:"btn-group"}).append(s("<a>",{class:"btn btn-default t3js-languagePacks-activateLanguage","data-iso":t.iso,"data-toggle":"tooltip",title:"Activate"}).append(a))))),d.append(s("<td>").text(t.iso),s("<td>").text(t.dependencies.join(", ")),s("<td>").text(null===t.lastUpdate?"":t.lastUpdate)),o.append(d)}),i.append(s("<h3>").text("Active languages"),s("<table>",{class:"table table-striped table-bordered"}).append(s("<thead>").append(s("<tr>").append(s("<th>").append(s("<div />",{class:"btn-group"}).append(s("<button>",{class:"btn btn-default t3js-languagePacks-addLanguage-toggle",type:"button"}).append(s("<span>").append(a)," Add language"),s("<button>",{class:"btn btn-default t3js-languagePacks-update",type:"button"}).append(s("<span>").append(n)," Update all"))),s("<th>").text("Locale"),s("<th>").text("Dependencies"),s("<th>").text("Last update"))),o)),i.html()}extensionMatrixHtml(t){const a=this.findInModal(this.selectorExtensionPackMissesIcon).html(),e=this.findInModal(this.selectorLanguageUpdateIcon).html();let n,i="",o=!0,c=0;const p=s("<div>"),g=s("<tr>");g.append(s("<th>").text("Extension"),s("<th>").text("Key")),t.activeLanguages.forEach(t=>{g.append(s("<th>").append(s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-iso":t,"data-toggle":"tooltip",title:"Download and update all language packs"}).append(s("<span>").append(e)," "+t)))});const r=s("<tbody>");return t.extensions.forEach(t=>{if(o=!0,t.packs.forEach(t=>{!1===t.exists&&(o=!1)}),!0===o)return;c++,n=""!==t.icon?s("<span>").append(s("<img>",{style:"max-height: 16px; max-width: 16px;",src:"../"+t.icon,alt:t.title}),s("<span>").text(" "+t.title)):s("<span>").text(t.title);const e=s("<tr>");e.append(s("<td>").html(n.html()),s("<td>").text(t.key)),t.packs.forEach(n=>{!0!==n.exists&&(i=null!==n.lastUpdate?"No language pack available when tried at "+n.lastUpdate+". Click to re-try.":"Language pack not downloaded. Click to download",e.append(s("<td>").append(s("<a>",{class:"btn btn-default t3js-languagePacks-update","data-extension":t.key,"data-iso":n.iso,"data-toggle":"tooltip",title:i}).append(a))))}),r.append(e)}),p.append(s("<h3>").text("Translation status"),s("<table>",{class:"table table-striped table-bordered"}).append(s("<thead>").append(g),r)),0===c?d.render(l.ok,"Language packs have been found for every installed extension.","To download the latest changes, use the refresh button in the list above."):p.html()}getNotificationBox(){return this.findInModal(this.selectorNotifications)}addNotification(t){this.notifications.push(t)}renderNotifications(){const t=this.getNotificationBox();for(let a of this.notifications)t.append(a);this.notifications=[]}}});
\ No newline at end of file
index 54ecd9f..5c75ad7 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","../AbstractInteractableModule","jquery","../../Router","TYPO3/CMS/Backend/Notification","bootstrap","../../Renderable/Clearable"],function(e,t,s,a,o,n){"use strict";class l extends s.AbstractInteractableModule{constructor(){super(...arguments),this.selectorFulltextSearch=".t3js-upgradeDocs-fulltext-search",this.selectorChosenField=".t3js-upgradeDocs-chosen-select",this.selectorChangeLogsForVersionContainer=".t3js-version-changes",this.selectorChangeLogsForVersion=".t3js-changelog-list",this.selectorUpgradeDoc=".t3js-upgrade-doc"}static trimExplodeAndUnique(e,t){const s=[],o=t.split(e);for(let e=0;e<o.length;e++){const t=o[e].trim();t.length>0&&-1===a.inArray(t,s)&&s.push(t)}return s}initialize(t){this.currentModal=t,window.location!==window.parent.location?top.require(["TYPO3/CMS/Install/chosen.jquery.min"],()=>{this.getContent()}):e(["TYPO3/CMS/Install/chosen.jquery.min"],()=>{this.getContent()}),t.on("click",".t3js-upgradeDocs-markRead",e=>{this.markRead(e.target)}),t.on("click",".t3js-upgradeDocs-unmarkRead",e=>{this.unmarkRead(e.target)}),jQuery.expr[":"].contains=jQuery.expr.createPseudo(e=>t=>jQuery(t).text().toUpperCase().includes(e.toUpperCase()));const s=t.find(this.selectorFulltextSearch).get(0);s.clearable(),s.focus()}getContent(){const e=this.getModalBody();e.on("show.bs.collapse",this.selectorUpgradeDoc,e=>{this.renderTags(a(e.currentTarget))}),a.ajax({url:o.getUrl("upgradeDocsGetContent"),cache:!1,success:t=>{!0===t.success&&"undefined"!==t.html&&t.html.length>0&&(e.empty().append(t.html),this.initializeFullTextSearch(),this.initializeChosenSelector(),this.loadChangelogs())},error:t=>{o.handleAjaxError(t,e)}})}loadChangelogs(){const e=[],t=this.getModalBody();this.findInModal(this.selectorChangeLogsForVersionContainer).each((s,l)=>{const i=a.ajax({url:o.getUrl("upgradeDocsGetChangelogForVersion"),cache:!1,data:{install:{version:l.dataset.version}},success:e=>{if(!0===e.success){const t=a(l),s=t.find(this.selectorChangeLogsForVersion);s.html(e.html),this.moveNotRelevantDocuments(s),t.find(".t3js-panel-loading").remove()}else n.error("Something went wrong")},error:e=>{o.handleAjaxError(e,t)}});e.push(i)}),a.when.apply(a,e).done(()=>{this.fulltextSearchField.prop("disabled",!1),this.appendItemsToChosenSelector()})}initializeFullTextSearch(){this.fulltextSearchField=this.findInModal(this.selectorFulltextSearch);const e=this.fulltextSearchField.get(0);e.clearable(),e.focus(),this.initializeChosenSelector(),this.fulltextSearchField.on("keyup",()=>{this.combinedFilterSearch()})}initializeChosenSelector(){this.chosenField=this.getModalBody().find(this.selectorChosenField);const e={".chosen-select":{width:"100%",placeholder_text_multiple:"tags"},".chosen-select-deselect":{allow_single_deselect:!0},".chosen-select-no-single":{disable_search_threshold:10},".chosen-select-no-results":{no_results_text:"Oops, nothing found!"},".chosen-select-width":{width:"100%"}};for(const t in e)e.hasOwnProperty(t)&&this.findInModal(t).chosen(e[t]);this.chosenField.on("change",()=>{this.combinedFilterSearch()})}appendItemsToChosenSelector(){let e="";a(this.findInModal(this.selectorUpgradeDoc)).each((t,s)=>{e+=a(s).data("item-tags")+","});const t=l.trimExplodeAndUnique(",",e).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()));this.chosenField.prop("disabled",!1),a.each(t,(e,t)=>{this.chosenField.append(a("<option>").text(t))}),this.chosenField.trigger("chosen:updated")}combinedFilterSearch(){const e=this.getModalBody(),t=e.find("div.item");if(this.chosenField.val().length<1&&this.fulltextSearchField.val().length<1)return a(".panel-version:not(:first) > .panel-collapse").collapse("hide"),t.removeClass("hidden searchhit filterhit"),!1;if(t.addClass("hidden").removeClass("searchhit filterhit"),this.chosenField.val().length>0){t.addClass("hidden").removeClass("filterhit");const s=[],o=[];a.each(this.chosenField.val(),(e,t)=>{const a='[data-item-tags*="'+t+'"]';t.contains(":",1)?s.push(a):o.push(a)});const n=o.join(""),l=[];if(s.length)for(let e=0;e<s.length;e++)l.push(n+s[e]);else l.push(n);const i=l.join(",");e.find(i).removeClass("hidden").addClass("searchhit filterhit")}else t.addClass("filterhit").removeClass("hidden");const s=this.fulltextSearchField.val();return e.find("div.item.filterhit").each((e,t)=>{const o=a(t);a(":contains("+s+")",o).length>0||a('input[value*="'+s+'"]',o).length>0?o.removeClass("hidden").addClass("searchhit"):o.removeClass("searchhit").addClass("hidden")}),e.find(".searchhit").closest(".panel-collapse").collapse("show"),e.find(".panel-version").each((e,t)=>{const s=a(t);s.find(".searchhit",".filterhit").length<1&&s.find(" > .panel-collapse").collapse("hide")}),!0}renderTags(e){const t=e.find(".t3js-tags");if(0===t.children().length){e.data("item-tags").split(",").forEach(e=>{t.append(a("<span />",{class:"label"}).text(e))})}}moveNotRelevantDocuments(e){e.find('[data-item-state="read"]').appendTo(this.findInModal(".panel-body-read")),e.find('[data-item-state="notAffected"]').appendTo(this.findInModal(".panel-body-not-affected"))}markRead(e){const t=this.getModalBody(),s=this.getModuleContent().data("upgrade-docs-mark-read-token"),n=a(e).closest("a");n.toggleClass("t3js-upgradeDocs-unmarkRead t3js-upgradeDocs-markRead"),n.find("i").toggleClass("fa-check fa-ban"),n.closest(".panel").appendTo(this.findInModal(".panel-body-read")),a.ajax({method:"POST",url:o.getUrl(),data:{install:{ignoreFile:n.data("filepath"),token:s,action:"upgradeDocsMarkRead"}},error:e=>{o.handleAjaxError(e,t)}})}unmarkRead(e){const t=this.getModalBody(),s=this.getModuleContent().data("upgrade-docs-unmark-read-token"),n=a(e).closest("a"),l=n.closest(".panel").data("item-version");n.toggleClass("t3js-upgradeDocs-markRead t3js-upgradeDocs-unmarkRead"),n.find("i").toggleClass("fa-check fa-ban"),n.closest(".panel").appendTo(this.findInModal('*[data-group-version="'+l+'"] .panel-body')),a.ajax({method:"POST",url:o.getUrl(),data:{install:{ignoreFile:n.data("filepath"),token:s,action:"upgradeDocsUnmarkRead"}},error:e=>{o.handleAjaxError(e,t)}})}}return new l});
\ No newline at end of file
+define(["require","exports","../AbstractInteractableModule","jquery","../../Router","TYPO3/CMS/Backend/Notification","bootstrap","../../Renderable/Clearable"],function(e,t,s,a,o,n){"use strict";class l extends s.AbstractInteractableModule{constructor(){super(...arguments),this.selectorFulltextSearch=".t3js-upgradeDocs-fulltext-search",this.selectorChosenField=".t3js-upgradeDocs-chosen-select",this.selectorChangeLogsForVersionContainer=".t3js-version-changes",this.selectorChangeLogsForVersion=".t3js-changelog-list",this.selectorUpgradeDoc=".t3js-upgrade-doc"}static trimExplodeAndUnique(e,t){const s=[],o=t.split(e);for(let e=0;e<o.length;e++){const t=o[e].trim();t.length>0&&-1===a.inArray(t,s)&&s.push(t)}return s}initialize(t){this.currentModal=t,window.location!==window.parent.location?top.require(["TYPO3/CMS/Install/chosen.jquery.min"],()=>{this.getContent()}):e(["TYPO3/CMS/Install/chosen.jquery.min"],()=>{this.getContent()}),t.on("click",".t3js-upgradeDocs-markRead",e=>{this.markRead(e.target)}),t.on("click",".t3js-upgradeDocs-unmarkRead",e=>{this.unmarkRead(e.target)}),jQuery.expr[":"].contains=jQuery.expr.createPseudo(e=>t=>jQuery(t).text().toUpperCase().includes(e.toUpperCase()));const s=t.find(this.selectorFulltextSearch).get(0);s.clearable(),s.focus()}getContent(){const e=this.getModalBody();e.on("show.bs.collapse",this.selectorUpgradeDoc,e=>{this.renderTags(a(e.currentTarget))}),a.ajax({url:o.getUrl("upgradeDocsGetContent"),cache:!1,success:t=>{!0===t.success&&"undefined"!==t.html&&t.html.length>0&&(e.empty().append(t.html),this.initializeFullTextSearch(),this.initializeChosenSelector(),this.loadChangelogs())},error:t=>{o.handleAjaxError(t,e)}})}loadChangelogs(){const e=[],t=this.getModalBody();this.findInModal(this.selectorChangeLogsForVersionContainer).each((s,l)=>{const i=a.ajax({url:o.getUrl("upgradeDocsGetChangelogForVersion"),cache:!1,data:{install:{version:l.dataset.version}},success:e=>{if(!0===e.success){const t=a(l),s=t.find(this.selectorChangeLogsForVersion);s.html(e.html),this.moveNotRelevantDocuments(s),t.find(".t3js-panel-loading").remove()}else n.error("Something went wrong")},error:e=>{o.handleAjaxError(e,t)}});e.push(i)}),a.when.apply(a,e).done(()=>{this.fulltextSearchField.prop("disabled",!1),this.appendItemsToChosenSelector()})}initializeFullTextSearch(){this.fulltextSearchField=this.findInModal(this.selectorFulltextSearch);const e=this.fulltextSearchField.get(0);e.clearable(),e.focus(),this.initializeChosenSelector(),this.fulltextSearchField.on("keyup",()=>{this.combinedFilterSearch()})}initializeChosenSelector(){this.chosenField=this.getModalBody().find(this.selectorChosenField);const e={".chosen-select":{width:"100%",placeholder_text_multiple:"tags"},".chosen-select-deselect":{allow_single_deselect:!0},".chosen-select-no-single":{disable_search_threshold:10},".chosen-select-no-results":{no_results_text:"Oops, nothing found!"},".chosen-select-width":{width:"100%"}};for(const t in e)e.hasOwnProperty(t)&&this.findInModal(t).chosen(e[t]);this.chosenField.on("change",()=>{this.combinedFilterSearch()})}appendItemsToChosenSelector(){let e="";a(this.findInModal(this.selectorUpgradeDoc)).each((t,s)=>{e+=a(s).data("item-tags")+","});const t=l.trimExplodeAndUnique(",",e).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()));this.chosenField.prop("disabled",!1),a.each(t,(e,t)=>{this.chosenField.append(a("<option>").text(t))}),this.chosenField.trigger("chosen:updated")}combinedFilterSearch(){const e=this.getModalBody(),t=e.find("div.item");if(this.chosenField.val().length<1&&this.fulltextSearchField.val().length<1)return a(".panel-version:not(:first) > .panel-collapse").collapse("hide"),t.removeClass("hidden searchhit filterhit"),!1;if(t.addClass("hidden").removeClass("searchhit filterhit"),this.chosenField.val().length>0){t.addClass("hidden").removeClass("filterhit");const s=[],o=[];a.each(this.chosenField.val(),(e,t)=>{const a='[data-item-tags*="'+t+'"]';t.contains(":",1)?s.push(a):o.push(a)});const n=o.join(""),l=[];if(s.length)for(let e of s)l.push(n+e);else l.push(n);const i=l.join(",");e.find(i).removeClass("hidden").addClass("searchhit filterhit")}else t.addClass("filterhit").removeClass("hidden");const s=this.fulltextSearchField.val();return e.find("div.item.filterhit").each((e,t)=>{const o=a(t);a(":contains("+s+")",o).length>0||a('input[value*="'+s+'"]',o).length>0?o.removeClass("hidden").addClass("searchhit"):o.removeClass("searchhit").addClass("hidden")}),e.find(".searchhit").closest(".panel-collapse").collapse("show"),e.find(".panel-version").each((e,t)=>{const s=a(t);s.find(".searchhit",".filterhit").length<1&&s.find(" > .panel-collapse").collapse("hide")}),!0}renderTags(e){const t=e.find(".t3js-tags");if(0===t.children().length){e.data("item-tags").split(",").forEach(e=>{t.append(a("<span />",{class:"label"}).text(e))})}}moveNotRelevantDocuments(e){e.find('[data-item-state="read"]').appendTo(this.findInModal(".panel-body-read")),e.find('[data-item-state="notAffected"]').appendTo(this.findInModal(".panel-body-not-affected"))}markRead(e){const t=this.getModalBody(),s=this.getModuleContent().data("upgrade-docs-mark-read-token"),n=a(e).closest("a");n.toggleClass("t3js-upgradeDocs-unmarkRead t3js-upgradeDocs-markRead"),n.find("i").toggleClass("fa-check fa-ban"),n.closest(".panel").appendTo(this.findInModal(".panel-body-read")),a.ajax({method:"POST",url:o.getUrl(),data:{install:{ignoreFile:n.data("filepath"),token:s,action:"upgradeDocsMarkRead"}},error:e=>{o.handleAjaxError(e,t)}})}unmarkRead(e){const t=this.getModalBody(),s=this.getModuleContent().data("upgrade-docs-unmark-read-token"),n=a(e).closest("a"),l=n.closest(".panel").data("item-version");n.toggleClass("t3js-upgradeDocs-markRead t3js-upgradeDocs-unmarkRead"),n.find("i").toggleClass("fa-check fa-ban"),n.closest(".panel").appendTo(this.findInModal('*[data-group-version="'+l+'"] .panel-body')),a.ajax({method:"POST",url:o.getUrl(),data:{install:{ignoreFile:n.data("filepath"),token:s,action:"upgradeDocsUnmarkRead"}},error:e=>{o.handleAjaxError(e,t)}})}}return new l});
\ No newline at end of file
index 092584f..b15a8ca 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./ElementBrowser","TYPO3/CMS/Backend/LegacyTree"],function(e,t,n,l,c){"use strict";class s{constructor(){c.noop(),s.File=new r,s.Selector=new i,n(()=>{s.elements=n("body").data("elements"),n("[data-close]").on("click",e=>{e.preventDefault(),s.File.insertElement("file_"+n(e.currentTarget).data("fileIndex"),1===parseInt(n(e.currentTarget).data("close"),10))}),n("#t3js-importSelection").on("click",s.Selector.handle),n("#t3js-toggleSelection").on("click",s.Selector.toggle)})}}class r{insertElement(e,t){let n=!1;if(void 0!==s.elements[e]){const c=s.elements[e];n=l.insertElement(c.table,c.uid,c.type,c.fileName,c.filePath,c.fileExt,c.fileIcon,"",t)}return n}}class i{constructor(){this.toggle=(e=>{e.preventDefault();const t=this.getItems();t.length&&t.each((e,t)=>{t.checked=t.checked?null:"checked"})}),this.handle=(e=>{e.preventDefault();const t=this.getItems(),n=[];if(t.length){if(t.each((e,t)=>{t.checked&&t.name&&n.push(t.name)}),n.length>0)for(let e=0;e<n.length;e++)s.File.insertElement(n[e]);l.focusOpenerAndClose()}})}getItems(){return n("#typo3-filelist").find(".typo3-bulk-item")}}return new s});
\ No newline at end of file
+define(["require","exports","jquery","./ElementBrowser","TYPO3/CMS/Backend/LegacyTree"],function(e,t,n,l,c){"use strict";class s{constructor(){c.noop(),s.File=new r,s.Selector=new i,n(()=>{s.elements=n("body").data("elements"),n("[data-close]").on("click",e=>{e.preventDefault(),s.File.insertElement("file_"+n(e.currentTarget).data("fileIndex"),1===parseInt(n(e.currentTarget).data("close"),10))}),n("#t3js-importSelection").on("click",s.Selector.handle),n("#t3js-toggleSelection").on("click",s.Selector.toggle)})}}class r{insertElement(e,t){let n=!1;if(void 0!==s.elements[e]){const c=s.elements[e];n=l.insertElement(c.table,c.uid,c.type,c.fileName,c.filePath,c.fileExt,c.fileIcon,"",t)}return n}}class i{constructor(){this.toggle=(e=>{e.preventDefault();const t=this.getItems();t.length&&t.each((e,t)=>{t.checked=t.checked?null:"checked"})}),this.handle=(e=>{e.preventDefault();const t=this.getItems(),n=[];if(t.length){if(t.each((e,t)=>{t.checked&&t.name&&n.push(t.name)}),n.length>0)for(let e of n)s.File.insertElement(e);l.focusOpenerAndClose()}})}getItems(){return n("#typo3-filelist").find(".typo3-bulk-item")}}return new s});
\ No newline at end of file
index 952c267..6171c87 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=0;e<i.length;e++)t=t[i[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,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
index 9e72fcb..28ce920 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery"],function(t,e,r){"use strict";return new class{constructor(){this.thisScriptUrl="",this.urlParameters={},this.parameters={},this.addOnParams="",this.additionalLinkAttributes={},this.loadTarget=(t=>{const e=r(t.currentTarget);r(".t3js-linkTarget").val(e.val()),e.get(0).selectedIndex=0}),r(()=>{const t=r("body").data();this.thisScriptUrl=t.thisScriptUrl,this.urlParameters=t.urlParameters,this.parameters=t.parameters,this.addOnParams=t.addOnParams,this.linkAttributeFields=t.linkAttributeFields,r(".t3js-targetPreselect").on("change",this.loadTarget),r("form.t3js-dummyform").on("submit",t=>{t.preventDefault()})})}getLinkAttributeValues(){const t={};return r.each(this.linkAttributeFields,(e,i)=>{const s=r('[name="l'+i+'"]').val();s&&(t[i]=s)}),r.extend(t,this.additionalLinkAttributes),t}encodeGetParameters(t,e,r){const i=[];for(let s in t)if(t.hasOwnProperty(s)){const n=e?e+"["+s+"]":s,a=t[s];r.includes(n+"=")||i.push("object"==typeof a?this.encodeGetParameters(a,n,r):encodeURIComponent(n)+"="+encodeURIComponent(a))}return"&"+i.join("&")}setAdditionalLinkAttribute(t,e){this.additionalLinkAttributes[t]=e}finalizeFunction(t){throw"The link browser requires the finalizeFunction to be set. Seems like you discovered a major bug."}}});
\ No newline at end of file
+define(["require","exports","jquery"],function(t,e,r){"use strict";return new class{constructor(){this.thisScriptUrl="",this.urlParameters={},this.parameters={},this.addOnParams="",this.additionalLinkAttributes={},this.loadTarget=(t=>{const e=r(t.currentTarget);r(".t3js-linkTarget").val(e.val()),e.get(0).selectedIndex=0}),r(()=>{const t=r("body").data();this.thisScriptUrl=t.thisScriptUrl,this.urlParameters=t.urlParameters,this.parameters=t.parameters,this.addOnParams=t.addOnParams,this.linkAttributeFields=t.linkAttributeFields,r(".t3js-targetPreselect").on("change",this.loadTarget),r("form.t3js-dummyform").on("submit",t=>{t.preventDefault()})})}getLinkAttributeValues(){const t={};return r.each(this.linkAttributeFields,(e,i)=>{const s=r('[name="l'+i+'"]').val();s&&(t[i]=s)}),r.extend(t,this.additionalLinkAttributes),t}encodeGetParameters(t,e,r){const i=[];for(const s of Object.entries(t)){const[t,n]=s,a=e?e+"["+t+"]":t;r.includes(a+"=")||i.push("object"==typeof n?this.encodeGetParameters(n,a,r):encodeURIComponent(a)+"="+encodeURIComponent(n))}return"&"+i.join("&")}setAdditionalLinkAttribute(t,e){this.additionalLinkAttributes[t]=e}finalizeFunction(t){throw"The link browser requires the finalizeFunction to be set. Seems like you discovered a major bug."}}});
\ No newline at end of file
index cc977f2..4e377f6 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","TYPO3/CMS/Backend/Enum/Severity","./Workspaces","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Storage/Persistent","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Utility","TYPO3/CMS/Backend/Viewport","TYPO3/CMS/Backend/Wizard","TYPO3/CMS/Core/SecurityUtility","nprogress","twbs/bootstrap-slider","TYPO3/CMS/Backend/Input/Clearable"],function(require,exports,$,Severity_1,Workspaces_1,Modal,Persistent,Tooltip,Utility,Viewport,Wizard,SecurityUtility){"use strict";var Identifiers;!function(e){e.searchForm="#workspace-settings-form",e.searchTextField='#workspace-settings-form input[name="search-text"]',e.searchSubmitBtn='#workspace-settings-form button[type="submit"]',e.depthSelector='#workspace-settings-form [name="depth"]',e.languageSelector='#workspace-settings-form select[name="languages"]',e.chooseStageAction='#workspace-actions-form [name="stage-action"]',e.chooseSelectionAction='#workspace-actions-form [name="selection-action"]',e.chooseMassAction='#workspace-actions-form [name="mass-action"]',e.container="#workspace-panel",e.actionIcons="#workspace-action-icons",e.toggleAll=".t3js-toggle-all",e.previewLinksButton=".t3js-preview-link",e.pagination="#workspace-pagination"}(Identifiers||(Identifiers={}));class Backend extends Workspaces_1.default{constructor(){super(),this.elements={},this.settings={dir:"ASC",id:TYPO3.settings.Workspaces.id,language:TYPO3.settings.Workspaces.language,limit:30,query:"",sort:"label_Live",start:0,filterTxt:""},this.paging={currentPage:1,totalPages:1,totalItems:0},this.allToggled=!1,this.latestPath="",this.markedRecordsForMassAction=[],this.indentationPadding=26,this.handleCheckboxChange=(e=>{const t=$(e.currentTarget),a=t.parents("tr"),s=a.data("table")+":"+a.data("uid")+":"+a.data("t3ver_oid");if(t.prop("checked"))this.markedRecordsForMassAction.push(s),a.addClass("warning");else{const e=this.markedRecordsForMassAction.indexOf(s);e>-1&&this.markedRecordsForMassAction.splice(e,1),a.removeClass("warning")}this.elements.$chooseStageAction.prop("disabled",0===this.markedRecordsForMassAction.length),this.elements.$chooseSelectionAction.prop("disabled",0===this.markedRecordsForMassAction.length),this.elements.$chooseMassAction.prop("disabled",this.markedRecordsForMassAction.length>0)}),this.viewChanges=(e=>{e.preventDefault();const t=$(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemotePayload("getRowDetails",{stage:t.data("stage"),t3ver_oid:t.data("t3ver_oid"),table:t.data("table"),uid:t.data("uid")})).done(e=>{const a=e[0].result.data[0],s=$("<div />"),n=$("<ul />",{class:"nav nav-tabs",role:"tablist"}),i=$("<div />",{class:"tab-content"}),o=[];s.append($("<p />").html(TYPO3.lang.path.replace("{0}",a.path_Live)),$("<p />").html(TYPO3.lang.current_step.replace("{0}",a.label_Stage).replace("{1}",a.stage_position).replace("{2}",a.stage_count))),a.diff.length>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-changes","aria-controls":"workspace-changes",role:"tab","data-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.changeSummary"]))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-changes"}).append($("<div />",{class:"form-section"}).append(Backend.generateDiffView(a.diff))))),a.comments.length>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-comments","aria-controls":"workspace-comments",role:"tab","data-toggle":"tab"}).html(TYPO3.lang["window.recordChanges.tabs.comments"]+"&nbsp;").append($("<span />",{class:"badge"}).text(a.comments.length)))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-comments"}).append($("<div />",{class:"form-section"}).append(Backend.generateCommentView(a.comments))))),a.history.total>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-history","aria-controls":"workspace-history",role:"tab","data-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.history"]))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-history"}).append($("<div />",{class:"form-section"}).append(Backend.generateHistoryView(a.history.data))))),n.find("li").first().addClass("active"),i.find(".tab-pane").first().addClass("active"),s.append($("<div />").append(n,i)),t.data("stage")!==t.data("prevStage")&&o.push({text:a.label_PrevStage.title,active:!0,btnClass:"btn-default",name:"prevstage",trigger:()=>{Modal.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"prev")}}),o.push({text:a.label_NextStage.title,active:!0,btnClass:"btn-default",name:"nextstage",trigger:()=>{Modal.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"next")}}),o.push({text:TYPO3.lang.close,active:!0,btnClass:"btn-info",name:"cancel",trigger:()=>{Modal.currentModal.trigger("modal-dismiss")}}),Modal.advanced({type:Modal.types.default,title:TYPO3.lang["window.recordInformation"].replace("{0}",$.trim(t.find(".t3js-title-live").text())),content:s,severity:Severity_1.SeverityEnum.info,buttons:o,size:Modal.sizes.medium})})}),this.openPreview=(e=>{const $tr=$(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemoteActionsPayload("viewSingleRecord",[$tr.data("table"),$tr.data("uid")])).done(response=>{eval(response[0].result)})}),this.confirmDeleteRecordFromWorkspace=(e=>{const t=$(e.target).closest("tr"),a=Modal.confirm(TYPO3.lang["window.discard.title"],TYPO3.lang["window.discard.message"],Severity_1.SeverityEnum.warning,[{text:TYPO3.lang.cancel,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{a.modal("hide")}},{text:TYPO3.lang.ok,btnClass:"btn-warning",name:"ok"}]);a.on("button.clicked",e=>{"ok"===e.target.name&&this.sendRemoteRequest([this.generateRemoteActionsPayload("deleteSingleRecord",[t.data("table"),t.data("uid")])]).done(()=>{a.modal("hide"),this.getWorkspaceInfos(),Backend.refreshPageTree()})})}),this.runSelectionAction=(()=>{const e=this.elements.$chooseSelectionAction.val(),t="discard"!==e;if(0===e.length)return;const a=[];for(let e=0;e<this.markedRecordsForMassAction.length;++e){const t=this.markedRecordsForMassAction[e].split(":");a.push({table:t[0],liveId:t[2],versionId:t[1]})}t?this.checkIntegrity({selection:a,type:"selection"}).done(t=>{Wizard.setForceSelection(!1),"warning"===t[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderSelectionActionWizard(e,a)}):(Wizard.setForceSelection(!1),this.renderSelectionActionWizard(e,a))}),this.addIntegrityCheckWarningToWizard=(()=>{Wizard.addSlide("integrity-warning","Warning",TYPO3.lang["integrity.hasIssuesDescription"]+"<br>"+TYPO3.lang["integrity.hasIssuesQuestion"],Severity_1.SeverityEnum.warning)}),this.runMassAction=(()=>{const e=this.elements.$chooseMassAction.val(),t="discard"!==e;0!==e.length&&(t?this.checkIntegrity({language:this.settings.language,type:e}).done(t=>{Wizard.setForceSelection(!1),"warning"===t[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderMassActionWizard(e)}):(Wizard.setForceSelection(!1),this.renderMassActionWizard(e)))}),this.sendToSpecificStageAction=(e=>{const t=[],a=$(e.currentTarget).val();for(let e=0;e<this.markedRecordsForMassAction.length;++e){const a=this.markedRecordsForMassAction[e].split(":");t.push({table:a[0],uid:a[1],t3ver_oid:a[2]})}this.sendRemoteRequest(this.generateRemoteActionsPayload("sendToSpecificStageWindow",[a,t])).done(e=>{const s=this.renderSendToStageWindow(e);s.on("button.clicked",e=>{if("ok"===e.target.name){const n=Utility.convertFormToObject(e.currentTarget.querySelector("form"));n.affects={elements:t,nextStage:a},this.sendRemoteRequest([this.generateRemoteActionsPayload("sendToSpecificStageExecute",[n]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{s.modal("hide"),this.renderWorkspaceInfos(e[1].result),Backend.refreshPageTree()})}}).on("modal-destroyed",()=>{this.elements.$chooseStageAction.val("")})})}),this.generatePreviewLinks=(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("generateWorkspacePreviewLinksForAllLanguages",[this.settings.id])).done(e=>{const t=e[0].result,a=$("<dl />");$.each(t,(e,t)=>{a.append($("<dt />").text(e),$("<dd />").append($("<a />",{href:t,target:"_blank"}).text(t)))}),Modal.show(TYPO3.lang.previewLink,a,Severity_1.SeverityEnum.info,[{text:TYPO3.lang.ok,active:!0,btnClass:"btn-info",name:"ok",trigger:()=>{Modal.currentModal.trigger("modal-dismiss")}}],["modal-inner-scroll"])})}),$(()=>{let e;this.getElements(),this.registerEvents(),Persistent.isset("this.Module.depth")?(e=Persistent.get("this.Module.depth"),this.elements.$depthSelector.val(e),this.settings.depth=e):this.settings.depth=TYPO3.settings.Workspaces.depth,this.loadWorkspaceComponents()})}static refreshPageTree(){Viewport.NavigationContainer&&Viewport.NavigationContainer.PageTree&&Viewport.NavigationContainer.PageTree.refreshTree()}static generateDiffView(e){const t=$("<div />",{class:"diff"});for(let a=0;a<e.length;++a)t.append($("<div />",{class:"diff-item"}).append($("<div />",{class:"diff-item-title"}).text(e[a].label),$("<div />",{class:"diff-item-result diff-item-result-inline"}).html(e[a].content)));return t}static generateCommentView(e){const t=$("<div />");for(let a=0;a<e.length;++a){const s=$("<div />",{class:"panel panel-default"});e[a].user_comment.length>0&&s.append($("<div />",{class:"panel-body"}).html(e[a].user_comment)),s.append($("<div />",{class:"panel-footer"}).append($("<span />",{class:"label label-success"}).text(e[a].stage_title),$("<span />",{class:"label label-info"}).text(e[a].tstamp))),t.append($("<div />",{class:"media"}).append($("<div />",{class:"media-left text-center"}).text(e[a].user_username).prepend($("<div />").html(e[a].user_avatar)),$("<div />",{class:"media-body"}).append(s)))}return t}static generateHistoryView(e){const t=$("<div />");for(let a=0;a<e.length;++a){const s=$("<div />",{class:"panel panel-default"});let n;if("object"==typeof e[a].differences){if(0===e[a].differences.length)continue;n=$("<div />",{class:"diff"});for(let t=0;t<e[a].differences.length;++t)n.append($("<div />",{class:"diff-item"}).append($("<div />",{class:"diff-item-title"}).text(e[a].differences[t].label),$("<div />",{class:"diff-item-result diff-item-result-inline"}).html(e[a].differences[t].html)));s.append($("<div />").append(n))}else s.append($("<div />",{class:"panel-body"}).text(e[a].differences));s.append($("<div />",{class:"panel-footer"}).append($("<span />",{class:"label label-info"}).text(e[a].datetime))),t.append($("<div />",{class:"media"}).append($("<div />",{class:"media-left text-center"}).text(e[a].user).prepend($("<div />").html(e[a].user_avatar)),$("<div />",{class:"media-body"}).append(s)))}return t}getElements(){this.elements.$searchForm=$(Identifiers.searchForm),this.elements.$searchTextField=$(Identifiers.searchTextField),this.elements.$searchSubmitBtn=$(Identifiers.searchSubmitBtn),this.elements.$depthSelector=$(Identifiers.depthSelector),this.elements.$languageSelector=$(Identifiers.languageSelector),this.elements.$container=$(Identifiers.container),this.elements.$tableBody=this.elements.$container.find("tbody"),this.elements.$actionIcons=$(Identifiers.actionIcons),this.elements.$toggleAll=$(Identifiers.toggleAll),this.elements.$chooseStageAction=$(Identifiers.chooseStageAction),this.elements.$chooseSelectionAction=$(Identifiers.chooseSelectionAction),this.elements.$chooseMassAction=$(Identifiers.chooseMassAction),this.elements.$previewLinksButton=$(Identifiers.previewLinksButton),this.elements.$pagination=$(Identifiers.pagination)}registerEvents(){$(document).on("click",'[data-action="swap"]',e=>{const t=e.target.closest("tr");this.checkIntegrity({selection:[{liveId:t.dataset.uid,versionId:t.dataset.t3ver_oid,table:t.dataset.table}],type:"selection"}).done(e=>{"warning"===e[0].result.result&&this.addIntegrityCheckWarningToWizard(),Wizard.setForceSelection(!1),Wizard.addSlide("swap-confirm","Swap",TYPO3.lang["window.swap.message"],Severity_1.SeverityEnum.info),Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("swapSingleRecord",[t.dataset.table,t.dataset.t3ver_oid,t.dataset.uid])).done(()=>{Wizard.dismiss(),this.getWorkspaceInfos(),Backend.refreshPageTree()})}).done(()=>{Wizard.show()})})}).on("click",'[data-action="prevstage"]',e=>{this.sendToStage($(e.currentTarget).closest("tr"),"prev")}).on("click",'[data-action="nextstage"]',e=>{this.sendToStage($(e.currentTarget).closest("tr"),"next")}).on("click",'[data-action="changes"]',this.viewChanges).on("click",'[data-action="preview"]',this.openPreview).on("click",'[data-action="open"]',e=>{const t=e.currentTarget.closest("tr");let a=TYPO3.settings.FormEngine.moduleUrl+"&returnUrl="+encodeURIComponent(document.location.href)+"&id="+TYPO3.settings.Workspaces.id+"&edit["+t.dataset.table+"]["+t.dataset.uid+"]=edit";TYPO3.settings.Workspaces.allView&&(a+="&workspace="+t.dataset.t3ver_wsid),window.location.href=a}).on("click",'[data-action="version"]',e=>{const t=e.currentTarget.closest("tr"),a="pages"===t.dataset.table?t.dataset.t3ver_oid:t.dataset.pid;window.location.href=top.TYPO3.configuration.pageModuleUrl+"&id="+a+"&returnUrl="+encodeURIComponent(window.location.href)}).on("click",'[data-action="remove"]',this.confirmDeleteRecordFromWorkspace).on("click",'[data-action="expand"]',e=>{const t=$(e.currentTarget);let a;a="true"===this.elements.$tableBody.find(t.data("target")).first().attr("aria-expanded")?"apps-pagetree-expand":"apps-pagetree-collapse",t.empty().append(this.getPreRenderedIcon(a))}),$(window.top.document).on("click",".t3js-workspace-recipients-selectall",e=>{e.preventDefault(),$(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!0)}).on("click",".t3js-workspace-recipients-deselectall",e=>{e.preventDefault(),$(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!1)}),this.elements.$searchForm.on("submit",e=>{e.preventDefault(),this.settings.filterTxt=this.elements.$searchTextField.val(),this.getWorkspaceInfos()}),this.elements.$searchTextField.on("keyup",e=>{""!==e.target.value?this.elements.$searchSubmitBtn.removeClass("disabled"):(this.elements.$searchSubmitBtn.addClass("disabled"),this.getWorkspaceInfos())}),this.elements.$searchTextField.get(0).clearable({onClear:()=>{this.elements.$searchSubmitBtn.addClass("disabled"),this.settings.filterTxt="",this.getWorkspaceInfos()}}),this.elements.$toggleAll.on("click",()=>{this.allToggled=!this.allToggled,this.elements.$tableBody.find('input[type="checkbox"]').prop("checked",this.allToggled).trigger("change")}),this.elements.$tableBody.on("change","tr input[type=checkbox]",this.handleCheckboxChange),this.elements.$depthSelector.on("change",e=>{const t=e.target.value;Persistent.set("this.Module.depth",t),this.settings.depth=t,this.getWorkspaceInfos()}),this.elements.$previewLinksButton.on("click",this.generatePreviewLinks),this.elements.$languageSelector.on("change",e=>{const t=$(e.target);this.settings.language=t.val(),this.sendRemoteRequest([this.generateRemoteActionsPayload("saveLanguageSelection",[t.val()]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{this.elements.$languageSelector.prev().html(t.find(":selected").data("icon")),this.renderWorkspaceInfos(e[1].result)})}),this.elements.$chooseStageAction.on("change",this.sendToSpecificStageAction),this.elements.$chooseSelectionAction.on("change",this.runSelectionAction),this.elements.$chooseMassAction.on("change",this.runMassAction),this.elements.$pagination.on("click","a[data-action]",e=>{e.preventDefault();const t=$(e.currentTarget);let a=!1;switch(t.data("action")){case"previous":this.paging.currentPage>1&&(this.paging.currentPage--,a=!0);break;case"next":this.paging.currentPage<this.paging.totalPages&&(this.paging.currentPage++,a=!0);break;case"page":this.paging.currentPage=parseInt(t.data("page"),10),a=!0;break;default:throw'Unknown action "'+t.data("action")+'"'}a&&(this.settings.start=parseInt(this.settings.limit.toString(),10)*(this.paging.currentPage-1),this.getWorkspaceInfos())})}sendToStage(e,t){let a,s,n;if("next"===t)a=e.data("nextStage"),s="sendToNextStageWindow",n="sendToNextStageExecute";else{if("prev"!==t)throw"Invalid direction given.";a=e.data("prevStage"),s="sendToPrevStageWindow",n="sendToPrevStageExecute"}this.sendRemoteRequest(this.generateRemoteActionsPayload(s,[e.data("uid"),e.data("table"),e.data("t3ver_oid")])).done(t=>{const s=this.renderSendToStageWindow(t);s.on("button.clicked",t=>{if("ok"===t.target.name){const i=Utility.convertFormToObject(t.currentTarget.querySelector("form"));i.affects={table:e.data("table"),nextStage:a,t3ver_oid:e.data("t3ver_oid"),uid:e.data("uid"),elements:[]},this.sendRemoteRequest([this.generateRemoteActionsPayload(n,[i]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{s.modal("hide"),this.renderWorkspaceInfos(e[1].result),Backend.refreshPageTree()})}})})}loadWorkspaceComponents(){this.sendRemoteRequest([this.generateRemotePayload("getWorkspaceInfos",this.settings),this.generateRemotePayload("getStageActions",{}),this.generateRemoteMassActionsPayload("getMassStageActions",{}),this.generateRemotePayload("getSystemLanguages",{pageUid:this.elements.$container.data("pageUid")})]).done(e=>{this.elements.$depthSelector.prop("disabled",!1),this.renderWorkspaceInfos(e[0].result);const t=e[1].result.data;let a;for(a=0;a<t.length;++a)this.elements.$chooseStageAction.append($("<option />").val(t[a].uid).text(t[a].title));const s=e[2].result.data;for(a=0;a<s.length;++a)this.elements.$chooseSelectionAction.append($("<option />").val(s[a].action).text(s[a].title)),this.elements.$chooseMassAction.append($("<option />").val(s[a].action).text(s[a].title));const n=e[3].result.data;for(a=0;a<n.length;++a){const e=$("<option />").val(n[a].uid).text(n[a].title).data("icon",n[a].icon);String(n[a].uid)===String(TYPO3.settings.Workspaces.language)&&(e.prop("selected",!0),this.elements.$languageSelector.prev().html(n[a].icon)),this.elements.$languageSelector.append(e)}this.elements.$languageSelector.prop("disabled",!1)})}getWorkspaceInfos(){this.sendRemoteRequest(this.generateRemotePayload("getWorkspaceInfos",this.settings)).done(e=>{this.renderWorkspaceInfos(e[0].result)})}renderWorkspaceInfos(e){this.elements.$tableBody.children().remove(),this.allToggled=!1,this.elements.$chooseStageAction.prop("disabled",!0),this.elements.$chooseSelectionAction.prop("disabled",!0),this.elements.$chooseMassAction.prop("disabled",0===e.data.length),this.buildPagination(e.total);for(let t=0;t<e.data.length;++t){const a=e.data[t],s=$("<div />",{class:"btn-group"});let n;s.append(this.getAction(a.Workspaces_CollectionChildren>0&&""!==a.Workspaces_CollectionCurrent,"expand","apps-pagetree-collapse").attr("title",TYPO3.lang["tooltip.expand"]).attr("data-target",'[data-collection="'+a.Workspaces_CollectionCurrent+'"]').attr("data-toggle","collapse"),$("<button />",{class:"btn btn-default","data-action":"changes","data-toggle":"tooltip",title:TYPO3.lang["tooltip.showChanges"]}).append(this.getPreRenderedIcon("actions-document-info")),this.getAction(a.allowedAction_swap&&""===a.Workspaces_CollectionParent,"swap","actions-version-swap-version").attr("title",TYPO3.lang["tooltip.swap"]),this.getAction(a.allowedAction_view,"preview","actions-version-workspace-preview").attr("title",TYPO3.lang["tooltip.viewElementAction"]),this.getAction(a.allowedAction_edit,"open","actions-open").attr("title",TYPO3.lang["tooltip.editElementAction"]),this.getAction(!0,"version","actions-version-page-open").attr("title",TYPO3.lang["tooltip.openPage"]),this.getAction(a.allowedAction_delete,"remove","actions-version-document-remove").attr("title",TYPO3.lang["tooltip.discardVersion"])),""!==a.integrity.messages&&(n=$(TYPO3.settings.Workspaces.icons[a.integrity.status])).attr("data-toggle","tooltip").attr("data-placement","top").attr("data-html","true").attr("title",a.integrity.messages),this.latestPath!==a.path_Workspace&&(this.latestPath=a.path_Workspace,this.elements.$tableBody.append($("<tr />").append($("<th />"),$("<th />",{colspan:6}).text(this.latestPath))));const i=$("<label />",{class:"btn btn-default btn-checkbox"}).append($("<input />",{type:"checkbox"}),$("<span />",{class:"t3-icon fa"})),o={"data-uid":a.uid,"data-pid":a.livepid,"data-t3ver_oid":a.t3ver_oid,"data-t3ver_wsid":a.t3ver_wsid,"data-table":a.table,"data-next-stage":a.value_nextStage,"data-prev-stage":a.value_prevStage,"data-stage":a.stage};""!==a.Workspaces_CollectionParent&&(o["data-collection"]=a.Workspaces_CollectionParent,o.class="collapse"),this.elements.$tableBody.append($("<tr />",o).append($("<td />").empty().append(i),$("<td />",{class:"t3js-title-workspace",style:a.Workspaces_CollectionLevel>0?"padding-left: "+this.indentationPadding*a.Workspaces_CollectionLevel+"px":""}).html(a.icon_Workspace+'&nbsp;<a href="#" data-action="changes"><span class="item-state-'+a.state_Workspace+'">'+a.label_Workspace+"</span></a>"),$("<td />",{class:"t3js-title-live"}).html(a.icon_Live+"&nbsp;"+a.label_Live),$("<td />").text(a.label_Stage),$("<td />").empty().append(n),$("<td />").html(a.language.icon),$("<td />",{class:"text-right nowrap"}).append(s))),Tooltip.initialize('[data-toggle="tooltip"]',{delay:{show:500,hide:100},trigger:"hover",container:"body"})}}buildPagination(e){if(0===e)return void this.elements.$pagination.contents().remove();if(this.paging.totalItems=e,this.paging.totalPages=Math.ceil(e/parseInt(this.settings.limit.toString(),10)),1===this.paging.totalPages)return void this.elements.$pagination.contents().remove();const t=$("<ul />",{class:"pagination pagination-block"}),a=[],s=$("<li />").append($("<a />",{"data-action":"previous"}).append($("<span />",{class:"t3-icon fa fa-arrow-left"}))),n=$("<li />").append($("<a />",{"data-action":"next"}).append($("<span />",{class:"t3-icon fa fa-arrow-right"})));1===this.paging.currentPage&&s.disablePagingAction(),this.paging.currentPage===this.paging.totalPages&&n.disablePagingAction();for(let e=1;e<=this.paging.totalPages;e++){const t=$("<li />",{class:this.paging.currentPage===e?"active":""});t.append($("<a />",{"data-action":"page","data-page":e}).append($("<span />").text(e))),a.push(t)}t.append(s,a,n),this.elements.$pagination.empty().append(t)}renderSelectionActionWizard(e,t){Wizard.addSlide("mass-action-confirmation",TYPO3.lang["window.selectionAction.title"],"<p>"+(new SecurityUtility).encodeHtml(TYPO3.lang["tooltip."+e+"Selected"])+"</p>",Severity_1.SeverityEnum.warning),Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("executeSelectionAction",{action:e,selection:t})).done(()=>{this.getWorkspaceInfos(),Wizard.dismiss(),Backend.refreshPageTree()})}).done(()=>{Wizard.show(),Wizard.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseSelectionAction.val("")})})}renderMassActionWizard(e){let t,a=!1;switch(e){case"publish":t="publishWorkspace";break;case"swap":t="publishWorkspace",a=!0;break;case"discard":t="flushWorkspace";break;default:throw"Invalid mass action "+e+" called."}const s=new SecurityUtility;Wizard.setForceSelection(!1),Wizard.addSlide("mass-action-confirmation",TYPO3.lang["window.massAction.title"],"<p>"+s.encodeHtml(TYPO3.lang["tooltip."+e+"All"])+"<br><br>"+s.encodeHtml(TYPO3.lang["tooltip.affectWholeWorkspace"])+"</p>",Severity_1.SeverityEnum.warning);const n=e=>{const a=e[0].result;a.processed<a.total?this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,a)).done(n):(this.getWorkspaceInfos(),Wizard.dismiss())};Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,{init:!0,total:0,processed:0,language:this.settings.language,swap:a})).done(n)}).done(()=>{Wizard.show(),Wizard.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseMassAction.val("")})})}getAction(e,t,a){return e?$("<button />",{class:"btn btn-default","data-action":t,"data-toggle":"tooltip"}).append(this.getPreRenderedIcon(a)):$("<span />",{class:"btn btn-default disabled"}).append(this.getPreRenderedIcon("empty-empty"))}getPreRenderedIcon(e){return this.elements.$actionIcons.find('[data-identifier="'+e+'"]').clone()}}return new Backend});
\ No newline at end of file
+define(["require","exports","jquery","TYPO3/CMS/Backend/Enum/Severity","./Workspaces","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Storage/Persistent","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Utility","TYPO3/CMS/Backend/Viewport","TYPO3/CMS/Backend/Wizard","TYPO3/CMS/Core/SecurityUtility","nprogress","twbs/bootstrap-slider","TYPO3/CMS/Backend/Input/Clearable"],function(require,exports,$,Severity_1,Workspaces_1,Modal,Persistent,Tooltip,Utility,Viewport,Wizard,SecurityUtility){"use strict";var Identifiers;!function(e){e.searchForm="#workspace-settings-form",e.searchTextField='#workspace-settings-form input[name="search-text"]',e.searchSubmitBtn='#workspace-settings-form button[type="submit"]',e.depthSelector='#workspace-settings-form [name="depth"]',e.languageSelector='#workspace-settings-form select[name="languages"]',e.chooseStageAction='#workspace-actions-form [name="stage-action"]',e.chooseSelectionAction='#workspace-actions-form [name="selection-action"]',e.chooseMassAction='#workspace-actions-form [name="mass-action"]',e.container="#workspace-panel",e.actionIcons="#workspace-action-icons",e.toggleAll=".t3js-toggle-all",e.previewLinksButton=".t3js-preview-link",e.pagination="#workspace-pagination"}(Identifiers||(Identifiers={}));class Backend extends Workspaces_1.default{constructor(){super(),this.elements={},this.settings={dir:"ASC",id:TYPO3.settings.Workspaces.id,language:TYPO3.settings.Workspaces.language,limit:30,query:"",sort:"label_Live",start:0,filterTxt:""},this.paging={currentPage:1,totalPages:1,totalItems:0},this.allToggled=!1,this.latestPath="",this.markedRecordsForMassAction=[],this.indentationPadding=26,this.handleCheckboxChange=(e=>{const t=$(e.currentTarget),a=t.parents("tr"),s=a.data("table")+":"+a.data("uid")+":"+a.data("t3ver_oid");if(t.prop("checked"))this.markedRecordsForMassAction.push(s),a.addClass("warning");else{const e=this.markedRecordsForMassAction.indexOf(s);e>-1&&this.markedRecordsForMassAction.splice(e,1),a.removeClass("warning")}this.elements.$chooseStageAction.prop("disabled",0===this.markedRecordsForMassAction.length),this.elements.$chooseSelectionAction.prop("disabled",0===this.markedRecordsForMassAction.length),this.elements.$chooseMassAction.prop("disabled",this.markedRecordsForMassAction.length>0)}),this.viewChanges=(e=>{e.preventDefault();const t=$(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemotePayload("getRowDetails",{stage:t.data("stage"),t3ver_oid:t.data("t3ver_oid"),table:t.data("table"),uid:t.data("uid")})).done(e=>{const a=e[0].result.data[0],s=$("<div />"),n=$("<ul />",{class:"nav nav-tabs",role:"tablist"}),i=$("<div />",{class:"tab-content"}),o=[];s.append($("<p />").html(TYPO3.lang.path.replace("{0}",a.path_Live)),$("<p />").html(TYPO3.lang.current_step.replace("{0}",a.label_Stage).replace("{1}",a.stage_position).replace("{2}",a.stage_count))),a.diff.length>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-changes","aria-controls":"workspace-changes",role:"tab","data-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.changeSummary"]))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-changes"}).append($("<div />",{class:"form-section"}).append(Backend.generateDiffView(a.diff))))),a.comments.length>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-comments","aria-controls":"workspace-comments",role:"tab","data-toggle":"tab"}).html(TYPO3.lang["window.recordChanges.tabs.comments"]+"&nbsp;").append($("<span />",{class:"badge"}).text(a.comments.length)))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-comments"}).append($("<div />",{class:"form-section"}).append(Backend.generateCommentView(a.comments))))),a.history.total>0&&(n.append($("<li />",{role:"presentation"}).append($("<a />",{href:"#workspace-history","aria-controls":"workspace-history",role:"tab","data-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.history"]))),i.append($("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-history"}).append($("<div />",{class:"form-section"}).append(Backend.generateHistoryView(a.history.data))))),n.find("li").first().addClass("active"),i.find(".tab-pane").first().addClass("active"),s.append($("<div />").append(n,i)),t.data("stage")!==t.data("prevStage")&&o.push({text:a.label_PrevStage.title,active:!0,btnClass:"btn-default",name:"prevstage",trigger:()=>{Modal.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"prev")}}),o.push({text:a.label_NextStage.title,active:!0,btnClass:"btn-default",name:"nextstage",trigger:()=>{Modal.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"next")}}),o.push({text:TYPO3.lang.close,active:!0,btnClass:"btn-info",name:"cancel",trigger:()=>{Modal.currentModal.trigger("modal-dismiss")}}),Modal.advanced({type:Modal.types.default,title:TYPO3.lang["window.recordInformation"].replace("{0}",$.trim(t.find(".t3js-title-live").text())),content:s,severity:Severity_1.SeverityEnum.info,buttons:o,size:Modal.sizes.medium})})}),this.openPreview=(e=>{const $tr=$(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemoteActionsPayload("viewSingleRecord",[$tr.data("table"),$tr.data("uid")])).done(response=>{eval(response[0].result)})}),this.confirmDeleteRecordFromWorkspace=(e=>{const t=$(e.target).closest("tr"),a=Modal.confirm(TYPO3.lang["window.discard.title"],TYPO3.lang["window.discard.message"],Severity_1.SeverityEnum.warning,[{text:TYPO3.lang.cancel,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{a.modal("hide")}},{text:TYPO3.lang.ok,btnClass:"btn-warning",name:"ok"}]);a.on("button.clicked",e=>{"ok"===e.target.name&&this.sendRemoteRequest([this.generateRemoteActionsPayload("deleteSingleRecord",[t.data("table"),t.data("uid")])]).done(()=>{a.modal("hide"),this.getWorkspaceInfos(),Backend.refreshPageTree()})})}),this.runSelectionAction=(()=>{const e=this.elements.$chooseSelectionAction.val(),t="discard"!==e;if(0===e.length)return;const a=[];for(let e=0;e<this.markedRecordsForMassAction.length;++e){const t=this.markedRecordsForMassAction[e].split(":");a.push({table:t[0],liveId:t[2],versionId:t[1]})}t?this.checkIntegrity({selection:a,type:"selection"}).done(t=>{Wizard.setForceSelection(!1),"warning"===t[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderSelectionActionWizard(e,a)}):(Wizard.setForceSelection(!1),this.renderSelectionActionWizard(e,a))}),this.addIntegrityCheckWarningToWizard=(()=>{Wizard.addSlide("integrity-warning","Warning",TYPO3.lang["integrity.hasIssuesDescription"]+"<br>"+TYPO3.lang["integrity.hasIssuesQuestion"],Severity_1.SeverityEnum.warning)}),this.runMassAction=(()=>{const e=this.elements.$chooseMassAction.val(),t="discard"!==e;0!==e.length&&(t?this.checkIntegrity({language:this.settings.language,type:e}).done(t=>{Wizard.setForceSelection(!1),"warning"===t[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderMassActionWizard(e)}):(Wizard.setForceSelection(!1),this.renderMassActionWizard(e)))}),this.sendToSpecificStageAction=(e=>{const t=[],a=$(e.currentTarget).val();for(let e=0;e<this.markedRecordsForMassAction.length;++e){const a=this.markedRecordsForMassAction[e].split(":");t.push({table:a[0],uid:a[1],t3ver_oid:a[2]})}this.sendRemoteRequest(this.generateRemoteActionsPayload("sendToSpecificStageWindow",[a,t])).done(e=>{const s=this.renderSendToStageWindow(e);s.on("button.clicked",e=>{if("ok"===e.target.name){const n=Utility.convertFormToObject(e.currentTarget.querySelector("form"));n.affects={elements:t,nextStage:a},this.sendRemoteRequest([this.generateRemoteActionsPayload("sendToSpecificStageExecute",[n]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{s.modal("hide"),this.renderWorkspaceInfos(e[1].result),Backend.refreshPageTree()})}}).on("modal-destroyed",()=>{this.elements.$chooseStageAction.val("")})})}),this.generatePreviewLinks=(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("generateWorkspacePreviewLinksForAllLanguages",[this.settings.id])).done(e=>{const t=e[0].result,a=$("<dl />");$.each(t,(e,t)=>{a.append($("<dt />").text(e),$("<dd />").append($("<a />",{href:t,target:"_blank"}).text(t)))}),Modal.show(TYPO3.lang.previewLink,a,Severity_1.SeverityEnum.info,[{text:TYPO3.lang.ok,active:!0,btnClass:"btn-info",name:"ok",trigger:()=>{Modal.currentModal.trigger("modal-dismiss")}}],["modal-inner-scroll"])})}),$(()=>{let e;this.getElements(),this.registerEvents(),Persistent.isset("this.Module.depth")?(e=Persistent.get("this.Module.depth"),this.elements.$depthSelector.val(e),this.settings.depth=e):this.settings.depth=TYPO3.settings.Workspaces.depth,this.loadWorkspaceComponents()})}static refreshPageTree(){Viewport.NavigationContainer&&Viewport.NavigationContainer.PageTree&&Viewport.NavigationContainer.PageTree.refreshTree()}static generateDiffView(e){const t=$("<div />",{class:"diff"});for(let a of e)t.append($("<div />",{class:"diff-item"}).append($("<div />",{class:"diff-item-title"}).text(a.label),$("<div />",{class:"diff-item-result diff-item-result-inline"}).html(a.content)));return t}static generateCommentView(e){const t=$("<div />");for(let a of e){const e=$("<div />",{class:"panel panel-default"});a.user_comment.length>0&&e.append($("<div />",{class:"panel-body"}).html(a.user_comment)),e.append($("<div />",{class:"panel-footer"}).append($("<span />",{class:"label label-success"}).text(a.stage_title),$("<span />",{class:"label label-info"}).text(a.tstamp))),t.append($("<div />",{class:"media"}).append($("<div />",{class:"media-left text-center"}).text(a.user_username).prepend($("<div />").html(a.user_avatar)),$("<div />",{class:"media-body"}).append(e)))}return t}static generateHistoryView(e){const t=$("<div />");for(let a of e){const e=$("<div />",{class:"panel panel-default"});let s;if("object"==typeof a.differences){if(0===a.differences.length)continue;s=$("<div />",{class:"diff"});for(let e=0;e<a.differences.length;++e)s.append($("<div />",{class:"diff-item"}).append($("<div />",{class:"diff-item-title"}).text(a.differences[e].label),$("<div />",{class:"diff-item-result diff-item-result-inline"}).html(a.differences[e].html)));e.append($("<div />").append(s))}else e.append($("<div />",{class:"panel-body"}).text(a.differences));e.append($("<div />",{class:"panel-footer"}).append($("<span />",{class:"label label-info"}).text(a.datetime))),t.append($("<div />",{class:"media"}).append($("<div />",{class:"media-left text-center"}).text(a.user).prepend($("<div />").html(a.user_avatar)),$("<div />",{class:"media-body"}).append(e)))}return t}getElements(){this.elements.$searchForm=$(Identifiers.searchForm),this.elements.$searchTextField=$(Identifiers.searchTextField),this.elements.$searchSubmitBtn=$(Identifiers.searchSubmitBtn),this.elements.$depthSelector=$(Identifiers.depthSelector),this.elements.$languageSelector=$(Identifiers.languageSelector),this.elements.$container=$(Identifiers.container),this.elements.$tableBody=this.elements.$container.find("tbody"),this.elements.$actionIcons=$(Identifiers.actionIcons),this.elements.$toggleAll=$(Identifiers.toggleAll),this.elements.$chooseStageAction=$(Identifiers.chooseStageAction),this.elements.$chooseSelectionAction=$(Identifiers.chooseSelectionAction),this.elements.$chooseMassAction=$(Identifiers.chooseMassAction),this.elements.$previewLinksButton=$(Identifiers.previewLinksButton),this.elements.$pagination=$(Identifiers.pagination)}registerEvents(){$(document).on("click",'[data-action="swap"]',e=>{const t=e.target.closest("tr");this.checkIntegrity({selection:[{liveId:t.dataset.uid,versionId:t.dataset.t3ver_oid,table:t.dataset.table}],type:"selection"}).done(e=>{"warning"===e[0].result.result&&this.addIntegrityCheckWarningToWizard(),Wizard.setForceSelection(!1),Wizard.addSlide("swap-confirm","Swap",TYPO3.lang["window.swap.message"],Severity_1.SeverityEnum.info),Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("swapSingleRecord",[t.dataset.table,t.dataset.t3ver_oid,t.dataset.uid])).done(()=>{Wizard.dismiss(),this.getWorkspaceInfos(),Backend.refreshPageTree()})}).done(()=>{Wizard.show()})})}).on("click",'[data-action="prevstage"]',e=>{this.sendToStage($(e.currentTarget).closest("tr"),"prev")}).on("click",'[data-action="nextstage"]',e=>{this.sendToStage($(e.currentTarget).closest("tr"),"next")}).on("click",'[data-action="changes"]',this.viewChanges).on("click",'[data-action="preview"]',this.openPreview).on("click",'[data-action="open"]',e=>{const t=e.currentTarget.closest("tr");let a=TYPO3.settings.FormEngine.moduleUrl+"&returnUrl="+encodeURIComponent(document.location.href)+"&id="+TYPO3.settings.Workspaces.id+"&edit["+t.dataset.table+"]["+t.dataset.uid+"]=edit";TYPO3.settings.Workspaces.allView&&(a+="&workspace="+t.dataset.t3ver_wsid),window.location.href=a}).on("click",'[data-action="version"]',e=>{const t=e.currentTarget.closest("tr"),a="pages"===t.dataset.table?t.dataset.t3ver_oid:t.dataset.pid;window.location.href=top.TYPO3.configuration.pageModuleUrl+"&id="+a+"&returnUrl="+encodeURIComponent(window.location.href)}).on("click",'[data-action="remove"]',this.confirmDeleteRecordFromWorkspace).on("click",'[data-action="expand"]',e=>{const t=$(e.currentTarget);let a;a="true"===this.elements.$tableBody.find(t.data("target")).first().attr("aria-expanded")?"apps-pagetree-expand":"apps-pagetree-collapse",t.empty().append(this.getPreRenderedIcon(a))}),$(window.top.document).on("click",".t3js-workspace-recipients-selectall",e=>{e.preventDefault(),$(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!0)}).on("click",".t3js-workspace-recipients-deselectall",e=>{e.preventDefault(),$(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!1)}),this.elements.$searchForm.on("submit",e=>{e.preventDefault(),this.settings.filterTxt=this.elements.$searchTextField.val(),this.getWorkspaceInfos()}),this.elements.$searchTextField.on("keyup",e=>{""!==e.target.value?this.elements.$searchSubmitBtn.removeClass("disabled"):(this.elements.$searchSubmitBtn.addClass("disabled"),this.getWorkspaceInfos())}),this.elements.$searchTextField.get(0).clearable({onClear:()=>{this.elements.$searchSubmitBtn.addClass("disabled"),this.settings.filterTxt="",this.getWorkspaceInfos()}}),this.elements.$toggleAll.on("click",()=>{this.allToggled=!this.allToggled,this.elements.$tableBody.find('input[type="checkbox"]').prop("checked",this.allToggled).trigger("change")}),this.elements.$tableBody.on("change","tr input[type=checkbox]",this.handleCheckboxChange),this.elements.$depthSelector.on("change",e=>{const t=e.target.value;Persistent.set("this.Module.depth",t),this.settings.depth=t,this.getWorkspaceInfos()}),this.elements.$previewLinksButton.on("click",this.generatePreviewLinks),this.elements.$languageSelector.on("change",e=>{const t=$(e.target);this.settings.language=t.val(),this.sendRemoteRequest([this.generateRemoteActionsPayload("saveLanguageSelection",[t.val()]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{this.elements.$languageSelector.prev().html(t.find(":selected").data("icon")),this.renderWorkspaceInfos(e[1].result)})}),this.elements.$chooseStageAction.on("change",this.sendToSpecificStageAction),this.elements.$chooseSelectionAction.on("change",this.runSelectionAction),this.elements.$chooseMassAction.on("change",this.runMassAction),this.elements.$pagination.on("click","a[data-action]",e=>{e.preventDefault();const t=$(e.currentTarget);let a=!1;switch(t.data("action")){case"previous":this.paging.currentPage>1&&(this.paging.currentPage--,a=!0);break;case"next":this.paging.currentPage<this.paging.totalPages&&(this.paging.currentPage++,a=!0);break;case"page":this.paging.currentPage=parseInt(t.data("page"),10),a=!0;break;default:throw'Unknown action "'+t.data("action")+'"'}a&&(this.settings.start=parseInt(this.settings.limit.toString(),10)*(this.paging.currentPage-1),this.getWorkspaceInfos())})}sendToStage(e,t){let a,s,n;if("next"===t)a=e.data("nextStage"),s="sendToNextStageWindow",n="sendToNextStageExecute";else{if("prev"!==t)throw"Invalid direction given.";a=e.data("prevStage"),s="sendToPrevStageWindow",n="sendToPrevStageExecute"}this.sendRemoteRequest(this.generateRemoteActionsPayload(s,[e.data("uid"),e.data("table"),e.data("t3ver_oid")])).done(t=>{const s=this.renderSendToStageWindow(t);s.on("button.clicked",t=>{if("ok"===t.target.name){const i=Utility.convertFormToObject(t.currentTarget.querySelector("form"));i.affects={table:e.data("table"),nextStage:a,t3ver_oid:e.data("t3ver_oid"),uid:e.data("uid"),elements:[]},this.sendRemoteRequest([this.generateRemoteActionsPayload(n,[i]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).done(e=>{s.modal("hide"),this.renderWorkspaceInfos(e[1].result),Backend.refreshPageTree()})}})})}loadWorkspaceComponents(){this.sendRemoteRequest([this.generateRemotePayload("getWorkspaceInfos",this.settings),this.generateRemotePayload("getStageActions",{}),this.generateRemoteMassActionsPayload("getMassStageActions",{}),this.generateRemotePayload("getSystemLanguages",{pageUid:this.elements.$container.data("pageUid")})]).done(e=>{this.elements.$depthSelector.prop("disabled",!1),this.renderWorkspaceInfos(e[0].result);const t=e[1].result.data;let a;for(a=0;a<t.length;++a)this.elements.$chooseStageAction.append($("<option />").val(t[a].uid).text(t[a].title));const s=e[2].result.data;for(a=0;a<s.length;++a)this.elements.$chooseSelectionAction.append($("<option />").val(s[a].action).text(s[a].title)),this.elements.$chooseMassAction.append($("<option />").val(s[a].action).text(s[a].title));const n=e[3].result.data;for(a=0;a<n.length;++a){const e=$("<option />").val(n[a].uid).text(n[a].title).data("icon",n[a].icon);String(n[a].uid)===String(TYPO3.settings.Workspaces.language)&&(e.prop("selected",!0),this.elements.$languageSelector.prev().html(n[a].icon)),this.elements.$languageSelector.append(e)}this.elements.$languageSelector.prop("disabled",!1)})}getWorkspaceInfos(){this.sendRemoteRequest(this.generateRemotePayload("getWorkspaceInfos",this.settings)).done(e=>{this.renderWorkspaceInfos(e[0].result)})}renderWorkspaceInfos(e){this.elements.$tableBody.children().remove(),this.allToggled=!1,this.elements.$chooseStageAction.prop("disabled",!0),this.elements.$chooseSelectionAction.prop("disabled",!0),this.elements.$chooseMassAction.prop("disabled",0===e.data.length),this.buildPagination(e.total);for(let t=0;t<e.data.length;++t){const a=e.data[t],s=$("<div />",{class:"btn-group"});let n;s.append(this.getAction(a.Workspaces_CollectionChildren>0&&""!==a.Workspaces_CollectionCurrent,"expand","apps-pagetree-collapse").attr("title",TYPO3.lang["tooltip.expand"]).attr("data-target",'[data-collection="'+a.Workspaces_CollectionCurrent+'"]').attr("data-toggle","collapse"),$("<button />",{class:"btn btn-default","data-action":"changes","data-toggle":"tooltip",title:TYPO3.lang["tooltip.showChanges"]}).append(this.getPreRenderedIcon("actions-document-info")),this.getAction(a.allowedAction_swap&&""===a.Workspaces_CollectionParent,"swap","actions-version-swap-version").attr("title",TYPO3.lang["tooltip.swap"]),this.getAction(a.allowedAction_view,"preview","actions-version-workspace-preview").attr("title",TYPO3.lang["tooltip.viewElementAction"]),this.getAction(a.allowedAction_edit,"open","actions-open").attr("title",TYPO3.lang["tooltip.editElementAction"]),this.getAction(!0,"version","actions-version-page-open").attr("title",TYPO3.lang["tooltip.openPage"]),this.getAction(a.allowedAction_delete,"remove","actions-version-document-remove").attr("title",TYPO3.lang["tooltip.discardVersion"])),""!==a.integrity.messages&&(n=$(TYPO3.settings.Workspaces.icons[a.integrity.status])).attr("data-toggle","tooltip").attr("data-placement","top").attr("data-html","true").attr("title",a.integrity.messages),this.latestPath!==a.path_Workspace&&(this.latestPath=a.path_Workspace,this.elements.$tableBody.append($("<tr />").append($("<th />"),$("<th />",{colspan:6}).text(this.latestPath))));const i=$("<label />",{class:"btn btn-default btn-checkbox"}).append($("<input />",{type:"checkbox"}),$("<span />",{class:"t3-icon fa"})),o={"data-uid":a.uid,"data-pid":a.livepid,"data-t3ver_oid":a.t3ver_oid,"data-t3ver_wsid":a.t3ver_wsid,"data-table":a.table,"data-next-stage":a.value_nextStage,"data-prev-stage":a.value_prevStage,"data-stage":a.stage};""!==a.Workspaces_CollectionParent&&(o["data-collection"]=a.Workspaces_CollectionParent,o.class="collapse"),this.elements.$tableBody.append($("<tr />",o).append($("<td />").empty().append(i),$("<td />",{class:"t3js-title-workspace",style:a.Workspaces_CollectionLevel>0?"padding-left: "+this.indentationPadding*a.Workspaces_CollectionLevel+"px":""}).html(a.icon_Workspace+'&nbsp;<a href="#" data-action="changes"><span class="item-state-'+a.state_Workspace+'">'+a.label_Workspace+"</span></a>"),$("<td />",{class:"t3js-title-live"}).html(a.icon_Live+"&nbsp;"+a.label_Live),$("<td />").text(a.label_Stage),$("<td />").empty().append(n),$("<td />").html(a.language.icon),$("<td />",{class:"text-right nowrap"}).append(s))),Tooltip.initialize('[data-toggle="tooltip"]',{delay:{show:500,hide:100},trigger:"hover",container:"body"})}}buildPagination(e){if(0===e)return void this.elements.$pagination.contents().remove();if(this.paging.totalItems=e,this.paging.totalPages=Math.ceil(e/parseInt(this.settings.limit.toString(),10)),1===this.paging.totalPages)return void this.elements.$pagination.contents().remove();const t=$("<ul />",{class:"pagination pagination-block"}),a=[],s=$("<li />").append($("<a />",{"data-action":"previous"}).append($("<span />",{class:"t3-icon fa fa-arrow-left"}))),n=$("<li />").append($("<a />",{"data-action":"next"}).append($("<span />",{class:"t3-icon fa fa-arrow-right"})));1===this.paging.currentPage&&s.disablePagingAction(),this.paging.currentPage===this.paging.totalPages&&n.disablePagingAction();for(let e=1;e<=this.paging.totalPages;e++){const t=$("<li />",{class:this.paging.currentPage===e?"active":""});t.append($("<a />",{"data-action":"page","data-page":e}).append($("<span />").text(e))),a.push(t)}t.append(s,a,n),this.elements.$pagination.empty().append(t)}renderSelectionActionWizard(e,t){Wizard.addSlide("mass-action-confirmation",TYPO3.lang["window.selectionAction.title"],"<p>"+(new SecurityUtility).encodeHtml(TYPO3.lang["tooltip."+e+"Selected"])+"</p>",Severity_1.SeverityEnum.warning),Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("executeSelectionAction",{action:e,selection:t})).done(()=>{this.getWorkspaceInfos(),Wizard.dismiss(),Backend.refreshPageTree()})}).done(()=>{Wizard.show(),Wizard.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseSelectionAction.val("")})})}renderMassActionWizard(e){let t,a=!1;switch(e){case"publish":t="publishWorkspace";break;case"swap":t="publishWorkspace",a=!0;break;case"discard":t="flushWorkspace";break;default:throw"Invalid mass action "+e+" called."}const s=new SecurityUtility;Wizard.setForceSelection(!1),Wizard.addSlide("mass-action-confirmation",TYPO3.lang["window.massAction.title"],"<p>"+s.encodeHtml(TYPO3.lang["tooltip."+e+"All"])+"<br><br>"+s.encodeHtml(TYPO3.lang["tooltip.affectWholeWorkspace"])+"</p>",Severity_1.SeverityEnum.warning);const n=e=>{const a=e[0].result;a.processed<a.total?this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,a)).done(n):(this.getWorkspaceInfos(),Wizard.dismiss())};Wizard.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,{init:!0,total:0,processed:0,language:this.settings.language,swap:a})).done(n)}).done(()=>{Wizard.show(),Wizard.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseMassAction.val("")})})}getAction(e,t,a){return e?$("<button />",{class:"btn btn-default","data-action":t,"data-toggle":"tooltip"}).append(this.getPreRenderedIcon(a)):$("<span />",{class:"btn btn-default disabled"}).append(this.getPreRenderedIcon("empty-empty"))}getPreRenderedIcon(e){return this.elements.$actionIcons.find('[data-identifier="'+e+'"]').clone()}}return new Backend});
\ No newline at end of file
index 6675acc..d2dcd67 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Backend/Modal"],function(e,t,a,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.tid=0}renderSendToStageWindow(e){const t=e[0].result,s=n("<form />");if(void 0!==t.sendMailTo&&t.sendMailTo.length>0){s.append(n("<label />",{class:"control-label"}).text(TYPO3.lang["window.sendToNextStageWindow.itemsWillBeSentTo"])),s.append(n("<div />",{class:"form-group"}).append(n('<a href="#" class="btn btn-default btn-xs t3js-workspace-recipients-selectall" />').text(TYPO3.lang["window.sendToNextStageWindow.selectAll"]),"&nbsp;",n('<a href="#" class="btn btn-default btn-xs t3js-workspace-recipients-deselectall" />').text(TYPO3.lang["window.sendToNextStageWindow.deselectAll"])));for(let e=0;e<t.sendMailTo.length;++e){const a=t.sendMailTo[e];s.append(n("<div />",{class:"checkbox"}).append(n("<label />").text(a.label).prepend(n("<input />",{type:"checkbox",name:"recipients",class:"t3js-workspace-recipient",id:a.name,value:a.value}).prop("checked",a.checked).prop("disabled",a.disabled))))}}void 0!==t.additional&&s.append(n("<div />",{class:"form-group"}).append(n("<label />",{class:"control-label",for:"additional"}).text(TYPO3.lang["window.sendToNextStageWindow.additionalRecipients"]),n("<textarea />",{class:"form-control",name:"additional",id:"additional"}).text(t.additional.value),n("<span />",{class:"help-block"}).text(TYPO3.lang["window.sendToNextStageWindow.additionalRecipients.hint"]))),s.append(n("<div />",{class:"form-group"}).append(n("<label />",{class:"control-label",for:"comments"}).text(TYPO3.lang["window.sendToNextStageWindow.comments"]),n("<textarea />",{class:"form-control",name:"comments",id:"comments"}).text(t.comments.value)));const l=o.show(TYPO3.lang.actionSendToStage,s,a.SeverityEnum.info,[{text:TYPO3.lang.cancel,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{l.modal("hide")}},{text:TYPO3.lang.ok,btnClass:"btn-info",name:"ok"}]);return l}checkIntegrity(e){return this.sendRemoteRequest(this.generateRemotePayload("checkIntegrity",e))}sendRemoteRequest(e){return n.ajax({url:TYPO3.settings.ajaxUrls.workspace_dispatch,method:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify(e)})}generateRemotePayload(e,t={}){return this.generateRemotePayloadBody("RemoteServer",e,t)}generateRemoteMassActionsPayload(e,t={}){return this.generateRemotePayloadBody("MassActions",e,t)}generateRemoteActionsPayload(e,t={}){return this.generateRemotePayloadBody("Actions",e,t)}generateRemotePayloadBody(e,t,a){return a instanceof Array?a.push(TYPO3.settings.Workspaces.token):a=[a,TYPO3.settings.Workspaces.token],{action:e,data:a,method:t,type:"rpc",tid:this.tid++}}}});
\ No newline at end of file
+define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Backend/Modal"],function(e,t,a,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.tid=0}renderSendToStageWindow(e){const t=e[0].result,s=n("<form />");if(void 0!==t.sendMailTo&&t.sendMailTo.length>0){s.append(n("<label />",{class:"control-label"}).text(TYPO3.lang["window.sendToNextStageWindow.itemsWillBeSentTo"])),s.append(n("<div />",{class:"form-group"}).append(n('<a href="#" class="btn btn-default btn-xs t3js-workspace-recipients-selectall" />').text(TYPO3.lang["window.sendToNextStageWindow.selectAll"]),"&nbsp;",n('<a href="#" class="btn btn-default btn-xs t3js-workspace-recipients-deselectall" />').text(TYPO3.lang["window.sendToNextStageWindow.deselectAll"])));for(const e of t.sendMailTo)s.append(n("<div />",{class:"checkbox"}).append(n("<label />").text(e.label).prepend(n("<input />",{type:"checkbox",name:"recipients",class:"t3js-workspace-recipient",id:e.name,value:e.value}).prop("checked",e.checked).prop("disabled",e.disabled))))}void 0!==t.additional&&s.append(n("<div />",{class:"form-group"}).append(n("<label />",{class:"control-label",for:"additional"}).text(TYPO3.lang["window.sendToNextStageWindow.additionalRecipients"]),n("<textarea />",{class:"form-control",name:"additional",id:"additional"}).text(t.additional.value),n("<span />",{class:"help-block"}).text(TYPO3.lang["window.sendToNextStageWindow.additionalRecipients.hint"]))),s.append(n("<div />",{class:"form-group"}).append(n("<label />",{class:"control-label",for:"comments"}).text(TYPO3.lang["window.sendToNextStageWindow.comments"]),n("<textarea />",{class:"form-control",name:"comments",id:"comments"}).text(t.comments.value)));const d=o.show(TYPO3.lang.actionSendToStage,s,a.SeverityEnum.info,[{text:TYPO3.lang.cancel,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{d.modal("hide")}},{text:TYPO3.lang.ok,btnClass:"btn-info",name:"ok"}]);return d}checkIntegrity(e){return this.sendRemoteRequest(this.generateRemotePayload("checkIntegrity",e))}sendRemoteRequest(e){return n.ajax({url:TYPO3.settings.ajaxUrls.workspace_dispatch,method:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify(e)})}generateRemotePayload(e,t={}){return this.generateRemotePayloadBody("RemoteServer",e,t)}generateRemoteMassActionsPayload(e,t={}){return this.generateRemotePayloadBody("MassActions",e,t)}generateRemoteActionsPayload(e,t={}){return this.generateRemotePayloadBody("Actions",e,t)}generateRemotePayloadBody(e,t,a){return a instanceof Array?a.push(TYPO3.settings.Workspaces.token):a=[a,TYPO3.settings.Workspaces.token],{action:e,data:a,method:t,type:"rpc",tid:this.tid++}}}});
\ No newline at end of file