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:
parent
6beaaa3122
commit
727fec0d5f
8 changed files with 90 additions and 37 deletions
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isEqual,
|
|
||||||
isPresent,
|
|
||||||
computed,
|
computed,
|
||||||
set
|
set
|
||||||
|
|
||||||
|
@ -15,35 +24,35 @@ export default Ember.Component.extend({
|
||||||
lastnameEmpty: computed.empty('model.lastname'),
|
lastnameEmpty: computed.empty('model.lastname'),
|
||||||
emailEmpty: computed.empty('model.email'),
|
emailEmpty: computed.empty('model.email'),
|
||||||
passwordEmpty: computed.empty('model.password'),
|
passwordEmpty: computed.empty('model.password'),
|
||||||
hasPasswordError: computed.and('titleEmpty', 'titleError'),
|
hasEmptyTitleError: computed.and('titleEmpty', 'titleError'),
|
||||||
hasConfirmError: computed.and('firstnameEmpty', 'adminFirstnameError'),
|
hasEmptyFirstnameError: computed.and('firstnameEmpty', 'adminFirstnameError'),
|
||||||
hasPasswordError: computed.and('lastnameEmpty', 'adminLastnameError'),
|
hasEmptyLastnameError: computed.and('lastnameEmpty', 'adminLastnameError'),
|
||||||
hasConfirmError: computed.and('emailEmpty', 'adminEmailError'),
|
hasEmptyEmailError: computed.and('emailEmpty', 'adminEmailError'),
|
||||||
hasPasswordError: computed.and('passwordEmpty', 'adminPasswordError'),
|
hasEmptyPasswordError: computed.and('passwordEmpty', 'adminPasswordError'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
if (isEmpty(this.model.title)) {
|
if (isEmpty(this.get('model.title'))) {
|
||||||
set(this, 'titleError', true);
|
set(this, 'titleError', true);
|
||||||
return $("#siteTitle").focus();
|
return $("#siteTitle").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.model.firstname)) {
|
if (isEmpty(this.get('model.firstname'))) {
|
||||||
set(this, 'adminFirstnameError', true);
|
set(this, 'adminFirstnameError', true);
|
||||||
return $("#adminFirstname").focus();
|
return $("#adminFirstname").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.model.lastname)) {
|
if (isEmpty(this.get('model.lastname'))) {
|
||||||
set(this, 'adminLastnameError', true);
|
set(this, 'adminLastnameError', true);
|
||||||
return $("#adminLastname").focus();
|
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);
|
set(this, 'adminEmailError', true);
|
||||||
return $("#adminEmail").focus();
|
return $("#adminEmail").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.model.password)) {
|
if (isEmpty(this.get('model.password'))) {
|
||||||
set(this, 'adminPasswordError', true);
|
set(this, 'adminPasswordError', true);
|
||||||
return $("#adminPassword").focus();
|
return $("#adminPassword").focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -24,7 +35,7 @@ export default Ember.Component.extend({
|
||||||
Ember.set(this, 'sayThanks', true);
|
Ember.set(this, 'sayThanks', true);
|
||||||
Ember.set(this, 'email', '');
|
Ember.set(this, 'email', '');
|
||||||
Ember.set(this, 'emailIsEmpty', false);
|
Ember.set(this, 'emailIsEmpty', false);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isEmpty,
|
isEmpty,
|
||||||
computed,
|
computed,
|
||||||
get,
|
|
||||||
set
|
set
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
|
@ -15,19 +25,18 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
if (isEmpty(this.model.get('title'))) {
|
if (isEmpty(this.get('model.title'))) {
|
||||||
set(this, 'titleError', true);
|
set(this, 'titleError', true);
|
||||||
return $("#siteTitle").focus();
|
return $("#siteTitle").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.model.get('message'))) {
|
if (isEmpty(this.get('model.message'))) {
|
||||||
set(this, 'messageError', true);
|
set(this, 'messageError', true);
|
||||||
return $("#siteMessage").focus();
|
return $("#siteMessage").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
|
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
|
||||||
this.get('save')().then(() => {
|
this.get('save')().then(() => {
|
||||||
this.showNotification('Saved');
|
|
||||||
set(this, 'titleError', false);
|
set(this, 'titleError', false);
|
||||||
set(this, 'messageError', false);
|
set(this, 'messageError', false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isEqual,
|
isEqual,
|
||||||
isPresent,
|
|
||||||
computed,
|
computed,
|
||||||
set
|
set
|
||||||
|
|
||||||
|
|
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -38,13 +49,13 @@ export default Ember.Component.extend({
|
||||||
let password = this.get('password.password');
|
let password = this.get('password.password');
|
||||||
let confirmation = this.get('password.confirmation');
|
let confirmation = this.get('password.confirmation');
|
||||||
|
|
||||||
if (isEmpty(this.model.get('firstname'))) {
|
if (isEmpty(this.get('model.firstname'))) {
|
||||||
return $("#firstname").focus();
|
return $("#firstname").focus();
|
||||||
}
|
}
|
||||||
if (isEmpty(this.model.get('lastname'))) {
|
if (isEmpty(this.get('model.lastname'))) {
|
||||||
return $("#lastname").focus();
|
return $("#lastname").focus();
|
||||||
}
|
}
|
||||||
if (isEmpty(this.model.get('email'))) {
|
if (isEmpty(this.get('model.email'))) {
|
||||||
return $("#email").focus();
|
return $("#email").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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';
|
import Ember from 'ember';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -18,15 +29,15 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
add() {
|
add() {
|
||||||
if (isEmpty(this.newUser.firstname)) {
|
if (isEmpty(this.get('newUser.firstname'))) {
|
||||||
set(this, 'firstnameError', true);
|
set(this, 'firstnameError', true);
|
||||||
return $("#newUserFirstname").focus();
|
return $("#newUserFirstname").focus();
|
||||||
}
|
}
|
||||||
if (isEmpty(this.newUser.lastname)) {
|
if (isEmpty(this.get('newUser.lastname'))) {
|
||||||
set(this, 'lastnameError', true);
|
set(this, 'lastnameError', true);
|
||||||
return $("#newUserLastname").focus();
|
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);
|
set(this, 'emailError', true);
|
||||||
return $("#newUserEmail").focus();
|
return $("#newUserEmail").focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,6 @@ import Ember from 'ember';
|
||||||
import NotifierMixin from "../../mixins/notifier";
|
import NotifierMixin from "../../mixins/notifier";
|
||||||
import Encoding from "../../utils/encoding";
|
import Encoding from "../../utils/encoding";
|
||||||
|
|
||||||
const {
|
|
||||||
isEmpty,
|
|
||||||
computed,
|
|
||||||
isPresent,
|
|
||||||
get,
|
|
||||||
set
|
|
||||||
} = Ember;
|
|
||||||
|
|
||||||
export default Ember.Controller.extend(NotifierMixin, {
|
export default Ember.Controller.extend(NotifierMixin, {
|
||||||
|
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
|
|
@ -9,27 +9,27 @@
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Team</label>
|
<label>Team</label>
|
||||||
<div class="tip">What's your tribe called?</div>
|
<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>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Firstname</label>
|
<label>Firstname</label>
|
||||||
<div class="tip">What do people call you?</div>
|
<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>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Lastname</label>
|
<label>Lastname</label>
|
||||||
<div class="tip">How the government refers to you.</div>
|
<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>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Email</label>
|
<label>Email</label>
|
||||||
<div class="tip">No spam. Ever!</div>
|
<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>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<div class="tip">Something you can remember without writing it down.</div>
|
<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>
|
||||||
<div class="regular-button button-green" {{ action 'save' }}>Go Setup</div>
|
<div class="regular-button button-green" {{ action 'save' }}>Go Setup</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue