1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00
documize/gui/app/components/customize/general-settings.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

// 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 $ from 'jquery';
import { empty, and } from '@ember/object/computed';
import { isEmpty } from '@ember/utils';
import { set } from '@ember/object';
import Notifier from '../../mixins/notifier';
import Component from '@ember/component';
export default Component.extend(Notifier, {
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() {
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();
}
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();
}
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));
}
this.model.general.set('allowAnonymousAccess', $("#allowAnonymousAccess").prop('checked'));
this.showWait();
2016-07-28 15:17:14 +02:00
this.get('save')().then(() => {
this.showDone();
2016-07-28 15:17:14 +02:00
set(this, 'titleError', false);
set(this, 'messageError', false);
set(this, 'conversionEndpointError', false);
2016-07-28 15:17:14 +02:00
});
2016-07-27 13:18:57 +02:00
}
}
});