Merge pull request #5433 from tsiegleauq/import-doubled-topics
Allow to import the same topic multiple times
This commit is contained in:
commit
2fd4e70b0c
@ -26,7 +26,7 @@ export interface NewEntry<V> {
|
|||||||
newEntry: V;
|
newEntry: V;
|
||||||
status: CsvImportStatus;
|
status: CsvImportStatus;
|
||||||
errors: string[];
|
errors: string[];
|
||||||
hasDuplicates: boolean;
|
hasDuplicates?: boolean;
|
||||||
importTrackId?: number;
|
importTrackId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ export class TopicImportService extends BaseImportService<CreateTopic> {
|
|||||||
*/
|
*/
|
||||||
public errorList = {
|
public errorList = {
|
||||||
NoTitle: 'A Topic needs a title',
|
NoTitle: 'A Topic needs a title',
|
||||||
Duplicates: 'A topic with this title already exists',
|
|
||||||
ParsingErrors: 'Some csv values could not be read correctly.'
|
ParsingErrors: 'Some csv values could not be read correctly.'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +98,6 @@ export class TopicImportService extends BaseImportService<CreateTopic> {
|
|||||||
newEntry[this.expectedHeader[idx]] = line[idx];
|
newEntry[this.expectedHeader[idx]] = line[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const hasDuplicates = this.repo.getViewModelList().some(topic => topic.title === newEntry.title);
|
|
||||||
|
|
||||||
// set type to 'public' if none is given in import
|
// set type to 'public' if none is given in import
|
||||||
if (!newEntry.agenda_type) {
|
if (!newEntry.agenda_type) {
|
||||||
@ -107,13 +105,9 @@ export class TopicImportService extends BaseImportService<CreateTopic> {
|
|||||||
}
|
}
|
||||||
const mappedEntry: NewEntry<CreateTopic> = {
|
const mappedEntry: NewEntry<CreateTopic> = {
|
||||||
newEntry: newEntry,
|
newEntry: newEntry,
|
||||||
hasDuplicates: hasDuplicates,
|
|
||||||
status: 'new',
|
status: 'new',
|
||||||
errors: []
|
errors: []
|
||||||
};
|
};
|
||||||
if (hasDuplicates) {
|
|
||||||
this.setError(mappedEntry, 'Duplicates');
|
|
||||||
}
|
|
||||||
if (hasErrors) {
|
if (hasErrors) {
|
||||||
this.setError(mappedEntry, 'ParsingErrors');
|
this.setError(mappedEntry, 'ParsingErrors');
|
||||||
}
|
}
|
||||||
@ -196,16 +190,11 @@ export class TopicImportService extends BaseImportService<CreateTopic> {
|
|||||||
agenda_type: 1 // set type to 'public item' by default
|
agenda_type: 1 // set type to 'public item' by default
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const hasDuplicates = this.repo.getViewModelList().some(topic => topic.title === newTopic.title);
|
|
||||||
const newEntry: NewEntry<CreateTopic> = {
|
const newEntry: NewEntry<CreateTopic> = {
|
||||||
newEntry: newTopic,
|
newEntry: newTopic,
|
||||||
hasDuplicates: hasDuplicates,
|
|
||||||
status: 'new',
|
status: 'new',
|
||||||
errors: []
|
errors: []
|
||||||
};
|
};
|
||||||
if (hasDuplicates) {
|
|
||||||
this.setError(newEntry, 'Duplicates');
|
|
||||||
}
|
|
||||||
newEntries.push(newEntry);
|
newEntries.push(newEntry);
|
||||||
});
|
});
|
||||||
this.setParsedEntries(newEntries);
|
this.setParsedEntries(newEntries);
|
||||||
|
Loading…
Reference in New Issue
Block a user