I firmly believe in free software. The application I'm making here have capabilities that I've not seen in any system. It presents itself as an opportunity to collaborate on a tool that serves the people rather than corporations. Whose incentives are to help people rather, not make the most money. And whose terms ensure that these freedoms and incentives cannot be taken back or subverted. I license this software under the AGPL.
47 lines
1.2 KiB
Vue
47 lines
1.2 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
-->
|
|
<template>
|
|
<DiffEntry
|
|
v-if='state !== "modified" || after !== before'
|
|
:title
|
|
:entries
|
|
/>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import type { ApiEntity } from '~/shared/types/api';
|
|
import type { Id } from '~/shared/types/common';
|
|
import type { ClientEntity } from '~/utils/client-entity';
|
|
|
|
const props = defineProps<{
|
|
title: string,
|
|
before: Id | undefined,
|
|
after: Id | undefined,
|
|
entities: ClientMap<ClientEntity<ApiEntity> & { name?: string }>,
|
|
state: "deleted" | "created" | "modified",
|
|
}>();
|
|
|
|
function getName(id?: Id) {
|
|
if (id === undefined)
|
|
return undefined;
|
|
const entity = props.entities.get(id);
|
|
if (entity?.name !== undefined)
|
|
return entity.name;
|
|
return String(id);
|
|
}
|
|
|
|
const entries = computed(() => {
|
|
const result: ["removed" | "added", string][] = [];
|
|
const beforeName = getName(props.before);
|
|
if (props.state !== "created" && beforeName) {
|
|
result.push(["removed", beforeName]);
|
|
}
|
|
const afterName = getName(props.after);
|
|
if (props.state !== "deleted" && afterName) {
|
|
result.push(["added", afterName]);
|
|
}
|
|
return result;
|
|
})
|
|
</script>
|