src/lib/model/inbox-item.model.ts
InboxState
Properties |
calculationtime |
calculationtime:
|
Type : Date
|
overduemessages |
overduemessages:
|
Type : number
|
totalmessages |
totalmessages:
|
Type : number
|
unreadmessages |
unreadmessages:
|
Type : number
|
import moment from 'moment';
/**
* Items emitted by the inbox service
*/
export class InboxItem {
public static TYPE_BPM = 'BPM';
public static TYPE_RESUBMISSION = 'RESUBMISSION';
public static TYPE_SUBSCRIPTION = 'SUBSCRIPTION';
/**
* Items ID
*/
id: string;
/**
* Items title
*/
title: string;
/**
* Items description
*/
description: string;
/**
* Items type ('BPM', 'RESUBMISSION', 'SUBSCRIPTION')
*/
type: string;
/**
* ID of the object that caused the inbox entry.
* In case of type SUBSCRIPTION and RESUBMISSION this is the id of the dms object,
* for type BPM it is a process id
*/
sourceId: string;
/**
* Items icon ID
*/
iconId: string;
/**
* Flag indicating whether or not the entry has been accepted
*/
accepted: boolean;
/**
* Flag indicating that the current user got this task in substitute
*/
isdeputy: boolean;
/**
* The date the item is due.
*/
duetime: Date;
/**
* The date the item was received
*/
received: Date;
target: any;
/**
* Creates a new instance
* @param json The JSON object received from the backend. This will be used to construct the new inbox item instance
*/
constructor(json: any) {
// todo: jsut use Object assign when backend changes are done
// Object.assign(this, json);
this.id = json.inboxentryid;
this.title = json.title;
this.description = json.description;
this.type = json.type;
this.sourceId = json.source ? json.source.id : null;
this.iconId = json.target && json.target.icon ? json.target.icon.id : null;
this.accepted = json.accepted;
this.isdeputy = json.isdeputy;
this.duetime = json.duetime;
this.received = json.receivetime;
this.target = json.target;
}
/**
* Determines whether or not the inbox item is overdue
* @returns True when inbox item is overdue, false otherwise
*/
isOverdue() {
return this.duetime && moment(this.duetime).isBefore(moment());
}
}
/**
* InboxState
*/
export interface InboxState {
totalmessages: number;
overduemessages: number;
unreadmessages: number;
calculationtime: Date;
}