Améliore les types et la gestion des propriétés dans les composants Vue :

- Modifie les types des propriétés dans DownloadButton.vue pour gérer les versions d'objet.
- Corrige les types de davLink et davLinkExpiration dans DocumentActionButtonsGroup.vue.
- Réorganise l'interface DesktopEditButtonConfig pour une meilleure clarté.
- Ajuste l'extension de fichier dans DownloadButton.vue pour éviter les erreurs de type.
This commit is contained in:
Boris Waaub
2026-02-03 14:42:35 +01:00
parent 6852dcd0f0
commit 307200c5f4
4 changed files with 52 additions and 52 deletions

View File

@@ -46,7 +46,8 @@ export interface StoredObjectVersionCreated extends StoredObjectVersion {
persisted: false;
}
export interface StoredObjectVersionPersisted extends StoredObjectVersionCreated {
export interface StoredObjectVersionPersisted
extends StoredObjectVersionCreated {
version: number;
id: number;
createdAt: DateTime | null;
@@ -60,7 +61,8 @@ export interface StoredObjectStatusChange {
type: string;
}
export interface StoredObjectVersionWithPointInTime extends StoredObjectVersionPersisted {
export interface StoredObjectVersionWithPointInTime
extends StoredObjectVersionPersisted {
"point-in-times": StoredObjectPointInTime[];
"from-restored": StoredObjectVersionPersisted | null;
}

View File

@@ -75,7 +75,6 @@ import {
import {
StoredObject,
StoredObjectStatusChange,
StoredObjectVersion,
WopiEditButtonExecutableBeforeLeaveFunction,
} from "../types";
import DesktopEditButton from "ChillDocStoreAssets/vuejs/StoredObjectButton/DesktopEditButton.vue";
@@ -105,12 +104,12 @@ interface DocumentActionButtonsGroupConfig {
/**
* a link to download and edit file using webdav
*/
davLink?: string;
davLink: string;
/**
* the expiration date of the download, as a unix timestamp
*/
davLinkExpiration?: number;
davLinkExpiration: number;
}
const emit =
@@ -206,10 +205,6 @@ const checkForReady = function (): void {
};
const onObjectNewStatusCallback = async function (): Promise<void> {
if (props.storedObject.status === "stored_object_created") {
return Promise.resolve();
}
const new_status = await is_object_ready(props.storedObject);
if (props.storedObject.status !== new_status.status) {
emit("onStoredObjectStatusChange", new_status);

View File

@@ -1,42 +1,3 @@
<script setup lang="ts">
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import { computed, reactive } from "vue";
export interface DesktopEditButtonConfig {
editLink: null;
classes: Record<string, boolean>;
expirationLink: number | Date;
}
interface DesktopEditButtonState {
modalOpened: boolean;
}
const state: DesktopEditButtonState = reactive({ modalOpened: false });
const props = defineProps<DesktopEditButtonConfig>();
const buildCommand = computed<string>(
() => "vnd.libreoffice.command:ofe|u|" + props.editLink,
);
const editionUntilFormatted = computed<string>(() => {
let d;
if (props.expirationLink instanceof Date) {
d = props.expirationLink;
} else {
d = new Date(props.expirationLink * 1000);
}
console.log(props.expirationLink);
return new Intl.DateTimeFormat(undefined, {
dateStyle: "long",
timeStyle: "medium",
}).format(d);
});
</script>
<template>
<teleport to="body">
<modal v-if="state.modalOpened" @close="state.modalOpened = false">
@@ -90,3 +51,41 @@ i.fa::before {
color: var(--bs-dropdown-link-hover-color);
}
</style>
<script setup lang="ts">
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import { computed, reactive } from "vue";
export interface DesktopEditButtonConfig {
editLink: string;
classes: Record<string, boolean>;
expirationLink: number | Date;
}
interface DesktopEditButtonState {
modalOpened: boolean;
}
const state: DesktopEditButtonState = reactive({ modalOpened: false });
const props = defineProps<DesktopEditButtonConfig>();
const buildCommand = computed<string>(
() => "vnd.libreoffice.command:ofe|u|" + props.editLink,
);
const editionUntilFormatted = computed<string>(() => {
let d;
if (props.expirationLink instanceof Date) {
d = props.expirationLink;
} else {
d = new Date(props.expirationLink * 1000);
}
return new Intl.DateTimeFormat(undefined, {
dateStyle: "long",
timeStyle: "medium",
}).format(d);
});
</script>

View File

@@ -12,7 +12,7 @@
v-else
:class="props.classes"
target="_blank"
:type="props.atVersion.type"
:type="props.atVersion?.type"
:download="buildDocumentName()"
:href="state.href_url"
ref="open_button"
@@ -27,11 +27,15 @@
import { reactive, ref, nextTick, onMounted } from "vue";
import { download_and_decrypt_doc } from "./helpers";
import mime from "mime";
import { StoredObject, StoredObjectVersion } from "../../types";
import {
StoredObject,
StoredObjectVersionCreated,
StoredObjectVersionPersisted,
} from "../../types";
interface DownloadButtonConfig {
storedObject: StoredObject;
atVersion: StoredObjectVersion;
atVersion: null | StoredObjectVersionCreated | StoredObjectVersionPersisted;
classes: Record<string, boolean>;
filename?: string;
/**
@@ -70,7 +74,7 @@ function buildDocumentName(): string {
document_name = "document";
}
const ext = mime.getExtension(props.atVersion.type);
const ext = mime.getExtension(props.atVersion?.type ?? "");
if (null !== ext) {
return document_name + "." + ext;