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
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
import $ from 'jquery';
|
2017-11-28 12:27:50 +00:00
|
|
|
import { empty, and } from '@ember/object/computed';
|
2017-11-16 13:28:05 +00:00
|
|
|
import { isEmpty } from '@ember/utils';
|
|
|
|
import { set } from '@ember/object';
|
2018-06-05 14:04:14 +01:00
|
|
|
import Notifier from '../../mixins/notifier';
|
|
|
|
import Component from '@ember/component';
|
2017-11-16 13:28:05 +00:00
|
|
|
|
2018-06-05 14:04:14 +01:00
|
|
|
export default Component.extend(Notifier, {
|
2017-11-16 13:28:05 +00:00
|
|
|
titleEmpty: empty('model.general.title'),
|
|
|
|
messageEmpty: empty('model.general.message'),
|
|
|
|
conversionEndpointEmpty: empty('model.general.conversionEndpoint'),
|
|
|
|
hasTitleInputError: and('titleEmpty', 'titleError'),
|
|
|
|
hasMessageInputError: and('messageEmpty', 'messageError'),
|
|
|
|
hasConversionEndpointInputError: and('conversionEndpointEmpty', 'conversionEndpointError'),
|
2016-07-27 13:18:57 +02:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
save() {
|
2016-10-18 19:20:51 -07:00
|
|
|
if (isEmpty(this.get('model.general.title'))) {
|
2016-07-28 15:17:14 +02:00
|
|
|
set(this, 'titleError', true);
|
2016-07-27 13:18:57 +02:00
|
|
|
return $("#siteTitle").focus();
|
|
|
|
}
|
|
|
|
|
2016-10-18 19:20:51 -07:00
|
|
|
if (isEmpty(this.get('model.general.message'))) {
|
2016-07-28 15:17:14 +02:00
|
|
|
set(this, 'messageError', true);
|
2016-07-27 13:18:57 +02:00
|
|
|
return $("#siteMessage").focus();
|
|
|
|
}
|
|
|
|
|
2017-06-06 19:00:35 -04:00
|
|
|
if (isEmpty(this.get('model.general.conversionEndpoint'))) {
|
|
|
|
set(this, 'conversionEndpointError', true);
|
|
|
|
return $("#conversionEndpoint").focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
let e = this.get('model.general.conversionEndpoint');
|
|
|
|
if (is.endWith(e, '/')) {
|
|
|
|
this.set('model.general.conversionEndpoint', e.substring(0, e.length-1));
|
|
|
|
}
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
this.model.general.set('allowAnonymousAccess', $("#allowAnonymousAccess").prop('checked'));
|
2017-06-06 19:00:35 -04:00
|
|
|
|
2018-06-05 14:04:14 +01:00
|
|
|
this.showWait();
|
|
|
|
|
2016-07-28 15:17:14 +02:00
|
|
|
this.get('save')().then(() => {
|
2018-06-05 14:04:14 +01:00
|
|
|
this.showDone();
|
2016-07-28 15:17:14 +02:00
|
|
|
set(this, 'titleError', false);
|
|
|
|
set(this, 'messageError', false);
|
2017-06-06 19:00:35 -04:00
|
|
|
set(this, 'conversionEndpointError', false);
|
2016-07-28 15:17:14 +02:00
|
|
|
});
|
2016-07-27 13:18:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|