Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°7371 - Remembers the choice done in the popup that appears when saving public and private logs at the same time #636

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions js/layouts/activity-panel/activity-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $(function()
lock_token: null,
lock_watcher_period: 30, // Period (in seconds) between lock status update, uses the "activity_panel.lock_watcher_period" config. param.
lock_endpoint: null,
show_multiple_entries_submit_confirmation: true,
save_state_endpoint: null,
last_loaded_entries_ids: {},
load_more_entries_endpoint: null,
Expand Down Expand Up @@ -473,8 +472,10 @@ $(function()
}

let sStimulusCode = (undefined !== oData.stimulus_code) ? oData.stimulus_code : null
// If several entry forms filled, show a confirmation message
if ((true === this.options.show_multiple_entries_submit_confirmation) && (Object.keys(await this._GetEntriesFromAllForms()).length > 1)) {
// If several entry forms filled, show a confirmation message
if ((GetUserPreference('activity_panel.show_multiple_entries_submit_confirmation',true) === true
|| GetUserPreference('activity_panel.show_multiple_entries_submit_confirmation', true) === "true")
&& (Object.keys(await this._GetEntriesFromAllForms()).length > 1)) {
this._ShowEntriesSubmitConfirmation(sStimulusCode);
}
// Else push data directly to the server
Expand Down Expand Up @@ -823,7 +824,7 @@ $(function()
// };
// }
// });

const aFormElements = this.element.find(this.js_selectors.caselog_entry_form);

// Create an array of promises for each form element
Expand Down
11 changes: 8 additions & 3 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,15 @@ function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent) {
} catch (err) {
sPreviousValue = undefined;
}
oUserPreferences[sPreferenceCode] = sPrefValue;
if (bPersistent && (sPrefValue != sPreviousValue)) {
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
{operation: 'set_pref', code: sPreferenceCode, value: sPrefValue}); // Make it persistent
return $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
{operation: 'set_pref', code: sPreferenceCode, value: sPrefValue}, function (data) {
//do nothing
}).done(function() {
oUserPreferences[sPreferenceCode] = sPrefValue;
}); // Make it persistent
Comment on lines +218 to +222
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is misleading. Making the POST call actually persist the preference, so it doesn't do "nothing" and it's not L221 that persists it (it updates local state).

} else {
oUserPreferences[sPreferenceCode] = sPrefValue;
}
}

Expand Down
16 changes: 0 additions & 16 deletions sources/Application/UI/Base/Layout/ActivityPanel/ActivityPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public function __construct(DBObject $oObject, array $aEntries = [], ?string $sI
$this->bAreEntriesSorted = false;
$this->bHasMoreEntriesToLoad = false;
$this->aLastLoadedEntriesIds = [];
$this->ComputedShowMultipleEntriesSubmitConfirmation();
}

/**
Expand Down Expand Up @@ -960,21 +959,6 @@ public function GetSubBlocks(): array
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;
}

/**
* @return bool
* @throws \CoreException
Expand Down
1 change: 0 additions & 1 deletion templates/base/layouts/activity-panel/layout.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ $('#{{ oUIBlock.GetId() }}').activity_panel({
lock_enabled: {{ oUIBlock.IsLockEnabled()|var_export }},
lock_watcher_period: {{ oUIBlock.GetLockWatcherPeriod() }},
lock_endpoint: {{ oUIBlock.GetLockEndpoint()|var_export|raw }},
show_multiple_entries_submit_confirmation: {{ oUIBlock.GetShowMultipleEntriesSubmitConfirmation()|var_export }},
save_state_endpoint: {{ oUIBlock.GetSaveStateEndpoint()|var_export|raw }},
last_loaded_entries_ids: {{ oUIBlock.GetLastEntryIds()|json_encode|raw }},
load_more_entries_endpoint: {{ oUIBlock.GetLoadMoreEntriesEndpoint()|var_export|raw }},
Expand Down