Skip to content

Commit

Permalink
Update media field
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Sep 5, 2024
1 parent 512ac6b commit aa8fdb8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 49 deletions.
90 changes: 45 additions & 45 deletions assets/vendor/manager/dist/index.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions assets/vendor/manager/src/components/helpers/MediaManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const _imagePreview = ref('');
onMounted(() => {
if (props.modelValue !== '') {
_imagePreview.value = constant.site_url + props.field.input.mediaPath + '/'+ props.modelValue;
updatePreview();
}
const mediaContent = document.getElementById(props.field.input.id+'modal');
if (mediaContent) {
Expand All @@ -31,11 +31,17 @@ onMounted(() => {
})
onUpdated(()=>{
if (props.modelValue !== _imagePreview.value.replace(constant.site_url + props.field.input.mediaPath + '/','')) {
_imagePreview.value = constant.site_url + props.field.input.mediaPath + '/'+ props.modelValue;
}
updatePreview();
})
function updatePreview() {
if (props.modelValue.search(/https*:\/\//i) !== -1) {
_imagePreview.value = props.modelValue;
} else if (props.modelValue !== '') {
_imagePreview.value = constant.site_url + props.field.input.mediaPath + '/'+ props.modelValue;
}
}
function generateData(json = null) {
if (!json) return false;
_showDirLocation.value = json.current_folder.split('/');
Expand Down Expand Up @@ -150,6 +156,10 @@ function uploadReset() {
<i v-if="props.field.input.media === 'videos'" class="fa-solid fa-video fa-3x"></i>
<img v-else :src="_imagePreview" :alt="props.field.name" />
</div>
<div class="input-group input-group-sm mb-3">
<span class="input-group-text" :id="props.field.input.id+`url`">Url</span>
<input type="text" class="form-control" :value="modelValue" @input="emit('update:modelValue', $event.target.value)" aria-label="URL" :aria-describedby="props.field.input.id+`url`">
</div>
<div v-if="_imagePreview === ''" class="astroid-media-selector">
<button class="btn btn-sm btn-as btn-primary btn-as-primary" @click.prevent="" data-bs-toggle="modal" :data-bs-target="`#`+props.field.input.id+`modal`">{{ props.field.input.lang['select_media'] }}</button>
</div>
Expand Down

0 comments on commit aa8fdb8

Please sign in to comment.