FIX: Disable save button when new group form is empty.
https://meta.discourse.org/t/adding-owners-members-ux-is-inconsistent-and-misleading/58084/26?u=tgxworld
This commit is contained in:
parent
71b2f8ae1d
commit
c0595ebe99
|
@ -4,13 +4,18 @@ import InputValidation from 'discourse/models/input-validation';
|
|||
import debounce from 'discourse/lib/debounce';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
saving: null,
|
||||
disableSave: null,
|
||||
nameInput: null,
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
const name = this.get('model.name');
|
||||
if (name) this.set("nameInput", name);
|
||||
|
||||
if (name) {
|
||||
this.set("nameInput", name);
|
||||
} else {
|
||||
this.set('disableSave', true);
|
||||
}
|
||||
},
|
||||
|
||||
@computed('basicNameValidation', 'uniqueNameValidation')
|
||||
|
@ -58,7 +63,7 @@ export default Ember.Component.extend({
|
|||
reason: I18n.t('admin.groups.new.name.available')
|
||||
}));
|
||||
|
||||
this.set('saving', false);
|
||||
this.set('disableSave', false);
|
||||
this.set('model.name', this.get('nameInput'));
|
||||
} else {
|
||||
let reason;
|
||||
|
@ -75,7 +80,7 @@ export default Ember.Component.extend({
|
|||
}, 500),
|
||||
|
||||
_failedInputValidation(reason) {
|
||||
this.set('saving', true);
|
||||
this.set('disableSave', true);
|
||||
|
||||
const options = { failed: true };
|
||||
if (reason) options.reason = reason;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form class="groups-form form-vertical">
|
||||
{{groups-form-profile-fields model=model saving=saving}}
|
||||
{{groups-form-profile-fields model=model disableSave=saving}}
|
||||
{{group-manage-save-button model=model saving=saving}}
|
||||
</form>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<hr/>
|
||||
|
||||
<form class="groups-form form-vertical">
|
||||
{{#groups-form-profile-fields model=model saving=saving}}
|
||||
{{#groups-form-profile-fields model=model disableSave=saving}}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="owner-selector">{{i18n 'admin.groups.add_owners'}}</label>
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ QUnit.test("As an anon user", assert => {
|
|||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('.groups-admin-dropdown').length, 0,
|
||||
'it should not display the admin dropdown'
|
||||
find('.groups-header-new').length, 0,
|
||||
'it should not display the button to create a group'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -20,6 +20,14 @@ QUnit.test("Creating a new group", assert => {
|
|||
visit("/groups");
|
||||
|
||||
click(".groups-header-new");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('.group-form-save[disabled]').length, 1,
|
||||
'save button should be disabled'
|
||||
);
|
||||
});
|
||||
|
||||
fillIn("input[name='name']", '1');
|
||||
|
||||
andThen(() => {
|
||||
|
|
Loading…
Reference in New Issue