[BUGFIX] "Add media by URL" is not hidden if maxItems is reached 19/45419/2
authorSascha Egerer <sascha@sascha-egerer.de>
Wed, 23 Dec 2015 10:41:27 +0000 (11:41 +0100)
committerBenni Mack <benni@typo3.org>
Thu, 24 Dec 2015 12:16:49 +0000 (13:16 +0100)
The "Add media by URL" button for FAL realtions is not hidden
if maxItems has already been reached by the opened record.

Change-Id: I71a27cbabd1fc6660f58d0374595af0558fb8a12
Resolves: #72408
Related: #70762
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/45419
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js

index a8e3667..cb01264 100644 (file)
@@ -248,6 +248,7 @@ class InlineControlContainer extends AbstractContainer
         if ($numberOfFullLocalizedChildren >= $config['maxitems'] || $uniqueMax > 0 && $numberOfFullLocalizedChildren >= $uniqueMax) {
             $config['inline']['inlineNewButtonStyle'] = 'display: none;';
             $config['inline']['inlineNewRelationButtonStyle'] = 'display: none;';
+            $config['inline']['inlineOnlineMediaAddButtonStyle'] = 'display: none;';
         }
 
         // Render the level links (create new record):
@@ -496,12 +497,17 @@ class InlineControlContainer extends AbstractContainer
 
                 $this->requireJsModules[] = ['TYPO3/CMS/Backend/DragUploader' => 'function(dragUploader){dragUploader.initialize()}'];
                 if (!empty($onlineMediaAllowed)) {
+                    $buttonStyle = '';
+                    if (isset($inlineConfiguration['inline']['inlineOnlineMediaAddButtonStyle'])) {
+                        $buttonStyle = ' style="' . $inlineConfiguration['inline']['inlineOnlineMediaAddButtonStyle'] . '"';
+                    }
                     $this->requireJsModules[] = 'TYPO3/CMS/Backend/OnlineMedia';
                     $buttonText = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.button', true);
                     $placeholder = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.placeholder', true);
                     $buttonSubmit = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.submit', true);
                     $item .= '
                                                <span class="btn btn-default t3js-online-media-add-btn ' . $this->inlineData['config'][$nameObject]['md5'] . '"
+                                                       ' . $buttonStyle . '
                                                        data-file-irre-object="' . htmlspecialchars($objectPrefix) . '"
                                                        data-online-media-allowed="' . htmlspecialchars(implode(',', $onlineMediaAllowed)) . '"
                                                        data-target-folder="' . htmlspecialchars($folder->getCombinedIdentifier()) . '"
index 680da2b..b05f917 100644 (file)
@@ -983,7 +983,7 @@ var inline = {
                        this.showElementsWithClassName('.inlineNewButton' + (md5 ? '.' + md5 : ''), objectParent);
                        this.showElementsWithClassName('.inlineNewRelationButton' + (md5 ? '.' + md5 : ''), objectParent);
                        this.showElementsWithClassName('.inlineNewFileUploadButton' + (md5 ? '.' + md5 : ''), objectParent);
-                       this.hideElementsWithClassName('.t3js-online-media-add-btn' + (md5 ? '.' + md5 : ''), objectParent);
+                       this.showElementsWithClassName('.t3js-online-media-add-btn' + (md5 ? '.' + md5 : ''), objectParent);
                        this.showElementsWithClassName('.inlineForeignSelector' + (md5 ? '.' + md5 : ''), 't3-form-field-item');
                }
                TYPO3.FormEngine.Validation.validate();