N°2844 - Fix object panel layout during a transition

This commit is contained in:
Molkobain
2020-12-22 16:32:43 +01:00
parent 27eb3a8509
commit 874bf38316
6 changed files with 102 additions and 66 deletions

View File

@@ -237,18 +237,18 @@ EOF
}
/**
* @param \WebPage $oPage
* @param bool $bEditMode
* @param \WebPage $oPage
* @param bool $bEditMode
* @param string $sMode Mode in which the object is displayed (see static::ENUM_OBJECT_MODE_XXX)
*
* @throws \ApplicationException
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \DictExceptionMissingString
* @throws \MySQLException
* @throws \OQLException
* @throws \Exception
*/
public function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
public function DisplayBareHeader(WebPage $oPage, $bEditMode = false, $sMode = self::ENUM_OBJECT_MODE_VIEW)
{
// Standard Header with name, actions menu and history block
//
@@ -301,7 +301,7 @@ EOF
}
}
if (!$oPage->IsPrintableVersion())
if (!$oPage->IsPrintableVersion() && ($sMode === static::ENUM_OBJECT_MODE_VIEW))
{
// action menu
$oSingletonFilter = new DBObjectSearch(get_class($this));
@@ -989,8 +989,11 @@ EOF
/**
* @param \WebPage $oPage
* @param bool $bEditMode
* @param bool $bEditMode
* @param string $sMode Mode in which the object will be displayed (see static::ENUM_OBJECT_MODE_XXX)
*
* @throws \ApplicationException
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \DictExceptionMissingString
@@ -998,13 +1001,11 @@ EOF
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
* @throws \OQLException
* @throws \Exception
*/
public function DisplayDetails(WebPage $oPage, $bEditMode = false)
public function DisplayDetails(WebPage $oPage, $bEditMode = false, $sMode = self::ENUM_OBJECT_MODE_VIEW)
{
$sClass = get_class($this);
$iKey = $this->GetKey();
$sMode = static::ENUM_OBJECT_MODE_VIEW;
$oPage->add(<<<HTML
<!-- Beginning of object-details -->
@@ -1013,7 +1014,7 @@ HTML
);
/** @var \iTopWebPage $oPage */
$this->DisplayBareHeader($oPage, $bEditMode);
$this->DisplayBareHeader($oPage, $bEditMode, $sMode);
// Object's details
// TODO 3.0.0: Complete the factory and use it in the different methods (DisplayModifyForm, DisplayTransitionForm), see N°3518
$oObjectDetails = ObjectFactory::MakeDetails($this);
@@ -2852,8 +2853,9 @@ EOF
/**
* @param \WebPage $oPage
* @param string $sStimulus
* @param null $aPrefillFormParam
* @param string $sStimulus
* @param null $aPrefillFormParam
* @param bool $bDisplayBareProperties Whether to display the object details or not
*
* @throws \ApplicationException
* @throws \ArchivedObjectException
@@ -2863,12 +2865,14 @@ EOF
* @throws \MissingQueryArgument
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
* @throws \OQLException
*/
public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormParam = null, $bDisplayBareProperties = true)
{
$sClass = get_class($this);
$iKey = $this->GetKey();
$sMode = static::ENUM_OBJECT_MODE_STIMULUS;
$iTransactionId = utils::GetNewTransactionId();
$aTransitions = $this->EnumTransitions();
$aStimuli = MetaModel::EnumStimuli($sClass);
@@ -2906,17 +2910,6 @@ EOF
$sCurrentState = $this->GetState();
$sTargetState = $aTransitions[$sStimulus]['target_state'];
$oPage->set_title($sActionLabel);
$oPage->add(<<<HTML
<!-- Beginning of object-details -->
<div class="object-details" data-object-class="$sClass" data-object-id="$iKey" data-object-mode="$sMode" data-object-current-state="$sCurrentState" data-object-target-state="$sTargetState">
<div class="page_header">
<h1>$sActionLabel - <span class="hilite">{$this->GetName()}</span></h1>
</div>
<h1>$sActionDetails</h1>
HTML
);
$aExpectedAttributes = $this->GetTransitionAttributes($sStimulus /*, current state*/);
if ($aPrefillFormParam != null)
{
@@ -2924,19 +2917,12 @@ HTML
$this->PrefillForm('state_change', $aPrefillFormParam);
$aExpectedAttributes = $aPrefillFormParam['expected_attributes'];
}
$sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
if ($sButtonsPosition == 'bottom' && $bDisplayBareProperties)
{
// bottom: Displays the ticket details BEFORE the actions
$oPage->add('<div class="ui-widget-content">');
$this->DisplayBareProperties($oPage);
$oPage->add('</div>');
}
$oPage->add("<div class=\"wizContainer\">\n");
$oPage->add("<form id=\"apply_stimulus\" method=\"post\" enctype=\"multipart/form-data\" onSubmit=\"return OnSubmit('apply_stimulus');\">\n");
$aDetails = array();
$iFieldIndex = 0;
$aFieldsMap = array();
$aFieldsMap = [
'id' => 'id',
];
// The list of candidate fields is made of the ordered list of "details" attributes + other attributes
$aAttributes = array();
@@ -3039,37 +3025,70 @@ HTML
}
}
$oPage->add('<table><tr><td>');
$oPage->details($aDetails);
$oPage->add('</td></tr></table>');
$oPage->add("<input type=\"hidden\" name=\"id\" value=\"".$this->GetKey()."\" id=\"id\">\n");
$aFieldsMap['id'] = 'id';
$oPage->add("<input type=\"hidden\" name=\"class\" value=\"$sClass\">\n");
$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"apply_stimulus\">\n");
$oPage->add("<input type=\"hidden\" name=\"stimulus\" value=\"$sStimulus\">\n");
$iTransactionId = utils::GetNewTransactionId();
$oPage->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".$iTransactionId."\">\n");
if ($sOwnershipToken !== null)
{
$oPage->add("<input type=\"hidden\" name=\"ownership_token\" value=\"".htmlentities($sOwnershipToken,
ENT_QUOTES, 'UTF-8')."\">\n");
}
$oAppContext = new ApplicationContext();
$oPage->add($oAppContext->GetForForm());
$oPage->add("<button type=\"button\" class=\"action cancel\" onClick=\"BackToDetails('$sClass', ".$this->GetKey().", '', '$sOwnershipToken')\"><span>".Dict::S('UI:Button:Cancel')."</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n");
$oPage->add("<button type=\"submit\" class=\"action\"><span>$sActionLabel</span></button>\n");
$oPage->add("</form>\n");
$oPage->set_title($sActionLabel);
$oPage->add(<<<HTML
</div>
</div><!-- End of object-details -->
<!-- Beginning of object-transition -->
<div class="object-transition" data-object-class="$sClass" data-object-id="$iKey" data-object-mode="$sMode" data-object-current-state="$sCurrentState" data-object-target-state="$sTargetState">
HTML
);
// Page title and subtitles
$oPage->AddUiBlock(TitleFactory::MakeForPage($sActionLabel.' - '.$this->GetName()));
if(!empty($sActionDetails)) {
$oPage->AddUiBlock(TitleFactory::MakeForPage($sActionDetails));
}
$sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
// Display object detail above if buttons must be displayed on the bottom
if ($sButtonsPosition == 'bottom' && $bDisplayBareProperties)
{
// bottom: Displays the ticket details BEFORE the actions
$this->DisplayDetails($oPage, false, $sMode);
}
$oFormContainer = new UIContentBlock(null, 'ibo-wizard-container');
$oPage->AddUiBlock($oFormContainer);
$oForm = new Combodo\iTop\Application\UI\Base\Component\Form\Form('apply_stimulus');
$oFormContainer->AddSubBlock($oForm);
$oForm->SetOnSubmitJsCode("return OnSubmit('apply_stimulus');")
->AddSubBlock(InputFactory::MakeForHidden('id', $this->GetKey(), 'id'))
->AddSubBlock(InputFactory::MakeForHidden('class', $sClass))
->AddSubBlock(InputFactory::MakeForHidden('operation', 'apply_stimulus'))
->AddSubBlock(InputFactory::MakeForHidden('stimulus', $sStimulus))
->AddSubBlock(InputFactory::MakeForHidden('transaction_id', $iTransactionId));
if ($sOwnershipToken !== null)
{
$oForm->AddSubBlock(InputFactory::MakeForHidden('ownership_token', utils::HtmlEntities($sOwnershipToken)));
}
// Note: Remove the table is we want fields to occupy the whole width of the container
$oForm->AddHtml('<table><tr><td>');
$oForm->AddHtml($oPage->GetDetails($aDetails));
$oForm->AddHtml('</td></tr></table>');
$oAppContext = new ApplicationContext();
$oForm->AddHtml($oAppContext->GetForForm());
$oCancelButton = ButtonFactory::MakeForSecondaryAction(Dict::S('UI:Button:Cancel'), 'cancel', 'cancel');
$oCancelButton->SetOnClickJsCode("BackToDetails('{$sClass}', '{$this->GetKey()}', '', '{$sOwnershipToken}');");
$oForm->AddSubBlock($oCancelButton);
$oSubmitButton = ButtonFactory::MakeForPrimaryAction($sActionLabel, 'submit', 'submit', true);
$oForm->AddSubBlock($oSubmitButton);
$oPage->add(<<<HTML
<!-- End of object-transition -->
</div>
HTML
);
// Display object detail below if buttons must be displayed on the top
if ($sButtonsPosition != 'top' && $bDisplayBareProperties)
{
// bottom or both: Displays the ticket details AFTER the actions
$oPage->add('<div class="ui-widget-content">');
$this->DisplayBareProperties($oPage);
$oPage->add('</div>');
$this->DisplayDetails($oPage, false, $sMode);
}
$iFieldsCount = count($aFieldsMap);

View File

@@ -24,6 +24,7 @@
@import "multi-column/multi-column";
@import "multi-column/column";
@import "dashboard/dashboard";
@import "wizard-container/wizard-container";
@import "object-details";
@import "activity-panel/activity-panel";
@import "activity-panel/activity-entry";

View File

@@ -16,7 +16,7 @@
position: absolute;
margin-top: 16px;
}
.object-details .ibo-title .ibo-title--content {
.object-details .ibo-title.ibo-has-icon .ibo-title--content {
margin-left: calc(90px + 32px);
}
.object-details .ibo-panel {

View File

@@ -0,0 +1,16 @@
/*!
* @copyright Copyright (C) 2010-2020 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
$ibo-wizard-container--padding: 10px 16px !default;
$ibo-wizard-container--background-color: $ibo-color-blue-200 !default;
$ibo-wizard-container--border-color: $ibo-color-blue-600 !default;
$ibo-wizard-container--border-width: 3px !default;
.ibo-wizard-container {
padding: $ibo-wizard-container--padding;
background: $ibo-wizard-container--background-color;
border-radius: $ibo-border-radius-300;
border-left: $ibo-wizard-container--border-width solid $ibo-wizard-container--border-color;
}

View File

@@ -801,18 +801,18 @@ class WebPage implements Page
// - Value raw
$sDataValueRaw = isset($aAttrib['value_raw']) ? 'data-value-raw="'.utils::HtmlEntities($aAttrib['value_raw']).'"' : '';
$sHtml .= "<div class=\"field_container field_{$sLayout}\" $sDataAttributeCode $sDataAttributeType $sDataAttributeLabel $sDataAttributeFlags $sDataValueRaw>\n";
$sHtml .= "<div class=\"field_label label\">{$aAttrib['label']}</div>\n";
$sHtml .= "<div class=\"ibo-field ibo-field-{$sLayout}\" $sDataAttributeCode $sDataAttributeType $sDataAttributeLabel $sDataAttributeFlags $sDataValueRaw>\n";
$sHtml .= "<div class=\"ibo-field--label\">{$aAttrib['label']}</div>\n";
$sHtml .= "<div class=\"field_data\">\n";
// By Rom, for csv import, proposed to show several values for column selection
if (is_array($aAttrib['value']))
{
$sHtml .= "<div class=\"field_value\">".implode("</div><div>", $aAttrib['value'])."</div>\n";
$sHtml .= "<div class=\"ibo-field--value\">".implode("</div><div>", $aAttrib['value'])."</div>\n";
}
else
{
$sHtml .= "<div class=\"field_value\">".$aAttrib['value']."</div>\n";
$sHtml .= "<div class=\"ibo-field--value\">".$aAttrib['value']."</div>\n";
}
// Checking if we should add comments & infos
$sComment = (isset($aAttrib['comments'])) ? $aAttrib['comments'] : '';

View File

@@ -1,5 +1,5 @@
{% apply spaceless %}
<div class="ibo-title">
<div class="ibo-title {% if oUIBlock.HasIcon() %}ibo-has-icon{% endif %}">
{% if oUIBlock.HasIcon() %}
<div class="ibo-title--medallion">
<img class="ibo-title--icon ibo-title--icon--must-{{ oUIBlock.GetIconCoverMethod() }}" src="{{ oUIBlock.GetIconUrl() }}">