diff --git a/client/src/app/core/core-services/view-model-store.service.ts b/client/src/app/core/core-services/view-model-store.service.ts index c5eae06f4..1ceafce56 100644 --- a/client/src/app/core/core-services/view-model-store.service.ts +++ b/client/src/app/core/core-services/view-model-store.service.ts @@ -66,7 +66,7 @@ export class ViewModelStoreService { } /** - * Get all view modles from a collection, that satisfy the callback + * Get all view models from a collection, that satisfy the callback * * @param collectionString The collection * @param callback The function to check @@ -80,7 +80,7 @@ export class ViewModelStoreService { } /** - * Finds one view model from the collection, that satifies the callback + * Finds one view model from the collection, that satisfies the callback * * @param collectionString The collection * @param callback THe callback to satisfy diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index 86926fe60..4cbe0d779 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -16,6 +16,7 @@ import { ViewMotionBlock } from './view-motion-block'; import { BaseViewModel } from 'app/site/base/base-view-model'; import { ConfigService } from 'app/core/ui-services/config.service'; import { ViewMotionChangeRecommendation } from './view-change-recommendation'; +import { ViewPersonalNote } from 'app/site/users/models/view-personal-note'; import { _ } from 'app/core/translate/translation-marker'; /** @@ -318,6 +319,13 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable { return this.motion.comments.map(comment => comment.section_id); } + /** + * @returns the text of a personal note + */ + public get personalNoteText(): string { + return this.personalNote.note; + } + /** * Getter to query the 'favorite'/'star' status of the motions * @@ -477,6 +485,8 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable { this.updateMotion(update); } else if (update instanceof ViewMotionChangeRecommendation) { this.updateChangeRecommendation(update); + } else if (update instanceof ViewPersonalNote) { + this.updatePersonalNote(update); } } @@ -599,6 +609,10 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable { } } + private updatePersonalNote(personalNote: ViewPersonalNote): void { + this.personalNote = personalNote.getNoteContent(this.collectionString, this.id); + } + public hasSupporters(): boolean { return !!(this.supporters && this.supporters.length > 0); } diff --git a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html index 328da1665..6463e87dc 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.html @@ -1,42 +1,47 @@ + Personal note + + + + + + + + + -
-
+
+
No personal note

Personal note

- +
- - - - - - - diff --git a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts index 7bc061511..f0e36a291 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts @@ -35,6 +35,10 @@ export class PersonalNoteComponent extends BaseComponent { */ public isEditMode = false; + public get personalNoteText(): string { + return this.motion.personalNoteText; + } + /** * Constructor. Creates form * diff --git a/client/src/app/site/users/models/view-personal-note.ts b/client/src/app/site/users/models/view-personal-note.ts index 38f89d824..f4d391601 100644 --- a/client/src/app/site/users/models/view-personal-note.ts +++ b/client/src/app/site/users/models/view-personal-note.ts @@ -1,5 +1,5 @@ import { BaseViewModel } from 'app/site/base/base-view-model'; -import { PersonalNote, PersonalNotesFormat } from 'app/shared/models/users/personal-note'; +import { PersonalNote, PersonalNotesFormat, PersonalNoteContent } from 'app/shared/models/users/personal-note'; export class ViewPersonalNote extends BaseViewModel { public static COLLECTIONSTRING = PersonalNote.COLLECTIONSTRING; @@ -32,6 +32,14 @@ export class ViewPersonalNote extends BaseViewModel { this._personalNote = personalNote; } + public getNoteContent(collection: string, id: number): PersonalNoteContent | null { + if (this.notes[collection]) { + return this.notes[collection][id]; + } else { + return null; + } + } + public getTitle = () => { return this.personalNote ? this.personalNote.toString() : null; };