MDL-75335 mod_data: Change Use a preset string

This commit is contained in:
Amaia Anabitarte 2022-10-25 15:58:27 +02:00
parent 35f39c45b7
commit 32c8f75c0d
10 changed files with 17 additions and 17 deletions

View File

@ -1 +1 @@
{"version":3,"file":"selectpreset.min.js","sources":["../src/selectpreset.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module to control the form responsible for selecting a preset.\n *\n * @module mod_data/selectpreset\n * @copyright 2021 Mihail Geshoski <mihail@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst selectors = {\n presetRadioButton: 'input[name=\"fullname\"]',\n selectPresetButton: 'input[name=\"selectpreset\"]',\n selectedPresetRadioButton: 'input[name=\"fullname\"]:checked',\n};\n\n/**\n * Initialize module.\n */\nexport const init = () => {\n const radioButton = document.querySelectorAll(selectors.presetRadioButton);\n\n // Initialize the \"Use preset\" button properly.\n disableUsePresetButton();\n\n radioButton.forEach((elem) => {\n elem.addEventListener('change', function(event) {\n event.preventDefault();\n // Enable the \"Use preset\" button when any of the radio buttons in the presets list is checked.\n disableUsePresetButton();\n });\n });\n\n};\n\n/**\n * Decide whether to disable or not the \"Use preset\" button.\n * When there is no preset selected, the button should be displayed disabled; otherwise, it will appear enabled as a primary button.\n *\n * @method\n * @private\n */\nconst disableUsePresetButton = () => {\n let selectPresetButton = document.querySelector(selectors.selectPresetButton);\n const selectedRadioButton = document.querySelectorAll(selectors.selectedPresetRadioButton);\n\n if (selectedRadioButton.length > 0) {\n // There is one preset selected, so the button should be enabled.\n selectPresetButton.removeAttribute('disabled');\n selectPresetButton.classList.remove('btn-secondary');\n selectPresetButton.classList.add('btn-primary');\n } else {\n // There is no any preset selected, so the button should be disabled.\n selectPresetButton.setAttribute('disabled', true);\n selectPresetButton.classList.remove('btn-primary');\n selectPresetButton.classList.add('btn-secondary');\n }\n};\n"],"names":["selectors","radioButton","document","querySelectorAll","disableUsePresetButton","forEach","elem","addEventListener","event","preventDefault","selectPresetButton","querySelector","length","removeAttribute","classList","remove","add","setAttribute"],"mappings":";;;;;;;;MAuBMA,4BACiB,yBADjBA,6BAEkB,6BAFlBA,oCAGyB,+CAMX,WACVC,YAAcC,SAASC,iBAAiBH,6BAG9CI,yBAEAH,YAAYI,SAASC,OACjBA,KAAKC,iBAAiB,UAAU,SAASC,OACrCA,MAAMC,iBAENL,sCAaNA,uBAAyB,SACvBM,mBAAqBR,SAASS,cAAcX,8BACpBE,SAASC,iBAAiBH,qCAE9BY,OAAS,GAE7BF,mBAAmBG,gBAAgB,YACnCH,mBAAmBI,UAAUC,OAAO,iBACpCL,mBAAmBI,UAAUE,IAAI,iBAGjCN,mBAAmBO,aAAa,YAAY,GAC5CP,mBAAmBI,UAAUC,OAAO,eACpCL,mBAAmBI,UAAUE,IAAI"}
{"version":3,"file":"selectpreset.min.js","sources":["../src/selectpreset.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript module to control the form responsible for selecting a preset.\n *\n * @module mod_data/selectpreset\n * @copyright 2021 Mihail Geshoski <mihail@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst selectors = {\n presetRadioButton: 'input[name=\"fullname\"]',\n selectPresetButton: 'input[name=\"selectpreset\"]',\n selectedPresetRadioButton: 'input[name=\"fullname\"]:checked',\n};\n\n/**\n * Initialize module.\n */\nexport const init = () => {\n const radioButton = document.querySelectorAll(selectors.presetRadioButton);\n\n // Initialize the \"Use a preset\" button properly.\n disableUsePresetButton();\n\n radioButton.forEach((elem) => {\n elem.addEventListener('change', function(event) {\n event.preventDefault();\n // Enable the \"Use a preset\" button when any of the radio buttons in the presets list is checked.\n disableUsePresetButton();\n });\n });\n\n};\n\n/**\n * Decide whether to disable or not the \"Use a preset\" button.\n * When there is no preset selected, the button should be displayed disabled; otherwise, it will appear enabled as a primary button.\n *\n * @method\n * @private\n */\nconst disableUsePresetButton = () => {\n let selectPresetButton = document.querySelector(selectors.selectPresetButton);\n const selectedRadioButton = document.querySelectorAll(selectors.selectedPresetRadioButton);\n\n if (selectedRadioButton.length > 0) {\n // There is one preset selected, so the button should be enabled.\n selectPresetButton.removeAttribute('disabled');\n selectPresetButton.classList.remove('btn-secondary');\n selectPresetButton.classList.add('btn-primary');\n } else {\n // There is no any preset selected, so the button should be disabled.\n selectPresetButton.setAttribute('disabled', true);\n selectPresetButton.classList.remove('btn-primary');\n selectPresetButton.classList.add('btn-secondary');\n }\n};\n"],"names":["selectors","radioButton","document","querySelectorAll","disableUsePresetButton","forEach","elem","addEventListener","event","preventDefault","selectPresetButton","querySelector","length","removeAttribute","classList","remove","add","setAttribute"],"mappings":";;;;;;;;MAuBMA,4BACiB,yBADjBA,6BAEkB,6BAFlBA,oCAGyB,+CAMX,WACVC,YAAcC,SAASC,iBAAiBH,6BAG9CI,yBAEAH,YAAYI,SAASC,OACjBA,KAAKC,iBAAiB,UAAU,SAASC,OACrCA,MAAMC,iBAENL,sCAaNA,uBAAyB,SACvBM,mBAAqBR,SAASS,cAAcX,8BACpBE,SAASC,iBAAiBH,qCAE9BY,OAAS,GAE7BF,mBAAmBG,gBAAgB,YACnCH,mBAAmBI,UAAUC,OAAO,iBACpCL,mBAAmBI,UAAUE,IAAI,iBAGjCN,mBAAmBO,aAAa,YAAY,GAC5CP,mBAAmBI,UAAUC,OAAO,eACpCL,mBAAmBI,UAAUE,IAAI"}

View File

@ -33,13 +33,13 @@ const selectors = {
export const init = () => {
const radioButton = document.querySelectorAll(selectors.presetRadioButton);
// Initialize the "Use preset" button properly.
// Initialize the "Use a preset" button properly.
disableUsePresetButton();
radioButton.forEach((elem) => {
elem.addEventListener('change', function(event) {
event.preventDefault();
// Enable the "Use preset" button when any of the radio buttons in the presets list is checked.
// Enable the "Use a preset" button when any of the radio buttons in the presets list is checked.
disableUsePresetButton();
});
});
@ -47,7 +47,7 @@ export const init = () => {
};
/**
* Decide whether to disable or not the "Use preset" button.
* Decide whether to disable or not the "Use a preset" button.
* When there is no preset selected, the button should be displayed disabled; otherwise, it will appear enabled as a primary button.
*
* @method

View File

@ -438,7 +438,7 @@ $string['uploadrecords_link'] = 'mod/data/import';
$string['url'] = 'URL';
$string['usedate'] = 'Include in search.';
$string['usepredefinedset'] = 'Use predefined set';
$string['usepreset'] = 'Use preset';
$string['usepreset'] = 'Use a preset';
$string['usestandard'] = 'Use a preset';
$string['usestandard_help'] = 'To use a preset available to the whole site, select it from the list. (If you have added a preset to the list using the save as preset feature then you have the option of deleting it.)';
$string['viewfromdate'] = 'Read only from';

View File

@ -22,7 +22,7 @@ Feature: Users can use the Image gallery preset
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And I click on "Use preset" "button"
And I click on "Use a preset" "button"
And the following "mod_data > entries" exist:
| database | user | title | description | image |
| data1 | student1 | First image | This is the description text for image 1 | first.png |

View File

@ -22,7 +22,7 @@ Feature: Users can use the Journal preset
And I am on the "Student reflections" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Journal" "table_row"
And I click on "Use preset" "button"
And I click on "Use a preset" "button"
And the following "mod_data > entries" exist:
| database | user | Title | Content |
| data1 | student1 | Reflection created by student | This is the content for the entry 1 |

View File

@ -22,7 +22,7 @@ Feature: Users can use the Proposals preset
And I am on the "Student projects" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Proposals" "table_row"
And I click on "Use preset" "button"
And I click on "Use a preset" "button"
And the following "mod_data > entries" exist:
| database | user | Title | Summary | Content | Status |
| data1 | student1 | Project created by student | Summary 1 | Content for entry 1 | Pending |

View File

@ -22,7 +22,7 @@ Feature: Users can use the Resources preset
And I am on the "Student resources" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Resources" "table_row"
And I click on "Use preset" "button"
And I click on "Use a preset" "button"
And the following "mod_data > entries" exist:
| database | user | Title | Description | Type | Author | Web link | Cover |
| data1 | student1 | My favourite book | Book content | Type1 | The book author | http://myfavouritebook.cat | first.png |

View File

@ -63,10 +63,10 @@ Feature: Users can view and manage data presets
And I should see "Delete"
# Teachers can't delete the presets they haven't created.
And I should not see "Actions" in the "Saved preset 1" "table_row"
# The "Use preset" button should be enabled only when a preset is selected.
And the "Use preset" "button" should be disabled
# The "Use a preset" button should be enabled only when a preset is selected.
And the "Use a preset" "button" should be disabled
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And the "Use preset" "button" should be enabled
And the "Use a preset" "button" should be enabled
@javascript
Scenario: Only users with the viewalluserpresets capability can see presets created by other users
@ -286,7 +286,7 @@ Feature: Users can view and manage data presets
And I should see "My funny description goes here"
And I should see "Test field name"
And I should see "This is a short text"
Then "Use preset" "button" should exist
Then "Use a preset" "button" should exist
@javascript
Scenario: Teachers can export any saved preset

View File

@ -138,7 +138,7 @@ Feature: Users can preview presets
Scenario: Apply plugin preset from preview in database
Given I follow "Presets"
And I click on "Image gallery" "link"
When I click on "Use preset" "button"
When I click on "Use a preset" "button"
Then I should see "image"
And I should see "title"
@ -155,5 +155,5 @@ Feature: Users can preview presets
And I click on "Save" "button" in the "Save all fields and templates as preset" "dialogue"
When I follow "Presets"
And I click on "Saved preset by teacher1" "link"
And I click on "Use preset" "button"
And I click on "Use a preset" "button"
Then I should see "My URL field"

View File

@ -26,6 +26,6 @@ Feature: Zero state page (no fields created)
And I click on "Create a new field" "button"
And I should see "Manage fields"
And I am on the "Test database name" "data activity" page
And "Use preset" "button" should exist
And I click on "Use preset" "button"
And "Use a preset" "button" should exist
And I click on "Use a preset" "button"
And I should see "Presets"