Skip to content

Commit

Permalink
Do not submit work type selection form if no checkbox selected
Browse files Browse the repository at this point in the history
Fixes #3135

I have looked at the commit that added this es6 module, and it is not clear to me that I can tweak an existing test to test this behavior.
  • Loading branch information
mjgiarlo committed Mar 14, 2017
1 parent a7ee5cb commit ef3631c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/assets/javascripts/sufia/select_work_type.es6
Expand Up @@ -6,17 +6,17 @@ export default class SelectWorkType {
constructor(element) {
this.$element = element;
this.target = element.data('target')
this.modal = $(this.target);
this.modal = $(this.target)
this.form = this.modal.find('form.new-work-select')

// launch the modal.
element.on('click', (e) => {
e.preventDefault();
this.modal.modal();
element.on('click', (e) => {
e.preventDefault()
this.modal.modal()
// ensure the type is set for the last clicked element
this.type = element.data('create-type')
// add custom routing logic when the modal is shown
this.form.on('submit', this.routingLogic.bind(this));
this.form.on('submit', this.routingLogic.bind(this))
});

// remove the routing logic when the modal is hidden
Expand All @@ -27,7 +27,9 @@ export default class SelectWorkType {

// when the form is submitted route to the correct location
routingLogic(e) {
e.preventDefault();
e.preventDefault()
if (this.destination() === undefined)
return false
// get the destination from the data attribute of the selected radio button
window.location.href = this.destination()
}
Expand Down

0 comments on commit ef3631c

Please sign in to comment.