From 3b4072870170eecd4f1ae126c5c73a81b6d3717f Mon Sep 17 00:00:00 2001
From: Molkobain
Date: Mon, 1 Mar 2021 23:54:21 +0100
Subject: [PATCH] =?UTF-8?q?N=C2=B03649=20-=20Activity=20panel:=20Add=20use?=
=?UTF-8?q?r=20pref.=20to=20define=20whether=20the=20entry=20form=20should?=
=?UTF-8?q?=20be=20opened=20by=20default?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pages/en.dictionary.itop.preferences.php | 7 +++-
js/layouts/activity-panel/activity-panel.js | 2 +
.../activity-panel/caselog-entry-form.js | 15 +++----
pages/preferences.php | 41 ++++++++++++++++++-
.../Layout/ActivityPanel/ActivityPanel.php | 15 ++++++-
.../ActivityPanel/ActivityPanelHelper.php | 2 +
.../caselog-entry-form/layout.html.twig | 2 +-
.../layouts/activity-panel/layout.html.twig | 4 +-
.../tab-toolbar/caselog.html.twig | 8 ++--
9 files changed, 76 insertions(+), 20 deletions(-)
diff --git a/dictionaries/ui/pages/en.dictionary.itop.preferences.php b/dictionaries/ui/pages/en.dictionary.itop.preferences.php
index 90473b612..8f0a2b0d7 100644
--- a/dictionaries/ui/pages/en.dictionary.itop.preferences.php
+++ b/dictionaries/ui/pages/en.dictionary.itop.preferences.php
@@ -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',
));
diff --git a/js/layouts/activity-panel/activity-panel.js b/js/layouts/activity-panel/activity-panel.js
index 9b4f0f93f..95c1e666d 100644
--- a/js/layouts/activity-panel/activity-panel.js
+++ b/js/layouts/activity-panel/activity-panel.js
@@ -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
diff --git a/js/layouts/activity-panel/caselog-entry-form.js b/js/layouts/activity-panel/caselog-entry-form.js
index 61dac1e06..7b6ac2196 100644
--- a/js/layouts/activity-panel/caselog-entry-form.js
+++ b/js/layouts/activity-panel/caselog-entry-form.js
@@ -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();
diff --git a/pages/preferences.php b/pages/preferences.php
index 8cfae5763..b223945c0 100644
--- a/pages/preferences.php
+++ b/pages/preferences.php
@@ -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;
+
+ 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;
@@ -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);
diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php
index 1cead5895..cd1f0a539 100644
--- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php
+++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php
@@ -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
{
diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelHelper.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelHelper.php
index 60c767fdf..1d2932281 100644
--- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelHelper.php
+++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanelHelper.php
@@ -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)
{
diff --git a/templates/base/layouts/activity-panel/caselog-entry-form/layout.html.twig b/templates/base/layouts/activity-panel/caselog-entry-form/layout.html.twig
index 98f2b7104..8cde8d0f8 100644
--- a/templates/base/layouts/activity-panel/caselog-entry-form/layout.html.twig
+++ b/templates/base/layouts/activity-panel/caselog-entry-form/layout.html.twig
@@ -1,5 +1,5 @@