images resources component - support dynamic images depending on tab id
This commit is contained in:
parent
c062c40b31
commit
09eb3e1969
3 changed files with 8 additions and 5 deletions
|
|
@ -28,7 +28,7 @@
|
|||
<component
|
||||
@add-images="addImages"
|
||||
:is="tab.component"
|
||||
:params="tab.params ? tab.params : {}"
|
||||
:id="tab.id"
|
||||
:class="{ hidden: activeTab.name !== tab.name }"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@ import { useAddImagesModalStore } from "../../../../stores/addImagesModal";
|
|||
import { computed } from "vue";
|
||||
import ArrayUtils from "../../../../utils/array";
|
||||
|
||||
const { id } = defineProps({
|
||||
id: String,
|
||||
});
|
||||
const { tabs } = storeToRefs(useAddImagesModalStore());
|
||||
|
||||
const tab = computed(() => {
|
||||
return tabs.value.find((tab) => tab.id === "materials");
|
||||
return tabs.value.find((tab) => tab.id === id);
|
||||
});
|
||||
|
||||
function isSelected(image) {
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ export const useAddImagesModalStore = defineStore("add-images-modal", () => {
|
|||
.fetchPageData("materials")
|
||||
.then((json) => (images.value = tabs.value[1].images = json.images));
|
||||
|
||||
api
|
||||
.fetchPageData("creations")
|
||||
.then((json) => (images.value = tabs.value[2].images = json.images));
|
||||
api.fetchPageData("creations").then((json) => {
|
||||
images.value = tabs.value[2].images = json.images;
|
||||
});
|
||||
|
||||
return { images, activeTabId, tabs, activeTab };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue