@@ -789,17 +789,9 @@ jQuery(document).ready(function () {
789
789
vm . subscription ( ) [ 0 ] . restPostBodyMediaType . valueHasMutated ( ) ;
790
790
loadTooltip ( ) ;
791
791
$ ( '#modal_form' ) . modal ( 'show' ) ;
792
- if ( save_method_in === "edit" ) {
793
- title_ = 'Edit Subscription' ;
794
- addEditMode ( ) ;
795
- } else if ( save_method_in === "add" ) {
796
792
797
- title_ = 'Add Subscription' ;
798
- addEditMode ( ) ;
799
- } else {
800
- title_ = 'View Subscription' ;
801
- viewMode ( ) ;
802
- }
793
+ setViewMode ( save_method_in ) ;
794
+
803
795
$ ( '.modal-title' ) . text ( title_ ) ;
804
796
save_method = save_method_in ;
805
797
$ ( '#modal_form' ) . on ( 'hidden.bs.modal' , function ( ) {
@@ -808,11 +800,26 @@ jQuery(document).ready(function () {
808
800
}
809
801
}
810
802
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 ( ) {
812
818
$ ( '#modal_form :button' ) . show ( ) ;
813
819
$ ( '#modal_form :input' ) . prop ( "disabled" , false ) ;
814
820
}
815
- function viewMode ( ) {
821
+
822
+ function disableAllForms ( ) {
816
823
$ ( '#modal_form :button' ) . hide ( ) ;
817
824
$ ( '#modal_form :input' ) . prop ( "disabled" , true ) ;
818
825
$ ( '#modal_form .close' ) . show ( ) ;
0 commit comments