1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00

Refactor general settings route

This commit is contained in:
zinyando 2016-07-27 13:18:57 +02:00
parent ab76137f5c
commit fadbb57188
4 changed files with 86 additions and 41 deletions

View file

@ -0,0 +1,51 @@
import Ember from 'ember';
const {
isEmpty,
isPresent,
computed,
get,
set
} = Ember;
export default Ember.Component.extend({
titleInputError: computed('titleError', 'model.title', {
get() {
let error = get(this, 'titleError');
let title = this.get('model.title');
if (isPresent(error) || isEmpty(title)) {
return `error`;
}
return;
}
}),
messageInputError: computed('messageError', 'model.message', {
get() {
let error = get(this, 'messageError');
let message = this.get('model.message');
if (isPresent(error) || isEmpty(message)) {
return `error`;
}
return;
}
}),
actions: {
save() {
if (isEmpty(this.model.get('title'))) {
set(this, 'titleError', 'error');
return $("#siteTitle").focus();
}
if (isEmpty(this.model.get('message'))) {
set(this, 'messageError', 'error');
return $("#siteMessage").focus();
}
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
this.get('save')();
}
}
});

View file

@ -1,35 +1,28 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import NotifierMixin from "../../../mixins/notifier";
const {
isEmpty
} = Ember;
export default Ember.Controller.extend(NotifierMixin, {
orgService: Ember.inject.service('organization'),
actions: {
save() {
if (is.empty(this.model.get('title'))) {
$("#siteTitle").addClass("error").focus();
return;
}
if (is.empty(this.model.get('message'))) {
$("#siteMessage").addClass("error").focus();
return;
}
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
this.get('orgService').save(this.model);
this.showNotification('Saved');
}
}
});
});

View file

@ -1,29 +1,3 @@
<div class="input-form form-borderless">
<form>
<div class="heading">
<div class="title">General Settings</div>
<div class="tip">Tell people about this Documize instance</div>
</div>
<div>
<div class="input-control">
<label>Title</label>
<div class="tip">Describe the title of this Documize instance</div>
{{focus-input id="siteTitle" type="text" value=model.title}}
</div>
<div class="input-control">
<label>Message</label>
<div class="tip">Describe the purpose of this Documize instance</div>
{{textarea id="siteMessage" rows="3" value=model.message}}
</div>
<div class="input-control">
<label>Anonymous Access</label>
<div class="tip">Content within "Everyone" will be made available to anonymous users</div>
<div class="checkbox">
<input type="checkbox" id="allowAnonymousAccess" checked= {{model.allowAnonymousAccess}} />
<label for="allowAnonymousAccess">Allow anyone to access this Documize instance</label>
</div>
</div>
<div class="regular-button button-blue" {{ action 'save' }}>save</div>
</div>
</form>
{{general-settings model=model save=(action 'save')}}
</div>

View file

@ -0,0 +1,27 @@
<form>
<div class="heading">
<div class="title">General Settings</div>
<div class="tip">Tell people about this Documize instance</div>
</div>
<div>
<div class="input-control">
<label>Title</label>
<div class="tip">Describe the title of this Documize instance</div>
{{focus-input id="siteTitle" type="text" value=model.title class=titleInputError}}
</div>
<div class="input-control">
<label>Message</label>
<div class="tip">Describe the purpose of this Documize instance</div>
{{textarea id="siteMessage" rows="3" value=model.message class=messageInputError}}
</div>
<div class="input-control">
<label>Anonymous Access</label>
<div class="tip">Content within "Everyone" will be made available to anonymous users</div>
<div class="checkbox">
<input type="checkbox" id="allowAnonymousAccess" checked= {{model.allowAnonymousAccess}} />
<label for="allowAnonymousAccess">Allow anyone to access this Documize instance</label>
</div>
</div>
<div class="regular-button button-blue" {{ action 'save' }}>save</div>
</div>
</form>