don't show prerequisites section for first module
previously, while editing the first module, we showed a select-prerequisite-module dropdown with all its contents disabled. this is confusing from an a11y standpoint because it looks like the dropdown isn't responding to keyboard input. instead, we will simply not show the Prerequisites section where it doesn't apply. test plan: - when adding a new module to a course with no existing modules, there should be no "Prerequisites" section on the "Add Module" dialog - when editing the first module in the list, there should be no "Prerequisites" section - when editing subsequent modules, there should be a "Prerequisites" section and the module dropdown should contain only the preceding modules. it shouldn't include but disable the modules that follow it. fixes CNVS-25733 Change-Id: I1a6656e23a30e7dc4ae5d0932f1fe824a8a6fd31 Reviewed-on: https://gerrit.instructure.com/69160 Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Ryan Allen <rallen@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
90ba4dc7b5
commit
15dd6f46d6
|
@ -346,7 +346,10 @@ define([
|
|||
$form.find("#unlock_module_at").prop('checked', data.unlock_at).change()
|
||||
$form.find("#require_sequential_progress").attr('checked', data.require_sequential_progress == "true" || data.require_sequential_progress == "1");
|
||||
$form.find("#publish_final_grade").attr('checked', data.publish_final_grade == "true" || data.publish_final_grade == "1");
|
||||
$form.find(".prerequisites_entry").showIf($("#context_modules .context_module").length > 1);
|
||||
|
||||
var has_predecessors = $("#context_modules .context_module").length > 1 &&
|
||||
$("#context_modules .context_module:first").attr("id") !== $module.attr("id")
|
||||
$form.find(".prerequisites_entry").showIf(has_predecessors);
|
||||
var prerequisites = [];
|
||||
$module.find(".prerequisites .prerequisite_criterion").each(function() {
|
||||
prerequisites.push($(this).getTemplateData({textValues: ['id', 'name', 'type']}));
|
||||
|
@ -369,10 +372,9 @@ define([
|
|||
.find(".type").val(data.criterion_type || "").change().end()
|
||||
.find(".min_score").val(data.min_score || "");
|
||||
});
|
||||
var no_prereqs = $("#context_modules .context_module").length == 1;
|
||||
var no_items = $module.find(".content .context_module_item").length === 0;
|
||||
$form.find(".prerequisites_list .criteria_list").showIf(prerequisites.length != 0).end()
|
||||
.find(".add_prerequisite_link").showIf(!no_prereqs).end()
|
||||
.find(".add_prerequisite_link").showIf(has_predecessors).end()
|
||||
.find(".completion_entry .criteria_list").showIf(!no_items).end()
|
||||
|
||||
.find(".completion_entry .no_items_message").hide().end()
|
||||
|
@ -878,7 +880,7 @@ define([
|
|||
}
|
||||
});
|
||||
for(var idx in afters) {
|
||||
$select.find("." + afters[idx]).attr('disabled', true);
|
||||
$select.find("." + afters[idx]).hide();
|
||||
}
|
||||
|
||||
$pre.find(".option").empty().append($select.show());
|
||||
|
@ -1300,7 +1302,7 @@ define([
|
|||
}
|
||||
});
|
||||
for(var idx in afters) {
|
||||
$select.find(".context_module_" + afters[idx]).attr('disabled', true);
|
||||
$select.find(".context_module_" + afters[idx]).hide();
|
||||
}
|
||||
$("#add_module_prerequisite_dialog").find(".prerequisite_module_select").empty().append($select.show());
|
||||
$("#add_module_prerequisite_dialog").dialog({
|
||||
|
|
|
@ -468,6 +468,38 @@ describe "context modules" do
|
|||
test_relock
|
||||
end
|
||||
|
||||
it "does not have a prerequisites section when creating the first module" do
|
||||
get "/courses/#{@course.id}/modules"
|
||||
wait_for_modules_ui
|
||||
|
||||
form = new_module_form
|
||||
expect(f('.prerequisites_entry', form)).not_to be_displayed
|
||||
replace_content(form.find_element(:id, 'context_module_name'), "first")
|
||||
submit_form(form)
|
||||
|
||||
form = new_module_form
|
||||
expect(f('.prerequisites_entry', form)).to be_displayed
|
||||
end
|
||||
|
||||
it "does not have a prerequisites section when editing the first module" do
|
||||
modules = create_modules(2)
|
||||
get "/courses/#{@course.id}/modules"
|
||||
wait_for_modules_ui
|
||||
|
||||
mod0 = f("#context_module_#{modules[0].id}")
|
||||
f(".ig-header-admin .al-trigger", mod0).click
|
||||
f('.edit_module_link', mod0).click
|
||||
edit_form = f('#add_context_module_form')
|
||||
expect(f('.prerequisites_entry', edit_form)).not_to be_displayed
|
||||
submit_form(edit_form)
|
||||
|
||||
mod1 = f("#context_module_#{modules[1].id}")
|
||||
f(".ig-header-admin .al-trigger", mod1).click
|
||||
f('.edit_module_link', mod1).click
|
||||
edit_form = f('#add_context_module_form')
|
||||
expect(f('.prerequisites_entry', edit_form)).to be_displayed
|
||||
end
|
||||
|
||||
it "should save the requirement count chosen in the Edit Module form" do
|
||||
get "/courses/#{@course.id}/modules"
|
||||
add_existing_module_item('#assignments_select', 'Assignment', @assignment.title)
|
||||
|
|
Loading…
Reference in New Issue