Add motion controls + small fixes
This commit is contained in:
parent
b6ad0d759c
commit
0c05eb38e2
@ -249,7 +249,17 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #contentTemplate>
|
<ng-template #contentTemplate>
|
||||||
<form [formGroup]='contentForm' (ngSubmit)='saveMotion()'>
|
<form class="motion-content" [formGroup]='contentForm' (ngSubmit)='saveMotion()'>
|
||||||
|
|
||||||
|
<!-- Line Number and Diff buttons-->
|
||||||
|
<div class="motion-text-controls">
|
||||||
|
<button type="button" mat-icon-button [matMenuTriggerFor]="lineNumberingMenu">
|
||||||
|
<fa-icon icon="list-ol" [fixedWidth]="true"></fa-icon>
|
||||||
|
</button>
|
||||||
|
<button type="button" mat-icon-button [matMenuTriggerFor]="changeRecoMenu">
|
||||||
|
<fa-icon icon="edit" [fixedWidth]="true"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
<div *ngIf="motion && motion.title || editMotion">
|
<div *ngIf="motion && motion.title || editMotion">
|
||||||
@ -266,7 +276,7 @@
|
|||||||
<!-- TODO: this is a config variable. Read it out -->
|
<!-- TODO: this is a config variable. Read it out -->
|
||||||
<h3 translate>The assembly may decide:</h3>
|
<h3 translate>The assembly may decide:</h3>
|
||||||
<div *ngIf='motion && !editMotion'>
|
<div *ngIf='motion && !editMotion'>
|
||||||
<div [innerHtml]='motion.text'></div>
|
<div [innerHtml]='getFormatedText()'></div>
|
||||||
</div>
|
</div>
|
||||||
<mat-form-field *ngIf="motion && editMotion" class="wide-form">
|
<mat-form-field *ngIf="motion && editMotion" class="wide-form">
|
||||||
<textarea matInput placeholder='Motion Text' formControlName='text' [value]='motionCopy.text'></textarea>
|
<textarea matInput placeholder='Motion Text' formControlName='text' [value]='motionCopy.text'></textarea>
|
||||||
@ -286,3 +296,18 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
|
<!-- Line number Menu -->
|
||||||
|
<mat-menu #lineNumberingMenu="matMenu">
|
||||||
|
<button mat-menu-item translate (click)=setLineNumberingMode(0)>None</button>
|
||||||
|
<button mat-menu-item translate (click)=setLineNumberingMode(1)>Inline</button>
|
||||||
|
<button mat-menu-item translate (click)=setLineNumberingMode(2)>Outside</button>
|
||||||
|
</mat-menu>
|
||||||
|
|
||||||
|
<!-- Diff View Menu -->
|
||||||
|
<mat-menu #changeRecoMenu="matMenu">
|
||||||
|
<button mat-menu-item translate (click)=setChangeRecoMode(0)>Original version</button>
|
||||||
|
<button mat-menu-item translate (click)=setChangeRecoMode(1)>Changed version</button>
|
||||||
|
<button mat-menu-item translate (click)=setChangeRecoMode(2)>Diff version</button>
|
||||||
|
<button mat-menu-item translate (click)=setChangeRecoMode(3)>Final version</button>
|
||||||
|
</mat-menu>
|
||||||
|
@ -7,6 +7,17 @@ span {
|
|||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.motion-content {
|
||||||
|
display: flow-root;
|
||||||
|
}
|
||||||
|
|
||||||
|
.motion-text-controls {
|
||||||
|
float: right;
|
||||||
|
button {
|
||||||
|
font-size: 115%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.motion-submitter {
|
.motion-submitter {
|
||||||
display: inline;
|
display: inline;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -168,8 +168,8 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|||||||
category_id: [''],
|
category_id: [''],
|
||||||
state_id: [''],
|
state_id: [''],
|
||||||
recommendation_id: [''],
|
recommendation_id: [''],
|
||||||
submitters_id: [''],
|
submitters_id: [],
|
||||||
supporters_id: [''],
|
supporters_id: [],
|
||||||
origin: ['']
|
origin: ['']
|
||||||
});
|
});
|
||||||
this.contentForm = this.formBuilder.group({
|
this.contentForm = this.formBuilder.group({
|
||||||
@ -197,28 +197,42 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|||||||
|
|
||||||
if (this.newMotion) {
|
if (this.newMotion) {
|
||||||
this.repo.create(fromForm).subscribe(response => {
|
this.repo.create(fromForm).subscribe(response => {
|
||||||
this.router.navigate(['./motions/' + response.id]);
|
if (response.id) {
|
||||||
|
this.router.navigate(['./motions/' + response.id]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.repo.update(fromForm, this.motionCopy).subscribe();
|
this.repo.update(fromForm, this.motionCopy).subscribe(response => {
|
||||||
|
// if the motion was successfully updated, change the edit mode.
|
||||||
|
// TODO: Show errors if there appear here
|
||||||
|
if (response.id) {
|
||||||
|
this.editMotion = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the formated motion text from the repository.
|
||||||
|
*/
|
||||||
|
public getFormatedText(): string {
|
||||||
|
return this.repo.formatMotion(this.motion.id, this.motion.lnMode, this.motion.crMode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Click on the edit button (pen-symbol)
|
* Click on the edit button (pen-symbol)
|
||||||
*/
|
*/
|
||||||
public editMotionButton(): void {
|
public editMotionButton(): void {
|
||||||
this.editMotion ? (this.editMotion = false) : (this.editMotion = true);
|
|
||||||
if (this.editMotion) {
|
if (this.editMotion) {
|
||||||
// copy the motion
|
this.saveMotion();
|
||||||
|
} else {
|
||||||
|
this.editMotion = true;
|
||||||
this.motionCopy = this.motion.copy();
|
this.motionCopy = this.motion.copy();
|
||||||
this.patchForm(this.motionCopy);
|
this.patchForm(this.motionCopy);
|
||||||
if (this.vp.isMobile) {
|
if (this.vp.isMobile) {
|
||||||
this.metaInfoPanel.open();
|
this.metaInfoPanel.open();
|
||||||
this.contentPanel.open();
|
this.contentPanel.open();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.saveMotion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,6 +260,22 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the motions line numbering mode
|
||||||
|
* @param mode Needs to fot to the enum defined in ViewMotion
|
||||||
|
*/
|
||||||
|
public setLineNumberingMode(mode: number): void {
|
||||||
|
this.motion.lnMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the motions change reco mode
|
||||||
|
* @param mode Needs to fot to the enum defined in ViewMotion
|
||||||
|
*/
|
||||||
|
public setChangeRecoMode(mode: number): void {
|
||||||
|
this.motion.crMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init. Does nothing here.
|
* Init. Does nothing here.
|
||||||
*/
|
*/
|
||||||
|
@ -6,6 +6,20 @@ import { WorkflowState } from '../../../shared/models/motions/workflow-state';
|
|||||||
import { BaseModel } from '../../../shared/models/base/base-model';
|
import { BaseModel } from '../../../shared/models/base/base-model';
|
||||||
import { BaseViewModel } from '../../base/base-view-model';
|
import { BaseViewModel } from '../../base/base-view-model';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
enum LineNumbering {
|
||||||
|
None,
|
||||||
|
Inside,
|
||||||
|
Outside
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ChangeReco {
|
||||||
|
Original,
|
||||||
|
Change,
|
||||||
|
Diff,
|
||||||
|
Final
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Motion class for the View
|
* Motion class for the View
|
||||||
*
|
*
|
||||||
@ -21,6 +35,18 @@ export class ViewMotion extends BaseViewModel {
|
|||||||
private _workflow: Workflow;
|
private _workflow: Workflow;
|
||||||
private _state: WorkflowState;
|
private _state: WorkflowState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the LineNumbering Mode.
|
||||||
|
* Needs to be accessed from outside
|
||||||
|
*/
|
||||||
|
public lnMode: LineNumbering;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the Change reco Mode.
|
||||||
|
* Needs to be accessed from outside
|
||||||
|
*/
|
||||||
|
public crMode: ChangeReco;
|
||||||
|
|
||||||
public get motion(): Motion {
|
public get motion(): Motion {
|
||||||
return this._motion;
|
return this._motion;
|
||||||
}
|
}
|
||||||
@ -150,6 +176,10 @@ export class ViewMotion extends BaseViewModel {
|
|||||||
this._supporters = supporters;
|
this._supporters = supporters;
|
||||||
this._workflow = workflow;
|
this._workflow = workflow;
|
||||||
this._state = state;
|
this._state = state;
|
||||||
|
|
||||||
|
// TODO: Should be set using a a config variable
|
||||||
|
this.lnMode = LineNumbering.None;
|
||||||
|
this.crMode = ChangeReco.Original;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(translate?: TranslateService): string {
|
public getTitle(translate?: TranslateService): string {
|
||||||
|
@ -66,6 +66,9 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
* TODO: Remove the viewMotion and make it actually distignuishable from save()
|
* TODO: Remove the viewMotion and make it actually distignuishable from save()
|
||||||
*/
|
*/
|
||||||
public create(motion: Motion): Observable<any> {
|
public create(motion: Motion): Observable<any> {
|
||||||
|
if (!motion.supporters_id) {
|
||||||
|
delete motion.supporters_id;
|
||||||
|
}
|
||||||
return this.dataSend.createModel(motion);
|
return this.dataSend.createModel(motion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +97,56 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
public delete(viewMotion: ViewMotion): Observable<any> {
|
public delete(viewMotion: ViewMotion): Observable<any> {
|
||||||
return this.dataSend.delete(viewMotion.motion);
|
return this.dataSend.delete(viewMotion.motion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the motion text using the line numbering and change
|
||||||
|
* reco algorithm.
|
||||||
|
*
|
||||||
|
* TODO: Call DiffView and LineNumbering Service here.
|
||||||
|
*
|
||||||
|
* Can be called from detail view and exporter
|
||||||
|
* @param id Motion ID - will be pulled from the repository
|
||||||
|
* @param lnMode indicator for the line numbering mode
|
||||||
|
* @param crMode indicator for the change reco mode
|
||||||
|
*/
|
||||||
|
public formatMotion(id: number, lnMode: number, crMode: number): string {
|
||||||
|
const targetMotion = this.getViewModel(id);
|
||||||
|
|
||||||
|
if (targetMotion && targetMotion.text) {
|
||||||
|
let motionText = targetMotion.text;
|
||||||
|
|
||||||
|
// TODO : Use Line numbering service here
|
||||||
|
switch (lnMode) {
|
||||||
|
case 0: // no line numbers
|
||||||
|
break;
|
||||||
|
case 1: // line number inside
|
||||||
|
motionText = 'Get line numbers outside';
|
||||||
|
break;
|
||||||
|
case 2: // line number outside
|
||||||
|
motionText = 'Get line numbers inside';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : Use Diff Service here.
|
||||||
|
// this will(currently) append the previous changes.
|
||||||
|
// update
|
||||||
|
switch (crMode) {
|
||||||
|
case 0: // Original
|
||||||
|
break;
|
||||||
|
case 1: // Changed Version
|
||||||
|
motionText += ' and get changed version';
|
||||||
|
break;
|
||||||
|
case 2: // Diff Version
|
||||||
|
motionText += ' and get diff version';
|
||||||
|
break;
|
||||||
|
case 3: // Final Version
|
||||||
|
motionText += ' and final version';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return motionText;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"Assignments": "Wahlen",
|
"Assignments": "Wahlen",
|
||||||
"Category": "",
|
"Category": "",
|
||||||
"Change Password": "Passwort ändern",
|
"Change Password": "Passwort ändern",
|
||||||
|
"Changed version": "",
|
||||||
"Comment": "",
|
"Comment": "",
|
||||||
"Content": "",
|
"Content": "",
|
||||||
"Copyright by": "Copyright by",
|
"Copyright by": "Copyright by",
|
||||||
@ -21,6 +22,7 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Diff version": "",
|
||||||
"EMail": "",
|
"EMail": "",
|
||||||
"Edit Profile": "Profil bearbeiten",
|
"Edit Profile": "Profil bearbeiten",
|
||||||
"Edit category details:": "",
|
"Edit category details:": "",
|
||||||
@ -34,6 +36,7 @@
|
|||||||
},
|
},
|
||||||
"FILTER": "",
|
"FILTER": "",
|
||||||
"Files": "Dateien",
|
"Files": "Dateien",
|
||||||
|
"Final version": "",
|
||||||
"First Name": "",
|
"First Name": "",
|
||||||
"French": "Französisch",
|
"French": "Französisch",
|
||||||
"German": "Deutsch",
|
"German": "Deutsch",
|
||||||
@ -41,6 +44,7 @@
|
|||||||
"Home": "Startseite",
|
"Home": "Startseite",
|
||||||
"Identifier": "",
|
"Identifier": "",
|
||||||
"Initial Password": "",
|
"Initial Password": "",
|
||||||
|
"Inline": "",
|
||||||
"Installed plugins": "",
|
"Installed plugins": "",
|
||||||
"Is Active": "",
|
"Is Active": "",
|
||||||
"Is Present": "",
|
"Is Present": "",
|
||||||
@ -64,6 +68,8 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
},
|
},
|
||||||
"Origin": "",
|
"Origin": "",
|
||||||
|
"Original version": "",
|
||||||
|
"Outside": "",
|
||||||
"Participant Number": "",
|
"Participant Number": "",
|
||||||
"Participants": "Teilnehmer",
|
"Participants": "Teilnehmer",
|
||||||
"Personal Note": "",
|
"Personal Note": "",
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"Assignments": "",
|
"Assignments": "",
|
||||||
"Category": "",
|
"Category": "",
|
||||||
"Change Password": "",
|
"Change Password": "",
|
||||||
|
"Changed version": "",
|
||||||
"Comment": "",
|
"Comment": "",
|
||||||
"Content": "",
|
"Content": "",
|
||||||
"Copyright by": "",
|
"Copyright by": "",
|
||||||
@ -21,6 +22,7 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Diff version": "",
|
||||||
"EMail": "",
|
"EMail": "",
|
||||||
"Edit Profile": "",
|
"Edit Profile": "",
|
||||||
"Edit category details:": "",
|
"Edit category details:": "",
|
||||||
@ -34,6 +36,7 @@
|
|||||||
},
|
},
|
||||||
"FILTER": "",
|
"FILTER": "",
|
||||||
"Files": "",
|
"Files": "",
|
||||||
|
"Final version": "",
|
||||||
"First Name": "",
|
"First Name": "",
|
||||||
"French": "",
|
"French": "",
|
||||||
"German": "",
|
"German": "",
|
||||||
@ -41,6 +44,7 @@
|
|||||||
"Home": "",
|
"Home": "",
|
||||||
"Identifier": "",
|
"Identifier": "",
|
||||||
"Initial Password": "",
|
"Initial Password": "",
|
||||||
|
"Inline": "",
|
||||||
"Installed plugins": "",
|
"Installed plugins": "",
|
||||||
"Is Active": "",
|
"Is Active": "",
|
||||||
"Is Present": "",
|
"Is Present": "",
|
||||||
@ -64,6 +68,8 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
},
|
},
|
||||||
"Origin": "",
|
"Origin": "",
|
||||||
|
"Original version": "",
|
||||||
|
"Outside": "",
|
||||||
"Participant Number": "",
|
"Participant Number": "",
|
||||||
"Participants": "",
|
"Participants": "",
|
||||||
"Personal Note": "",
|
"Personal Note": "",
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"Assignments": "",
|
"Assignments": "",
|
||||||
"Category": "",
|
"Category": "",
|
||||||
"Change Password": "",
|
"Change Password": "",
|
||||||
|
"Changed version": "",
|
||||||
"Comment": "",
|
"Comment": "",
|
||||||
"Content": "",
|
"Content": "",
|
||||||
"Copyright by": "",
|
"Copyright by": "",
|
||||||
@ -21,6 +22,7 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Diff version": "",
|
||||||
"EMail": "",
|
"EMail": "",
|
||||||
"Edit Profile": "",
|
"Edit Profile": "",
|
||||||
"Edit category details:": "",
|
"Edit category details:": "",
|
||||||
@ -34,6 +36,7 @@
|
|||||||
},
|
},
|
||||||
"FILTER": "",
|
"FILTER": "",
|
||||||
"Files": "",
|
"Files": "",
|
||||||
|
"Final version": "",
|
||||||
"First Name": "",
|
"First Name": "",
|
||||||
"French": "",
|
"French": "",
|
||||||
"German": "",
|
"German": "",
|
||||||
@ -41,6 +44,7 @@
|
|||||||
"Home": "",
|
"Home": "",
|
||||||
"Identifier": "",
|
"Identifier": "",
|
||||||
"Initial Password": "",
|
"Initial Password": "",
|
||||||
|
"Inline": "",
|
||||||
"Installed plugins": "",
|
"Installed plugins": "",
|
||||||
"Is Active": "",
|
"Is Active": "",
|
||||||
"Is Present": "",
|
"Is Present": "",
|
||||||
@ -64,6 +68,8 @@
|
|||||||
"0": ""
|
"0": ""
|
||||||
},
|
},
|
||||||
"Origin": "",
|
"Origin": "",
|
||||||
|
"Original version": "",
|
||||||
|
"Outside": "",
|
||||||
"Participant Number": "",
|
"Participant Number": "",
|
||||||
"Participants": "",
|
"Participants": "",
|
||||||
"Personal Note": "",
|
"Personal Note": "",
|
||||||
|
Loading…
Reference in New Issue
Block a user