[TASK] Migrate TYPO3/CMS/Scheduler/* to TypeScript 94/59694/3
authorFrank Naegler <frank.naegler@typo3.org>
Wed, 13 Feb 2019 11:56:35 +0000 (12:56 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 17 Feb 2019 09:29:17 +0000 (10:29 +0100)
Resolves: #87707
Releases: master
Change-Id: I942fcd9b98daea74c97e42885bd079ad5505c409
Reviewed-on: https://review.typo3.org/c/59694
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Build/types/TYPO3/index.d.ts
typo3/sysext/scheduler/Resources/Private/TypeScript/PageBrowser.ts [new file with mode: 0644]
typo3/sysext/scheduler/Resources/Private/TypeScript/Scheduler.ts [new file with mode: 0644]
typo3/sysext/scheduler/Resources/Public/JavaScript/PageBrowser.js
typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js

index 3d544f9..f3657e4 100644 (file)
@@ -132,5 +132,7 @@ interface JQuery {
 
   // To be able to use jquery/autocomplete-slider we have to override the definition of jquerui
   autocomplete(options?: { [key: string]: any }): any;
+
+  DataTable(options?: any): JQuery;
 }
 
diff --git a/typo3/sysext/scheduler/Resources/Private/TypeScript/PageBrowser.ts b/typo3/sysext/scheduler/Resources/Private/TypeScript/PageBrowser.ts
new file mode 100644 (file)
index 0000000..1fb41a6
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+import * as $ from 'jquery';
+
+/**
+ * Module: TYPO3/CMS/Scheduler/PageBrowser
+ * Javascript for adding links for calling the page browser pop up
+ */
+class PageBrowser {
+  constructor() {
+    $(document).on('click', '.t3js-pageBrowser', (evt: JQueryEventObject): void => {
+      let browserWin: Window;
+      let pageUrl: string = $(evt.currentTarget).data('url');
+      browserWin = window.open(pageUrl, 'Typo3WinBrowser', 'height=650,width=800,status=0,menubar=0,resizable=1,scrollbars=1');
+      browserWin.focus();
+    });
+  }
+}
+
+export = new PageBrowser();
diff --git a/typo3/sysext/scheduler/Resources/Private/TypeScript/Scheduler.ts b/typo3/sysext/scheduler/Resources/Private/TypeScript/Scheduler.ts
new file mode 100644 (file)
index 0000000..040e07c
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+import * as $ from 'jquery';
+import 'datatables';
+import SplitButtons = require('TYPO3/CMS/Backend/SplitButtons');
+
+interface TableNumberMapping {
+  [s: string]: number;
+}
+declare var defaultNumberOfDays: TableNumberMapping;
+
+/**
+ * Module: TYPO3/CMS/Scheduler/Scheduler
+ * @exports TYPO3/CMS/Scheduler/Scheduler
+ */
+class Scheduler {
+  private allCheckedStatus: boolean = false;
+
+  constructor() {
+    this.initializeEvents();
+    this.initializeDefaultStates();
+
+    SplitButtons.addPreSubmitCallback((): void => {
+      let taskClass = $('#task_class').val();
+      taskClass = taskClass.toLowerCase().replace(/\\/g, '-');
+
+      $('.extraFields').appendTo($('#extraFieldsHidden'));
+      $('.extra_fields_' + taskClass).appendTo($('#extraFieldsSection'));
+    });
+  }
+
+  /**
+   * This method reacts on changes to the task class
+   * It switches on or off the relevant extra fields
+   */
+  public actOnChangedTaskClass = (theSelector: JQuery): void => {
+    let taskClass: string = theSelector.val();
+    taskClass = taskClass.toLowerCase().replace(/\\/g, '-');
+
+    // Hide all extra fields
+    $('.extraFields').hide();
+    // Show only relevant extra fields
+    $('.extra_fields_' + taskClass).show();
+  }
+
+  /**
+   * This method reacts on changes to the type of a task, i.e. single or recurring
+   */
+  public actOnChangedTaskType = (evt: JQueryEventObject): void => {
+    this.toggleFieldsByTaskType($(evt.currentTarget).val());
+  }
+
+  /**
+   * This method reacts on field changes of all table field for table garbage collection task
+   */
+  public actOnChangeSchedulerTableGarbageCollectionAllTables = (theCheckbox: JQuery): void => {
+    let $numberOfDays = $('#task_tableGarbageCollection_numberOfDays');
+    let $taskTableGarbageCollectionTable = $('#task_tableGarbageCollection_table');
+    if (theCheckbox.prop('checked')) {
+      $taskTableGarbageCollectionTable.prop('disabled', true);
+      $numberOfDays.prop('disabled', true);
+    } else {
+      // Get number of days for selected table
+      let numberOfDays = parseInt($numberOfDays.val(), 10);
+      if (numberOfDays < 1) {
+        let selectedTable = $taskTableGarbageCollectionTable.val();
+        if (typeof(defaultNumberOfDays[selectedTable]) !== 'undefined') {
+          numberOfDays = defaultNumberOfDays[selectedTable];
+        }
+      }
+
+      $taskTableGarbageCollectionTable.prop('disabled', false);
+      if (numberOfDays > 0) {
+        $numberOfDays.prop('disabled', false);
+      }
+    }
+  }
+
+  /**
+   * This methods set the 'number of days' field to the default expire period
+   * of the selected table
+   */
+  public actOnChangeSchedulerTableGarbageCollectionTable = (theSelector: JQuery): void => {
+    let $numberOfDays = $('#task_tableGarbageCollection_numberOfDays');
+    if (defaultNumberOfDays[theSelector.val()] > 0) {
+      $numberOfDays.prop('disabled', false);
+      $numberOfDays.val(defaultNumberOfDays[theSelector.val()]);
+    } else {
+      $numberOfDays.prop('disabled', true);
+      $numberOfDays.val(0);
+    }
+  }
+
+  /**
+   * Check or uncheck all checkboxes
+   */
+  public checkOrUncheckAllCheckboxes = (theSelector: JQuery): boolean => {
+    theSelector.parents('.tx_scheduler_mod1_table').find(':checkbox').prop('checked', !this.allCheckedStatus);
+    this.allCheckedStatus = !this.allCheckedStatus;
+    return false;
+  }
+
+  /**
+   * Toggle the relevant form fields by task type
+   */
+  public toggleFieldsByTaskType = (taskType: number): void => {
+    // Single task option = 1, Recurring task option = 2
+    taskType = parseInt(taskType + '', 10);
+    $('#task_end_col').toggle(taskType === 2);
+    $('#task_frequency_row').toggle(taskType === 2);
+  }
+
+  /**
+   * Toggle the visibility of task groups by clicking anywhere on the
+   * task group header
+   */
+  public toggleTaskGroups = (theSelector: JQuery): void => {
+    let taskGroup = theSelector.data('task-group-id');
+    $('#recordlist-task-group-' + taskGroup).collapse('toggle');
+  }
+
+  /**
+   * Registers listeners
+   */
+  public initializeEvents = (): void => {
+    $('.checkall').on('click', (evt: JQueryEventObject): void => {
+      this.checkOrUncheckAllCheckboxes($(evt.currentTarget));
+    });
+
+    $('#task_class').change((evt: JQueryEventObject): void => {
+      this.actOnChangedTaskClass($(evt.currentTarget));
+    });
+
+    $('#task_type').change(this.actOnChangedTaskType);
+
+    $('#task_tableGarbageCollection_allTables').change((evt: JQueryEventObject): void => {
+      this.actOnChangeSchedulerTableGarbageCollectionAllTables($(evt.currentTarget));
+    });
+
+    $('#task_tableGarbageCollection_table').change((evt: JQueryEventObject): void => {
+      this.actOnChangeSchedulerTableGarbageCollectionTable($(evt.currentTarget));
+    });
+
+    $('.taskGroup').on('click', (evt: JQueryEventObject): void => {
+      this.toggleTaskGroups($(evt.currentTarget));
+    });
+
+    $('table.taskGroup-table').DataTable({
+      'paging': false,
+      'searching': false
+    });
+  }
+
+  /**
+   * Initialize default states
+   */
+  public initializeDefaultStates = (): void => {
+    let $taskType = $('#task_type');
+    if ($taskType.length) {
+      this.toggleFieldsByTaskType($taskType.val());
+    }
+    let $taskClass = $('#task_class');
+    if ($taskClass.length) {
+      this.actOnChangedTaskClass($taskClass);
+    }
+  }
+}
+
+export = new Scheduler();
index e89f52d..3199e97 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
-
-/**
- * Module: TYPO3/CMS/Scheduler/PageBrowser
- * Javascript for adding links for calling the page browser pop up
- */
-define(['jquery'], function($) {
-  'use strict';
-
-  $(document).on('click', '.t3js-pageBrowser', function() {
-    var $this = $(this),
-      browserWin = "",
-      pageUrl = $this.data('url');
-
-    browserWin = window.open(pageUrl, "Typo3WinBrowser", "height=650,width=800,status=0,menubar=0,resizable=1,scrollbars=1");
-    browserWin.focus();
-  });
-
-});
+define(["require","exports","jquery"],function(e,r,n){"use strict";return new function(){n(document).on("click",".t3js-pageBrowser",function(e){var r=n(e.currentTarget).data("url");window.open(r,"Typo3WinBrowser","height=650,width=800,status=0,menubar=0,resizable=1,scrollbars=1").focus()})}});
\ No newline at end of file
index dd0590c..89120e1 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
-
-/**
- * Module: TYPO3/CMS/Scheduler/Scheduler
- */
-define(['jquery',
-  'TYPO3/CMS/Backend/SplitButtons',
-  'datatables'
-], function($, SplitButtons) {
-
-  /**
-   *
-   * @type {{}}
-   * @exports TYPO3/CMS/Scheduler/Scheduler
-   */
-  var Scheduler = {};
-
-  var allCheckedStatus = false;
-
-  /**
-   * This method reacts on changes to the task class
-   * It switches on or off the relevant extra fields
-   *
-   * @param {Object} theSelector
-   */
-  Scheduler.actOnChangedTaskClass = function(theSelector) {
-    var taskClass = theSelector.val();
-    taskClass = taskClass.toLowerCase().replace(/\\/g, '-');
-
-    // Hide all extra fields
-    $('.extraFields').hide();
-    // Show only relevant extra fields
-    $('.extra_fields_' + taskClass).show();
-  };
-
-  /**
-   * This method reacts on changes to the type of a task, i.e. single or recurring
-   */
-  Scheduler.actOnChangedTaskType = function() {
-    Scheduler.toggleFieldsByTaskType($(this).val());
-  };
-
-  /**
-   * This method reacts on field changes of all table field for table garbage collection task
-   *
-   * @param {Object} theCheckbox
-   */
-  Scheduler.actOnChangeSchedulerTableGarbageCollectionAllTables = function(theCheckbox) {
-    var $numberOfDays = $('#task_tableGarbageCollection_numberOfDays');
-    var $taskTableGarbageCollectionTable = $('#task_tableGarbageCollection_table');
-    if (theCheckbox.prop('checked')) {
-      $taskTableGarbageCollectionTable.prop('disabled', true);
-      $numberOfDays.prop('disabled', true);
-    } else {
-      // Get number of days for selected table
-      var numberOfDays = parseInt($numberOfDays.val());
-      if (numberOfDays < 1) {
-        var selectedTable = $taskTableGarbageCollectionTable.val();
-        if (typeof(defaultNumberOfDays[selectedTable]) !== 'undefined') {
-          numberOfDays = defaultNumberOfDays[selectedTable];
-        }
-      }
-
-      $taskTableGarbageCollectionTable.prop('disabled', false);
-      if (numberOfDays > 0) {
-        $numberOfDays.prop('disabled', false);
-      }
-    }
-  };
-
-  /**
-   * This methods set the 'number of days' field to the default expire period
-   * of the selected table
-   *
-   * @param {Object} theSelector
-   */
-  Scheduler.actOnChangeSchedulerTableGarbageCollectionTable = function(theSelector) {
-    var $numberOfDays = $('#task_tableGarbageCollection_numberOfDays');
-    if (defaultNumberOfDays[theSelector.val()] > 0) {
-      $numberOfDays.prop('disabled', false);
-      $numberOfDays.val(defaultNumberOfDays[theSelector.val()]);
-    } else {
-      $numberOfDays.prop('disabled', true);
-      $numberOfDays.val(0);
-    }
-  };
-
-  /**
-   * Check or uncheck all checkboxes
-   *
-   * @param {Object} theSelector
-   * @returns {Boolean}
-   */
-  Scheduler.checkOrUncheckAllCheckboxes = function(theSelector) {
-    theSelector.parents('.tx_scheduler_mod1_table').find(':checkbox').prop('checked', !allCheckedStatus);
-    allCheckedStatus = !allCheckedStatus;
-    return false;
-  };
-
-  /**
-   * Toggle the relevant form fields by task type
-   *
-   * @param {Integer} taskType
-   */
-  Scheduler.toggleFieldsByTaskType = function(taskType) {
-    // Single task option = 1, Recurring task option = 2
-    taskType = parseInt(taskType);
-    $('#task_end_col').toggle(taskType === 2);
-    $('#task_frequency_row').toggle(taskType === 2);
-  };
-
-  /**
-   * Toggle the visibility of task groups by clicking anywhere on the
-   * task group header
-   *
-   * @param {Object} theSelector
-   */
-  Scheduler.toggleTaskGroups = function(theSelector) {
-    var taskGroup = theSelector.data('task-group-id');
-    $('#recordlist-task-group-' + taskGroup).collapse('toggle');
-  };
-
-  /**
-   * Registers listeners
-   */
-  Scheduler.initializeEvents = function() {
-    $('.checkall').on('click', function() {
-      Scheduler.checkOrUncheckAllCheckboxes($(this));
-    });
-
-    $('#task_class').change(function() {
-      Scheduler.actOnChangedTaskClass($(this));
-    });
-
-    $('#task_type').change(Scheduler.actOnChangedTaskType);
-
-    $('#task_tableGarbageCollection_allTables').change(function() {
-      Scheduler.actOnChangeSchedulerTableGarbageCollectionAllTables($(this));
-    });
-
-    $('#task_tableGarbageCollection_table').change(function() {
-      Scheduler.actOnChangeSchedulerTableGarbageCollectionTable($(this));
-    });
-
-    $('.taskGroup').on('click', function() {
-      Scheduler.toggleTaskGroups($(this));
-    });
-
-    $('table.taskGroup-table').DataTable({
-      "paging": false,
-      "searching": false
-    });
-  };
-
-  /**
-   * Initialize default states
-   */
-  Scheduler.initializeDefaultStates = function() {
-    var $taskType = $('#task_type');
-    if ($taskType.length) {
-      Scheduler.toggleFieldsByTaskType($taskType.val());
-    }
-    var $taskClass = $('#task_class');
-    if ($taskClass.length) {
-      Scheduler.actOnChangedTaskClass($taskClass);
-    }
-  };
-
-  $(Scheduler.initializeEvents);
-  $(Scheduler.initializeDefaultStates);
-
-  SplitButtons.addPreSubmitCallback(function() {
-    var taskClass = $('#task_class').val();
-    taskClass = taskClass.toLowerCase().replace(/\\/g, '-');
-
-    $('.extraFields').appendTo($('#extraFieldsHidden'));
-    $('.extra_fields_' + taskClass).appendTo($('#extraFieldsSection'));
-  });
-
-  return Scheduler;
-});
+define(["require","exports","jquery","TYPO3/CMS/Backend/SplitButtons","datatables"],function(e,a,t,l){"use strict";return new function(){var e=this;this.allCheckedStatus=!1,this.actOnChangedTaskClass=function(e){var a=e.val();a=a.toLowerCase().replace(/\\/g,"-"),t(".extraFields").hide(),t(".extra_fields_"+a).show()},this.actOnChangedTaskType=function(a){e.toggleFieldsByTaskType(t(a.currentTarget).val())},this.actOnChangeSchedulerTableGarbageCollectionAllTables=function(e){var a=t("#task_tableGarbageCollection_numberOfDays"),l=t("#task_tableGarbageCollection_table");if(e.prop("checked"))l.prop("disabled",!0),a.prop("disabled",!0);else{var n=parseInt(a.val(),10);if(n<1){var s=l.val();void 0!==defaultNumberOfDays[s]&&(n=defaultNumberOfDays[s])}l.prop("disabled",!1),n>0&&a.prop("disabled",!1)}},this.actOnChangeSchedulerTableGarbageCollectionTable=function(e){var a=t("#task_tableGarbageCollection_numberOfDays");defaultNumberOfDays[e.val()]>0?(a.prop("disabled",!1),a.val(defaultNumberOfDays[e.val()])):(a.prop("disabled",!0),a.val(0))},this.checkOrUncheckAllCheckboxes=function(a){return a.parents(".tx_scheduler_mod1_table").find(":checkbox").prop("checked",!e.allCheckedStatus),e.allCheckedStatus=!e.allCheckedStatus,!1},this.toggleFieldsByTaskType=function(e){e=parseInt(e+"",10),t("#task_end_col").toggle(2===e),t("#task_frequency_row").toggle(2===e)},this.toggleTaskGroups=function(e){var a=e.data("task-group-id");t("#recordlist-task-group-"+a).collapse("toggle")},this.initializeEvents=function(){t(".checkall").on("click",function(a){e.checkOrUncheckAllCheckboxes(t(a.currentTarget))}),t("#task_class").change(function(a){e.actOnChangedTaskClass(t(a.currentTarget))}),t("#task_type").change(e.actOnChangedTaskType),t("#task_tableGarbageCollection_allTables").change(function(a){e.actOnChangeSchedulerTableGarbageCollectionAllTables(t(a.currentTarget))}),t("#task_tableGarbageCollection_table").change(function(a){e.actOnChangeSchedulerTableGarbageCollectionTable(t(a.currentTarget))}),t(".taskGroup").on("click",function(a){e.toggleTaskGroups(t(a.currentTarget))}),t("table.taskGroup-table").DataTable({paging:!1,searching:!1})},this.initializeDefaultStates=function(){var a=t("#task_type");a.length&&e.toggleFieldsByTaskType(a.val());var l=t("#task_class");l.length&&e.actOnChangedTaskClass(l)},this.initializeEvents(),this.initializeDefaultStates(),l.addPreSubmitCallback(function(){var e=t("#task_class").val();e=e.toLowerCase().replace(/\\/g,"-"),t(".extraFields").appendTo(t("#extraFieldsHidden")),t(".extra_fields_"+e).appendTo(t("#extraFieldsSection"))})}});
\ No newline at end of file