-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transform Add Entity (copy Attributes) to Bulk Add (copy Attributes) …
…via new component EntityBulkAdd
- Loading branch information
1 parent
cf5ab56
commit 3620404
Showing
2 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div v-for="num in entityFormComponentsCountRange" :key="`ef-${num}`"> | ||
<EntityForm :ref="`entity-form-${num}`" :schema="schema" | ||
:attributes="attributes" :batch-mode="true" @save-all="saveAll"/> | ||
</div> | ||
<div class="container mt-2"> | ||
<button class="btn btn-outline-secondary w-100" @click="addEntityForm"> | ||
<i class='eos-icons'>add_circle</i> | ||
Add more | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import EntityForm from "@/components/inputs/EntityForm.vue"; | ||
export default { | ||
name: "EntityBulkAdd", | ||
components: {EntityForm}, | ||
props: { | ||
schema: { | ||
type: Object, | ||
required: true | ||
}, | ||
attributes: { | ||
type: Object, | ||
required: true, | ||
} | ||
}, | ||
data() { | ||
return { | ||
entityFormComponentCount: 1, | ||
} | ||
}, | ||
computed: { | ||
entityFormComponentsCountRange() { | ||
return [...Array(this.entityFormComponentCount).keys()] | ||
}, | ||
}, | ||
methods: { | ||
async saveAll() { | ||
const promises = Object.entries(this.$refs) | ||
.filter(x => x[0].startsWith("entity-form-")) | ||
.map(x => x[1][0].createEntity()); | ||
await Promise.all(promises) | ||
}, | ||
addEntityForm() { | ||
++this.entityFormComponentCount; | ||
}, | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |