[TASK] Flash message warning for max number of IRRE items 21/32221/13
authorNikola Stojiljkovic <nikola.stojiljkovic@essentialdots.com>
Fri, 26 Dec 2014 13:39:24 +0000 (14:39 +0100)
committerBenjamin Mack <benni@typo3.org>
Thu, 29 Jan 2015 14:34:56 +0000 (15:34 +0100)
Implements flash message warning when max number of items
is reached in IRRE field.

Resolves: #61031
Releases: master
Change-Id: I00c243a2878f70d1c01e137d3477ada1011182ca
Reviewed-on: http://review.typo3.org/32221
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
typo3/sysext/lang/locallang_core.xlf

index 65a2fed..3d8bc8b 100644 (file)
@@ -300,7 +300,8 @@ class InlineElement {
                if (in_array($config['appearance']['levelLinksPosition'], array('both', 'top'))) {
                        $item .= $levelLinks . $localizationLinks;
                }
-               $item .= '<div id="' . $nameObject . '_records">';
+               $title = $this->getLanguageService()->sL($PA['fieldConf']['label']);
+               $item .= '<div id="' . $nameObject . '_records" data-title="' . htmlspecialchars($title) . '">';
                $relationList = array();
                if (count($relatedRecords['records'])) {
                        foreach ($relatedRecords['records'] as $rec) {
index 851873c..e457025 100644 (file)
@@ -4099,6 +4099,7 @@ class FormEngine {
                        TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '";
                        TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . ';
                        TBE_EDITOR.labels.fieldsMissing = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsMissing')) . ';
+                       TBE_EDITOR.labels.maxItemsAllowed = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.maxItemsAllowed')) . ';
                        TBE_EDITOR.labels.refresh_login = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.refresh_login')) . ';
                        TBE_EDITOR.labels.onChangeAlert = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.onChangeAlert')) . ';
                        evalFunc.USmode = ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . ';
index cbf884a..3f06aba 100644 (file)
@@ -2620,8 +2620,10 @@ class BackendUtility {
                                        $wrappedText .= ' data-description="' . htmlspecialchars($overloadHelpText['description']) . '"';
                                }
                        }
-                       $wrappedText .= '>' . $text . '</span>';
+               } else {
+                       $wrappedText = '<span data-table="' . $table . '" data-field="' . $field . '"';
                }
+               $wrappedText .= '>' . $text . '</span>';
                return $wrappedText;
        }
 
index 4cce270..9de3fa4 100644 (file)
@@ -167,7 +167,13 @@ var inline = {
                        }
                        this.makeAjaxCall('createNewRecord', [this.getNumberOfRTE(), objectId], true, context);
                } else {
-                       alert('There are no more relations possible at this moment!');
+                       var message = TBE_EDITOR.labels.maxItemsAllowed.replace('{0}', this.data.config[objectId].max);
+                       var matches = objectId.match(/^(data-\d+-.*?-\d+-.*?)-(.*?)$/);
+                       var title = '';
+                       if (matches) {
+                               title = TYPO3.jQuery('#' + matches[1] + '_records').data('title');
+                       }
+                       top.TYPO3.Flashmessage.display(top.TYPO3.Severity.error, title, message, 5);
                }
                return false;
        },
@@ -501,15 +507,20 @@ var inline = {
        },
 
        domAddNewRecord: function (method, insertObjectId, objectPrefix, htmlData) {
+               var $insertObject = TYPO3.jQuery('#' + this.escapeObjectId(insertObjectId));
                if (this.isBelowMax(objectPrefix)) {
-                       var $insertObject = TYPO3.jQuery('#' + this.escapeObjectId(insertObjectId));
                        if (method == 'bottom') {
                                $insertObject.append(htmlData);
                        } else if (method == 'after') {
                                $insertObject.after(htmlData);
                        }
+               } else {
+                       var message = TBE_EDITOR.labels.maxItemsAllowed.replace('{0}', this.data.config[objectPrefix].max);
+                       var title = $insertObject.data('title');
+                       top.TYPO3.Flashmessage.display(top.TYPO3.Severity.error, title, message, 500);
                }
        },
+
        domAddRecordDetails: function (objectId, objectPrefix, expandSingle, htmlData) {
                var hiddenValue, formObj, valueObj;
                var escapeObjectId = this.escapeObjectId(objectId);
index 8048610..72e1054 100644 (file)
@@ -76,6 +76,9 @@
                                <source>There are unsaved changes in the form!
 Do you want to continue WITHOUT saving?</source>
                        </trans-unit>
+                       <trans-unit id="labels.maxItemsAllowed" xml:space="preserve">
+                               <source>A maximum of {0} child records are allowed.</source>
+                       </trans-unit>
                        <trans-unit id="labels.noRTEfound" xml:space="preserve">
                                <source>Notice: This field can only be edited with a Rich Text Editor. No editor is currently available or enabled.</source>
                        </trans-unit>