Skip to content

Commit

Permalink
Send metadata as JS object to avoid messy html
Browse files Browse the repository at this point in the history
  • Loading branch information
ToukL committed Jan 20, 2025
1 parent 6556c95 commit 2c694be
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 0 additions & 2 deletions resources/assets/js/volumes/components/metadataModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<modal
id="modal-show-metadata"
ref="modal"
v-model="show"
size="sm"
Expand Down Expand Up @@ -77,7 +76,6 @@ export default {
},
created() {
this.show = false;
this.$emit('load-modal');
}
}
</script>
4 changes: 2 additions & 2 deletions resources/assets/js/volumes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MetadataUpload from './metadataUpload';
import ProjectsBreadcrumb from './projectsBreadcrumb';
import SearchResults from './searchResults';
import VolumeContainer from './volumeContainer';
import VolumeMetadata from './volumeMetadata.vue';
import VideoMetadata from './videoMetadata.vue';

biigle.$mount('annotation-session-panel', AnnotationSessionPanel);
biigle.$mount('create-volume-form-step-1', CreateFormStep1);
Expand All @@ -31,4 +31,4 @@ biigle.$mount('search-results', SearchResults);
biigle.$mount('volume-container', VolumeContainer);
biigle.$mount('volume-file-count', FileCount);
biigle.$mount('volume-metadata-upload', MetadataUpload);
biigle.$mount('volume-metadata-modal', VolumeMetadata);
biigle.$mount('video-metadata-modal', VideoMetadata);
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default {
data() {
return {
showModal: false,
metadata: null,
metadataMap: {},
times: [],
items: [],
name: "",
Expand All @@ -39,9 +41,9 @@ export default {
this.name = "Times";
this.showModal = true;
},
getMetadata(key, data) {
this.name = key;
this.items = data;
showMetadata(field) {
this.name = this.metadataMap[field];
this.items = this.metadata[field];
this.showModal = true;
},
hideMetadataModal() {
Expand All @@ -53,5 +55,10 @@ export default {
Messages.danger(message);
},
},
created() {
this.getTimes(biigle.$require('videos.times'));
this.metadata = biigle.$require('videos.metadata');
this.metadataMap = biigle.$require('videos.metadataMap');
}
};
</script>
14 changes: 11 additions & 3 deletions resources/views/volumes/videos/index/meta.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<div id="volume-metadata-modal" class="panel panel-default">
@push('scripts')
<script type="text/javascript">
biigle.$declare('videos.times', {!! collect($video->taken_at) !!});
biigle.$declare('videos.metadata', {!! collect($video->metadata) !!});
biigle.$declare('videos.metadataMap', {!! collect($metadataMap) !!});
</script>
@endpush

<div id="video-metadata-modal" class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Video information</h3>
</div>
Expand All @@ -23,7 +31,7 @@
@endif
@if ($video->taken_at)
@if (is_array($video->taken_at))
<metadata-modal v-bind:show-modal="showModal" v-bind:times="times" v-bind:items="items" v-bind:name="name" v-on:load-modal="getTimes({{ collect($video->taken_at) }})" v-on:close-modal="hideMetadataModal"></metadata-modal>
<metadata-modal v-bind:show-modal="showModal" v-bind:times="times" v-bind:items="items" v-bind:name="name" v-on:close-modal="hideMetadataModal"></metadata-modal>
<tr>
<th>Created</th>
<td>
Expand All @@ -35,7 +43,7 @@
<th>{{ $metadataMap[$field] }}</th>
@if (is_array($value))
<td>
<button class="btn btn-default" type="button" title="Show full metadata array" v-on:click.prevent="getMetadata({{ json_encode($metadataMap[$field]) }}, {{ collect($value) }})">Show values</button>
<button class="btn btn-default" type="button" title="Show full metadata array" v-on:click.prevent="showMetadata({{ json_encode($field) }})">Show values</button>
</td>
@else
<td>{{ $value }}</td>
Expand Down

0 comments on commit 2c694be

Please sign in to comment.