settings: Disable submit button when no input is changed.

We now disable the submit button if no input is changed
in modals used for editing name and descriptions of
stream and user groups. The button is enabled if any
value is changed.
This commit is contained in:
Sahil Batra 2023-09-20 12:14:27 +05:30 committed by Tim Abbott
parent a37c91e5f9
commit 00424748f4
4 changed files with 6 additions and 11 deletions

View File

@ -454,6 +454,7 @@ export function initialize() {
.addClass("save-button") .addClass("save-button")
.attr("data-stream-id", stream_id); .attr("data-stream-id", stream_id);
}, },
update_submit_disabled_state_on_change: true,
}); });
}); });
@ -504,10 +505,6 @@ export function initialize() {
const new_name = $("#change_stream_name").val().trim(); const new_name = $("#change_stream_name").val().trim();
const new_description = $("#change_stream_description").val().trim(); const new_description = $("#change_stream_description").val().trim();
if (new_name === sub.name && new_description === sub.description) {
dialog_widget.hide_dialog_spinner();
return;
}
if (new_name !== sub.name) { if (new_name !== sub.name) {
data.new_name = new_name; data.new_name = new_name;
} }

View File

@ -277,6 +277,7 @@ export function initialize() {
.addClass("save-button") .addClass("save-button")
.attr("data-group-id", user_group_id); .attr("data-group-id", user_group_id);
}, },
update_submit_disabled_state_on_change: true,
}); });
}); });
@ -328,9 +329,6 @@ export function initialize() {
const new_name = $("#change_user_group_name").val().trim(); const new_name = $("#change_user_group_name").val().trim();
const new_description = $("#change_user_group_description").val().trim(); const new_description = $("#change_user_group_description").val().trim();
if (new_name === group.name && new_description === group.description) {
return;
}
if (new_name !== group.name) { if (new_name !== group.name) {
data.name = new_name; data.name = new_name;
} }

View File

@ -2,12 +2,12 @@
<label for="change_stream_name"> <label for="change_stream_name">
{{t 'Stream name' }} {{t 'Stream name' }}
</label> </label>
<input type="text" id="change_stream_name" class="modal_text_input" value="{{ stream_name }}" maxlength="{{ max_stream_name_length }}" /> <input type="text" id="change_stream_name" class="modal_text_input" name="stream_name" value="{{ stream_name }}" maxlength="{{ max_stream_name_length }}" />
</div> </div>
<div> <div>
<label for="change_stream_description"> <label for="change_stream_description">
{{t 'Description' }} {{t 'Description' }}
{{> ../help_link_widget link="/help/change-the-stream-description" }} {{> ../help_link_widget link="/help/change-the-stream-description" }}
</label> </label>
<textarea id="change_stream_description" class="settings_textarea" maxlength="{{ max_stream_description_length }}">{{ stream_description }}</textarea> <textarea id="change_stream_description" class="settings_textarea" name="stream_description" maxlength="{{ max_stream_description_length }}">{{ stream_description }}</textarea>
</div> </div>

View File

@ -2,11 +2,11 @@
<label for="change_user_group_name"> <label for="change_user_group_name">
{{t 'User group name' }} {{t 'User group name' }}
</label> </label>
<input type="text" id="change_user_group_name" class="modal_text_input" value="{{ group_name }}" maxlength="{{max_user_group_name_length}}" /> <input type="text" id="change_user_group_name" class="modal_text_input" name="user_group_name" value="{{ group_name }}" maxlength="{{max_user_group_name_length}}" />
</div> </div>
<div> <div>
<label for="change_user_group_description"> <label for="change_user_group_description">
{{t 'User group description' }} {{t 'User group description' }}
</label> </label>
<textarea id="change_user_group_description" class="settings_textarea">{{ group_description }}</textarea> <textarea id="change_user_group_description" class="settings_textarea" name="user_group_description">{{ group_description }}</textarea>
</div> </div>