Skip to content

Commit 5e4a3a8

Browse files
author
Anders Breid
authored
Name change is now disabled on edit (#138)
1 parent 3476e0b commit 5e4a3a8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/main/resources/static/js/subscription.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -789,17 +789,9 @@ jQuery(document).ready(function () {
789789
vm.subscription()[0].restPostBodyMediaType.valueHasMutated();
790790
loadTooltip();
791791
$('#modal_form').modal('show');
792-
if (save_method_in === "edit") {
793-
title_ = 'Edit Subscription';
794-
addEditMode();
795-
} else if (save_method_in === "add") {
796792

797-
title_ = 'Add Subscription';
798-
addEditMode();
799-
} else {
800-
title_ = 'View Subscription';
801-
viewMode();
802-
}
793+
setViewMode(save_method_in);
794+
803795
$('.modal-title').text(title_);
804796
save_method = save_method_in;
805797
$('#modal_form').on('hidden.bs.modal', function() {
@@ -808,11 +800,26 @@ jQuery(document).ready(function () {
808800
}
809801
}
810802

811-
function addEditMode() {
803+
function setViewMode(save_method_in) {
804+
if (save_method_in === "edit") {
805+
title_ = 'Edit Subscription';
806+
enableAllForms();
807+
$('#subscriptionNameInput').prop('disabled', true);
808+
} else if (save_method_in === "add") {
809+
title_ = 'Add Subscription';
810+
enableAllForms();
811+
} else {
812+
title_ = 'View Subscription';
813+
disableAllForms();
814+
}
815+
}
816+
817+
function enableAllForms() {
812818
$('#modal_form :button').show();
813819
$('#modal_form :input').prop("disabled", false);
814820
}
815-
function viewMode() {
821+
822+
function disableAllForms() {
816823
$('#modal_form :button').hide();
817824
$('#modal_form :input').prop("disabled", true);
818825
$('#modal_form .close').show();

0 commit comments

Comments
 (0)