Merge pull request #4144 from MaximilianKrambach/dateSort
sort by date in motion
This commit is contained in:
commit
034a4d2a67
@ -241,7 +241,11 @@ export abstract class SortListService<V extends BaseViewModel> {
|
|||||||
const b = secondProperty();
|
const b = secondProperty();
|
||||||
return a.localeCompare(b, lang);
|
return a.localeCompare(b, lang);
|
||||||
case 'object':
|
case 'object':
|
||||||
|
if (firstProperty instanceof Date) {
|
||||||
|
return firstProperty > secondProperty ? 1 : -1;
|
||||||
|
} else {
|
||||||
return firstProperty.toString().localeCompare(secondProperty.toString(), lang);
|
return firstProperty.toString().localeCompare(secondProperty.toString(), lang);
|
||||||
|
}
|
||||||
case 'undefined':
|
case 'undefined':
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
|
@ -41,6 +41,8 @@ export class Motion extends AgendaBaseModel {
|
|||||||
public log_messages: MotionLog[];
|
public log_messages: MotionLog[];
|
||||||
public weight: number;
|
public weight: number;
|
||||||
public sort_parent_id: number;
|
public sort_parent_id: number;
|
||||||
|
public created: string;
|
||||||
|
public last_modified: string;
|
||||||
|
|
||||||
public constructor(input?: any) {
|
public constructor(input?: any) {
|
||||||
super('motions/motion', 'Motion', input);
|
super('motions/motion', 'Motion', input);
|
||||||
|
@ -220,6 +220,26 @@ export class ViewMotion extends BaseViewModel {
|
|||||||
return this._attachments ? this._attachments : null;
|
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
|
* 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: 'submitters' },
|
||||||
{ property: 'category' },
|
{ property: 'category' },
|
||||||
{ property: 'motion_block_id', label: 'Motion block' },
|
{ property: 'motion_block_id', label: 'Motion block' },
|
||||||
{ property: 'state' }
|
{ property: 'state' },
|
||||||
// choices from 2.3:
|
{ property: 'creationDate', label: 'Creation date' },
|
||||||
// TODO creation date
|
{ property: 'lastChangeDate', label: 'Last modified' }
|
||||||
// TODO last modified
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
protected name = 'Motion';
|
protected name = 'Motion';
|
||||||
|
@ -576,7 +576,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
|
|
||||||
# Save motion.
|
# Save motion.
|
||||||
motion.save(
|
motion.save(
|
||||||
update_fields=["state", "identifier", "identifier_number"],
|
update_fields=["state", "identifier", "identifier_number", "last_modified"],
|
||||||
skip_autoupdate=True,
|
skip_autoupdate=True,
|
||||||
)
|
)
|
||||||
message = f"The state of the motion was set to {motion.state.name}."
|
message = f"The state of the motion was set to {motion.state.name}."
|
||||||
@ -648,7 +648,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
motion.set_state(state_id)
|
motion.set_state(state_id)
|
||||||
|
|
||||||
# Save motion.
|
# Save motion.
|
||||||
motion.save(update_fields=["state"], skip_autoupdate=True)
|
motion.save(update_fields=["state", "last_modified"], skip_autoupdate=True)
|
||||||
|
|
||||||
# Write the log message.
|
# Write the log message.
|
||||||
motion.write_log(
|
motion.write_log(
|
||||||
@ -708,7 +708,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
motion.recommendation = None
|
motion.recommendation = None
|
||||||
|
|
||||||
# Save motion.
|
# Save motion.
|
||||||
motion.save(update_fields=["recommendation"], skip_autoupdate=True)
|
motion.save(update_fields=["recommendation", "last_modified"], skip_autoupdate=True)
|
||||||
label = (
|
label = (
|
||||||
motion.recommendation.recommendation_label
|
motion.recommendation.recommendation_label
|
||||||
if motion.recommendation
|
if motion.recommendation
|
||||||
@ -794,7 +794,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
motion.set_recommendation(recommendation_state_id)
|
motion.set_recommendation(recommendation_state_id)
|
||||||
|
|
||||||
# Save motion.
|
# Save motion.
|
||||||
motion.save(update_fields=["recommendation"], skip_autoupdate=True)
|
motion.save(update_fields=["recommendation", "last_modified"], skip_autoupdate=True)
|
||||||
label = (
|
label = (
|
||||||
motion.recommendation.recommendation_label
|
motion.recommendation.recommendation_label
|
||||||
if motion.recommendation
|
if motion.recommendation
|
||||||
@ -842,6 +842,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
"identifier",
|
"identifier",
|
||||||
"identifier_number",
|
"identifier_number",
|
||||||
"state_extension",
|
"state_extension",
|
||||||
|
"last_modified",
|
||||||
],
|
],
|
||||||
skip_autoupdate=True,
|
skip_autoupdate=True,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user