N°3649 - Activity panel: Remove entry form from the activity tab, only case log tabs will have one

This commit is contained in:
Molkobain
2021-01-20 17:10:39 +01:00
parent 16ca856996
commit cebc51e045
5 changed files with 19 additions and 117 deletions

View File

@@ -63,8 +63,6 @@ class ActivityPanel extends UIBlock
protected $bAreEntriesSorted;
/** @var bool $bHasLifecycle True if the host object has a lifecycle */
protected $bHasLifecycle;
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\CaseLogEntryForm\CaseLogEntryForm $oActivityTabEntryForm New entry form for the activity tab which is different from the case log tabs */
protected $oActivityTabEntryForm;
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\CaseLogEntryForm\CaseLogEntryForm[] $aCaseLogTabsEntryForms */
protected $aCaseLogTabsEntryForms;
@@ -532,6 +530,23 @@ class ActivityPanel extends UIBlock
return !empty($this->aCaseLogTabsEntryForms[$sCaseLogId]);
}
/**
* Whether the submission of the case logs present in the activity panel is autonomous or will be handled by another form
*
* @return bool
*/
public function IsCaseLogsSubmitAutonomous(): bool
{
$bIsAutonomous = true;
foreach ($this->GetCaseLogTabsEntryForms() as $oCaseLogEntryForm) {
$bIsAutonomous = $oCaseLogEntryForm->IsSubmitAutonomous();
break;
}
return $bIsAutonomous;
}
/**
* Return true if the host object has a lifecycle
*
@@ -554,42 +569,6 @@ class ActivityPanel extends UIBlock
return $oDateTimeFormat->ToMomentJS();
}
/**
* Return the entry form for the activity tab
*
* @see $oActivityTabEntryForm
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\CaseLogEntryForm\CaseLogEntryForm
*/
public function GetActivityTabEntryForm(): CaseLogEntryForm
{
return $this->oActivityTabEntryForm;
}
/**
* Set the entry form for the activity tab
*
* @param \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\CaseLogEntryForm\CaseLogEntryForm $oCaseLogEntryForm
* @see $oActivityTabEntryForm
*
* @return $this
*
*/
public function SetActivityTabEntryForm(CaseLogEntryForm $oCaseLogEntryForm)
{
$this->oActivityTabEntryForm = $oCaseLogEntryForm;
return $this;
}
/**
* Return true is there is an entry form for the activity tab
*
* @return bool
*/
public function HasActivityTabEntryForm()
{
return $this->oActivityTabEntryForm !== null;
}
/**
* @inheritdoc
*/
@@ -601,11 +580,6 @@ class ActivityPanel extends UIBlock
$aSubBlocks[$oCaseLogEntryForm->GetId()] = $oCaseLogEntryForm;
}
if ($this->HasActivityTabEntryForm()) {
$oNewEntryForm = $this->GetActivityTabEntryForm();
$aSubBlocks[$oNewEntryForm->GetId()] = $oNewEntryForm;
}
return $aSubBlocks;
}
}

View File

@@ -90,12 +90,6 @@ class ActivityPanelFactory
}
}
// Activity tab entry form is only in view mode
// As caselog tabs input will be attached to the main object form and submit button hidden, we can't have an entry form in the activity tab as it's not for a specific caselog
if($sMode === cmdbAbstractObject::ENUM_OBJECT_MODE_VIEW) {
$oActivityPanel->SetActivityTabEntryForm(CaseLogEntryFormFactory::MakeForActivityTab($oObject, $sMode));
}
// Retrieve history changes (including case logs entries)
// - Prepare query to retrieve changes
$oChangesSearch = DBObjectSearch::FromOQL('SELECT CMDBChangeOp WHERE objclass = :obj_class AND objkey = :obj_key');

View File

@@ -43,18 +43,6 @@ class CaseLogEntryFormFactory
return $oCaseLogEntryForm;
}
public static function MakeForActivityTab(DBObject $oObject, string $sObjectMode = cmdbAbstractObject::DEFAULT_OBJECT_MODE)
{
$oCaseLogEntryForm = new CaseLogEntryForm();
$oCaseLogEntryForm->SetSubmitModeFromHostObjectMode($sObjectMode)
->AddMainActionButtons(static::PrepareCancelButton())
->AddMainActionButtons(static::PrepareSendButton()->SetLabel(Dict::S('UI:Button:AddEntryToWithChoice')));
$oCaseLogEntryForm->SetSendButtonPopoverMenu(static::PrepareTargetCaseLogSelectionPopoverMenu($oObject));
return $oCaseLogEntryForm;
}
/**
* @return \Combodo\iTop\Application\UI\Base\Component\Button\Button
*/
@@ -122,43 +110,6 @@ JS
}
}
return $oMenu;
}
/**
* Return a PopoverMenu with the list of the caselog attributes of $oObject
*
* @param \DBObject $oObject
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu
* @throws \CoreException
* @throws \Exception
*/
protected static function PrepareTargetCaseLogSelectionPopoverMenu(DBObject $oObject): PopoverMenu
{
$sObjClass = get_class($oObject);
$oMenu = new PopoverMenu();
$sSectionId = 'target-caselogs';
$oMenu->AddSection($sSectionId);
$sCaseLogEntryFormDataRole = CaseLogEntryForm::BLOCK_CODE;
foreach(MetaModel::GetCaseLogs($sObjClass) as $sCaseLogAttCode) {
$oMenuItem = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
CaseLogEntryForm::BLOCK_CODE.'--target-caselog--'.$sCaseLogAttCode,
MetaModel::GetLabel($sObjClass, $sCaseLogAttCode),
<<<JS
$(this).closest('[data-role="{$sCaseLogEntryFormDataRole}"]').trigger('add_to_caselog.caselog_entry_form.itop', {caselog_att_code: '{$sCaseLogAttCode}'});
JS
)
);
$oMenu->AddItem($sSectionId, $oMenuItem);
}
return $oMenu;
}
}

View File

@@ -81,18 +81,11 @@
</label>
</div>
</div>
{% if oUIBlock.HasActivityTabEntryForm() %}
<div class="ibo-activity-panel--tab-toggler-entry-form" data-role="ibo-activity-panel--tab-toggler-entry-form">
{{ render_block(oUIBlock.GetActivityTabEntryForm()) }}
</div>
{% endif %}
</div>
</div>
</div>
{% if oUIBlock.HasActivityTabEntryForm() %}
{% if oUIBlock.GetActivityTabEntryForm().IsSubmitAutonomous() %}
<a href="#" class="ibo-activity-panel--body--add-caselog-entry--toggler" data-role="ibo-activity-panel--body--add-caselog-entry--toggler"><i class="fas fa-feather"></i></a>
{% endif %}
{% if oUIBlock.IsCaseLogsSubmitAutonomous() %}
<a href="#" class="ibo-activity-panel--body--add-caselog-entry--toggler" data-role="ibo-activity-panel--body--add-caselog-entry--toggler"><i class="fas fa-feather"></i></a>
{% endif %}
<div class="ibo-activity-panel--body">
{% if oUIBlock.GetGroupedEntries()|length > 0 %}

View File

@@ -35,19 +35,9 @@
</label>
</div>
</div>
{% if oUIBlock.HasActivityTabEntryForm() %}
<div class="ibo-activity-panel--tab-toggler-entry-form" data-role="ibo-activity-panel--tab-toggler-entry-form">
{{ render_block(oUIBlock.GetActivityTabEntryForm()) }}
</div>
{% endif %}
</div>
</div>
</div>
{% if oUIBlock.HasActivityTabEntryForm() %}
{% if oUIBlock.GetActivityTabEntryForm().IsSubmitAutonomous() %}
<a href="#" class="ibo-activity-panel--body--add-caselog-entry--toggler" data-role="ibo-activity-panel--body--add-caselog-entry--toggler"><i class="fas fa-feather"></i></a>
{% endif %}
{% endif %}
<div class="ibo-activity-panel--body">
{% if oUIBlock.GetGroupedEntries()|length > 0 %}
{% for aEntryGroup in oUIBlock.GetGroupedEntries() %}