fix #69
This commit is contained in:
parent
bff0f8eda3
commit
cb1f842fc9
4 changed files with 53 additions and 14 deletions
|
|
@ -8,6 +8,7 @@ function getFileData($file) {
|
||||||
'quality' => 80,
|
'quality' => 80,
|
||||||
'format' => 'webp'
|
'format' => 'webp'
|
||||||
])->url(),
|
])->url(),
|
||||||
|
'source' => $file->url(),
|
||||||
'parent' => [
|
'parent' => [
|
||||||
"title" => (string) $file->parent()->title(),
|
"title" => (string) $file->parent()->title(),
|
||||||
"uri" => $file->parent()->uri()
|
"uri" => $file->parent()->uri()
|
||||||
|
|
@ -28,10 +29,10 @@ function getFileData($file) {
|
||||||
$data['tags'] = $file->tags()->split();
|
$data['tags'] = $file->tags()->split();
|
||||||
};
|
};
|
||||||
|
|
||||||
if($file->comments()->exists()) {
|
if ($file->comments()->exists()) {
|
||||||
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
|
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
|
||||||
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
|
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
@ -43,6 +43,7 @@ const { activeTrack } = defineProps({
|
||||||
// Helper
|
// Helper
|
||||||
const { openedFile } = storeToRefs(useDialogStore());
|
const { openedFile } = storeToRefs(useDialogStore());
|
||||||
const virtualSampleStore = useVirtualSampleStore();
|
const virtualSampleStore = useVirtualSampleStore();
|
||||||
|
const { isDownloadTriggered } = storeToRefs(useVirtualSampleStore());
|
||||||
const isHelperHidden = ref(localStorage.getItem("isHelperHidden"));
|
const isHelperHidden = ref(localStorage.getItem("isHelperHidden"));
|
||||||
localStorage.setItem("isHelperHidden", true);
|
localStorage.setItem("isHelperHidden", true);
|
||||||
|
|
||||||
|
|
@ -187,4 +188,16 @@ function preloadImages() {
|
||||||
image.src = imageUrl;
|
image.src = imageUrl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download image
|
||||||
|
watch(isDownloadTriggered, (newValue) => {
|
||||||
|
if (!newValue) return;
|
||||||
|
|
||||||
|
const downloadNode = document.createElement("a");
|
||||||
|
downloadNode.setAttribute("href", currentFile.value.source);
|
||||||
|
downloadNode.setAttribute("download", "");
|
||||||
|
document.body.appendChild(downloadNode);
|
||||||
|
downloadNode.click();
|
||||||
|
document.body.removeChild(downloadNode);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -44,18 +44,15 @@
|
||||||
<StaticView id="static" v-if="activeTab === 'static'" />
|
<StaticView id="static" v-if="activeTab === 'static'" />
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a
|
<button
|
||||||
v-if="currentFile"
|
v-if="currentFile"
|
||||||
id="download-image"
|
id="download-image"
|
||||||
class="btn btn--white-10"
|
class="btn btn--white-10"
|
||||||
data-icon="download"
|
data-icon="download"
|
||||||
:href="currentFile.url"
|
@click="downloadFiles()"
|
||||||
download
|
|
||||||
>
|
>
|
||||||
<span>{{
|
<span>{{ downloadText }}</span>
|
||||||
activeTab === "dynamic" ? "Télécharger l’image" : "Télécharger le PDF"
|
</button>
|
||||||
}}</span>
|
|
||||||
</a>
|
|
||||||
<button
|
<button
|
||||||
id="loop-animation"
|
id="loop-animation"
|
||||||
class="btn"
|
class="btn"
|
||||||
|
|
@ -92,7 +89,7 @@ import { storeToRefs } from "pinia";
|
||||||
import Dialog from "primevue/dialog";
|
import Dialog from "primevue/dialog";
|
||||||
import DynamicView from "./DynamicView.vue";
|
import DynamicView from "./DynamicView.vue";
|
||||||
import StaticView from "./StaticView.vue";
|
import StaticView from "./StaticView.vue";
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch, computed } from "vue";
|
||||||
import { useVirtualSampleStore } from "../../../stores/virtualSample";
|
import { useVirtualSampleStore } from "../../../stores/virtualSample";
|
||||||
import { useDialogStore } from "../../../stores/dialog";
|
import { useDialogStore } from "../../../stores/dialog";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
@ -101,11 +98,17 @@ const { file } = defineProps({
|
||||||
file: Object,
|
file: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { activeTab, currentFile, step, isLoopAnimationEnabled } = storeToRefs(
|
const {
|
||||||
useVirtualSampleStore()
|
activeTab,
|
||||||
);
|
currentFile,
|
||||||
|
step,
|
||||||
|
isLoopAnimationEnabled,
|
||||||
|
isDownloadTriggered,
|
||||||
|
} = storeToRefs(useVirtualSampleStore());
|
||||||
isLoopAnimationEnabled.value = false;
|
isLoopAnimationEnabled.value = false;
|
||||||
const { isCommentsOpen, isCommentPanelEnabled } = storeToRefs(useDialogStore());
|
const { isCommentsOpen, isCommentPanelEnabled, activeTracks } = storeToRefs(
|
||||||
|
useDialogStore()
|
||||||
|
);
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -114,6 +117,26 @@ const isOpen = ref(true);
|
||||||
watch(isOpen, (newValue) => {
|
watch(isOpen, (newValue) => {
|
||||||
router.push({ name: route.name });
|
router.push({ name: route.name });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const downloadText = computed(() => {
|
||||||
|
if (activeTab.value === "dynamic") {
|
||||||
|
if (activeTracks.value.length === 1) {
|
||||||
|
return "Télécharger l'image";
|
||||||
|
} else {
|
||||||
|
return "Télécharger les images";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "Télécharger le PDF";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
function downloadFiles() {
|
||||||
|
isDownloadTriggered.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
isDownloadTriggered.value = false;
|
||||||
|
}, 400);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export const useVirtualSampleStore = defineStore("virtual-sample", () => {
|
||||||
const activeTab = ref(step.files.dynamic ? "dynamic" : "static");
|
const activeTab = ref(step.files.dynamic ? "dynamic" : "static");
|
||||||
const currentFile = ref(null);
|
const currentFile = ref(null);
|
||||||
const isLoopAnimationEnabled = ref(false);
|
const isLoopAnimationEnabled = ref(false);
|
||||||
|
const isDownloadTriggered = ref(false);
|
||||||
|
|
||||||
watch(activeTab, () => (currentFile.value = null));
|
watch(activeTab, () => (currentFile.value = null));
|
||||||
|
|
||||||
|
|
@ -19,5 +20,6 @@ export const useVirtualSampleStore = defineStore("virtual-sample", () => {
|
||||||
step,
|
step,
|
||||||
isLoopAnimationEnabled,
|
isLoopAnimationEnabled,
|
||||||
isCompareModeEnabled,
|
isCompareModeEnabled,
|
||||||
|
isDownloadTriggered,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue