[BUGFIX] Show warning message if no language is activated 53/45753/2
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 9 Jan 2016 12:45:05 +0000 (13:45 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 9 Jan 2016 13:38:28 +0000 (14:38 +0100)
When no language is activated, while updating in the language module,
error messages appear. Show a nice error message that at least one
language must be activated.

Resolves: #72593
Releases: master,7.6
Change-Id: I20459d2f50551f2c1677e04779294feba03a26f1
Reviewed-on: https://review.typo3.org/45751
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
(cherry picked from commit b6b34962eb701028473408a52bd43a59fb1811a0)
Reviewed-on: https://review.typo3.org/45753

typo3/sysext/lang/Classes/Controller/LanguageController.php
typo3/sysext/lang/Resources/Private/Language/locallang.xlf
typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js

index d962bf6..02e3d1c 100644 (file)
@@ -245,6 +245,7 @@ class LanguageController extends ActionController
             'flashmessage.canceled',
             'flashmessage.languageActivated',
             'flashmessage.languageDeactivated',
+            'flashmessage.noLanguageActivated',
             'flashmessage.errorOccurred',
             'table.processing',
             'table.search',
index f773d11..be05d3f 100644 (file)
@@ -62,6 +62,9 @@
                        <trans-unit id="flashmessage.errorOccurred">
                                <source>The request has failed.</source>
                        </trans-unit>
+                       <trans-unit id="flashmessage.noLanguageActivated">
+                               <source>No language activated. Please activate at least one language.</source>
+                       </trans-unit>
 
                        <trans-unit id="table.ad">
                                <source>A/D</source>
index 220f218..540e1fc 100644 (file)
@@ -181,27 +181,31 @@ define(['jquery', 'moment', 'TYPO3/CMS/Backend/Icons', 'datatables', 'TYPO3/CMS/
         */
        LanguageModule.updateActiveLanguagesAction = function(triggerElement, parameters) {
                var $activeRows = $('tr.' + LanguageModule.classes.enabled, LanguageModule.table.table().container());
-               LanguageModule.updateButtonStatus('update');
-               LanguageModule.topMenu.addClass(LanguageModule.classes.processing);
-               $activeRows.addClass(LanguageModule.classes.processing);
-               LanguageModule.loadTranslationsByRows($activeRows, function(row, status, data, response) {
-                       var $progressBar = $(LanguageModule.identifiers.progressBar, row),
-                               $lastUpdate = $(LanguageModule.identifiers.lastUpdate, row);
+               if ($activeRows.length > 0) {
+                       LanguageModule.updateButtonStatus('update');
+                       LanguageModule.topMenu.addClass(LanguageModule.classes.processing);
+                       $activeRows.addClass(LanguageModule.classes.processing);
+                       LanguageModule.loadTranslationsByRows($activeRows, function(row, status, data, response) {
+                               var $progressBar = $(LanguageModule.identifiers.progressBar, row),
+                                       $lastUpdate = $(LanguageModule.identifiers.lastUpdate, row);
 
-                       if (status === 'success') {
-                               LanguageModule.setProgress($progressBar, 100);
-                               row.removeClass(LanguageModule.classes.processing).addClass(LanguageModule.classes.complete);
-                               $lastUpdate.html(LanguageModule.formatDate(response.timestamp));
-                       } else if (status === 'progress') {
-                               LanguageModule.setProgress($progressBar, parseFloat(response.progress));
-                       } else if (status === 'error') {
-                               LanguageModule.displayError(LanguageModule.labels.errorOccurred);
-                       } else if (status === 'finished') {
-                               LanguageModule.updateButtonStatus('cancel');
-                               LanguageModule.displaySuccess(LanguageModule.labels.updateComplete);
-                               LanguageModule.topMenu.removeClass(LanguageModule.classes.processing);
-                       }
-               });
+                               if (status === 'success') {
+                                       LanguageModule.setProgress($progressBar, 100);
+                                       row.removeClass(LanguageModule.classes.processing).addClass(LanguageModule.classes.complete);
+                                       $lastUpdate.html(LanguageModule.formatDate(response.timestamp));
+                               } else if (status === 'progress') {
+                                       LanguageModule.setProgress($progressBar, parseFloat(response.progress));
+                               } else if (status === 'error') {
+                                       LanguageModule.displayError(LanguageModule.labels.errorOccurred);
+                               } else if (status === 'finished') {
+                                       LanguageModule.updateButtonStatus('cancel');
+                                       LanguageModule.displaySuccess(LanguageModule.labels.updateComplete);
+                                       LanguageModule.topMenu.removeClass(LanguageModule.classes.processing);
+                               }
+                       });
+               } else {
+                       LanguageModule.displayError(LanguageModule.labels.noLanguageActivated);
+               }
        };
 
        /**
@@ -276,6 +280,7 @@ define(['jquery', 'moment', 'TYPO3/CMS/Backend/Icons', 'datatables', 'TYPO3/CMS/
                        languageActivated: TYPO3.lang['flashmessage.languageActivated'],
                        errorOccurred: TYPO3.lang['flashmessage.errorOccurred'],
                        languageDeactivated: TYPO3.lang['flashmessage.languageDeactivated'],
+                       noLanguageActivated: TYPO3.lang['flashmessage.noLanguageActivated'],
                        updateComplete: TYPO3.lang['flashmessage.updateComplete'],
                        canceled: TYPO3.lang['flashmessage.canceled']
                }