diff --git a/client/src/app/core/services/sort-list.service.ts b/client/src/app/core/services/sort-list.service.ts index e25287a69..af1015094 100644 --- a/client/src/app/core/services/sort-list.service.ts +++ b/client/src/app/core/services/sort-list.service.ts @@ -241,7 +241,11 @@ export abstract class SortListService { const b = secondProperty(); return a.localeCompare(b, lang); case 'object': - return firstProperty.toString().localeCompare(secondProperty.toString(), lang); + if (firstProperty instanceof Date) { + return firstProperty > secondProperty ? 1 : -1; + } else { + return firstProperty.toString().localeCompare(secondProperty.toString(), lang); + } case 'undefined': return 1; default: diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts index 4690acea8..48e96c726 100644 --- a/client/src/app/shared/models/motions/motion.ts +++ b/client/src/app/shared/models/motions/motion.ts @@ -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); diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index cdbbb87b4..d6efd3e2b 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -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 * diff --git a/client/src/app/site/motions/services/motion-sort-list.service.ts b/client/src/app/site/motions/services/motion-sort-list.service.ts index 6b32bfa92..d3117450c 100644 --- a/client/src/app/site/motions/services/motion-sort-list.service.ts +++ b/client/src/app/site/motions/services/motion-sort-list.service.ts @@ -17,10 +17,9 @@ export class MotionSortListService extends SortListService { { 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';