mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
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:
@@ -9,7 +9,6 @@ namespace Combodo\iTop\Application\UI\Links;
|
||||
use ApplicationException;
|
||||
use ArchivedObjectException;
|
||||
use AttributeLinkedSet;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use CoreException;
|
||||
use CoreWarning;
|
||||
@@ -17,7 +16,6 @@ use DBObject;
|
||||
use DictExceptionMissingString;
|
||||
use DisplayBlock;
|
||||
use Exception;
|
||||
use MetaModel;
|
||||
use MySQLException;
|
||||
use Utils;
|
||||
use WebPage;
|
||||
@@ -41,6 +39,20 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
'js/wizardhelper.js',
|
||||
];
|
||||
|
||||
// Dictionnary entries
|
||||
public const BUTTON_TOOLTIP = 'UI:Links:Add:Button+';
|
||||
public const DICT_CREATE_BUTTON_TOOLTIP = 'UI:Links:Create:Button+';
|
||||
public const DICT_MODIFY_LINK_BUTTON_TOOLTIP = 'UI:Links:ModifyLink:Button+';
|
||||
public const DICT_MODIFY_LINK_MODAL_TITLE = 'UI:Links:ModifyLink:Modal:Title';
|
||||
public const DICT_MODIFY_OBJECT_BUTTON_TOOLTIP = 'UI:Links:ModifyObject:Button+';
|
||||
public const DICT_MODIFY_OBJECT_MODAL_TITLE = 'UI:Links:ModifyObject:Modal:Title';
|
||||
public const DICT_REMOVE_BUTTON_TOOLTIP = 'UI:Links:Remove:Button+';
|
||||
public const DICT_REMOVE_MODAL_TITLE = 'UI:Links:Remove:Modal:Title';
|
||||
public const DICT_REMOVE_MODAL_MESSAGE = 'UI:Links:Remove:Modal:Message';
|
||||
public const DICT_DELETE_BUTTON_TOOLTIP = 'UI:Links:Delete:Button+';
|
||||
public const DICT_DELETE_MODAL_TITLE = 'UI:Links:Delete:Modal:Title';
|
||||
public const DICT_DELETE_MODAL_MESSAGE = 'UI:Links:Delete:Modal:Message';
|
||||
|
||||
/** @var DBObject $oDbObject db object witch link set belongs to */
|
||||
protected DBObject $oDbObject;
|
||||
|
||||
@@ -99,6 +111,25 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
$this->sTargetClass = $this->GetTargetClass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param \DBObject|null $oDBObject
|
||||
*
|
||||
* @return string
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetDictionaryEntry(string $sKey, DBObject $oDBObject = null)
|
||||
{
|
||||
return $this->oAttDef->SearchSpecificLabel($sKey, '', true,
|
||||
$this->sObjectClass,
|
||||
$this->oDbObject->Get('friendlyname'),
|
||||
$this->oAttDef->GetLabel(),
|
||||
$this->sTargetClass,
|
||||
$oDBObject !== null ? $oDBObject->Get('friendlyname') : '{item}');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize UI.
|
||||
*
|
||||
|
||||
@@ -49,9 +49,12 @@ class BlockDirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
}
|
||||
|
||||
// Add creation in modal if the linkset is not readonly
|
||||
if ($this->oAttDef->GetEditMode() != LINKSET_EDITMODE_NONE) {
|
||||
$aExtraParams['creation_in_modal_is_allowed'] = true;
|
||||
if (!$this->oAttDef->GetReadOnly() && $this->oAttDef->GetEditMode() != LINKSET_EDITMODE_NONE) {
|
||||
$aExtraParams['creation_in_modal'] = true;
|
||||
$aExtraParams['creation_in_modal_tooltip'] = $this->GetDictionaryEntry(static::DICT_CREATE_BUTTON_TOOLTIP);
|
||||
$aExtraParams['creation_in_modal_js_handler'] = "{$this->GetWidgetName()}.links_view_table('CreateLinkedObject');";
|
||||
} else {
|
||||
$aExtraParams['creation_disallowed'] = true;
|
||||
}
|
||||
|
||||
return $aExtraParams;
|
||||
@@ -69,30 +72,42 @@ class BlockDirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
|
||||
case LINKSET_EDITMODE_ADDONLY: // The only possible action is to open (in a new window) the form to create a new object
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Modify',
|
||||
'tooltip' => 'UI:Links:ActionRow:Modify+',
|
||||
'label' => 'UI:Links:ModifyObject:Button',
|
||||
'name' => 'ModifyButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-pen',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw']);",
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw'], oTrElement, aRowData['{$this->sTargetClass}/friendlyname']);",
|
||||
'metadata' => [
|
||||
'modal-title' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_MODAL_TITLE),
|
||||
],
|
||||
);
|
||||
break;
|
||||
|
||||
case LINKSET_EDITMODE_INPLACE: // The whole linkset can be edited 'in-place'
|
||||
case LINKSET_EDITMODE_ACTIONS: // Show the usual 'Actions' popup menu
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Modify',
|
||||
'tooltip' => 'UI:Links:ActionRow:Modify+',
|
||||
'label' => 'UI:Links:ModifyObject:Button',
|
||||
'name' => 'ModifyButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-pen',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw']);",
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw'], oTrElement, aRowData['{$this->sTargetClass}/friendlyname']);",
|
||||
'metadata' => [
|
||||
'modal-title' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_MODAL_TITLE),
|
||||
],
|
||||
);
|
||||
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Delete',
|
||||
'tooltip' => 'UI:Links:ActionRow:Delete+',
|
||||
'label' => 'UI:Links:Delete:Button',
|
||||
'name' => 'DeleteButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_DELETE_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-trash',
|
||||
'color' => Button::ENUM_COLOR_SCHEME_DESTRUCTIVE,
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('DeleteLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw'], oTrElement);",
|
||||
'confirmation' => [
|
||||
'message' => 'UI:Links:ActionRow:Delete:Confirmation',
|
||||
'message_row_data' => "{$this->sTargetClass}/hyperlink",
|
||||
'title' => $this->GetDictionaryEntry(static::DICT_DELETE_MODAL_TITLE),
|
||||
'message' => $this->GetDictionaryEntry(static::DICT_DELETE_MODAL_MESSAGE),
|
||||
'confirm_button_class' => 'ibo-is-danger',
|
||||
'row_data' => "{$this->sTargetClass}/hyperlink",
|
||||
'do_not_show_again_pref_key' => $this->GetDoNotShowAgainPreferenceKey(),
|
||||
],
|
||||
);
|
||||
@@ -100,19 +115,25 @@ class BlockDirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
|
||||
case LINKSET_EDITMODE_ADDREMOVE: // The whole linkset can be edited 'in-place'
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Modify',
|
||||
'tooltip' => 'UI:Links:ActionRow:Modify+',
|
||||
'label' => 'UI:Links:ModifyObject:Button',
|
||||
'name' => 'ModifyButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-pen',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw']);",
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw'], oTrElement, aRowData['{$this->sTargetClass}/friendlyname']);",
|
||||
'metadata' => [
|
||||
'modal-title' => $this->GetDictionaryEntry(static::DICT_MODIFY_OBJECT_MODAL_TITLE),
|
||||
],
|
||||
);
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Detach',
|
||||
'tooltip' => 'UI:Links:ActionRow:Detach+',
|
||||
'label' => 'UI:Links:Remove:Button',
|
||||
'name' => 'RemoveButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_REMOVE_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-minus',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('DetachLinkedObject', aRowData['{$this->sTargetClass}/_key_/raw'], oTrElement);",
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('DetachLinkedObject', aRowData['{$this->sTargetClass}/_key_/raw'], oTrElement, oTrElement);",
|
||||
'confirmation' => [
|
||||
'message' => 'UI:Links:ActionRow:Detach:Confirmation',
|
||||
'message_row_data' => "{$this->sTargetClass}/hyperlink",
|
||||
'title' => $this->GetDictionaryEntry(static::DICT_REMOVE_MODAL_TITLE),
|
||||
'message' => $this->GetDictionaryEntry(static::DICT_REMOVE_MODAL_MESSAGE),
|
||||
'row_data' => "{$this->sTargetClass}/hyperlink",
|
||||
'do_not_show_again_pref_key' => $this->GetDoNotShowAgainPreferenceKey(),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
namespace Combodo\iTop\Application\UI\Links\Indirect;
|
||||
|
||||
use Combodo\iTop\Application\UI\Links\AbstractBlockLinkSetViewTable;
|
||||
use Combodo\iTop\Service\Links\LinkSetModel;
|
||||
use MetaModel;
|
||||
use PHPUnit\Exception;
|
||||
|
||||
@@ -50,9 +49,9 @@ class BlockIndirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
'zlist' => false,
|
||||
'extra_fields' => $this->GetAttCodesToDisplay(),
|
||||
'row_actions' => $this->GetRowActions(),
|
||||
'currentId' => $this->GetTableId(),
|
||||
'panel_title' => $this->oAttDef->GetLabel(),
|
||||
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
|
||||
'currentId' => $this->GetTableId(),
|
||||
'panel_title' => $this->oAttDef->GetLabel(),
|
||||
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
|
||||
);
|
||||
|
||||
// Description
|
||||
@@ -62,9 +61,11 @@ class BlockIndirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
|
||||
// Add creation in modal if the linkset is not readonly
|
||||
if (!$this->oAttDef->GetReadOnly()) {
|
||||
$sHostClass = get_class($this->oDbObject);
|
||||
$aExtraParams['creation_in_modal_is_allowed'] = true;
|
||||
$aExtraParams['creation_in_modal'] = true;
|
||||
$aExtraParams['creation_in_modal_tooltip'] = $this->GetDictionaryEntry(static::BUTTON_TOOLTIP);
|
||||
$aExtraParams['creation_in_modal_js_handler'] = "{$this->GetWidgetName()}.links_view_table('CreateLinkedObject');";
|
||||
} else {
|
||||
$aExtraParams['creation_disallowed'] = true;
|
||||
}
|
||||
|
||||
return $aExtraParams;
|
||||
@@ -76,20 +77,26 @@ class BlockIndirectLinkSetViewTable extends AbstractBlockLinkSetViewTable
|
||||
$aRowActions = array();
|
||||
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Modify',
|
||||
'tooltip' => 'UI:Links:ActionRow:Modify+',
|
||||
'label' => 'UI:Links:ModifyLink:Button',
|
||||
'name' => 'ModifyButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_MODIFY_LINK_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-pen',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['Link/_key_/raw']);",
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('ModifyLinkedObject', aRowData['Link/_key_/raw'], oTrElement, aRowData['Remote/friendlyname']);",
|
||||
'metadata' => [
|
||||
'modal-title' => $this->GetDictionaryEntry(static::DICT_MODIFY_LINK_MODAL_TITLE),
|
||||
],
|
||||
);
|
||||
|
||||
$aRowActions[] = array(
|
||||
'label' => 'UI:Links:ActionRow:Detach',
|
||||
'tooltip' => 'UI:Links:ActionRow:Detach+',
|
||||
'label' => 'UI:Links:Remove:Button',
|
||||
'name' => 'RemoveButton',
|
||||
'tooltip' => $this->GetDictionaryEntry(static::DICT_REMOVE_BUTTON_TOOLTIP),
|
||||
'icon_classes' => 'fas fa-minus',
|
||||
'js_row_action' => "{$this->GetWidgetName()}.links_view_table('DeleteLinkedObject', aRowData['Link/_key_/raw'], oTrElement);",
|
||||
'confirmation' => [
|
||||
'message' => 'UI:Links:ActionRow:Detach:Confirmation',
|
||||
'message_row_data' => "Remote/hyperlink",
|
||||
'title' => $this->GetDictionaryEntry(static::DICT_REMOVE_MODAL_TITLE),
|
||||
'message' => $this->GetDictionaryEntry(static::DICT_REMOVE_MODAL_MESSAGE),
|
||||
'row_data' => "Remote/hyperlink",
|
||||
'do_not_show_again_pref_key' => $this->GetDoNotShowAgainPreferenceKey(),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user