2016-08-16 13:36:26 +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 { computed } from '@ember/object';
|
2016-08-09 13:16:29 +02:00
|
|
|
import Model from 'ember-data/model';
|
|
|
|
import attr from 'ember-data/attr';
|
|
|
|
|
|
|
|
export default Model.extend({
|
|
|
|
documentId: attr('string'),
|
|
|
|
orgId: attr('string'),
|
|
|
|
contentType: attr('string'),
|
2016-11-09 15:16:44 -08:00
|
|
|
pageType: attr('string'),
|
2016-08-09 13:16:29 +02:00
|
|
|
level: attr('number', { defaultValue: 1 }),
|
2018-01-22 10:31:03 +00:00
|
|
|
sequence: attr('number', { defaultValue: 1024 }),
|
2017-12-10 14:05:23 +00:00
|
|
|
numbering: attr('string'),
|
2016-08-09 13:16:29 +02:00
|
|
|
revisions: attr('number', { defaultValue: 0 }),
|
2017-01-21 14:29:36 -08:00
|
|
|
blockId: attr('string'),
|
2016-08-09 13:16:29 +02:00
|
|
|
title: attr('string'),
|
|
|
|
body: attr('string'),
|
|
|
|
rawBody: attr('string'),
|
|
|
|
meta: attr(),
|
2018-01-22 10:31:03 +00:00
|
|
|
status: attr('number', { defaultValue: 0 }),
|
2018-01-10 16:07:17 +00:00
|
|
|
relativeId: attr('string'),
|
2018-01-22 10:31:03 +00:00
|
|
|
userId: attr('string'),
|
2017-12-24 15:51:43 +00:00
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
tagName: computed('level', function () {
|
2017-03-05 17:27:43 +00:00
|
|
|
return "h2";
|
2016-08-09 13:16:29 +02:00
|
|
|
}),
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
tocIndent: computed('level', function () {
|
2019-04-18 13:31:48 +01:00
|
|
|
return (this.get('level') - 1) * 10;
|
2016-08-09 13:16:29 +02:00
|
|
|
}),
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
tocIndentCss: computed('tocIndent', function () {
|
2016-08-09 13:16:29 +02:00
|
|
|
let tocIndent = this.get('tocIndent');
|
|
|
|
return `margin-left-${tocIndent}`;
|
2016-08-24 13:10:54 +02:00
|
|
|
}),
|
2016-11-30 17:56:36 -08:00
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
hasRevisions: computed('revisions', function () {
|
2016-11-30 17:56:36 -08:00
|
|
|
return this.get('revisions') > 0;
|
|
|
|
}),
|
|
|
|
|
2016-08-24 13:10:54 +02:00
|
|
|
created: attr(),
|
2018-01-22 10:31:03 +00:00
|
|
|
revised: attr(),
|
|
|
|
|
|
|
|
// is this a new page that is pending and belongs to the user?
|
|
|
|
isNewPageUserPending(userId) {
|
|
|
|
return this.get('relativeId') === '' && this.get('userId') === userId && (
|
|
|
|
this.get('status') === this.get('constants').ChangeState.PendingNew || this.get('status') === this.get('constants').ChangeState.UnderReview);
|
|
|
|
},
|
|
|
|
|
|
|
|
// is this new page ready for review?
|
|
|
|
isNewPageReviewReady() {
|
|
|
|
return this.get('relativeId') === '' && this.get('status') === this.get('constants').ChangeState.UnderReview;
|
|
|
|
}
|
2016-11-10 16:19:51 -08:00
|
|
|
});
|