From cb5146db6566cc7e22aaf28f3faba6dd8be533f4 Mon Sep 17 00:00:00 2001
From: Andreas Fernandez <a.fernandez@scripting-base.de>
Date: Thu, 27 Feb 2020 17:34:49 +0100
Subject: [PATCH] [BUGFIX] Import dependencies of dashboard properly

The dependencies of the dashboard are now properly imported to fix
loading issues.

Resolves: #90546
Releases: master
Change-Id: I9f86e9e9dc87082269cda777b373bc02df414153
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63472
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
---
 .../dashboard/Resources/Public/TypeScript/ChartInitializer.ts   | 2 +-
 .../TypeScript/dashboard/Resources/Public/TypeScript/Grid.ts    | 2 +-
 Build/types/TYPO3/index.d.ts                                    | 2 ++
 .../dashboard/Resources/Public/JavaScript/ChartInitializer.js   | 2 +-
 typo3/sysext/dashboard/Resources/Public/JavaScript/Grid.js      | 2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/ChartInitializer.ts b/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/ChartInitializer.ts
index e217fe0b7f45..fe071d31ebaf 100644
--- a/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/ChartInitializer.ts
+++ b/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/ChartInitializer.ts
@@ -12,7 +12,7 @@
 */
 
 import * as $ from 'jquery';
-let Chart: any = require('TYPO3/CMS/Dashboard/Contrib/chartjs');
+import * as Chart from 'TYPO3/CMS/Dashboard/Contrib/chartjs';
 
 class ChartInitializer {
 
diff --git a/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/Grid.ts b/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/Grid.ts
index 5e982ae391c7..b3cc9865903c 100644
--- a/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/Grid.ts
+++ b/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/Grid.ts
@@ -12,7 +12,7 @@
 */
 
 import * as $ from 'jquery';
-let Muuri: any = require('muuri');
+import * as Muuri from 'muuri';
 import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
 import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
 
diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts
index 56257778e383..5554654e17d0 100644
--- a/Build/types/TYPO3/index.d.ts
+++ b/Build/types/TYPO3/index.d.ts
@@ -145,9 +145,11 @@ declare module 'TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min' {
 declare module 'TYPO3/CMS/Recordlist/LinkBrowser';
 declare module 'TYPO3/CMS/Backend/LegacyTree';
 
+declare module 'muuri';
 declare module 'cm/lib/codemirror';
 declare module 'moment';
 declare module 'Sortable';
+declare module 'TYPO3/CMS/Dashboard/Contrib/chartjs';
 
 interface JQueryTypedEvent<T extends Event> extends JQueryEventObject {
   originalEvent: T;
diff --git a/typo3/sysext/dashboard/Resources/Public/JavaScript/ChartInitializer.js b/typo3/sysext/dashboard/Resources/Public/JavaScript/ChartInitializer.js
index 28aee839caee..a10005664ecd 100644
--- a/typo3/sysext/dashboard/Resources/Public/JavaScript/ChartInitializer.js
+++ b/typo3/sysext/dashboard/Resources/Public/JavaScript/ChartInitializer.js
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery"],(function(e,t,n){"use strict";let r=e("TYPO3/CMS/Dashboard/Contrib/chartjs");return new class{constructor(){this.selector=".dashboard-item--chart",n(()=>{this.initialize()})}initialize(){n(document).on("widgetContentRendered",this.selector,(e,t)=>{e.preventDefault();const i=n(e.currentTarget);if("undefined"===t.graphConfig)return;let s,o=i.find("canvas:first");o.length>0&&(s=o[0].getContext("2d")),"undefined"!==s&&new r(s,t.graphConfig)})}}}));
\ No newline at end of file
+define(["require","exports","jquery","TYPO3/CMS/Dashboard/Contrib/chartjs"],(function(e,t,n,r){"use strict";return new class{constructor(){this.selector=".dashboard-item--chart",n(()=>{this.initialize()})}initialize(){n(document).on("widgetContentRendered",this.selector,(e,t)=>{e.preventDefault();const i=n(e.currentTarget);if("undefined"===t.graphConfig)return;let s,o=i.find("canvas:first");o.length>0&&(s=o[0].getContext("2d")),"undefined"!==s&&new r(s,t.graphConfig)})}}}));
\ No newline at end of file
diff --git a/typo3/sysext/dashboard/Resources/Public/JavaScript/Grid.js b/typo3/sysext/dashboard/Resources/Public/JavaScript/Grid.js
index a0b0b814c2f1..3c2df370506d 100644
--- a/typo3/sysext/dashboard/Resources/Public/JavaScript/Grid.js
+++ b/typo3/sysext/dashboard/Resources/Public/JavaScript/Grid.js
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,t,a,s){"use strict";let r=e("muuri");return new class{constructor(){this.selector=".dashboard-grid",a(()=>{this.initialize()})}initialize(){const e={dragEnabled:!0,dragSortHeuristics:{sortInterval:50,minDragDistance:10,minBounceBackAngle:1},layoutDuration:400,layoutEasing:"ease",dragPlaceholder:{enabled:!0,duration:400,createElement:e=>e.getElement().cloneNode(!0)},dragSortPredicate:{action:"move",threshold:30},dragStartPredicate:{handle:".js-dashboard-move-widget"},dragReleaseDuration:400,dragReleaseEasing:"ease",layout:{fillGaps:!1,rounding:!1}};if(a(this.selector).length){const t=new r(this.selector,e);t.on("dragStart",()=>{a(".dashboard-item").removeClass("dashboard-item--enableSelect")}),t.on("dragReleaseEnd",()=>{a(".dashboard-item").addClass("dashboard-item--enableSelect"),this.saveItems(t)}),a(".dashboard-item").on("widgetContentRendered",()=>{t.refreshItems().layout()})}}saveItems(e){let t=e.getItems().map((function(e){return[e.getElement().getAttribute("data-widget-key"),e.getElement().getAttribute("data-widget-hash")]}));new s(TYPO3.settings.ajaxUrls["ext-dashboard-save-widget-positions"]).post({widgets:t}).then(async e=>{await e.resolve()})}}}));
\ No newline at end of file
+define(["require","exports","jquery","muuri","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,t,a,s,r){"use strict";return new class{constructor(){this.selector=".dashboard-grid",a(()=>{this.initialize()})}initialize(){const e={dragEnabled:!0,dragSortHeuristics:{sortInterval:50,minDragDistance:10,minBounceBackAngle:1},layoutDuration:400,layoutEasing:"ease",dragPlaceholder:{enabled:!0,duration:400,createElement:e=>e.getElement().cloneNode(!0)},dragSortPredicate:{action:"move",threshold:30},dragStartPredicate:{handle:".js-dashboard-move-widget"},dragReleaseDuration:400,dragReleaseEasing:"ease",layout:{fillGaps:!1,rounding:!1}};if(a(this.selector).length){const t=new s(this.selector,e);t.on("dragStart",()=>{a(".dashboard-item").removeClass("dashboard-item--enableSelect")}),t.on("dragReleaseEnd",()=>{a(".dashboard-item").addClass("dashboard-item--enableSelect"),this.saveItems(t)}),a(".dashboard-item").on("widgetContentRendered",()=>{t.refreshItems().layout()})}}saveItems(e){let t=e.getItems().map((function(e){return[e.getElement().getAttribute("data-widget-key"),e.getElement().getAttribute("data-widget-hash")]}));new r(TYPO3.settings.ajaxUrls["ext-dashboard-save-widget-positions"]).post({widgets:t}).then(async e=>{await e.resolve()})}}}));
\ No newline at end of file
-- 
GitLab