MDL-77276 mod_data: Update reset single template string

When a single template is reset, the string displayed in the modal should
not reference to "all templates" to avoid confusion, as it was shown in the
original prototype for the 4.1 database project.
This commit is contained in:
Sara Arjona 2023-02-17 11:55:45 +01:00
parent 9ee4f8db8b
commit 529faa9eaa
6 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,6 @@ define("mod_data/templateseditor",["exports","core/str","core/prefetch","core/ur
* @module mod_data/templateseditor
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj},(0,_prefetch.prefetchStrings)("admin",["confirmation"]),(0,_prefetch.prefetchStrings)("mod_data",["resettemplateconfirmtitle","resettemplateconfirm","enabletemplateeditorcheck","editorenable"]),(0,_prefetch.prefetchStrings)("core",["reset"]);const selectors_toggleTemplateEditor='input[name="useeditor"]',selectors_resetTemplate='input[name="defaultform"]',selectors_resetAllTemplates='input[name="resetall"]',selectors_resetButton='input[name="resetbutton"]',selectors_resetAllCheck='input[name="resetallcheck"]',selectors_editForm="#edittemplateform",registerResetButton=()=>{const editForm=document.querySelector(selectors_editForm),resetButton=document.querySelector(selectors_resetButton),resetTemplate=document.querySelector(selectors_resetTemplate),resetAllTemplates=document.querySelector(selectors_resetAllTemplates);resetButton&&resetTemplate&&editForm&&(resetButton.addEventListener("click",(async event=>{event.preventDefault(),(0,_notification.saveCancel)((0,_str.get_string)("resettemplateconfirmtitle","mod_data"),_templates.default.render("mod_data/template_editor_resetmodal",{resetallname:"resetallcheck"}),(0,_str.get_string)("reset","core"),(()=>{resetTemplate.value="true",editForm.submit()}),null,{triggerElement:event.target})})),resetAllTemplates&&document.addEventListener("change",(event=>{event.target.matches(selectors_resetAllCheck)&&(resetAllTemplates.value=event.target.checked?"true":"")})))},registerEditorToggler=(instanceId,mode)=>{const toggleTemplateEditor=document.querySelector(selectors_toggleTemplateEditor);toggleTemplateEditor&&toggleTemplateEditor.addEventListener("click",(async event=>{event.preventDefault();event.target.checked?(0,_notification.saveCancel)((0,_str.get_string)("confirmation","admin"),(0,_str.get_string)("enabletemplateeditorcheck","mod_data"),(0,_str.get_string)("editorenable","mod_data"),(()=>{window.location=(0,_url.relativeUrl)("/mod/data/templates.php",{d:instanceId,mode:mode,useeditor:!0})}),null,{triggerElement:event.target}):window.location=(0,_url.relativeUrl)("/mod/data/templates.php",{d:instanceId,mode:mode,useeditor:!1})}))};_exports.init=(instanceId,mode)=>{((instanceId,mode)=>{registerResetButton(),registerEditorToggler(instanceId,mode)})(instanceId,mode)}}));
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj},(0,_prefetch.prefetchStrings)("admin",["confirmation"]),(0,_prefetch.prefetchStrings)("mod_data",["resettemplateconfirmtitle","enabletemplateeditorcheck","editorenable"]),(0,_prefetch.prefetchStrings)("core",["reset"]);const selectors_toggleTemplateEditor='input[name="useeditor"]',selectors_resetTemplate='input[name="defaultform"]',selectors_resetAllTemplates='input[name="resetall"]',selectors_resetButton='input[name="resetbutton"]',selectors_resetAllCheck='input[name="resetallcheck"]',selectors_editForm="#edittemplateform",registerResetButton=mode=>{const editForm=document.querySelector(selectors_editForm),resetButton=document.querySelector(selectors_resetButton),resetTemplate=document.querySelector(selectors_resetTemplate),resetAllTemplates=document.querySelector(selectors_resetAllTemplates);resetButton&&resetTemplate&&editForm&&(resetButton.addEventListener("click",(async event=>{event.preventDefault();const params={resetallname:"resetallcheck",templatename:await(0,_str.get_string)(mode,"mod_data")};(0,_notification.saveCancel)((0,_str.get_string)("resettemplateconfirmtitle","mod_data"),_templates.default.render("mod_data/template_editor_resetmodal",params),(0,_str.get_string)("reset","core"),(()=>{resetTemplate.value="true",editForm.submit()}),null,{triggerElement:event.target})})),resetAllTemplates&&document.addEventListener("change",(event=>{event.target.matches(selectors_resetAllCheck)&&(resetAllTemplates.value=event.target.checked?"true":"")})))},registerEditorToggler=(instanceId,mode)=>{const toggleTemplateEditor=document.querySelector(selectors_toggleTemplateEditor);toggleTemplateEditor&&toggleTemplateEditor.addEventListener("click",(async event=>{event.preventDefault();event.target.checked?(0,_notification.saveCancel)((0,_str.get_string)("confirmation","admin"),(0,_str.get_string)("enabletemplateeditorcheck","mod_data"),(0,_str.get_string)("editorenable","mod_data"),(()=>{window.location=(0,_url.relativeUrl)("/mod/data/templates.php",{d:instanceId,mode:mode,useeditor:!0})}),null,{triggerElement:event.target}):window.location=(0,_url.relativeUrl)("/mod/data/templates.php",{d:instanceId,mode:mode,useeditor:!1})}))};_exports.init=(instanceId,mode)=>{((instanceId,mode)=>{registerResetButton(mode),registerEditorToggler(instanceId,mode)})(instanceId,mode)}}));
//# sourceMappingURL=templateseditor.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,6 @@ import Templates from 'core/templates';
prefetchStrings('admin', ['confirmation']);
prefetchStrings('mod_data', [
'resettemplateconfirmtitle',
'resettemplateconfirm',
'enabletemplateeditorcheck',
'editorenable'
]);
@ -57,11 +56,11 @@ const selectors = {
* @param {string} mode The template mode
*/
const registerEventListeners = (instanceId, mode) => {
registerResetButton();
registerResetButton(mode);
registerEditorToggler(instanceId, mode);
};
const registerResetButton = () => {
const registerResetButton = (mode) => {
const editForm = document.querySelector(selectors.editForm);
const resetButton = document.querySelector(selectors.resetButton);
const resetTemplate = document.querySelector(selectors.resetTemplate);
@ -73,9 +72,13 @@ const registerResetButton = () => {
resetButton.addEventListener('click', async(event) => {
event.preventDefault();
const params = {
resetallname: "resetallcheck",
templatename: await getString(mode, 'mod_data'),
};
saveCancel(
getString('resettemplateconfirmtitle', 'mod_data'),
Templates.render('mod_data/template_editor_resetmodal', {resetallname: "resetallcheck"}),
Templates.render('mod_data/template_editor_resetmodal', params),
getString('reset', 'core'),
() => {
resetTemplate.value = "true";

View File

@ -402,7 +402,7 @@ $string['resetalltemplatesconfirm'] = 'You\'re about to remove all templates for
$string['resetsettings'] = 'Reset filters';
$string['resettemplate'] = 'Reset template';
$string['resettemplateconfirmtitle'] = 'Reset template?';
$string['resettemplateconfirm'] = 'Resetting a template removes the existing preset and any customisations you have done to the template. You can\'t undo this action.';
$string['resettemplateconfirm'] = 'This will permanently remove the {$a} for your current preset.';
$string['resizingimages'] = 'Resizing image thumbnails...';
$string['rows'] = 'rows';
$string['rssglobaldisabled'] = 'Disabled. See site configuration variables.';

View File

@ -21,7 +21,7 @@
"resetallname": "resetallcheck"
}
}}
<p>{{#str}} resetalltemplatesconfirm, mod_data {{/str}}</p>
<p>{{#str}} resettemplateconfirm, mod_data, {{templatename}} {{/str}}</p>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="modalcheckbox" name="{{resetallname}}">
<label class="form-check-label" for="modalcheckbox">{{#str}} resetalltemplates, mod_data {{/str}}</label>

View File

@ -124,6 +124,7 @@ Feature: Users can edit the database templates
When I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I click on "Reset" "button" in the "sticky-footer" "region"
And I should see "This will permanently remove the List view template for your current preset."
And I click on "Reset" "button" in the "Reset template?" "dialogue"
Then I should see "Template reset"
And I navigate to "Database" in current page administration
@ -156,6 +157,7 @@ Feature: Users can edit the database templates
When I navigate to "Templates" in current page administration
And I click on "Actions" "button"
And I choose "Reset all templates" in the open action menu
And I should see "You're about to remove all templates for your current preset."
And I click on "Reset" "button" in the "Reset all templates?" "dialogue"
Then I should see "All templates reset"
And I navigate to "Database" in current page administration
@ -193,6 +195,7 @@ Feature: Users can edit the database templates
And I should see "Initial add"
When I navigate to "Templates" in current page administration
And I click on "Reset" "button" in the "sticky-footer" "region"
And I should see "This will permanently remove the Add entry template for your current preset."
And I click on "Reset all templates" "checkbox"
And I click on "Reset" "button" in the "Reset template?" "dialogue"
Then I should see "All templates reset"