2016-08-01 15:07:46 +02:00
|
|
|
// 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
|
|
|
|
|
2019-03-03 18:03:48 +00:00
|
|
|
import stringUtil from '../../utils/string';
|
2019-06-19 12:46:46 +01:00
|
|
|
import $ from 'jquery';
|
|
|
|
import { empty } from '@ember/object/computed';
|
|
|
|
import { inject as service } from '@ember/service';
|
2018-09-24 18:53:01 +01:00
|
|
|
import Component from '@ember/component';
|
2016-07-28 16:49:31 +02:00
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
export default Component.extend({
|
2019-06-19 12:46:46 +01:00
|
|
|
appMeta: service(),
|
2018-09-26 17:59:56 +01:00
|
|
|
buttonLabel: 'Complete setup',
|
2019-06-19 12:46:46 +01:00
|
|
|
hasTitleError: empty('model.title'),
|
|
|
|
hasFirstnameError: empty('model.firstname'),
|
|
|
|
hasLastnameError: empty('model.lastname'),
|
|
|
|
hasEmailError: empty('model.email'),
|
|
|
|
hasPasswordError: empty('model.password'),
|
|
|
|
hasKeyError: empty('model.activationKey'),
|
2016-07-28 16:49:31 +02:00
|
|
|
|
|
|
|
actions: {
|
2019-06-19 12:46:46 +01:00
|
|
|
save () {
|
|
|
|
if (this.get('hasTitleError')) return $("#setup-title").focus();
|
|
|
|
if (this.get('hasFirstnameError')) return $("#setup-firstname").focus();
|
|
|
|
if (this.get('hasLastnameError')) return $("#setup-lastname").focus();
|
|
|
|
if (this.get('hasEmailError') || !stringUtil.isEmail(this.get('model.email'))) return $("#setup-email").focus();
|
|
|
|
if (this.get('hasPasswordError')) return $("#new-password").focus();
|
|
|
|
|
|
|
|
if (this.get('model.edition') === this.get('constants').Product.EnterpriseEdition && this.get('hasKeyError')) {
|
|
|
|
return $("#activation-key").focus();
|
2016-07-28 16:49:31 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 12:46:46 +01:00
|
|
|
this.set('buttonLabel', 'Setting up, please wait...');
|
2018-09-24 18:53:01 +01:00
|
|
|
|
2019-06-19 12:46:46 +01:00
|
|
|
this.get('save')();
|
2016-07-28 16:49:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|