diff --git a/client/src/app/core/ui-services/personal-note.service.ts b/client/src/app/core/ui-services/personal-note.service.ts index b181259ea..4c915c20b 100644 --- a/client/src/app/core/ui-services/personal-note.service.ts +++ b/client/src/app/core/ui-services/personal-note.service.ts @@ -60,6 +60,42 @@ export class PersonalNoteService { } pnObject.notes[model.collectionString][model.id] = content; + this.savePersonalNoteObject(pnObject); + } + + /** + * Sets the 'favorite' status for several models of a type in bulk + * + * @param models The model the content belongs to + * @param star The new 'favorite' status + */ + public async bulkSetStar(models: (BaseModel | BaseViewModel)[], star: boolean): Promise { + if (!models.length) { + return; + } + const pnObject: Partial = this.personalNoteObject || {}; + if (!pnObject.notes) { + pnObject.notes = {}; + } + for (const model of models) { + if (!pnObject.notes[model.collectionString]) { + pnObject.notes[model.collectionString] = {}; + } + if (pnObject.notes[model.collectionString][model.id]) { + pnObject.notes[model.collectionString][model.id].star = star; + } else { + pnObject.notes[model.collectionString][model.id] = { star: star, note: '' }; + } + } + await this.savePersonalNoteObject(pnObject); + } + + /** + * Sends an updated personal note to the server + * + * @param pnObject a partial (if new) or complete personal note object + */ + private async savePersonalNoteObject(pnObject: Partial): Promise { if (!pnObject.id) { await this.http.post('rest/users/personal-note/', pnObject); } else { 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 9892ffd9c..3778b4906 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 @@ -6,7 +6,7 @@
-
+
No personal note
diff --git a/client/src/app/site/motions/modules/motion-list/components/motion-list/motion-list.component.html b/client/src/app/site/motions/modules/motion-list/components/motion-list/motion-list.component.html index cb3416f37..c0ec1d13d 100644 --- a/client/src/app/site/motions/modules/motion-list/components/motion-list/motion-list.component.html +++ b/client/src/app/site/motions/modules/motion-list/components/motion-list/motion-list.component.html @@ -221,6 +221,10 @@
+