[BUGFIX] Hide "Add media by URL" if maxitems count is reached 49/44649/2
authorNicole Cordes <typo3@cordes.co>
Mon, 9 Nov 2015 22:48:12 +0000 (23:48 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 10 Nov 2015 06:21:10 +0000 (07:21 +0100)
If you have a reference field and the maxitems count is reached,
the buttons for "Add media file" and "Select & upload files" are hidden
but the button to add a media url still remains.

This patch adds needed class and Javascript to hide the button as well.

Resolves: #70762
Releases: master
Change-Id: I237ca08990df25c411b533dd68fb2f2944678ae8
Reviewed-on: https://review.typo3.org/44649
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@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 eb5fea3..45f00d1 100644 (file)
@@ -491,7 +491,7 @@ class InlineControlContainer extends AbstractContainer
                     $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"
+                                               <span class="btn btn-default t3js-online-media-add-btn ' . $this->inlineData['config'][$nameObject]['md5'] . '"
                                                        data-file-irre-object="' . htmlspecialchars($objectPrefix) . '"
                                                        data-online-media-allowed="' . htmlspecialchars(implode(',', $onlineMediaAllowed)) . '"
                                                        data-target-folder="' . htmlspecialchars($folder->getCombinedIdentifier()) . '"
index 458cb46..bb75030 100644 (file)
@@ -758,13 +758,14 @@ var inline = {
                        }
                }
 
-               // if we reached the maximum off possible records after this action, hide the new buttons
+               // if we reached the maximum of possible records after this action, hide the new buttons
                if (!this.isBelowMax(objectPrefix)) {
                        var objectParent = this.parseObjectId('full', objectPrefix, 0, 1);
                        var md5 = this.getObjectMD5(objectParent);
                        this.hideElementsWithClassName('.inlineNewButton' + (md5 ? '.' + md5 : ''), objectParent);
                        this.hideElementsWithClassName('.inlineNewRelationButton' + (md5 ? '.' + md5 : ''), objectParent);
                        this.hideElementsWithClassName('.inlineNewFileUploadButton' + (md5 ? '.' + md5 : ''), objectParent);
+                       this.hideElementsWithClassName('.t3js-online-media-add-btn' + (md5 ? '.' + md5 : ''), objectParent);
                        this.hideElementsWithClassName('.inlineForeignSelector' + (md5 ? '.' + md5 : ''), 't3-form-field-item');
                }
 
@@ -980,6 +981,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('.inlineForeignSelector' + (md5 ? '.' + md5 : ''), 't3-form-field-item');
                }
                TYPO3.FormEngine.Validation.validate();