forked from ebess/advanced-nova-media-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from workupsrl/develop
Develop
- Loading branch information
Showing
3 changed files
with
47 additions
and
12 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,51 @@ | ||
<template> | ||
<div class="advanced-nova-media-library"> | ||
<PanelItem :index="index" :field="field" > | ||
<template #value> | ||
<gallery :modelValue="field.value" :field="field" :multiple="field.multiple"/> | ||
</template> | ||
</PanelItem> | ||
</div> | ||
<div class="advanced-nova-media-library"> | ||
<PanelItem :index="index" :field="field"> | ||
<template #value> | ||
<a | ||
v-if="field.translatable" | ||
class="inline-block font-bold cursor-pointer mr-2 animate-text-color select-none" | ||
:class="{ 'text-60': localeKey !== currentLocale, 'text-primary': localeKey === currentLocale }" | ||
:key="`a-${localeKey}`" | ||
v-for="(locale, localeKey) in field.locales" | ||
@click="changeTab(localeKey)" | ||
> | ||
{{ locale }} | ||
</a> | ||
<div class="flex flex-row items-center"> | ||
<gallery v-model="gallery" :field="field" :multiple="field.multiple && !field.single"/> | ||
</div> | ||
</template> | ||
</PanelItem> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Gallery from '../Gallery'; | ||
import Gallery from '../Gallery'; | ||
export default { | ||
export default { | ||
components: { | ||
Gallery, | ||
Gallery, | ||
}, | ||
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'], | ||
}; | ||
data() { | ||
return { | ||
currentLocale: Object.keys(this.field?.locales ?? {})?.[0], | ||
gallery: [], | ||
} | ||
}, | ||
computed: { | ||
gallery() { | ||
return this.field.value.filter(media => media.custom_properties.locale === this.currentLocale) | ||
} | ||
}, | ||
methods: { | ||
changeTab(locale) { | ||
if (this.currentLocale !== locale) { | ||
Nova.$emit('localeChanged', locale); | ||
this.currentLocale = locale; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> |