1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 22:59:43 +02:00

Provide basis for document lifecycle

This commit is contained in:
Harvey Kandola 2018-03-15 17:11:53 +00:00
parent d9a9a828ed
commit ba52dfa11d
20 changed files with 350 additions and 154 deletions

View file

@ -10,10 +10,9 @@
// https://documize.com
import { computed } from '@ember/object';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import stringUtil from '../utils/string';
// import { belongsTo, hasMany } from 'ember-data/relationships';
import Model from 'ember-data/model';
export default Model.extend({
name: attr('string'),
@ -27,6 +26,11 @@ export default Model.extend({
template: attr('boolean'),
protection: attr('number', { defaultValue: 0 }),
approval: attr('number', { defaultValue: 0 }),
lifecycle: attr('number', { defaultValue: 1 }),
versioned: attr('boolean'),
versionID: attr('string'),
versionOrder: attr('number', { defaultValue: 0 }),
groupID: attr('string'),
// client-side property
selected: attr('boolean', { defaultValue: false }),
@ -34,5 +38,24 @@ export default Model.extend({
return stringUtil.makeSlug(this.get('name'));
}),
created: attr(),
revised: attr()
revised: attr(),
isDraft: computed('lifecycle', function () {
let constants = this.get('constants');
return this.get('lifecycle') == constants.Lifecycle.Draft;
}),
lifecycleLabel: computed('lifecycle', function () {
let constants = this.get('constants');
switch (this.get('lifecycle')) {
case constants.Lifecycle.Draft:
return constants.Lifecycle.DraftLabel;
case constants.Lifecycle.Live:
return constants.Lifecycle.LiveLabel;
case constants.Lifecycle.Archived:
return constants.Lifecycle.ArchivedLabel;
}
return '';
}),
});