Files
nairobi/app/assets/javascripts/legislation_admin.js
Javi Martín 1e70a3db02 Disable phase date fields when a phase is disabled
The JavaScript involved wasn't working since we removed the disable-date
attribute in commit 73ff6881.

We're also improving the JavaScript in two ways:

First, we trigger the `change` event immediately, so when the page loads
date fields are disabled when phases are disabled.

And second, we don't remove the selected dates when disabling a phase,
so disabling it and enabling it again will keep the selected values.
2020-08-15 13:31:32 +02:00

26 lines
733 B
JavaScript

(function() {
"use strict";
App.LegislationAdmin = {
initialize: function() {
$(".legislation-process-form").find("[name$='enabled]'],[name$='[published]']").on({
change: function() {
var checkbox;
checkbox = $(this);
checkbox.closest("fieldset").find("input[type='text']").each(function() {
if (checkbox.is(":checked")) {
$(this).removeAttr("disabled");
} else {
$(this).prop("disabled", true);
}
});
}
}).trigger("change");
$("#nested_question_options").on("cocoon:after-insert", function() {
App.Globalize.refresh_visible_translations();
});
}
};
}).call(this);