[TASK] Use AJAX API in context menus 91/62791/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 30 Dec 2019 16:58:43 +0000 (17:58 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Fri, 17 Jan 2020 11:25:59 +0000 (12:25 +0100)
The AJAX API is now used in context menus. This patch also incorporates
a neat ES6 feature to use variables in object keys in a sane way.

Resolves: #90039
Releases: master
Change-Id: Ib0edf1b530a1c059f9ff7937bd16358a07a656ea
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62791
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenu.ts
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts
Build/Sources/TypeScript/filelist/Resources/Public/TypeScript/ContextMenuActions.ts
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js
typo3/sysext/filelist/Resources/Public/JavaScript/ContextMenuActions.js

index 7c4b23e..93082a6 100644 (file)
@@ -12,6 +12,8 @@
  */
 
 import * as $ from 'jquery';
+import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
+import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
 import ContextMenuActions = require('./ContextMenuActions');
 
 interface MousePosition {
@@ -156,12 +158,10 @@ class ContextMenu {
    */
   private fetch(parameters: string): void {
     let url = TYPO3.settings.ajaxUrls.contextmenu;
-    if (parameters) {
-      url += (!url.includes('?') ? '?' : '&') + parameters;
-    }
-    $.ajax(url).done((response: MenuItems): void => {
+    (new AjaxRequest(url)).withQueryArguments(parameters).get().then(async (response: AjaxResponse): Promise<any> => {
+      const data: MenuItems = await response.resolve();
       if (typeof response !== 'undefined' && Object.keys(response).length > 0) {
-        this.populateData(response, 0);
+        this.populateData(data, 0);
       }
     });
   }
index e160051..71b76f9 100644 (file)
  * The TYPO3 project - inspiring people to share!
  */
 
+import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
 import {SeverityEnum} from './Enum/Severity';
 import * as $ from 'jquery';
 import AjaxDataHandler = require('./AjaxDataHandler');
+import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
 import InfoWindow = require('./InfoWindow');
 import Modal = require('./Modal');
 import ModuleMenu = require('./ModuleMenu');
-import Viewport = require('./Viewport');
 import Notification = require('TYPO3/CMS/Backend/Notification');
+import Viewport = require('./Viewport');
 
 /**
  * @exports TYPO3/CMS/Backend/ContextMenuActions
@@ -252,7 +254,7 @@ class ContextMenuActions {
       + '&CB[el][' + table + '%7C' + uid + ']=1'
       + '&CB[setCopyMode]=1';
 
-    $.ajax(url).always((): void => {
+    (new AjaxRequest(url)).get().finally((): void => {
       ContextMenuActions.triggerRefresh(Viewport.ContentContainer.get().location.href);
     });
   }
@@ -265,7 +267,7 @@ class ContextMenuActions {
     const url = TYPO3.settings.ajaxUrls.contextmenu_clipboard
       + '&CB[el][' + table + '%7C' + uid + ']=0';
 
-    $.ajax(url).always((): void => {
+    (new AjaxRequest(url)).get().finally((): void => {
       ContextMenuActions.triggerRefresh(Viewport.ContentContainer.get().location.href);
     });
   }
@@ -279,7 +281,7 @@ class ContextMenuActions {
       + '&CB[el][' + table + '%7C' + uid + ']=1'
       + '&CB[setCopyMode]=0';
 
-    $.ajax(url).always((): void => {
+    (new AjaxRequest(url)).get().finally((): void => {
       ContextMenuActions.triggerRefresh(Viewport.ContentContainer.get().location.href);
     });
   }
@@ -300,23 +302,21 @@ class ContextMenuActions {
    * @param {number} uid uid of the page
    */
   public static clearCache(table: string, uid: number): void {
-    $.ajax({
-      url: TYPO3.settings.ajaxUrls.web_list_clearpagecache + '&id=' + uid,
-      cache: false,
-      dataType: 'json',
-      success: (data: any): void => {
+    (new AjaxRequest(TYPO3.settings.ajaxUrls.web_list_clearpagecache)).withQueryArguments({id: uid}).get({cache: 'no-cache'}).then(
+      async (response: AjaxResponse): Promise<any> => {
+        const data = await response.resolve();
         if (data.success === true) {
           Notification.success(data.title, data.message, 1);
         } else {
           Notification.error(data.title, data.message, 1);
         }
       },
-      error: (): void => {
+      (): void => {
         Notification.error(
           'Clearing page caches went wrong on the server side.',
         );
-      },
-    });
+      }
+    );
   }
 
   /**
index 310a73e..b048b0d 100644 (file)
@@ -13,6 +13,7 @@
 
 import {SeverityEnum} from 'TYPO3/CMS/Backend/Enum/Severity';
 import * as $ from 'jquery';
+import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
 import Modal = require('TYPO3/CMS/Backend/Modal');
 import Md5 = require('TYPO3/CMS/Backend/Hashing/Md5');
 
@@ -110,36 +111,62 @@ class ContextMenuActions {
 
   public static copyFile(table: string, uid: string): void {
     const shortMD5 = Md5.hash(uid).substring(0, 10);
-    let url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
-    url += '&CB[el][_FILE%7C' + shortMD5 + ']=' + encodeURIComponent(uid) + '&CB[setCopyMode]=1';
-    $.ajax(url).always((): void => {
+    const url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
+    const queryArguments = {
+      CB: {
+        el: {
+          ['_FILE%7C' + shortMD5]: uid
+        },
+        setCopyMode: '1'
+      }
+    };
+    (new AjaxRequest(url)).withQueryArguments(queryArguments).get().finally((): void => {
       top.TYPO3.Backend.ContentContainer.refresh(true);
     });
   }
 
   public static copyReleaseFile(table: string, uid: string): void {
     const shortMD5 = Md5.hash(uid).substring(0, 10);
-    let url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
-    url += '&CB[el][_FILE%7C' + shortMD5 + ']=0&CB[setCopyMode]=1';
-    $.ajax(url).always((): void => {
+    const url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
+    const queryArguments = {
+      CB: {
+        el: {
+          ['_FILE%7C' + shortMD5]: '0'
+        },
+        setCopyMode: '1'
+      }
+    };
+    (new AjaxRequest(url)).withQueryArguments(queryArguments).get().finally((): void => {
       top.TYPO3.Backend.ContentContainer.refresh(true);
     });
   }
 
   public static cutFile(table: string, uid: string): void {
     const shortMD5 = Md5.hash(uid).substring(0, 10);
-    let url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
-    url += '&CB[el][_FILE%7C' + shortMD5 + ']=' + encodeURIComponent(uid);
-    $.ajax(url).always((): void => {
+    const url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
+    const queryArguments = {
+      CB: {
+        el: {
+          ['_FILE%7C' + shortMD5]: uid
+        }
+      }
+    };
+    (new AjaxRequest(url)).withQueryArguments(queryArguments).get().finally((): void => {
       top.TYPO3.Backend.ContentContainer.refresh(true);
     });
   }
 
   public static cutReleaseFile(table: string, uid: string): void {
     const shortMD5 = Md5.hash(uid).substring(0, 10);
-    let url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
-    url += '&CB[el][_FILE%7C' + shortMD5 + ']=0';
-    $.ajax(url).always((): void => {
+    const url = TYPO3.settings.ajaxUrls.contextmenu_clipboard;
+    const queryArguments = {
+      CB: {
+        el: {
+          ['_FILE%7C' + shortMD5]: '0'
+        }
+      }
+    };
+    (new AjaxRequest(url)).withQueryArguments(queryArguments).get().finally((): void => {
       top.TYPO3.Backend.ContentContainer.refresh(true);
     });
   }
index b02a04d..7b608fa 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(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
+var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function a(t){try{l(i.next(t))}catch(t){s(t)}}function c(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}l((i=i.apply(t,e||[])).next())}))};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","./ContextMenuActions"],(function(t,e,n,i,o){"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 n="";for(const t of Object.entries(e)){const[e,i]=t;n+=" "+e+'="'+i+'"'}return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+n+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"}static within(t,e,n){const i=t.offset();return n>=i.top&&n<i.top+t.height()&&e>=i.left&&e<i.left+t.width()}static initializeContextMenuContainer(){if(0===n("#contentMenu0").length){const t='<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>';n("body").append(t)}}initializeEvents(){n(document).on("click contextmenu",".t3js-contextmenutrigger",t=>{const e=n(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")))}),n(document).on("mousemove",this.storeMousePositionEvent)}show(t,e,n,i,o){this.record={table:t,uid:e};let s="";void 0!==t&&(s+="table="+encodeURIComponent(t)),void 0!==e&&(s+=(s.length>0?"&":"")+"uid="+e),void 0!==n&&(s+=(s.length>0?"&":"")+"context="+n),void 0!==i&&(s+=(s.length>0?"&":"")+"enDisItems="+i),void 0!==o&&(s+=(s.length>0?"&":"")+"addParams="+o),this.fetch(s)}fetch(t){let e=TYPO3.settings.ajaxUrls.contextmenu;new i(e).withQueryArguments(t).get().then(t=>__awaiter(this,void 0,void 0,(function*(){const e=yield t.resolve();void 0!==t&&Object.keys(t).length>0&&this.populateData(e,0)})))}populateData(e,i){s.initializeContextMenuContainer();const a=n("#contentMenu"+i);if(a.length&&(0===i||n("#contentMenu"+(i-1)).is(":visible"))){const s=this.drawMenu(e,i);a.html('<div class="list-group">'+s+"</div>"),n("a.list-group-item",a).click(e=>{e.preventDefault();const s=n(e.currentTarget);if(s.hasClass("list-group-item-submenu"))return void this.openSubmenu(i,s);const a=s.data("callback-action"),c=s.data("callback-module");s.data("callback-module")?t([c],t=>{t[a].bind(s)(this.record.table,this.record.uid)}):o&&"function"==typeof o[a]?o[a].bind(s)(this.record.table,this.record.uid):console.log("action: "+a+" not found"),this.hideAll()}),a.css(this.getPosition(a)).show()}}openSubmenu(t,e){const i=n("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(i),i.css(this.getPosition(i)).show()}getPosition(t){let e=this.mousePos.X,i=this.mousePos.Y;const o=n(window).width()-20,s=n(window).height(),a=t.width(),c=t.height(),l=this.mousePos.X-n(document).scrollLeft(),u=this.mousePos.Y-n(document).scrollTop();return s-c<u&&(u>c?i-=c-10:i+=s-c-u),o-a<l&&(l>a?e-=a-10:o-a-l<n(document).scrollLeft()?e=n(document).scrollLeft():e+=o-a-l),{left:e+"px",top:i+"px"}}drawMenu(t,e){let n="";for(let i of Object.values(t))if("item"===i.type)n+=s.drawActionItem(i);else if("divider"===i.type)n+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===i.type||i.childItems){n+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+i.icon+"</span> "+i.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',n+='<div class="context-menu contentMenu'+(e+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(i.childItems,1)+"</div></div>"}return n}mouseOutFromMenu(t){const e=n(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||n(t).hide()},500)}hideAll(){this.hide("#contentMenu0"),this.hide("#contentMenu1")}}return new s}));
\ No newline at end of file
index 8f4cc2c..1a03c48 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./Enum/Severity","jquery","./AjaxDataHandler","./InfoWindow","./Modal","./ModuleMenu","./Viewport","TYPO3/CMS/Backend/Notification"],(function(e,t,n,a,r,o,i,s,l,c){"use strict";class d{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),l.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+d.getReturnUrl())}static viewRecord(){const e=a(this).data("preview-url");if(e){window.open(e,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){o.showItem(e,t)}static mountAsTreeRoot(e,t){"pages"===e&&l.NavigationContainer.PageTree.setTemporaryMountPoint(t)}static newPageWizard(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+d.getReturnUrl())}static newContentWizard(){const e=a(this);let t=e.data("new-wizard-url");t&&(t+="&returnUrl="+d.getReturnUrl(),i.advanced({title:e.data("title"),type:i.types.ajax,size:i.sizes.medium,content:t,severity:n.SeverityEnum.notice}))}static newRecord(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+d.getReturnUrl())}static openHistoryPopUp(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+d.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a(this).data("page-uid");s.App.showModule("web_list","id="+n)}static pagesSort(){const e=a(this).data("pages-sort-url");e&&l.ContentContainer.setUrl(e)}static pagesNewMultiple(){const e=a(this).data("pages-new-multiple-url");e&&l.ContentContainer.setUrl(e)}static disableRecord(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=1&redirect="+d.getReturnUrl()).done(()=>{l.NavigationContainer.PageTree.refreshTree()})}static enableRecord(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=0&redirect="+d.getReturnUrl()).done(()=>{l.NavigationContainer.PageTree.refreshTree()})}static showInMenus(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=0&redirect="+d.getReturnUrl()).done(()=>{l.NavigationContainer.PageTree.refreshTree()})}static hideInMenus(e,t){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=1&redirect="+d.getReturnUrl()).done(()=>{l.NavigationContainer.PageTree.refreshTree()})}static deleteRecord(e,t){const o=a(this);i.confirm(o.data("title"),o.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){r.process("cmd["+e+"]["+t+"][delete]=1").done(()=>{if("pages"===e&&l.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){let e=l.NavigationContainer.PageTree.getFirstNode();l.NavigationContainer.PageTree.selectNode(e)}l.NavigationContainer.PageTree.refreshTree()}})}i.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";a.ajax(n).always(()=>{d.triggerRefresh(l.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";a.ajax(n).always(()=>{d.triggerRefresh(l.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";a.ajax(n).always(()=>{d.triggerRefresh(l.ContentContainer.get().location.href)})}static triggerRefresh(e){e.includes("record%2Fedit")||l.ContentContainer.refresh()}static clearCache(e,t){a.ajax({url:TYPO3.settings.ajaxUrls.web_list_clearpagecache+"&id="+t,cache:!1,dataType:"json",success:e=>{!0===e.success?c.success(e.title,e.message,1):c.error(e.title,e.message,1)},error:()=>{c.error("Clearing page caches went wrong on the server side.")}})}static pasteAfter(e,t){d.pasteInto.bind(a(this))(e,-t)}static pasteInto(e,t){const r=a(this),o=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+d.getReturnUrl();l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&l.NavigationContainer.PageTree&&l.NavigationContainer.PageTree.refreshTree()})};r.data("title")?i.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&o(),i.dismiss()}):o()}}return d}));
\ No newline at end of file
+var __awaiter=this&&this.__awaiter||function(e,t,n,a){return new(n||(n=Promise))((function(r,i){function o(e){try{l(a.next(e))}catch(e){i(e)}}function s(e){try{l(a.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((a=a.apply(e,t||[])).next())}))};define(["require","exports","./Enum/Severity","jquery","./AjaxDataHandler","TYPO3/CMS/Core/Ajax/AjaxRequest","./InfoWindow","./Modal","./ModuleMenu","TYPO3/CMS/Backend/Notification","./Viewport"],(function(e,t,n,a,r,i,o,s,l,c,d){"use strict";class g{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),d.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+g.getReturnUrl())}static viewRecord(){const e=a(this).data("preview-url");if(e){window.open(e,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){o.showItem(e,t)}static mountAsTreeRoot(e,t){"pages"===e&&d.NavigationContainer.PageTree.setTemporaryMountPoint(t)}static newPageWizard(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+g.getReturnUrl())}static newContentWizard(){const e=a(this);let t=e.data("new-wizard-url");t&&(t+="&returnUrl="+g.getReturnUrl(),s.advanced({title:e.data("title"),type:s.types.ajax,size:s.sizes.medium,content:t,severity:n.SeverityEnum.notice}))}static newRecord(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+g.getReturnUrl())}static openHistoryPopUp(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+g.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a(this).data("page-uid");l.App.showModule("web_list","id="+n)}static pagesSort(){const e=a(this).data("pages-sort-url");e&&d.ContentContainer.setUrl(e)}static pagesNewMultiple(){const e=a(this).data("pages-new-multiple-url");e&&d.ContentContainer.setUrl(e)}static disableRecord(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=1&redirect="+g.getReturnUrl()).done(()=>{d.NavigationContainer.PageTree.refreshTree()})}static enableRecord(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=0&redirect="+g.getReturnUrl()).done(()=>{d.NavigationContainer.PageTree.refreshTree()})}static showInMenus(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=0&redirect="+g.getReturnUrl()).done(()=>{d.NavigationContainer.PageTree.refreshTree()})}static hideInMenus(e,t){d.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=1&redirect="+g.getReturnUrl()).done(()=>{d.NavigationContainer.PageTree.refreshTree()})}static deleteRecord(e,t){const i=a(this);s.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){r.process("cmd["+e+"]["+t+"][delete]=1").done(()=>{if("pages"===e&&d.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){let e=d.NavigationContainer.PageTree.getFirstNode();d.NavigationContainer.PageTree.selectNode(e)}d.NavigationContainer.PageTree.refreshTree()}})}s.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";new i(n).get().finally(()=>{g.triggerRefresh(d.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";new i(n).get().finally(()=>{g.triggerRefresh(d.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";new i(n).get().finally(()=>{g.triggerRefresh(d.ContentContainer.get().location.href)})}static triggerRefresh(e){e.includes("record%2Fedit")||d.ContentContainer.refresh()}static clearCache(e,t){new i(TYPO3.settings.ajaxUrls.web_list_clearpagecache).withQueryArguments({id:t}).get({cache:"no-cache"}).then(e=>__awaiter(this,void 0,void 0,(function*(){const t=yield e.resolve();!0===t.success?c.success(t.title,t.message,1):c.error(t.title,t.message,1)})),()=>{c.error("Clearing page caches went wrong on the server side.")})}static pasteAfter(e,t){g.pasteInto.bind(a(this))(e,-t)}static pasteInto(e,t){const r=a(this),i=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+g.getReturnUrl();d.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&d.NavigationContainer.PageTree&&d.NavigationContainer.PageTree.refreshTree()})};r.data("title")?s.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&i(),s.dismiss()}):i()}}return g}));
\ No newline at end of file
index 05d522a..b7349ac 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","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r){"use strict";class s{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+s.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+s.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+s.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+s.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+s.getReturnUrl())}static deleteFile(t,e){const r=o(this),i=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+s.getReturnUrl())};r.data("title")?a.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.currentTarget.name&&i(),a.dismiss()}):i()}static copyFile(t,e){const n=r.hash(e).substring(0,10);let a=TYPO3.settings.ajaxUrls.contextmenu_clipboard;a+="&CB[el][_FILE%7C"+n+"]="+encodeURIComponent(e)+"&CB[setCopyMode]=1",o.ajax(a).always(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=r.hash(e).substring(0,10);let a=TYPO3.settings.ajaxUrls.contextmenu_clipboard;a+="&CB[el][_FILE%7C"+n+"]=0&CB[setCopyMode]=1",o.ajax(a).always(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=r.hash(e).substring(0,10);let a=TYPO3.settings.ajaxUrls.contextmenu_clipboard;a+="&CB[el][_FILE%7C"+n+"]="+encodeURIComponent(e),o.ajax(a).always(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=r.hash(e).substring(0,10);let a=TYPO3.settings.ajaxUrls.contextmenu_clipboard;a+="&CB[el][_FILE%7C"+n+"]=0",o.ajax(a).always(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const r=o(this),i=r.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+s.getReturnUrl())};i?a.confirm(i,r.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),a.dismiss()}):l()}static dropInto(t,e,n){const a=o(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+s.getReturnUrl())}static dropMoveInto(t,e){s.dropInto.bind(o(this))(t,e,"move")}static dropCopyInto(t,e){s.dropInto.bind(o(this))(t,e,"copy")}}return s}));
\ No newline at end of file
+define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r,s){"use strict";class i{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+i.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static deleteFile(t,e){const a=o(this),s=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+i.getReturnUrl())};a.data("title")?r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.currentTarget.name&&s(),r.dismiss()}):s()}static copyFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const a=o(this),s=a.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+i.getReturnUrl())};s?r.confirm(s,a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),r.dismiss()}):l()}static dropInto(t,e,n){const a=o(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+i.getReturnUrl())}static dropMoveInto(t,e){i.dropInto.bind(o(this))(t,e,"move")}static dropCopyInto(t,e){i.dropInto.bind(o(this))(t,e,"copy")}}return i}));
\ No newline at end of file