Jelajahi Sumber

Customer portal : Readonly attachments when object is not longer editable

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4250 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 tahun lalu
induk
melakukan
1a1e04df7c

+ 2 - 2
datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php

@@ -599,7 +599,7 @@ class ObjectFormManager extends FormManager
 					break;
 				}
 			}
-
+			
 			// Adding attachment field
 			if ($bClassAllowed)
 			{
@@ -611,7 +611,7 @@ class ObjectFormManager extends FormManager
 					->SetAllowDelete($this->oApp['combodo.portal.instance.conf']['properties']['attachments']['allow_delete'])
 					->SetObject($this->oObject);
 
-				if ($this->sMode === static::ENUM_MODE_VIEW)
+				if (($this->sMode === static::ENUM_MODE_VIEW) || ($oForm->GetEditableFieldCount() === 0))
 				{
 					$oField->SetReadOnly(true);
 				}

+ 8 - 2
datamodels/2.x/itop-portal-base/portal/src/views/bricks/object/mode_create.html.twig

@@ -72,8 +72,14 @@
 			var oNormalRegularButtons_{{ sFormIdSanitized }} = $('#{{ sFormId }} .form_btn_regular');
 			var oStickyRegularButtons_{{ sFormIdSanitized }} = oNormalRegularButtons_{{ sFormIdSanitized }}.clone(true, true);
 			oStickyRegularButtons_{{ sFormIdSanitized }}.addClass('sticky');
-			oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_submit').html( oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_submit span.glyphicon')[0].outerHTML );
-			oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_cancel').html( oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_cancel span.glyphicon')[0].outerHTML );
+			if(oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_submit span.glyphicon').length > 0)
+			{
+				oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_submit').html( oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_submit span.glyphicon')[0].outerHTML );
+			}
+			if(oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_cancel span.glyphicon').length > 0)
+			{
+				oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_cancel').html( oStickyRegularButtons_{{ sFormIdSanitized }}.find('.form_btn_cancel span.glyphicon')[0].outerHTML );
+			}
 			
 			$('#{{ sFormId }}').closest({% if tIsModal == true %}'.modal'{% else %}'#main-content'{% endif %}).append(oStickyRegularButtons_{{ sFormIdSanitized }});
 			

+ 1 - 1
sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php

@@ -48,7 +48,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
 		$oOutput = new RenderingOutput();
 
 		$sObjectClass = get_class($this->oField->GetObject());
-		$sIsDeleteAllowed = ($this->oField->GetAllowDelete()) ? 'true' : 'false';
+		$sIsDeleteAllowed = ($this->oField->GetAllowDelete() && !$this->oField->GetReadOnly()) ? 'true' : 'false';
 		$sDeleteBtn = Dict::S('Portal:Button:Delete');
 		$sTempId = session_id() . '_' . $this->oField->GetTransactionId();
 		$sUploadDropZoneLabel = Dict::S('Portal:Attachments:DropZone:Message');