N°3649 - Activity panel: Show confirmation dialog on multiple case logs entries submission

This commit is contained in:
Molkobain
2021-02-03 22:07:32 +01:00
parent 4a2cbc9be3
commit 40c112d47a
7 changed files with 180 additions and 22 deletions

View File

@@ -20,6 +20,7 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel;
use appUserPreferences;
use AttributeDateTime;
use cmdbAbstractObject;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry;
@@ -48,6 +49,12 @@ class ActivityPanel extends UIBlock
'js/layouts/activity-panel/activity-panel.js',
];
/**
* @var bool
* @see static::$bShowMultipleEntriesSubmitConfirmation
*/
public const DEFAULT_SHOW_MULTIPLE_ENTRIES_SUBMI_CONFIRMATION = true;
/** @var \DBObject $oObject The object for which the activity panel is for */
protected $oObject;
/**
@@ -68,6 +75,8 @@ class ActivityPanel extends UIBlock
protected $bHasStates;
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\CaseLogEntryForm\CaseLogEntryForm[] $aCaseLogTabsEntryForms */
protected $aCaseLogTabsEntryForms;
/** @var bool Whether a confirmation dialog should be prompt when multiple entries are about to be submitted at once */
protected $bShowMultipleEntriesSubmitConfirmation;
/**
* ActivityPanel constructor.
@@ -89,6 +98,7 @@ class ActivityPanel extends UIBlock
$this->SetObjectMode(cmdbAbstractObject::DEFAULT_OBJECT_MODE);
$this->SetEntries($aEntries);
$this->bAreEntriesSorted = false;
$this->ComputedShowMultipleEntriesSubmitConfirmation();
}
/**
@@ -550,6 +560,15 @@ class ActivityPanel extends UIBlock
return !empty($this->aCaseLogTabsEntryForms[$sCaseLogId]);
}
/**
* @uses static::$bShowMultipleEntriesSubmitConfirmation
* @return bool
*/
public function GetShowMultipleEntriesSubmitConfirmation(): bool
{
return $this->bShowMultipleEntriesSubmitConfirmation;
}
/**
* Whether the submission of the case logs present in the activity panel is autonomous or will be handled by another form
*
@@ -609,4 +628,19 @@ class ActivityPanel extends UIBlock
return $aSubBlocks;
}
/**
* @see static::$bShowMultipleEntriesSubmitConfirmation
* @return $this
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
protected function ComputedShowMultipleEntriesSubmitConfirmation()
{
// Note: Test on a string is necessary as we can only store strings from the JS API, not booleans.
// Note 2: Do not invert the test to "=== 'true'" as it won't work. Default value is a bool ("true"), values from the DB are strings (true|false)
$this->bShowMultipleEntriesSubmitConfirmation = appUserPreferences::GetPref('activity_panel.show_multiple_entries_submit_confirmation', static::DEFAULT_SHOW_MULTIPLE_ENTRIES_SUBMI_CONFIRMATION) !== 'false';
return $this;
}
}