1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-18 20:59:43 +02:00

Refactor setup route controller to remove jquery

This commit is contained in:
zinyando 2016-08-01 15:07:46 +02:00
parent 6beaaa3122
commit 727fec0d5f
8 changed files with 90 additions and 37 deletions

View file

@ -1,9 +1,18 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
isEmpty,
isEqual,
isPresent,
computed,
set
@ -15,35 +24,35 @@ export default Ember.Component.extend({
lastnameEmpty: computed.empty('model.lastname'),
emailEmpty: computed.empty('model.email'),
passwordEmpty: computed.empty('model.password'),
hasPasswordError: computed.and('titleEmpty', 'titleError'),
hasConfirmError: computed.and('firstnameEmpty', 'adminFirstnameError'),
hasPasswordError: computed.and('lastnameEmpty', 'adminLastnameError'),
hasConfirmError: computed.and('emailEmpty', 'adminEmailError'),
hasPasswordError: computed.and('passwordEmpty', 'adminPasswordError'),
hasEmptyTitleError: computed.and('titleEmpty', 'titleError'),
hasEmptyFirstnameError: computed.and('firstnameEmpty', 'adminFirstnameError'),
hasEmptyLastnameError: computed.and('lastnameEmpty', 'adminLastnameError'),
hasEmptyEmailError: computed.and('emailEmpty', 'adminEmailError'),
hasEmptyPasswordError: computed.and('passwordEmpty', 'adminPasswordError'),
actions: {
save() {
if (isEmpty(this.model.title)) {
if (isEmpty(this.get('model.title'))) {
set(this, 'titleError', true);
return $("#siteTitle").focus();
}
if (isEmpty(this.model.firstname)) {
if (isEmpty(this.get('model.firstname'))) {
set(this, 'adminFirstnameError', true);
return $("#adminFirstname").focus();
}
if (isEmpty(this.model.lastname)) {
if (isEmpty(this.get('model.lastname'))) {
set(this, 'adminLastnameError', true);
return $("#adminLastname").focus();
}
if (isEmpty(this.model.email) || !is.email(this.model.email)) {
if (isEmpty(this.get('model.email')) || !is.email(this.get('model.email'))) {
set(this, 'adminEmailError', true);
return $("#adminEmail").focus();
}
if (isEmpty(this.model.password)) {
if (isEmpty(this.get('model.password'))) {
set(this, 'adminPasswordError', true);
return $("#adminPassword").focus();
}

View file

@ -1,3 +1,14 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
@ -24,7 +35,7 @@ export default Ember.Component.extend({
Ember.set(this, 'sayThanks', true);
Ember.set(this, 'email', '');
Ember.set(this, 'emailIsEmpty', false);
})
});
}
}
});

View file

@ -1,9 +1,19 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
isEmpty,
computed,
get,
set
} = Ember;
@ -15,19 +25,18 @@ export default Ember.Component.extend({
actions: {
save() {
if (isEmpty(this.model.get('title'))) {
if (isEmpty(this.get('model.title'))) {
set(this, 'titleError', true);
return $("#siteTitle").focus();
}
if (isEmpty(this.model.get('message'))) {
if (isEmpty(this.get('model.message'))) {
set(this, 'messageError', true);
return $("#siteMessage").focus();
}
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
this.get('save')().then(() => {
this.showNotification('Saved');
set(this, 'titleError', false);
set(this, 'messageError', false);
});

View file

@ -1,9 +1,19 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
isEmpty,
isEqual,
isPresent,
computed,
set

View file

@ -1,3 +1,14 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
@ -38,13 +49,13 @@ export default Ember.Component.extend({
let password = this.get('password.password');
let confirmation = this.get('password.confirmation');
if (isEmpty(this.model.get('firstname'))) {
if (isEmpty(this.get('model.firstname'))) {
return $("#firstname").focus();
}
if (isEmpty(this.model.get('lastname'))) {
if (isEmpty(this.get('model.lastname'))) {
return $("#lastname").focus();
}
if (isEmpty(this.model.get('email'))) {
if (isEmpty(this.get('model.email'))) {
return $("#email").focus();
}

View file

@ -1,3 +1,14 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// 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>.
//
// https://documize.com
import Ember from 'ember';
const {
@ -18,15 +29,15 @@ export default Ember.Component.extend({
actions: {
add() {
if (isEmpty(this.newUser.firstname)) {
if (isEmpty(this.get('newUser.firstname'))) {
set(this, 'firstnameError', true);
return $("#newUserFirstname").focus();
}
if (isEmpty(this.newUser.lastname)) {
if (isEmpty(this.get('newUser.lastname'))) {
set(this, 'lastnameError', true);
return $("#newUserLastname").focus();
}
if (isEmpty(this.newUser.email) || is.not.email(this.newUser.email)) {
if (isEmpty(this.get('newUser.email')) || is.not.email(this.get('newUser.email'))) {
set(this, 'emailError', true);
return $("#newUserEmail").focus();
}

View file

@ -13,14 +13,6 @@ import Ember from 'ember';
import NotifierMixin from "../../mixins/notifier";
import Encoding from "../../utils/encoding";
const {
isEmpty,
computed,
isPresent,
get,
set
} = Ember;
export default Ember.Controller.extend(NotifierMixin, {
ajax: Ember.inject.service(),

View file

@ -9,27 +9,27 @@
<div class="input-control">
<label>Team</label>
<div class="tip">What's your tribe called?</div>
{{focus-input id="siteTitle" type="text" value=model.title}}
{{focus-input id="siteTitle" type="text" value=model.title class=(if hasEmptyTitleError 'error')}}
</div>
<div class="input-control">
<label>Firstname</label>
<div class="tip">What do people call you?</div>
{{input id="adminFirstname" type="text" value=model.firstname class=(unless model.firstName 'error')}}
{{input id="adminFirstname" type="text" value=model.firstname class=(if hasEmptyFirstnameError 'error')}}
</div>
<div class="input-control">
<label>Lastname</label>
<div class="tip">How the government refers to you.</div>
{{input id="adminLastname" type="text" value=model.lastname}}
{{input id="adminLastname" type="text" value=model.lastname class=(if hasEmptyLastnameError 'error')}}
</div>
<div class="input-control">
<label>Email</label>
<div class="tip">No spam. Ever!</div>
{{input id="adminEmail" type="email" value=model.email}}
{{input id="adminEmail" type="email" value=model.email class=(if hasEmptyEmailError 'error')}}
</div>
<div class="input-control">
<label>Password</label>
<div class="tip">Something you can remember without writing it down.</div>
{{input id="adminPassword" type="text" value=model.password}}
{{input id="adminPassword" type="text" value=model.password class=(if hasEmptyPasswordError 'error')}}
</div>
<div class="regular-button button-green" {{ action 'save' }}>Go Setup</div>
</div>