mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 06:48:50 +02:00
N°635 Portal: Parameter to show submit ("Update") button in forms only when there is no transition available.
SVN:trunk[4724]
This commit is contained in:
@@ -471,14 +471,18 @@ class ObjectController extends AbstractController
|
||||
$oObject = MetaModel::GetObject($sObjectClass, $sObjectId, true, $oApp['scope_validator']->IsAllDataAllowedForScope(UserRights::ListProfiles(), $sObjectClass));
|
||||
}
|
||||
|
||||
// Preparing transitions only if we are currently going through one
|
||||
// Preparing buttons
|
||||
$aFormData['buttons'] = array(
|
||||
'transitions' => array(),
|
||||
'actions' => array(),
|
||||
'links' => array(),
|
||||
'submit' => array(
|
||||
'label' => Dict::S('Portal:Button:Submit'),
|
||||
),
|
||||
);
|
||||
if ($sMode !== 'apply_stimulus')
|
||||
{
|
||||
// Add transition buttons
|
||||
$oSetToCheckRights = DBObjectSet::FromObject($oObject);
|
||||
$aStimuli = Metamodel::EnumStimuli($sObjectClass);
|
||||
foreach ($oObject->EnumTransitions() as $sStimulusCode => $aTransitionDef)
|
||||
@@ -491,7 +495,7 @@ class ObjectController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
// Add plugins buttons
|
||||
// Add plugin buttons
|
||||
foreach (MetaModel::EnumPlugins('iPopupMenuExtension') as $oExtensionInstance)
|
||||
{
|
||||
foreach($oExtensionInstance->EnumItems(iPopupMenuExtension::PORTAL_OBJDETAILS_ACTIONS, array('portal_id' => $oApp['combodo.portal.instance.id'], 'object' => $oObject)) as $oMenuItem)
|
||||
@@ -509,7 +513,18 @@ class ObjectController extends AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hiding submit button or changing its label if necessary
|
||||
if($aFormProperties['properties']['always_show_submit'] === false)
|
||||
{
|
||||
unset($aFormData['buttons']['submit']);
|
||||
}
|
||||
elseif($sMode === static::ENUM_MODE_EDIT)
|
||||
{
|
||||
$aFormData['buttons']['submit']['label'] = Dict::S('Portal:Button:Apply');
|
||||
}
|
||||
}
|
||||
|
||||
// Preparing callback urls
|
||||
$aCallbackUrls = $oApp['context_manipulator']->GetCallbackUrls($oApp, $aActionRules, $oObject, $bModal);
|
||||
$aFormData['submit_callback'] = $aCallbackUrls['submit'];
|
||||
|
||||
@@ -848,8 +848,25 @@ class ApplicationHelper
|
||||
// Parsing form object class
|
||||
if ($oFormNode->GetUniqueElement('class')->GetText() !== null)
|
||||
{
|
||||
// Parsing class
|
||||
$sFormClass = $oFormNode->GetUniqueElement('class')->GetText();
|
||||
|
||||
// Parsing properties
|
||||
$aFormProperties = array(
|
||||
'always_show_submit' => false,
|
||||
);
|
||||
if($oFormNode->GetOptionalElement('properties') !== null)
|
||||
{
|
||||
foreach($oFormNode->GetOptionalElement('properties')->childNodes as $oPropertyNode)
|
||||
{
|
||||
switch($oPropertyNode->nodeName)
|
||||
{
|
||||
case 'always_show_submit':
|
||||
$aFormProperties['always_show_submit'] = ($oPropertyNode->GetText('false') === 'true') ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parsing availables modes for that form (view, edit, create)
|
||||
if (($oFormNode->GetOptionalElement('modes') !== null) && ($oFormNode->GetOptionalElement('modes')->GetNodes('mode')->length > 0))
|
||||
{
|
||||
@@ -875,6 +892,7 @@ class ApplicationHelper
|
||||
$aFields = array(
|
||||
'id' => $oFormNode->getAttribute('id'),
|
||||
'type' => null,
|
||||
'properties' => $aFormProperties,
|
||||
'fields' => null,
|
||||
'layout' => null
|
||||
);
|
||||
@@ -955,7 +973,7 @@ class ApplicationHelper
|
||||
throw new DOMFormatException('There is already a form for the class "' . $sFormClass . '" in "' . $sMode . '"', null, null, $oFormNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new DOMFormatException('Class tag must be defined', null, null, $oFormNode);
|
||||
|
||||
@@ -42,10 +42,12 @@
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
{{ 'Portal:Button:Cancel'|dict_s }}
|
||||
</button>
|
||||
<button class="btn btn-primary form_btn_submit" type="submit" value="submit" title="{{ 'Portal:Button:Submit'|dict_s }}">
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
{{ 'Portal:Button:Submit'|dict_s }}
|
||||
</button>
|
||||
{% if form.buttons.submit is defined %}
|
||||
<button class="btn btn-primary form_btn_submit" type="submit" value="submit" title="{{ form.buttons.submit.label }}">
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
{{ form.buttons.submit.label }}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{# Modal mode #}
|
||||
{% if tIsModal %}
|
||||
|
||||
@@ -1321,6 +1321,10 @@
|
||||
</form>
|
||||
<form id="ticket-edit">
|
||||
<class>Ticket</class>
|
||||
<properties>
|
||||
<!-- When set to false, submit button is hidden when transitions are available on the object (in edit mode only). Default is false. -->
|
||||
<!--<always_show_submit>false</always_show_submit>-->
|
||||
</properties>
|
||||
<fields></fields>
|
||||
<twig>
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user