Переглянути джерело

Customer portal : Viewing an object now displays an edit button if the user is allowed to edit the viewed object.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4176 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 роки тому
батько
коміт
0d89f54c24

+ 9 - 0
datamodels/2.x/itop-portal-base/portal/src/controllers/objectcontroller.class.inc.php

@@ -91,6 +91,15 @@ class ObjectController extends AbstractController
 		$aData['form'] = $this->HandleForm($oRequest, $oApp, $aData['sMode'], $sObjectClass, $sObjectId);
 		$aData['form']['title'] = Dict::Format('Brick:Portal:Object:Form:View:Title', MetaModel::GetName($sObjectClass), $oObject->GetName());
 
+		// Add an edit button if user is allowed
+		if (SecurityHelper::IsActionAllowed($oApp, UR_ACTION_MODIFY, $sObjectClass, $sObjectId))
+		{
+			$aData['form']['buttons']['links'][] = array(
+				'label' => Dict::S('UI:Menu:Modify'),
+				'url' => $oApp['url_generator']->generate('p_object_edit', array('sObjectClass' => $sObjectClass, 'sObjectId' => $sObjectId))
+			);
+		}
+
 		// Preparing response
 		if ($oRequest->isXmlHttpRequest())
 		{

+ 7 - 1
datamodels/2.x/itop-portal-base/portal/src/views/bricks/object/mode_view.html.twig

@@ -4,8 +4,14 @@
 
 {# This layout is exactly the same as the mode_create.html.twig, we duplicated it in case we need to have some subtle differences #}
 
-
 {% block pFormButtons %}
+	{% if form.buttons is defined and form.buttons.links is defined %}
+		<div class="form_btn_transitions">
+			{% for aLink in form.buttons.links %}
+				<a class="btn btn-default" href="{{ aLink.url }}">{{ aLink.label }}</a>
+			{% endfor %}
+		</div>
+	{% endif %}
 	{% if tIsModal is defined and tIsModal == true %}
 		<div class="form_btn_regular">
 			<input class="btn btn-primary form_btn_cancel" type="button" value="{{ 'Portal:Button:Close'|dict_s }}" data-dismiss="modal">