[BUGFIX] IRRE hide/unhide broken
authordkd-egerer Sascha Egerer <sascha@sascha-egerer.de>
Sun, 15 Apr 2012 14:36:14 +0000 (16:36 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 28 Jun 2012 20:28:45 +0000 (22:28 +0200)
hide/unhide is broken when inline record is not opened before

Change-Id: I45d09705d4f11b7f4d829f33913b57b85e42fd3d
Resolves: #34303
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/10696
Reviewed-by: Stefan Neufeind
Reviewed-by: Marcus Schwemer
Tested-by: Marcus Schwemer
Reviewed-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_tceforms_inline.php
t3lib/jsfunc.inline.js

index 3fe653c..3857ed3 100644 (file)
@@ -434,6 +434,11 @@ class t3lib_TCEforms_inline {
                        } else {
                                        // set additional field for processing for saving
                                $fields .= '<input type="hidden" name="' . $this->prependCmdFieldNames . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
+                               if(!$isExpanded) {
+                                       $checked = ($rec['hidden'] == 1) ? ' checked="checked"' : '';
+                                       $fields .= '<input type="checkbox" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[hidden]_0" value="1"'.$checked.' />';
+                                       $fields .= '<input type="input" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[hidden]" value="'.$rec['hidden'].'" />';
+                               }
                        }
                                // if this record should be shown collapsed
                        if (!$isExpanded) {
index 1132ce1..09f8541 100644 (file)
@@ -410,7 +410,18 @@ var inline = {
                var objectDiv = $(objectId + '_fields');
                if (!objectDiv || objectDiv.innerHTML.substr(0,16) != '<!--notloaded-->')
                        return;
+
+               var elName = this.parseObjectId('full', objectId, 2, 0, true);
+
+               var formObj = document.getElementsByName(elName+'[hidden]_0')[0];
+               var tempHiddenValue = formObj.checked;
+               formObj.remove();
+               document.getElementsByName(elName+'[hidden]')[0].remove();
+
                objectDiv.update(htmlData);
+               document.getElementsByName(elName+'[hidden]')[0].value = tempHiddenValue ? 1 : 0;
+               document.getElementsByName(elName+'[hidden]_0')[0].checked = tempHiddenValue;
+
                        // remove loading-indicator
                if ($(objectId + '_icon')) {
                        $(objectId + '_iconcontainer').removeClassName('loading-indicator');
@@ -708,15 +719,21 @@ var inline = {
 
        enableDisableRecord: function(objectId) {
                var elName = this.parseObjectId('full', objectId, 2, 0, true);
-               var imageObj = $(objectId+'_disabled');
-               var valueObj = document.getElementsByName(elName+'[hidden]');
-               var formObj = document.getElementsByName(elName+'[hidden]_0');
-               var imagePath = '';
-
-               if (valueObj && formObj) {
-                       formObj[0].click();
-                       imagePath = this.parsePath(imageObj.src);
-                       imageObj.src = imagePath+(valueObj[0].value > 0 ? 'button_unhide.gif' : 'button_hide.gif');
+               var currentUid = this.parseObjectId('none', objectId, 1);
+               var objectPrefix = this.parseObjectId('full', objectId, 0, 1);
+               var formObj = document.getElementsByName(elName+'[hidden]_0')[0];
+
+               formObj.click();
+
+               document.getElementsByName(elName+'[hidden]')[0].value = formObj.checked?1:0;
+               TBE_EDITOR.fieldChanged(objectPrefix,'1','hidden',elName+'[hidden]');
+
+               if($(objectId+'_disabled').hasClassName('t3-icon-edit-hide')) {
+                       $(objectId+'_disabled').removeClassName ('t3-icon-edit-hide');
+                       $(objectId+'_disabled').addClassName('t3-icon-edit-unhide');
+               } else {
+                       $(objectId+'_disabled').removeClassName ('t3-icon-edit-unhide');
+                       $(objectId+'_disabled').addClassName('t3-icon-edit-hide');
                }
 
                return false;