sort by date in motion
This commit is contained in:
parent
12c6554064
commit
6d18d70845
@ -241,7 +241,11 @@ export abstract class SortListService<V extends BaseViewModel> {
|
||||
const b = secondProperty();
|
||||
return a.localeCompare(b, lang);
|
||||
case 'object':
|
||||
if (firstProperty instanceof Date) {
|
||||
return firstProperty > secondProperty ? 1 : -1;
|
||||
} else {
|
||||
return firstProperty.toString().localeCompare(secondProperty.toString(), lang);
|
||||
}
|
||||
case 'undefined':
|
||||
return 1;
|
||||
default:
|
||||
|
@ -41,6 +41,8 @@ export class Motion extends AgendaBaseModel {
|
||||
public log_messages: MotionLog[];
|
||||
public weight: number;
|
||||
public sort_parent_id: number;
|
||||
public created: string;
|
||||
public last_modified: string;
|
||||
|
||||
public constructor(input?: any) {
|
||||
super('motions/motion', 'Motion', input);
|
||||
|
@ -220,6 +220,26 @@ export class ViewMotion extends BaseViewModel {
|
||||
return this._attachments ? this._attachments : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the creation date as Date object
|
||||
*/
|
||||
public get creationDate(): Date {
|
||||
if (!this.motion || !this.motion.created) {
|
||||
return null;
|
||||
}
|
||||
return new Date(this.motion.created);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the date of the last change as Date object, null if empty
|
||||
*/
|
||||
public get lastChangeDate(): Date {
|
||||
if (!this.motion || !this.motion.last_modified) {
|
||||
return null;
|
||||
}
|
||||
return new Date(this.motion.last_modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comments' section ids of a motion. Used in filter by motionComment
|
||||
*
|
||||
|
@ -17,10 +17,9 @@ export class MotionSortListService extends SortListService<ViewMotion> {
|
||||
{ property: 'submitters' },
|
||||
{ property: 'category' },
|
||||
{ property: 'motion_block_id', label: 'Motion block' },
|
||||
{ property: 'state' }
|
||||
// choices from 2.3:
|
||||
// TODO creation date
|
||||
// TODO last modified
|
||||
{ property: 'state' },
|
||||
{ property: 'creationDate', label: 'Creation date' },
|
||||
{ property: 'lastChangeDate', label: 'Last modified' }
|
||||
]
|
||||
};
|
||||
protected name = 'Motion';
|
||||
|
Loading…
Reference in New Issue
Block a user