diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.html b/client/src/app/site/motions/components/motion-detail/motion-detail.component.html index d59f4e741..e38308f18 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.html +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.html @@ -249,7 +249,17 @@ -
+ + + +
+ + +
@@ -266,7 +276,7 @@

The assembly may decide:

-
+
@@ -286,3 +296,18 @@ + + + + + + + + + + + + + + + diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.scss b/client/src/app/site/motions/components/motion-detail/motion-detail.component.scss index 6cf5de421..17a9b2d6b 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.scss +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.scss @@ -7,6 +7,17 @@ span { line-height: 100%; } +.motion-content { + display: flow-root; +} + +.motion-text-controls { + float: right; + button { + font-size: 115%; + } +} + .motion-submitter { display: inline; font-weight: bold; diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts index 623512b4b..9f8b9be10 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts @@ -168,8 +168,8 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { category_id: [''], state_id: [''], recommendation_id: [''], - submitters_id: [''], - supporters_id: [''], + submitters_id: [], + supporters_id: [], origin: [''] }); this.contentForm = this.formBuilder.group({ @@ -197,28 +197,42 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { if (this.newMotion) { this.repo.create(fromForm).subscribe(response => { - this.router.navigate(['./motions/' + response.id]); + if (response.id) { + this.router.navigate(['./motions/' + response.id]); + } }); } 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) */ public editMotionButton(): void { - this.editMotion ? (this.editMotion = false) : (this.editMotion = true); if (this.editMotion) { - // copy the motion + this.saveMotion(); + } else { + this.editMotion = true; this.motionCopy = this.motion.copy(); this.patchForm(this.motionCopy); if (this.vp.isMobile) { this.metaInfoPanel.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. */ diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index 92d2addc1..b6e714110 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -6,6 +6,20 @@ import { WorkflowState } from '../../../shared/models/motions/workflow-state'; import { BaseModel } from '../../../shared/models/base/base-model'; import { BaseViewModel } from '../../base/base-view-model'; import { TranslateService } from '@ngx-translate/core'; + +enum LineNumbering { + None, + Inside, + Outside +} + +enum ChangeReco { + Original, + Change, + Diff, + Final +} + /** * Motion class for the View * @@ -21,6 +35,18 @@ export class ViewMotion extends BaseViewModel { private _workflow: Workflow; 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 { return this._motion; } @@ -150,6 +176,10 @@ export class ViewMotion extends BaseViewModel { this._supporters = supporters; this._workflow = workflow; 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 { diff --git a/client/src/app/site/motions/services/motion-repository.service.ts b/client/src/app/site/motions/services/motion-repository.service.ts index 3ba109dd5..0e2b2f902 100644 --- a/client/src/app/site/motions/services/motion-repository.service.ts +++ b/client/src/app/site/motions/services/motion-repository.service.ts @@ -66,6 +66,9 @@ export class MotionRepositoryService extends BaseRepository * TODO: Remove the viewMotion and make it actually distignuishable from save() */ public create(motion: Motion): Observable { + if (!motion.supporters_id) { + delete motion.supporters_id; + } return this.dataSend.createModel(motion); } @@ -94,4 +97,56 @@ export class MotionRepositoryService extends BaseRepository public delete(viewMotion: ViewMotion): Observable { 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; + } + } } diff --git a/client/src/assets/i18n/de.json b/client/src/assets/i18n/de.json index d25288a23..9b2afab4d 100644 --- a/client/src/assets/i18n/de.json +++ b/client/src/assets/i18n/de.json @@ -5,6 +5,7 @@ "Assignments": "Wahlen", "Category": "", "Change Password": "Passwort ändern", + "Changed version": "", "Comment": "", "Content": "", "Copyright by": "Copyright by", @@ -21,6 +22,7 @@ "0": "" } }, + "Diff version": "", "EMail": "", "Edit Profile": "Profil bearbeiten", "Edit category details:": "", @@ -34,6 +36,7 @@ }, "FILTER": "", "Files": "Dateien", + "Final version": "", "First Name": "", "French": "Französisch", "German": "Deutsch", @@ -41,6 +44,7 @@ "Home": "Startseite", "Identifier": "", "Initial Password": "", + "Inline": "", "Installed plugins": "", "Is Active": "", "Is Present": "", @@ -64,6 +68,8 @@ "0": "" }, "Origin": "", + "Original version": "", + "Outside": "", "Participant Number": "", "Participants": "Teilnehmer", "Personal Note": "", diff --git a/client/src/assets/i18n/en.json b/client/src/assets/i18n/en.json index 4754c498c..93643c7e3 100644 --- a/client/src/assets/i18n/en.json +++ b/client/src/assets/i18n/en.json @@ -5,6 +5,7 @@ "Assignments": "", "Category": "", "Change Password": "", + "Changed version": "", "Comment": "", "Content": "", "Copyright by": "", @@ -21,6 +22,7 @@ "0": "" } }, + "Diff version": "", "EMail": "", "Edit Profile": "", "Edit category details:": "", @@ -34,6 +36,7 @@ }, "FILTER": "", "Files": "", + "Final version": "", "First Name": "", "French": "", "German": "", @@ -41,6 +44,7 @@ "Home": "", "Identifier": "", "Initial Password": "", + "Inline": "", "Installed plugins": "", "Is Active": "", "Is Present": "", @@ -64,6 +68,8 @@ "0": "" }, "Origin": "", + "Original version": "", + "Outside": "", "Participant Number": "", "Participants": "", "Personal Note": "", diff --git a/client/src/assets/i18n/fr.json b/client/src/assets/i18n/fr.json index 4754c498c..93643c7e3 100644 --- a/client/src/assets/i18n/fr.json +++ b/client/src/assets/i18n/fr.json @@ -5,6 +5,7 @@ "Assignments": "", "Category": "", "Change Password": "", + "Changed version": "", "Comment": "", "Content": "", "Copyright by": "", @@ -21,6 +22,7 @@ "0": "" } }, + "Diff version": "", "EMail": "", "Edit Profile": "", "Edit category details:": "", @@ -34,6 +36,7 @@ }, "FILTER": "", "Files": "", + "Final version": "", "First Name": "", "French": "", "German": "", @@ -41,6 +44,7 @@ "Home": "", "Identifier": "", "Initial Password": "", + "Inline": "", "Installed plugins": "", "Is Active": "", "Is Present": "", @@ -64,6 +68,8 @@ "0": "" }, "Origin": "", + "Original version": "", + "Outside": "", "Participant Number": "", "Participants": "", "Personal Note": "",