N°3649 - Activity panel: Add user pref. to define whether the entry form should be opened by default

This commit is contained in:
Molkobain
2021-03-01 23:54:21 +01:00
parent e3015a284b
commit 3b40728701
9 changed files with 76 additions and 20 deletions

View File

@@ -24,11 +24,12 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:Preferences:UserInterface:Title' => 'User interface',
'UI:Preferences:Lists:Title' => 'Lists',
'UI:Preferences:RichText:Title' => 'Rich text editor',
'UI:Preferences:ChooseAPlaceholder' => 'User placeholder image',
'UI:Preferences:ChooseAPlaceholder+' => 'Choose a placeholder image that will be displayed if the contact linked to your user doesn\'t have one',
'UI:Preferences:RichText:ToolbarState' => 'Toolbar default state',
'UI:Preferences:RichText:ToolbarState:Expanded' => 'Expanded',
'UI:Preferences:RichText:ToolbarState:Collapsed' => 'Collapsed',
'UI:Preferences:ActivityPanel:Title' => 'Activity panel',
'UI:Preferences:ActivityPanel:EntryFormOpened' => 'Entry form opened by default',
'UI:Preferences:ActivityPanel:EntryFormOpened+' => 'Whether the entry form will be opened when displaying an object. If unchecked, you will still be able to open it by clicking the compose button',
'UI:Preferences:Tabs:Title' => 'Tabs',
'UI:Preferences:Tabs:Layout:Label' => 'Layout',
'UI:Preferences:Tabs:Layout:Horizontal' => 'Horizontal',
@@ -36,4 +37,6 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:Preferences:Tabs:Scrollable:Label' => 'Navigation',
'UI:Preferences:Tabs:Scrollable:Classic' => 'Classic',
'UI:Preferences:Tabs:Scrollable:Scrollable' => 'Scrollable',
'UI:Preferences:ChooseAPlaceholder' => 'User placeholder image',
'UI:Preferences:ChooseAPlaceholder+' => 'Choose a placeholder image that will be displayed if the contact linked to your user doesn\'t have one',
));

View File

@@ -129,6 +129,8 @@ $(function()
// TODO 3.0.0: Modify PopoverMenu so we can pass it the ID of the block triggering the open/close
//$(this.element).find(this.js_selectors.send_choices_picker).popover_menu({toggler: this.js_selectors.send_button});
this.element.trigger('ready.activity_panel.itop');
},
// events bound via _bind are removed automatically
// revert other modifications here

View File

@@ -67,19 +67,16 @@ $(function() {
}
this._UpdateState();
if(this._IsSubmitAutonomous())
{
this._HideEntryForm();
if (this._IsSubmitAutonomous()) {
this._ShowMainActions();
}
else
{
} else {
this._AddBridgeInput();
this._ShowEntryForm();
this._HideMainActions();
}
this._bindEvents();
this.element.trigger('ready.caselog_entry_form.itop');
},
_bindEvents: function() {
let me = this;
@@ -271,10 +268,10 @@ $(function() {
},
// - Main actions
_ShowMainActions: function() {
this.element.find(this.js_selectors.main_actions).show();
this.element.find(this.js_selectors.main_actions).removeClass(this.css_classes.is_hidden);
},
_HideMainActions: function() {
this.element.find(this.js_selectors.main_actions).hide();
this.element.find(this.js_selectors.main_actions).addClass(this.css_classes.is_hidden);
},
_UpdateState: function() {
this._UpdateEditingVisualHint();

View File

@@ -109,6 +109,11 @@ function DisplayPreferences($oP)
$oSecondColumn->AddSubBlock($oRichTextFieldset);
$oRichTextFieldset->AddSubBlock(GetRichTextToolbarExpandedFieldBlock());
// Activity panel
$oActivityPanelfieldset = FieldSetUIBlockFactory::MakeStandard(Dict::S('UI:Preferences:ActivityPanel:Title'), 'ibo-fieldset-for-activity-panel');
$oSecondColumn->AddSubBlock($oActivityPanelfieldset);
$oActivityPanelfieldset->AddSubBlock(GetActivityPanelEntryFormOpenedFieldBlock());
// Misc. options
$oMiscOptionsFieldset = FieldSetUIBlockFactory::MakeStandard(Dict::S('UI:FavoriteOtherSettings'), 'ibo-fieldset-for-misc-options');
$oSecondColumn->AddSubBlock($oMiscOptionsFieldset);
@@ -500,6 +505,32 @@ function GetRichTextToolbarExpandedFieldBlock(): iUIBlock
return $oSelect;
}
/**
* @return \Combodo\iTop\Application\UI\Base\iUIBlock
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @since 3.0.0
*/
function GetActivityPanelEntryFormOpenedFieldBlock(): iUIBlock
{
$bOpened = appUserPreferences::GetPref('activity_panel.is_entry_form_opened', false);
$sCheckedForHtmlAttribute = $bOpened ? 'checked="checked"' : '';
$sLabel = Dict::S('UI:Preferences:ActivityPanel:EntryFormOpened');
$sLabelDescription = Dict::S('UI:Preferences:ActivityPanel:EntryFormOpened+');
$sHtml = <<<HTML
<p>
<label data-tooltip-content="{$sLabelDescription}">
<span>{$sLabel}</span>
<input type="checkbox" name="activity_panel_entry_form_opened" value="1" {$sCheckedForHtmlAttribute}>
</label>
</p>
HTML;
return new Html($sHtml);
}
/**
* @return \Combodo\iTop\Application\UI\Base\iUIBlock
* @throws \CoreException
@@ -517,8 +548,10 @@ function GetObsoleteDataFieldBlock(): iUIBlock
$sLabelDescription = Dict::S('UI:Favorites:ShowObsoleteData+');
$sHtml = <<<HTML
<p>
<input type="checkbox" id="show_obsolete_data" name="show_obsolete_data" value="1"{$sSelectedForHtmlAttribute}{$sDisabledForHtmlAttribute}>
<label for="show_obsolete_data" title="{$sLabelDescription}">{$sLabel}</label>
<label data-tooltip-content="{$sLabelDescription}">
<span>{$sLabel}</span>
<input type="checkbox" name="show_obsolete_data" value="1"{$sSelectedForHtmlAttribute}{$sDisabledForHtmlAttribute}>
</label>
</p>
HTML;
@@ -602,6 +635,10 @@ try {
$aRichTextConfig['toolbarStartupExpanded'] = $bToolbarExpanded;
appUserPreferences::SetPref('richtext_config', json_encode($aRichTextConfig));
// Activity panel
$bActivityPanelEntryFormOpened = (bool)utils::ReadParam('activity_panel_entry_form_opened', 0);
appUserPreferences::SetPref('activity_panel.is_entry_form_opened', $bActivityPanelEntryFormOpened);
// Misc.
// - Obsolete data
$bShowObsoleteData = (bool)utils::ReadParam('show_obsolete_data', 0);

View File

@@ -667,8 +667,21 @@ class ActivityPanel extends UIBlock
}
/**
* @uses $bHasStates
* @return bool True if the entry form shouldbe opened by default, false otherwise. Based on the user pref. or false by default.
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function IsEntryFormOpened(): bool
{
$bDefault = false;
return appUserPreferences::GetPref('activity_panel.is_entry_form_opened', $bDefault);
}
/**
* @return bool
* @uses $bHasStates
*/
public function HasStates(): bool
{

View File

@@ -32,6 +32,7 @@ class ActivityPanelHelper
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @throws \Exception
*/
public static function SaveExpandedStateForClass(string $sObjectClass, string $sObjectMode, bool $bIsExpanded): void
{
@@ -58,6 +59,7 @@ class ActivityPanelHelper
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @throws \Exception
*/
public static function SaveClosedStateForClass(string $sObjectClass, string $sObjectMode, bool $bIsClosed)
{

View File

@@ -1,5 +1,5 @@
<form id="{{ oUIBlock.GetId() }}"
class="ibo-caselog-entry-form {% if oUIBlock.IsSubmitAutonomous %}ibo-is-closed{% endif %}"
class="ibo-caselog-entry-form {% if oUIBlock.IsSubmitAutonomous() and (bInitOpened == false) %}ibo-is-closed{% endif %}"
data-role="ibo-caselog-entry-form"
data-object-class="{{ oUIBlock.GetObjectClass() }}"
data-object-id="{{ oUIBlock.GetObjectId() }}"

View File

@@ -65,7 +65,9 @@
</div>
</div>
{% if oUIBlock.HasAnEditableCaseLogTab() and oUIBlock.IsCaseLogsSubmitAutonomous() %}
<a href="#" class="ibo-activity-panel--add-caselog-entry-button" data-role="ibo-activity-panel--add-caselog-entry-button"
<a href="#"
class="ibo-activity-panel--add-caselog-entry-button {% if oUIBlock.IsEntryFormOpened() %}ibo-is-hidden{% endif %}"
data-role="ibo-activity-panel--add-caselog-entry-button"
data-tooltip-content="{{ 'UI:Layout:ActivityPanel:ComposeButton:Tooltip'|dict_s }}">
<i class="fas fa-feather"></i>
</a>

View File

@@ -8,8 +8,8 @@
{% block bTabToolbarFirstRow %}
{% if oUIBlock.HasCaseLogTabEntryForm(sCaseLogAttCode) %}
<div class="ibo-activity-panel--tab-entry-form" data-role="ibo-activity-panel--tab-entry-form">
{{ render_block(oUIBlock.GetCaseLogTabEntryForm(sCaseLogAttCode)) }}
</div>
{% endif %}
<div class="ibo-activity-panel--tab-entry-form" data-role="ibo-activity-panel--tab-entry-form">
{{ render_block(oUIBlock.GetCaseLogTabEntryForm(sCaseLogAttCode), {bInitOpened: oUIBlock.IsEntryFormOpened()}) }}
</div>
{% endif %}
{% endblock %}