mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 06:48:50 +02:00
N°1192 - Change default behavior for navigation rules
This commit is contained in:
@@ -38,6 +38,7 @@ use FalseExpression;
|
||||
use FieldExpression;
|
||||
use FileUploadException;
|
||||
use IssueLog;
|
||||
use JSButtonItem;
|
||||
use ListExpression;
|
||||
use MetaModel;
|
||||
use ScalarExpression;
|
||||
@@ -45,7 +46,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use URLButtonItem;
|
||||
use UserRights;
|
||||
use utils;
|
||||
use VariableExpression;
|
||||
@@ -129,13 +129,14 @@ class ObjectController extends BrickController
|
||||
// Add an edit button if user is allowed
|
||||
if ($oSecurityHelper->IsActionAllowed(UR_ACTION_MODIFY, $sObjectClass, $sObjectId))
|
||||
{
|
||||
$oModifyButton = new URLButtonItem(
|
||||
$sModifyUrl = $oUrlGenerator->generate('p_object_edit', array('sObjectClass' => $sObjectClass, 'sObjectId' => $sObjectId));
|
||||
$oModifyButton = new JSButtonItem(
|
||||
'modify_object',
|
||||
Dict::S('UI:Menu:Modify'),
|
||||
$oUrlGenerator->generate('p_object_edit', array('sObjectClass' => $sObjectClass, 'sObjectId' => $sObjectId))
|
||||
'CombodoPortalToolbox.OpenUrlInModal("'.$sModifyUrl.'");'
|
||||
);
|
||||
// Putting this one first
|
||||
$aData['form']['buttons']['links'][] = $oModifyButton->GetMenuItem();
|
||||
$aData['form']['buttons']['actions'][] = $oModifyButton->GetMenuItem() + array('js_files' => $oModifyButton->GetLinkedScripts());
|
||||
}
|
||||
|
||||
// Preparing response
|
||||
|
||||
@@ -70,11 +70,11 @@ class NavigationRuleHelper
|
||||
/** @var string DEFAULT_RULE_SUBMIT_PAGE */
|
||||
const DEFAULT_RULE_SUBMIT_PAGE = self::ENUM_RULE_GO_TO_OBJECT;
|
||||
/** @var string DEFAULT_RULE_SUBMIT_MODAL */
|
||||
const DEFAULT_RULE_SUBMIT_MODAL = self::DEFAULT_RULE_SUBMIT_PAGE;
|
||||
const DEFAULT_RULE_SUBMIT_MODAL = self::ENUM_RULE_CLOSE;
|
||||
/** @var string DEFAULT_RULE_CANCEL_PAGE */
|
||||
const DEFAULT_RULE_CANCEL_PAGE = self::ENUM_RULE_CLOSE;
|
||||
/** @var string DEFAULT_RULE_CANCEL_MODAL */
|
||||
const DEFAULT_RULE_CANCEL_MODAL = self::DEFAULT_RULE_CANCEL_PAGE;
|
||||
const DEFAULT_RULE_CANCEL_MODAL = self::ENUM_RULE_CLOSE;
|
||||
|
||||
// Rule go-to-object properties
|
||||
/** @var string DEFAULT_RULE_GO_TO_OBJECT_PROP_MODE */
|
||||
@@ -231,6 +231,19 @@ class NavigationRuleHelper
|
||||
// Default rules definition
|
||||
//-------------------------
|
||||
|
||||
/**
|
||||
* Return the default definition of a rule based on the $sType (close, go-to-homepage, go-to-brick, ...)
|
||||
*
|
||||
* @param string $sRuleType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetDefaultRuleDefinitionFromType($sRuleType)
|
||||
{
|
||||
$sRuleFunctionName = 'GetDefault'.utils::ToCamelCase($sRuleType).'RuleDefinition';
|
||||
return $this->$sRuleFunctionName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default definition of the "Close" rule
|
||||
*
|
||||
@@ -570,13 +583,14 @@ class NavigationRuleHelper
|
||||
switch($sButtonCode)
|
||||
{
|
||||
case 'submit':
|
||||
$aRuleDef = $this->GetDefaultGoToObjectRuleDefinition();
|
||||
$sDefaultRuleType = ($bIsCurrentFormInModal) ? static::DEFAULT_RULE_SUBMIT_MODAL : static::DEFAULT_RULE_SUBMIT_PAGE;
|
||||
break;
|
||||
|
||||
case 'cancel':
|
||||
$aRuleDef = $this->GetDefaultCloseRuleDefinition();
|
||||
$sDefaultRuleType = ($bIsCurrentFormInModal) ? static::DEFAULT_RULE_CANCEL_MODAL : static::DEFAULT_RULE_CANCEL_PAGE;
|
||||
break;
|
||||
}
|
||||
$aRuleDef = $this->GetDefaultRuleDefinitionFromType($sDefaultRuleType);
|
||||
}
|
||||
// - Specified rule
|
||||
else
|
||||
|
||||
@@ -1427,7 +1427,11 @@
|
||||
mode). Default is false. -->
|
||||
<!--<always_show_submit>false</always_show_submit>-->
|
||||
<!-- Optional, navigation rules to define where to go when clicking on the submit/cancel buttons of the form -->
|
||||
<!-- <navigation_rules / -->
|
||||
<navigation_rules>
|
||||
<submit>
|
||||
<default>go-to-open-requests</default>
|
||||
</submit>
|
||||
</navigation_rules>
|
||||
</properties>
|
||||
<fields></fields>
|
||||
<twig>
|
||||
@@ -1485,6 +1489,13 @@
|
||||
</form>
|
||||
<form id="ticket-reopen">
|
||||
<class>Ticket</class>
|
||||
<properties>
|
||||
<navigation_rules>
|
||||
<submit>
|
||||
<default>go-to-open-requests</default>
|
||||
</submit>
|
||||
</navigation_rules>
|
||||
</properties>
|
||||
<fields />
|
||||
<twig>
|
||||
<div>
|
||||
@@ -1503,6 +1514,13 @@
|
||||
</form>
|
||||
<form id="ticket-apply-stimulus">
|
||||
<class>Ticket</class>
|
||||
<properties>
|
||||
<navigation_rules>
|
||||
<submit>
|
||||
<default>go-to-open-requests</default>
|
||||
</submit>
|
||||
</navigation_rules>
|
||||
</properties>
|
||||
<fields />
|
||||
<twig />
|
||||
<modes>
|
||||
|
||||
Reference in New Issue
Block a user