diff --git a/client/src/app/shared/models/motions/motion-log.ts b/client/src/app/shared/models/motions/motion-log.ts
new file mode 100644
index 000000000..c6be1a092
--- /dev/null
+++ b/client/src/app/shared/models/motions/motion-log.ts
@@ -0,0 +1,25 @@
+import { Deserializable } from '../deserializable.model';
+
+/**
+ * Representation of a Motion Version.
+ *
+ * @ignore
+ */
+export class MotionLog implements Deserializable {
+ message_list: string[];
+ person_id: number;
+ time: string;
+ message: string;
+
+ constructor(message_list?: string[], person_id?: number, time?: string, message?: string) {
+ this.message_list = message_list;
+ this.person_id = person_id;
+ this.time = time;
+ this.message = message;
+ }
+
+ deserialize(input: any): this {
+ Object.assign(this, input);
+ return this;
+ }
+}
diff --git a/client/src/app/shared/models/motions/motion-submitter.ts b/client/src/app/shared/models/motions/motion-submitter.ts
new file mode 100644
index 000000000..c355e8ecf
--- /dev/null
+++ b/client/src/app/shared/models/motions/motion-submitter.ts
@@ -0,0 +1,25 @@
+import { Deserializable } from '../deserializable.model';
+
+/**
+ * Representation of a Motion Submitter.
+ *
+ * @ignore
+ */
+export class MotionSubmitter implements Deserializable {
+ id: number;
+ user_id: number;
+ motion_id: number;
+ weight: number;
+
+ constructor(id?: number, user_id?: number, motion_id?: number, weight?: number) {
+ this.id = id;
+ this.user_id = user_id;
+ this.motion_id = motion_id;
+ this.weight = weight;
+ }
+
+ deserialize(input: any): this {
+ Object.assign(this, input);
+ return this;
+ }
+}
diff --git a/client/src/app/shared/models/motions/motion-version.ts b/client/src/app/shared/models/motions/motion-version.ts
new file mode 100644
index 000000000..522d6c84f
--- /dev/null
+++ b/client/src/app/shared/models/motions/motion-version.ts
@@ -0,0 +1,39 @@
+import { Deserializable } from '../deserializable.model';
+
+/**
+ * Representation of a Motion Version.
+ *
+ * @ignore
+ */
+export class MotionVersion implements Deserializable {
+ id: number;
+ version_number: number;
+ creation_time: string;
+ title: string;
+ text: string;
+ amendment_paragraphs: string;
+ reason: string;
+
+ constructor(
+ id?: number,
+ version_number?: number,
+ creation_time?: string,
+ title?: string,
+ text?: string,
+ amendment_paragraphs?: string,
+ reason?: string
+ ) {
+ this.id = id;
+ this.version_number = version_number;
+ this.creation_time = creation_time;
+ this.title = title;
+ this.text = text;
+ this.amendment_paragraphs = amendment_paragraphs;
+ this.reason = reason;
+ }
+
+ deserialize(input: any): this {
+ Object.assign(this, input);
+ return this;
+ }
+}
diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts
index ec910af07..1f9cc7a8e 100644
--- a/client/src/app/shared/models/motions/motion.ts
+++ b/client/src/app/shared/models/motions/motion.ts
@@ -1,9 +1,14 @@
import { BaseModel } from '../base.model';
+import { MotionVersion } from './motion-version';
+import { MotionSubmitter } from './motion-submitter';
+import { MotionLog } from './motion-log';
+import { Config } from '../core/config';
+import { Workflow } from './workflow';
/**
* Representation of Motion.
*
- * Untouched for now because of heavy maintainance on server side
+ * Slightly Defined cause heavy maintaince on server side.
*
* @ignore
*/
@@ -11,13 +16,13 @@ export class Motion extends BaseModel {
protected _collectionString: string;
id: number;
identifier: string;
- versions: Object[];
+ versions: MotionVersion[];
active_version: number;
parent_id: number;
category_id: number;
motion_block_id: number;
origin: string;
- submitters: Object[];
+ submitters: MotionSubmitter[];
supporters_id: number[];
comments: Object;
state_id: number;
@@ -27,18 +32,18 @@ export class Motion extends BaseModel {
attachments_id: number[];
polls: BaseModel[];
agenda_item_id: number;
- log_messages: Object[];
+ log_messages: MotionLog[];
constructor(
id?: number,
identifier?: string,
- versions?: Object[],
+ versions?: MotionVersion[],
active_version?: number,
parent_id?: number,
category_id?: number,
motion_block_id?: number,
origin?: string,
- submitters?: Object[],
+ submitters?: MotionSubmitter[],
supporters_id?: number[],
comments?: Object,
state_id?: number,
@@ -48,7 +53,7 @@ export class Motion extends BaseModel {
attachments_id?: number[],
polls?: BaseModel[],
agenda_item_id?: number,
- log_messages?: Object[]
+ log_messages?: MotionLog[]
) {
super();
this._collectionString = 'motions/motion';
@@ -72,4 +77,58 @@ export class Motion extends BaseModel {
this.agenda_item_id = agenda_item_id;
this.log_messages = log_messages;
}
+
+ /**
+ * return the submitters as uses objects
+ */
+ get submitterAsUser() {
+ const submitterIds = [];
+ this.submitters.forEach(submitter => {
+ submitterIds.push(submitter.user_id);
+ });
+ const users = this.DS.get('users/user', ...submitterIds);
+ return users;
+ }
+
+ /**
+ * return the workflow state
+ *
+ * Right now only the default workflow is assumes
+ */
+ get stateName() {
+ //get the default workflow
+ const motionsWorkflowConfig = this.DS.filter(Config, config => config.key === 'motions_workflow')[0] as Config;
+ //make sure this is a number
+ const workflowId = +motionsWorkflowConfig.value;
+ //get the workflow for out motion
+ const selectedWorkflow = this.DS.get(Workflow, workflowId) as Workflow;
+ return selectedWorkflow.getStateNameById(this.state_id);
+ }
+
+ deserialize(input: any): this {
+ Object.assign(this, input);
+
+ if (input.versions instanceof Array) {
+ this.versions = [];
+ input.versions.forEach(motionVersionData => {
+ this.versions.push(new MotionVersion().deserialize(motionVersionData));
+ });
+ }
+
+ if (input.submitters instanceof Array) {
+ this.submitters = [];
+ input.submitters.forEach(SubmitterData => {
+ this.submitters.push(new MotionSubmitter().deserialize(SubmitterData));
+ });
+ }
+
+ if (input.log_messages instanceof Array) {
+ this.log_messages = [];
+ input.log_messages.forEach(logData => {
+ this.log_messages.push(new MotionLog().deserialize(logData));
+ });
+ }
+
+ return this;
+ }
}
diff --git a/client/src/app/shared/models/motions/workflow.ts b/client/src/app/shared/models/motions/workflow.ts
index c26cfe179..0487fb07b 100644
--- a/client/src/app/shared/models/motions/workflow.ts
+++ b/client/src/app/shared/models/motions/workflow.ts
@@ -21,6 +21,16 @@ export class Workflow extends BaseModel {
this.first_state = first_state;
}
+ getStateNameById(id: number): string {
+ let stateName = 'NULL';
+ this.states.forEach(state => {
+ if (id === state.id) {
+ stateName = state.name;
+ }
+ });
+ return stateName;
+ }
+
deserialize(input: any): this {
Object.assign(this, input);
if (input.states instanceof Array) {
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 54fb55c32..cac662992 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -11,7 +11,9 @@ import {
MatInputModule,
MatProgressSpinnerModule,
MatSidenavModule,
- MatSnackBarModule
+ MatSnackBarModule,
+ MatTableModule,
+ MatPaginatorModule
} from '@angular/material';
import { MatDialogModule } from '@angular/material/dialog';
import { MatListModule } from '@angular/material/list';
@@ -53,6 +55,8 @@ library.add(fas);
MatToolbarModule,
MatCardModule,
MatInputModule,
+ MatTableModule,
+ MatPaginatorModule,
MatProgressSpinnerModule,
MatSidenavModule,
MatListModule,
@@ -70,6 +74,8 @@ library.add(fas);
MatToolbarModule,
MatCardModule,
MatInputModule,
+ MatTableModule,
+ MatPaginatorModule,
MatProgressSpinnerModule,
MatSidenavModule,
MatListModule,
diff --git a/client/src/app/site/motions/motion-list/motion-list.component.css b/client/src/app/site/motions/motion-list/motion-list.component.css
deleted file mode 100644
index e69de29bb..000000000
diff --git a/client/src/app/site/motions/motion-list/motion-list.component.html b/client/src/app/site/motions/motion-list/motion-list.component.html
index 23669987d..e8d2de377 100644
--- a/client/src/app/site/motions/motion-list/motion-list.component.html
+++ b/client/src/app/site/motions/motion-list/motion-list.component.html
@@ -14,128 +14,52 @@
-
Bezeichner | ++ + {{motion.identifier}} + + | +Titel | +
+ {{motion.versions[0].title}}
+ + + von + {{motion.submitterAsUser.username}} + + |
+ Status | +
+ |
+
---|