diff --git a/client/src/app/site/motions/models/import-create-motion.ts b/client/src/app/site/motions/models/import-create-motion.ts index 78a167d78..336128a3f 100644 --- a/client/src/app/site/motions/models/import-create-motion.ts +++ b/client/src/app/site/motions/models/import-create-motion.ts @@ -32,6 +32,11 @@ export class ImportCreateMotion extends CreateMotion { */ public csvSubmitters: CsvMapping[]; + /** + * Mapping for new/existing supporters. + */ + public csvSupporters: CsvMapping[]; + /** * Mapping for new/existing tags. */ @@ -115,6 +120,30 @@ export class ImportCreateMotion extends CreateMotion { return open; } + public solveSupporters(supporters: CsvMapping[]): number { + let open = 0; + const ids: number[] = []; + this.csvSupporters.forEach(csvSupporter => { + if (csvSupporter.id) { + ids.push(csvSupporter.id); + return; + } + if (!supporters.length) { + open += 1; + return; + } + const mapped = supporters.find(newSupporter => newSupporter.name === csvSupporter.name); + if (mapped) { + csvSupporter.id = mapped.id; + ids.push(mapped.id); + } else { + open += 1; + } + }); + this.supporters_id = ids; + return open; + } + /** * Function to iterate over the found tags. * diff --git a/client/src/app/site/motions/modules/motion-import/motion-import-list.component.html b/client/src/app/site/motions/modules/motion-import/motion-import-list.component.html index 0b88cc870..843c38424 100644 --- a/client/src/app/site/motions/modules/motion-import/motion-import-list.component.html +++ b/client/src/app/site/motions/modules/motion-import/motion-import-list.component.html @@ -18,8 +18,7 @@
- {{ header | translate }} + {{ header | translate }}