1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00
documize/gui/app/models/document-activity.js

118 lines
3.2 KiB
JavaScript
Raw Normal View History

2017-04-04 17:55:17 +01: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
import { computed } from '@ember/object';
2017-04-04 17:55:17 +01:00
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
orgId: attr('string'),
spaceId: attr('string'),
2017-04-04 17:55:17 +01:00
documentId: attr('string'),
2018-01-19 11:36:38 +00:00
pageId: attr('string'),
pageTitle: attr('string'),
2017-04-04 17:55:17 +01:00
userId: attr('string'),
firstname: attr('string'),
lastname: attr('string'),
activityType: attr('number'),
created: attr(),
activityLabel: computed('activityType', function() {
2017-04-04 17:55:17 +01:00
let label = '';
2018-04-20 14:38:10 +01:00
let constants = this.get('constants');
2017-04-04 17:55:17 +01:00
switch (this.get('activityType')) {
case constants.UserActivityType.Created:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('added');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Read:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('viewed');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Edited:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('edited');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Deleted:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('deleted');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Archived:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('archived');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Approved:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('approved');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Reverted:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('reverted');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.PublishedTemplate:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('template_published');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.PublishedBlock:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('block_published');
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Rejected:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('rejected');
break;
2018-04-20 14:38:10 +01:00
case constants.UserActivityType.Published:
2022-03-01 22:59:56 -05:00
label = this.i18n.localize('published');
2018-04-20 14:38:10 +01:00
break;
2017-04-04 17:55:17 +01:00
default:
break;
}
return label;
}),
activityColor: computed('activityType', function() {
2017-04-04 17:55:17 +01:00
let color = '';
2018-04-20 14:38:10 +01:00
let constants = this.get('constants');
2017-04-04 17:55:17 +01:00
switch (this.get('activityType')) {
case constants.UserActivityType.Created:
2018-12-04 17:26:57 +00:00
color = 'color-gray-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Read:
color = 'color-black';
break;
case constants.UserActivityType.Edited:
2018-12-04 17:26:57 +00:00
color = 'color-green-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Deleted:
2018-12-04 17:26:57 +00:00
color = 'color-red-600';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Archived:
2018-12-04 17:26:57 +00:00
color = 'color-gray-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Approved:
2018-12-04 17:26:57 +00:00
color = 'color-green-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Reverted:
2018-12-04 17:26:57 +00:00
color = 'color-red-600';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.PublishedTemplate:
2018-12-04 17:26:57 +00:00
color = 'color-gray-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.PublishedBlock:
2018-12-04 17:26:57 +00:00
color = 'color-gray-700';
2017-04-04 17:55:17 +01:00
break;
case constants.UserActivityType.Rejected:
2018-12-04 17:26:57 +00:00
color = 'color-red-600';
break;
2018-04-20 14:38:10 +01:00
case constants.UserActivityType.Published:
2018-12-04 17:26:57 +00:00
color = 'color-green-700';
2018-04-20 14:38:10 +01:00
break;
2017-04-04 17:55:17 +01:00
default:
break;
}
return color;
})
});