Merge branch 'MDL-77275-master' of https://github.com/laurentdavid/moodle

This commit is contained in:
Sara Arjona
2023-03-17 13:03:31 +01:00
8 changed files with 27 additions and 17 deletions
+1 -1
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","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)}}));
*/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_resetTemplateAction='[data-action="resettemplate"]',selectors_resetTemplate='input[name="defaultform"]',selectors_resetAllTemplates='input[name="resetall"]',selectors_resetAllCheck='input[name="resetallcheck"]',selectors_editForm="#edittemplateform",registerResetButton=mode=>{const editForm=document.querySelector(selectors_editForm),resetTemplate=document.querySelector(selectors_resetTemplate),resetAllTemplates=document.querySelector(selectors_resetAllTemplates),resetTemplateAction=document.querySelector(selectors_resetTemplateAction);resetTemplateAction&&resetTemplate&&editForm&&((0,_prefetch.prefetchStrings)("mod_data",[mode]),resetTemplateAction.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
+7 -5
View File
@@ -42,9 +42,9 @@ prefetchStrings('core', [
*/
const selectors = {
toggleTemplateEditor: 'input[name="useeditor"]',
resetTemplateAction: '[data-action="resettemplate"]',
resetTemplate: 'input[name="defaultform"]',
resetAllTemplates: 'input[name="resetall"]',
resetButton: 'input[name="resetbutton"]',
resetAllCheck: 'input[name="resetallcheck"]',
editForm: '#edittemplateform',
};
@@ -62,15 +62,17 @@ const registerEventListeners = (instanceId, mode) => {
const registerResetButton = (mode) => {
const editForm = document.querySelector(selectors.editForm);
const resetButton = document.querySelector(selectors.resetButton);
const resetTemplate = document.querySelector(selectors.resetTemplate);
const resetAllTemplates = document.querySelector(selectors.resetAllTemplates);
const resetTemplateAction = document.querySelector(selectors.resetTemplateAction);
if (!resetButton || !resetTemplate || !editForm) {
if (!resetTemplateAction || !resetTemplate || !editForm) {
return;
}
resetButton.addEventListener('click', async(event) => {
prefetchStrings('mod_data', [
mode
]);
resetTemplateAction.addEventListener('click', async(event) => {
event.preventDefault();
const params = {
resetallname: "resetallcheck",
+11
View File
@@ -196,6 +196,17 @@ class action_bar {
$presetsactions = $this->get_presets_actions_select(false);
// Reset single template action.
$resetcurrrent = new moodle_url($this->currenturl);
$resetcurrrent->param('action', 'resettemplate');
$presetsactions->add(new \action_menu_link(
$resetcurrrent,
null,
get_string('resettemplate', 'mod_data'),
false,
['data-action' => 'resettemplate', 'data-dataid' => $this->id]
));
// Reset all templates action.
$resetallurl = new moodle_url($this->currenturl);
$resetallurl->params([
+1 -1
View File
@@ -400,7 +400,7 @@ $string['resetalltemplates'] = 'Reset all templates';
$string['resetalltemplatesconfirmtitle'] = 'Reset all templates?';
$string['resetalltemplatesconfirm'] = 'You\'re about to remove all templates for your current preset. If you want to restore the templates later, you need to choose the preset again in the \'Presets\' tab.';
$string['resetsettings'] = 'Reset filters';
$string['resettemplate'] = 'Reset template';
$string['resettemplate'] = 'Reset current template';
$string['resettemplateconfirmtitle'] = 'Reset template?';
$string['resettemplateconfirm'] = 'This will permanently remove the {$a} for your current preset.';
$string['resizingimages'] = 'Resizing image thumbnails...';
@@ -113,12 +113,6 @@
{{< core/sticky_footer }}
{{$ stickycontent }}
<div>
<input
class="btn btn-secondary mx-1"
type="button"
name="resetbutton"
value="{{#str}} reset {{/str}}"
/>
<input
class="btn btn-primary mx-1"
type="submit"
@@ -142,7 +142,8 @@ Feature: Users can use mod_data without editing the templates
And I should not see "Some content 1"
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 click on "Actions" "button"
And I choose "Reset current template" in the open action menu
And I click on "Reset" "button" in the "Reset template?" "dialogue"
And I should see "Template reset"
And I navigate to "Database" in current page administration
+4 -2
View File
@@ -123,7 +123,8 @@ Feature: Users can edit the database templates
And I should not see "Some content 1"
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 click on "Actions" "button"
And I choose "Reset current template" in the open action menu
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"
@@ -194,7 +195,8 @@ Feature: Users can edit the database templates
And I click on "Add entry" "button"
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 click on "Actions" "button"
And I choose "Reset current template" in the open action menu
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"