Fix eslint

This commit is contained in:
2026-04-15 18:13:12 +02:00
parent d24842fc17
commit 60b31a0b19
10 changed files with 191 additions and 111 deletions

View File

@@ -66,7 +66,7 @@ window.addEventListener("DOMContentLoaded", function () {
},
onStoredObjectRefresh: function (newStoredObject: StoredObject) {
this.$data.storedObject = newStoredObject;
}
},
},
});

View File

@@ -3,14 +3,14 @@ import { SignedUrlGet } from "ChillDocStoreAssets/vuejs/StoredObjectButton/helpe
export type StoredObjectStatus = "empty" | "ready" | "failure" | "pending";
export type StoredObjectLockMethodEnum = 'webdav' | 'wopi';
export type StoredObjectLockMethodEnum = "webdav" | "wopi";
export interface StoredObjectLock {
uuid: string;
method: StoredObjectLockMethodEnum;
createdAt: DateTime;
expiresAt: DateTime;
users: User[];
uuid: string;
method: StoredObjectLockMethodEnum;
createdAt: DateTime;
expiresAt: DateTime;
users: User[];
}
export interface StoredObject {
@@ -41,11 +41,11 @@ export interface StoredObject {
};
downloadLink?: SignedUrlGet;
};
lock: StoredObjectLock|null;
_editor?: {
webdav: boolean;
wopi: boolean;
}
lock: StoredObjectLock | null;
_editor?: {
webdav: boolean;
wopi: boolean;
};
}
export interface StoredObjectVersion {

View File

@@ -14,13 +14,22 @@
aria-expanded="false"
>
Actions
<currently-editing-icon v-if="props.storedObject.lock !== null"></currently-editing-icon>
<currently-editing-icon
v-if="props.storedObject.lock !== null"
></currently-editing-icon>
</button>
<ul class="dropdown-menu">
<li v-if="null !== props.storedObject.lock">
<is-currently-edited :stored-object="props.storedObject as StoredObject & {lock: StoredObjectLock}" @require-refresh-stored-object="refreshStoredObject"></is-currently-edited>
<is-currently-edited
:stored-object="
props.storedObject as StoredObject & { lock: StoredObjectLock }
"
@require-refresh-stored-object="refreshStoredObject"
></is-currently-edited>
</li>
<li v-if="null !== props.storedObject.lock">
<hr class="dropdown-divider" />
</li>
<li v-if="null !== props.storedObject.lock"><hr class="dropdown-divider"></li>
<li v-if="isEditableOnline">
<wopi-edit-button
:stored-object="props.storedObject"
@@ -80,7 +89,8 @@ import {
is_object_ready,
} from "./StoredObjectButton/helpers";
import {
StoredObject, StoredObjectLock,
StoredObject,
StoredObjectLock,
StoredObjectStatusChange,
WopiEditButtonExecutableBeforeLeaveFunction,
} from "../types";
@@ -88,7 +98,7 @@ import DesktopEditButton from "ChillDocStoreAssets/vuejs/StoredObjectButton/Desk
import HistoryButton from "ChillDocStoreAssets/vuejs/StoredObjectButton/HistoryButton.vue";
import CurrentlyEditingIcon from "ChillDocStoreAssets/vuejs/StoredObjectButton/CurrentlyEditingIcon.vue";
import IsCurrentlyEdited from "ChillDocStoreAssets/vuejs/StoredObjectButton/IsCurrentlyEdited.vue";
import {useIntervalFn} from "@vueuse/core";
import { useIntervalFn } from "@vueuse/core";
interface DocumentActionButtonsGroupConfig {
storedObject: StoredObject;
@@ -137,18 +147,10 @@ interface DocumentActionButtonsGroupConfig {
refreshStoredObjectMaxTimes?: number;
}
const emit =
defineEmits<{
(
e: "onStoredObjectStatusChange",
newStatus: StoredObjectStatusChange,
): void
(
e: "onStoredObjectRefresh",
newStoredObject: StoredObject,
): void
}
>();
const emit = defineEmits<{
(e: "onStoredObjectStatusChange", newStatus: StoredObjectStatusChange): void;
(e: "onStoredObjectRefresh", newStoredObject: StoredObject): void;
}>();
const props = withDefaults(defineProps<DocumentActionButtonsGroupConfig>(), {
small: false,
@@ -273,7 +275,7 @@ const refreshStoredObject = async () => {
const interval = useIntervalFn(
refreshStoredObject,
props.refreshStoredObjectInterval,
{immediate: false, immediateCallback: false}
{ immediate: false, immediateCallback: false },
);
onMounted(() => {

View File

@@ -1,38 +1,53 @@
<script setup lang="ts">
</script>
<script setup lang="ts"></script>
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="icon-pen-fill">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
class="icon-pen-fill"
>
<defs>
<linearGradient id="pen-grad" gradientUnits="userSpaceOnUse" x1="-16" y1="0" x2="0" y2="0">
<stop offset="0%" stop-color="#334D5C"/>
<stop offset="40%" stop-color="#334D5C"/>
<stop offset="40%" stop-color="#43B29D"/>
<stop offset="50%" stop-color="#43B29D"/>
<stop offset="50%" stop-color="#328474"/>
<stop offset="60%" stop-color="#328474"/>
<stop offset="60%" stop-color="#EEC84A"/>
<stop offset="70%" stop-color="#EEC84A"/>
<stop offset="70%" stop-color="#E2793D"/>
<stop offset="80%" stop-color="#E2793D"/>
<stop offset="80%" stop-color="#DF4949"/>
<stop offset="90%" stop-color="#DF4949"/>
<stop offset="90%" stop-color="#cabb9f"/>
<stop offset="100%" stop-color="#cabb9f"/>
<stop offset="100%" stop-color="#334D5C"/>
<animateTransform attributeName="gradientTransform"
type="translate"
from="0 0" to="32 32"
dur="1.5s"
repeatCount="indefinite"/>
<linearGradient
id="pen-grad"
gradientUnits="userSpaceOnUse"
x1="-16"
y1="0"
x2="0"
y2="0"
>
<stop offset="0%" stop-color="#334D5C" />
<stop offset="40%" stop-color="#334D5C" />
<stop offset="40%" stop-color="#43B29D" />
<stop offset="50%" stop-color="#43B29D" />
<stop offset="50%" stop-color="#328474" />
<stop offset="60%" stop-color="#328474" />
<stop offset="60%" stop-color="#EEC84A" />
<stop offset="70%" stop-color="#EEC84A" />
<stop offset="70%" stop-color="#E2793D" />
<stop offset="80%" stop-color="#E2793D" />
<stop offset="80%" stop-color="#DF4949" />
<stop offset="90%" stop-color="#DF4949" />
<stop offset="90%" stop-color="#cabb9f" />
<stop offset="100%" stop-color="#cabb9f" />
<stop offset="100%" stop-color="#334D5C" />
<animateTransform
attributeName="gradientTransform"
type="translate"
from="0 0"
to="32 32"
dur="1.5s"
repeatCount="indefinite"
/>
</linearGradient>
</defs>
<path fill="url(#pen-grad)" d="m13.498.795.149-.149a1.207 1.207 0 1 1 1.707 1.708l-.149.148a1.5 1.5 0 0 1-.059 2.059L4.854 14.854a.5.5 0 0 1-.233.131l-4 1a.5.5 0 0 1-.606-.606l1-4a.5.5 0 0 1 .131-.232l9.642-9.642a.5.5 0 0 0-.642.056L6.854 4.854a.5.5 0 1 1-.708-.708L9.44.854A1.5 1.5 0 0 1 11.5.796a1.5 1.5 0 0 1 1.998-.001"/>
<path
fill="url(#pen-grad)"
d="m13.498.795.149-.149a1.207 1.207 0 1 1 1.707 1.708l-.149.148a1.5 1.5 0 0 1-.059 2.059L4.854 14.854a.5.5 0 0 1-.233.131l-4 1a.5.5 0 0 1-.606-.606l1-4a.5.5 0 0 1 .131-.232l9.642-9.642a.5.5 0 0 0-.642.056L6.854 4.854a.5.5 0 1 1-.708-.708L9.44.854A1.5 1.5 0 0 1 11.5.796a1.5 1.5 0 0 1 1.998-.001"
/>
</svg>
</template>
<style scoped lang="scss">
</style>
<style scoped lang="scss"></style>

View File

@@ -55,7 +55,7 @@ i.fa::before {
<script setup lang="ts">
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import { computed, reactive } from "vue";
import {StoredObject} from "ChillDocStoreAssets/types";
import { StoredObject } from "ChillDocStoreAssets/types";
export interface DesktopEditButtonConfig {
editLink: string;
@@ -78,12 +78,12 @@ const buildCommand = computed<string>(
function classesComputed(): Record<string, boolean> {
const cl = props.classes;
cl['btn'] = true;
cl["btn"] = true;
if (false === props.storedObject._editor?.webdav) {
cl['disabled'] = true;
cl["disabled"] = true;
} else {
cl['disabled'] = false;
cl["disabled"] = false;
}
return cl;

View File

@@ -1,11 +1,10 @@
<script setup lang="ts">
import {StoredObject, StoredObjectLock, StoredObjectStatusChange} from "ChillDocStoreAssets/types";
import { StoredObject, StoredObjectLock } from "ChillDocStoreAssets/types";
import CurrentlyEditingIcon from "ChillDocStoreAssets/vuejs/StoredObjectButton/CurrentlyEditingIcon.vue";
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import {computed, reactive} from "vue";
import {localizeList} from "ChillMainAssets/lib/localizationHelper/localizationHelper";
import {User} from "ChillMainAssets/types";
import { computed, reactive } from "vue";
import { localizeList } from "ChillMainAssets/lib/localizationHelper/localizationHelper";
import { User } from "ChillMainAssets/types";
import {
STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED,
STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_WITHOUT_USERS,
@@ -18,22 +17,17 @@ import {
STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK_WARNING,
STORED_OBJECT_LOCK_REMOVE_LOCK_FAILURE,
STORED_OBJECT_LOCK_REMOVE_LOCK_SUCCESS,
trans} from "translator";
import {ISOToDatetime} from "ChillMainAssets/chill/js/date";
import {remove_lock} from "ChillDocStoreAssets/vuejs/StoredObjectButton/helpers";
import {useToast} from "vue-toast-notification";
trans,
} from "translator";
import { ISOToDatetime } from "ChillMainAssets/chill/js/date";
import { remove_lock } from "ChillDocStoreAssets/vuejs/StoredObjectButton/helpers";
import { useToast } from "vue-toast-notification";
interface IsCurrentlyEditedConfig {
storedObject: StoredObject & {lock: StoredObjectLock}
storedObject: StoredObject & { lock: StoredObjectLock };
}
const emit =
defineEmits<{
(
e: "requireRefreshStoredObject",
): void
}
>();
const emit = defineEmits<(e: "requireRefreshStoredObject") => void>();
const props = defineProps<IsCurrentlyEditedConfig>();
@@ -43,33 +37,44 @@ const state = reactive({
const toast = useToast();
const sinceDate = computed<Date|null>(() => ISOToDatetime(props.storedObject.lock.createdAt.datetime))
const sinceDate = computed<Date | null>(() =>
ISOToDatetime(props.storedObject.lock.createdAt.datetime),
);
const onModalClose = function(): void {
const onModalClose = function (): void {
state.modalOpened = false;
}
};
const openModal = function(): void {
const openModal = function (): void {
state.modalOpened = true;
}
};
const removeLock = async function (): Promise<void> {
if (window.confirm(trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK_WARNING, {nb: props.storedObject.lock.users.length}))) {
if (
window.confirm(
trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK_WARNING, {
nb: props.storedObject.lock.users.length,
}),
)
) {
try {
await remove_lock(props.storedObject);
} catch (e: unknown) {
toast.error(trans(STORED_OBJECT_LOCK_REMOVE_LOCK_FAILURE, {status: (e as Error).toString()}));
toast.error(
trans(STORED_OBJECT_LOCK_REMOVE_LOCK_FAILURE, {
status: (e as Error).toString(),
}),
);
return Promise.reject(e);
}
emit('requireRefreshStoredObject');
emit("requireRefreshStoredObject");
toast.success(trans(STORED_OBJECT_LOCK_REMOVE_LOCK_SUCCESS));
return Promise.resolve();
} else {
console.log('User did not confirmed edit');
console.log("User did not confirmed edit");
}
}
};
</script>
<template>
@@ -77,22 +82,63 @@ const removeLock = async function (): Promise<void> {
<modal v-if="state.modalOpened" @close="onModalClose">
<template v-slot:body>
<div class="modal-currently-edit-content">
<p v-if="props.storedObject.lock.users.length > 0">{{ trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED, {byUsers: localizeList(props.storedObject.lock.users.map((u: User) => u.label))} ) }}.<template v-if="props.storedObject.lock.method === 'wopi'"> {{ trans(STORED_OBJECT_LOCK_LIST_OF_USERS_MAY_BE_INCOMPLETE) }}</template></p>
<p v-else>{{ trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_WITHOUT_USERS) }}</p>
<p v-if="sinceDate !== null">{{ trans(STORED_OBJECT_LOCK_EDITING_SINCE, {since: sinceDate}) }}</p>
<p v-if="props.storedObject.lock.users.length > 0">
{{
trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED, {
byUsers: localizeList(
props.storedObject.lock.users.map((u: User) => u.label),
),
})
}}.<template v-if="props.storedObject.lock.method === 'wopi'">
{{
trans(STORED_OBJECT_LOCK_LIST_OF_USERS_MAY_BE_INCOMPLETE)
}}</template
>
</p>
<p v-else>
{{ trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_WITHOUT_USERS) }}
</p>
<p v-if="sinceDate !== null">
{{ trans(STORED_OBJECT_LOCK_EDITING_SINCE, { since: sinceDate }) }}
</p>
<div v-if="props.storedObject._permissions.canEdit && props.storedObject.lock.method === 'webdav'" class="alert alert-danger">
<p><i class="bi bi-exclamation-lg"></i>{{ trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK_POSSIBLE_EXPLAIN) }}</p>
<button class="btn btn-delete" @click="removeLock">{{ trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK) }}</button>
<div
v-if="
props.storedObject._permissions.canEdit &&
props.storedObject.lock.method === 'webdav'
"
class="alert alert-danger"
>
<p>
<i class="bi bi-exclamation-lg"></i
>{{
trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK_POSSIBLE_EXPLAIN)
}}
</p>
<button class="btn btn-delete" @click="removeLock">
{{ trans(STORED_OBJECT_LOCK_FORCE_REMOVE_LOCK) }}
</button>
</div>
</div>
</template>
</modal>
</teleport>
<button class="dropdown-item" type="button" @click="openModal()">
<span class="currently-edited"><currently-editing-icon></currently-editing-icon></span>
<span v-if="props.storedObject.lock.users.length > 0">{{ trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_SHORT, {byUsers: localizeList([props.storedObject.lock.users[0].label]) } ) }}<span v-if="props.storedObject.lock.users.length > 1"> (+{{ props.storedObject.lock.users.length - 1 }})</span></span>
<span v-else>{{ trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_WITHOUT_USERS_SHORT) }}</span>
<span class="currently-edited"
><currently-editing-icon></currently-editing-icon
></span>
<span v-if="props.storedObject.lock.users.length > 0"
>{{
trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_SHORT, {
byUsers: localizeList([props.storedObject.lock.users[0].label]),
})
}}<span v-if="props.storedObject.lock.users.length > 1">
(+{{ props.storedObject.lock.users.length - 1 }})</span
></span
>
<span v-else>{{
trans(STORED_OBJECT_LOCK_IS_CURRENTLY_EDITED_WITHOUT_USERS_SHORT)
}}</span>
</button>
</template>

View File

@@ -30,12 +30,12 @@ let executed = false;
function classesComputed(): Record<string, boolean> {
const cl = props.classes;
cl['btn'] = true;
cl["btn"] = true;
if (false === props.storedObject._editor?.wopi) {
cl['disabled'] = true;
cl["disabled"] = true;
} else {
cl['disabled'] = false;
cl["disabled"] = false;
}
return cl;

View File

@@ -267,15 +267,20 @@ async function is_object_ready(
async function remove_lock(storedObject: StoredObject): Promise<void> {
const remove_lock_response = await window.fetch(
`/api/1.0/doc-store/stored-object/${storedObject.uuid}/lock`,
{method: 'DELETE'}
)
{ method: "DELETE" },
);
if (remove_lock_response.ok) {
return Promise.resolve();
} else if (remove_lock_response.status === 412) {
return Promise.resolve();
} else {
throw new Error("Could not remove lock: status code: " + remove_lock_response.status + ' message: ' + remove_lock_response.statusText);
throw new Error(
"Could not remove lock: status code: " +
remove_lock_response.status +
" message: " +
remove_lock_response.statusText,
);
}
}
@@ -285,9 +290,11 @@ async function remove_lock(storedObject: StoredObject): Promise<void> {
* @param {string} storedObjectUuid - The unique identifier of the stored object to retrieve.
* @return {Promise<StoredObject>} A promise that resolves to the retrieved stored object.
*/
async function get_stored_object(storedObjectUuid: string): Promise<StoredObject> {
async function get_stored_object(
storedObjectUuid: string,
): Promise<StoredObject> {
return await makeFetch<null, StoredObject>(
'GET',
"GET",
`/api/1.0/doc-store/stored-object/${storedObjectUuid}`,
);
}

View File

@@ -107,7 +107,10 @@ export function localizeDateTimeFormat(
*
* This method is a stub while PHP supports the formatting of list using ICU.
*/
export function localizeList(list: Iterable<string>, options?: Intl.ListFormatOptions): string {
export function localizeList(
list: Iterable<string>,
options?: Intl.ListFormatOptions,
): string {
const formatter = new Intl.ListFormat(getLocale(), options);
return formatter.format(list);
}

View File

@@ -106,7 +106,14 @@
@on-stored-object-status-change="
$emit('statusDocumentChanged', $event)
"
@on-stored-object-refresh="(newStoredObject) => replaceDocument(d, newStoredObject, newStoredObject.currentVersion)"
@on-stored-object-refresh="
(newStoredObject) =>
replaceDocument(
d,
newStoredObject,
newStoredObject.currentVersion,
)
"
></document-action-buttons-group>
</li>
<!--replace document-->
@@ -319,7 +326,7 @@ async function goToGenerateWorkflowEvaluationDocument({
* @return {void}
*/
async function replaceDocument(oldDocument, storedObject, storedObjectVersion) {
console.log('replaceDocument', storedObject, storedObjectVersion);
console.log("replaceDocument", storedObject, storedObjectVersion);
let document = {
type: "accompanying_period_work_evaluation_document",
storedObject: storedObject,