mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-48945-master' of https://github.com/sammarshallou/moodle
This commit is contained in:
commit
685b6681db
@ -94,6 +94,29 @@ class tool_filetypes_form extends moodleform {
|
||||
parent::set_data($data);
|
||||
}
|
||||
|
||||
public function get_data() {
|
||||
$data = parent::get_data();
|
||||
|
||||
// Update the data to handle the descriptiontype dropdown. (The type
|
||||
// is not explicitly stored, we just set or unset relevant fields.)
|
||||
if ($data) {
|
||||
switch ($data->descriptiontype) {
|
||||
case 'lang' :
|
||||
unset($data->description);
|
||||
break;
|
||||
case 'custom' :
|
||||
unset($data->corestring);
|
||||
break;
|
||||
default:
|
||||
unset($data->description);
|
||||
unset($data->corestring);
|
||||
break;
|
||||
}
|
||||
unset($data->descriptiontype);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
@ -110,6 +133,20 @@ class tool_filetypes_form extends moodleform {
|
||||
$errors['defaulticon'] = get_string('error_defaulticon', 'tool_filetypes', $extension);
|
||||
}
|
||||
|
||||
// If you choose 'lang' or 'custom' descriptiontype, you must fill something in the field.
|
||||
switch ($data['descriptiontype']) {
|
||||
case 'lang' :
|
||||
if (!trim($data['corestring'])) {
|
||||
$errors['corestring'] = get_string('required');
|
||||
}
|
||||
break;
|
||||
case 'custom' :
|
||||
if (!trim($data['description'])) {
|
||||
$errors['description'] = get_string('required');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,35 @@ Feature: Add customised file types
|
||||
And I press "Save changes"
|
||||
And I should see "frog" in the "application/x-7z-compressed" "table_row"
|
||||
|
||||
Scenario: Change the text option (was buggy)
|
||||
Given I log in as "admin"
|
||||
And I navigate to "File types" node in "Site administration > Server"
|
||||
When I click on "Edit 7z" "link"
|
||||
And I set the following fields to these values:
|
||||
| Description type | Custom description specified in this form |
|
||||
| Custom description | New description for 7z |
|
||||
And I press "Save changes"
|
||||
Then I should see "New description" in the "application/x-7z-compressed" "table_row"
|
||||
And I click on "Edit 7z" "link"
|
||||
And I set the field "Description type" to "Default"
|
||||
And I press "Save changes"
|
||||
And I should not see "New description" in the "application/x-7z-compressed" "table_row"
|
||||
|
||||
Scenario: Try to select a text option without entering a value.
|
||||
Given I log in as "admin"
|
||||
And I navigate to "File types" node in "Site administration > Server"
|
||||
When I click on "Edit dmg" "link"
|
||||
And I set the field "Description type" to "Custom description"
|
||||
And I press "Save changes"
|
||||
Then I should see "Required"
|
||||
And I set the field "Description type" to "Alternative language string"
|
||||
And I press "Save changes"
|
||||
And I should see "Required"
|
||||
And I set the field "Description type" to "Default"
|
||||
And I press "Save changes"
|
||||
# Check we're back on the main page now.
|
||||
And "dmg" "table_row" should exist
|
||||
|
||||
Scenario: Delete an existing file type
|
||||
Given I log in as "admin"
|
||||
And I navigate to "File types" node in "Site administration > Server"
|
||||
|
Loading…
x
Reference in New Issue
Block a user