Fixed BelongsToDropdown component: crashed when there was no value
This commit is contained in:
parent
36703bc9ac
commit
6b85d63f5e
1 changed files with 14 additions and 12 deletions
|
|
@ -109,18 +109,20 @@ export default defineComponent({
|
|||
methods: {
|
||||
parseTags(intSelectedItem: number[]): CustomTag[] {
|
||||
const out: CustomTag[] = [];
|
||||
intSelectedItem.forEach((intItem: number) => {
|
||||
const selectedItem = this.allItems.find(item => String(item.id) === String(intItem));
|
||||
if (!selectedItem) {
|
||||
console.debug(intItem);
|
||||
throw new Error(`Could not find enum ${intItem}`);
|
||||
}
|
||||
out.push({
|
||||
id: String(selectedItem.id),
|
||||
value: String(selectedItem.id),
|
||||
text: String(selectedItem[`${this.labelField}`])
|
||||
} as LaravelModel as CustomTag);
|
||||
});
|
||||
if (intSelectedItem[0] !== null) {
|
||||
intSelectedItem.forEach((intItem: number) => {
|
||||
const selectedItem = this.allItems.find(item => String(item.id) === String(intItem));
|
||||
if (!selectedItem) {
|
||||
console.debug(intItem);
|
||||
throw new Error(`Could not find enum ${intItem}`);
|
||||
}
|
||||
out.push({
|
||||
id: String(selectedItem.id),
|
||||
value: String(selectedItem.id),
|
||||
text: String(selectedItem[`${this.labelField}`])
|
||||
} as LaravelModel as CustomTag);
|
||||
});
|
||||
}
|
||||
return out;
|
||||
},
|
||||
parseNewlyCreated(newModel: LaravelModel): CustomTag {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue