N°6154 N°6219 - Relations Read - tooltip, confirmation title and message (#486)

N°6154 - n:n Read - tooltip, confirmation title and message on Add-Edit-Remove
N°6219 - 1:n Read: tooltip, modal title and message on Add-Edit-Remove-Delete
This commit is contained in:
bdalsass
2023-04-28 14:43:53 +02:00
committed by GitHub
parent 269c1bf005
commit de35d941c1
28 changed files with 461 additions and 254 deletions

View File

@@ -1844,7 +1844,12 @@ class MenuBlock extends DisplayBlock
$iSetCount = $oSet->Count();
/** @var string $sRefreshAction JS snippet to run when clicking on the refresh button of the menu */
$sRefreshAction = $aExtraParams['refresh_action'] ?? '';
$bIsCreationInModalAllowed = isset($aExtraParams['creation_in_modal_is_allowed']) && $aExtraParams['creation_in_modal_is_allowed'] === true;
$bIsCreationInModal = isset($aExtraParams['creation_in_modal']) && $aExtraParams['creation_in_modal'] === true;
$bIsCreationDisallowed = isset($aExtraParams['creation_disallowed']) && $aExtraParams['creation_disallowed'] === true;
// Check rights
$oReflectionClass = new ReflectionClass($sClass);
$bIsCreationAllowed = (!$bIsCreationDisallowed && UserRights::IsActionAllowed($sClass, UR_ACTION_CREATE) === UR_ALLOWED_YES) && ($oReflectionClass->IsSubclassOf('cmdbAbstractObject'));
/** @var array $aRegularActions Any action other than a transition */
$aRegularActions = [];
@@ -1860,7 +1865,7 @@ class MenuBlock extends DisplayBlock
$sContext = '&'.$sContext;
}
$oReflectionClass = new ReflectionClass($sClass);
$sFilter = $this->GetFilter()->serialize();
$sUIPage = cmdbAbstractObject::ComputeStandardUIPage($sClass);
$sRootUrl = utils::GetAbsoluteUrlAppRoot();
@@ -1880,10 +1885,6 @@ class MenuBlock extends DisplayBlock
}
}
// Check rights
$bIsCreationAllowed = (UserRights::IsActionAllowed($sClass, UR_ACTION_CREATE) === UR_ALLOWED_YES) && ($oReflectionClass->IsSubclassOf('cmdbAbstractObject'));
$bIsModifyAllowed = (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet) === UR_ALLOWED_YES) && ($oReflectionClass->IsSubclassOf('cmdbAbstractObject'));
// Check concurrent lock (can only be lock if we are handling a single object
$bLocked = false;
if ($iSetCount === 1) {
@@ -1905,7 +1906,7 @@ class MenuBlock extends DisplayBlock
//--------------------------------------------
// Create in new tab
if ($bIsCreationAllowed && !$bIsCreationInModalAllowed) {
if ($bIsCreationAllowed && !$bIsCreationInModal) {
$this->AddNewObjectMenuAction($aRegularActions, $sClass, $sDefaultValuesAsUrlParams);
}
@@ -2308,10 +2309,13 @@ class MenuBlock extends DisplayBlock
}
// - Creation in modal
if ($bIsCreationInModalAllowed === true) {
if ($bIsCreationAllowed && $bIsCreationInModal) {
$oAddLinkActionButton = ButtonUIBlockFactory::MakeIconAction(
'fas fa-plus',
Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass)),
// Allow button tooltip customization
array_key_exists('creation_in_modal_tooltip', $aExtraParams) ?
$aExtraParams['creation_in_modal_tooltip'] :
Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass)),
'UI:Links:New',
'',
false