mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-17 12:42:15 +01:00
add archiving for clients, fixes ST-279
This commit is contained in:
committed by
Constantin Graf
parent
5592d87cd5
commit
19cc05140a
@@ -118,7 +118,7 @@ const showFreeUpgradeBanner = computed(
|
|||||||
<span>Upgrade now</span>
|
<span>Upgrade now</span>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<button @click="hideTrialBanner = true" class="p-1">
|
<button @click="hideFreeUpgradeBanner = true" class="p-1">
|
||||||
<XMarkIcon
|
<XMarkIcon
|
||||||
class="w-4 opacity-50 hover:opacity-100"></XMarkIcon>
|
class="w-4 opacity-50 hover:opacity-100"></XMarkIcon>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { CreateClientBody } from '@/packages/api/src';
|
|||||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||||
import { useFocus } from '@vueuse/core';
|
import { useFocus } from '@vueuse/core';
|
||||||
import { useClientsStore } from '@/utils/useClients';
|
import { useClientsStore } from '@/utils/useClients';
|
||||||
|
import InputLabel from '../../../packages/ui/src/Input/InputLabel.vue';
|
||||||
|
|
||||||
const { createClient } = useClientsStore();
|
const { createClient } = useClientsStore();
|
||||||
const show = defineModel('show', { default: false });
|
const show = defineModel('show', { default: false });
|
||||||
@@ -36,6 +37,7 @@ useFocus(clientNameInput, { initialValue: true });
|
|||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex items-center space-x-4">
|
<div class="flex items-center space-x-4">
|
||||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||||
|
<InputLabel for="clientName" value="Client Name" />
|
||||||
<TextInput
|
<TextInput
|
||||||
id="clientName"
|
id="clientName"
|
||||||
ref="clientNameInput"
|
ref="clientNameInput"
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PencilSquareIcon, TrashIcon } from '@heroicons/vue/20/solid';
|
import {
|
||||||
|
ArchiveBoxIcon,
|
||||||
|
PencilSquareIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from '@heroicons/vue/20/solid';
|
||||||
import type { Client } from '@/packages/api/src';
|
import type { Client } from '@/packages/api/src';
|
||||||
import { canDeleteClients, canUpdateClients } from '@/utils/permissions';
|
import { canDeleteClients, canUpdateClients } from '@/utils/permissions';
|
||||||
import MoreOptionsDropdown from '@/packages/ui/src/MoreOptionsDropdown.vue';
|
import MoreOptionsDropdown from '@/packages/ui/src/MoreOptionsDropdown.vue';
|
||||||
@@ -7,6 +11,7 @@ import MoreOptionsDropdown from '@/packages/ui/src/MoreOptionsDropdown.vue';
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
delete: [];
|
delete: [];
|
||||||
edit: [];
|
edit: [];
|
||||||
|
archive: [];
|
||||||
}>();
|
}>();
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
client: Client;
|
client: Client;
|
||||||
@@ -26,6 +31,14 @@ const props = defineProps<{
|
|||||||
class="w-5 text-icon-active"></PencilSquareIcon>
|
class="w-5 text-icon-active"></PencilSquareIcon>
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
@click.prevent="emit('archive')"
|
||||||
|
v-if="canUpdateClients()"
|
||||||
|
:aria-label="'Archive Client ' + props.client.name"
|
||||||
|
class="flex items-center space-x-3 w-full px-3 py-2.5 text-start text-sm font-medium leading-5 text-white hover:bg-card-background-active focus:outline-none focus:bg-card-background-active transition duration-150 ease-in-out">
|
||||||
|
<ArchiveBoxIcon class="w-5 text-icon-active"></ArchiveBoxIcon>
|
||||||
|
<span>{{ client.is_archived ? 'Unarchive' : 'Archive' }}</span>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="canDeleteClients()"
|
v-if="canDeleteClients()"
|
||||||
@click="emit('delete')"
|
@click="emit('delete')"
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
|||||||
import { UserCircleIcon } from '@heroicons/vue/24/solid';
|
import { UserCircleIcon } from '@heroicons/vue/24/solid';
|
||||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||||
import { type Component, ref } from 'vue';
|
import { type Component, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { type Client } from '@/packages/api/src';
|
||||||
import { useClientsStore } from '@/utils/useClients';
|
|
||||||
import ClientTableRow from '@/Components/Common/Client/ClientTableRow.vue';
|
import ClientTableRow from '@/Components/Common/Client/ClientTableRow.vue';
|
||||||
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
||||||
import ClientTableHeading from '@/Components/Common/Client/ClientTableHeading.vue';
|
import ClientTableHeading from '@/Components/Common/Client/ClientTableHeading.vue';
|
||||||
import { canCreateClients } from '@/utils/permissions';
|
import { canCreateClients } from '@/utils/permissions';
|
||||||
|
|
||||||
const { clients } = storeToRefs(useClientsStore());
|
defineProps<{
|
||||||
|
clients: Client[];
|
||||||
|
}>();
|
||||||
const createClient = ref(false);
|
const createClient = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ const projectCount = computed(() => {
|
|||||||
).length;
|
).length;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function archiveClient() {
|
||||||
|
useClientsStore().updateClient(props.client.id, {
|
||||||
|
...props.client,
|
||||||
|
is_archived: !props.client.is_archived,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const showEditModal = ref(false);
|
const showEditModal = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -50,6 +57,7 @@ const showEditModal = ref(false);
|
|||||||
<ClientMoreOptionsDropdown
|
<ClientMoreOptionsDropdown
|
||||||
:client="client"
|
:client="client"
|
||||||
@edit="showEditModal = true"
|
@edit="showEditModal = true"
|
||||||
|
@archive="archiveClient"
|
||||||
@delete="deleteClient"></ClientMoreOptionsDropdown>
|
@delete="deleteClient"></ClientMoreOptionsDropdown>
|
||||||
</div>
|
</div>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@@ -1,27 +1,62 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
||||||
import AppLayout from '@/Layouts/AppLayout.vue';
|
import AppLayout from '@/Layouts/AppLayout.vue';
|
||||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
import { FolderIcon, PlusIcon } from '@heroicons/vue/16/solid';
|
||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||||
import { UserCircleIcon } from '@heroicons/vue/20/solid';
|
import { UserCircleIcon } from '@heroicons/vue/20/solid';
|
||||||
import { onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import { useClientsStore } from '@/utils/useClients';
|
import { useClientsStore } from '@/utils/useClients';
|
||||||
import ClientTable from '@/Components/Common/Client/ClientTable.vue';
|
import ClientTable from '@/Components/Common/Client/ClientTable.vue';
|
||||||
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
||||||
import PageTitle from '@/Components/Common/PageTitle.vue';
|
import PageTitle from '@/Components/Common/PageTitle.vue';
|
||||||
import { canCreateClients } from '@/utils/permissions';
|
import { canCreateClients } from '@/utils/permissions';
|
||||||
|
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||||
|
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
useClientsStore().fetchClients();
|
useClientsStore().fetchClients();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const activeTab = ref<'active' | 'archived'>('active');
|
||||||
|
|
||||||
|
function isActiveTab(tab: string) {
|
||||||
|
return activeTab.value === tab;
|
||||||
|
}
|
||||||
|
|
||||||
const createClient = ref(false);
|
const createClient = ref(false);
|
||||||
|
|
||||||
|
const { clients } = storeToRefs(useClientsStore());
|
||||||
|
|
||||||
|
const shownClients = computed(() => {
|
||||||
|
return clients.value.filter((client) => {
|
||||||
|
if (activeTab.value === 'active') {
|
||||||
|
return !client.is_archived;
|
||||||
|
}
|
||||||
|
return client.is_archived;
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout title="Clients" data-testid="clients_view">
|
<AppLayout title="Clients" data-testid="clients_view">
|
||||||
<MainContainer
|
<MainContainer
|
||||||
class="py-5 border-b border-default-background-separator flex justify-between items-center">
|
class="py-5 border-b border-default-background-separator flex justify-between items-center">
|
||||||
|
<div class="flex items-center space-x-3 sm:space-x-6">
|
||||||
|
<PageTitle :icon="FolderIcon" title="Projects"></PageTitle>
|
||||||
|
<TabBar>
|
||||||
|
<TabBarItem
|
||||||
|
:active="isActiveTab('active')"
|
||||||
|
@click="activeTab = 'active'"
|
||||||
|
>Active</TabBarItem
|
||||||
|
>
|
||||||
|
<TabBarItem
|
||||||
|
:active="isActiveTab('archived')"
|
||||||
|
@click="activeTab = 'archived'">
|
||||||
|
Archived
|
||||||
|
</TabBarItem>
|
||||||
|
</TabBar>
|
||||||
|
</div>
|
||||||
<div class="flex items-center space-x-6">
|
<div class="flex items-center space-x-6">
|
||||||
<PageTitle :icon="UserCircleIcon" title="Clients"> </PageTitle>
|
<PageTitle :icon="UserCircleIcon" title="Clients"> </PageTitle>
|
||||||
</div>
|
</div>
|
||||||
@@ -33,6 +68,6 @@ const createClient = ref(false);
|
|||||||
>
|
>
|
||||||
<ClientCreateModal v-model:show="createClient"></ClientCreateModal>
|
<ClientCreateModal v-model:show="createClient"></ClientCreateModal>
|
||||||
</MainContainer>
|
</MainContainer>
|
||||||
<ClientTable></ClientTable>
|
<ClientTable :clients="shownClients"></ClientTable>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ const props = defineProps<{
|
|||||||
currency: string;
|
currency: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const activeClients = computed(() => {
|
||||||
|
return props.clients.filter((client) => !client.is_archived);
|
||||||
|
});
|
||||||
|
|
||||||
const project = ref<CreateProjectBody>({
|
const project = ref<CreateProjectBody>({
|
||||||
name: '',
|
name: '',
|
||||||
color: getRandomColor(),
|
color: getRandomColor(),
|
||||||
@@ -100,7 +104,7 @@ const currentClientName = computed(() => {
|
|||||||
<InputLabel for="client" value="Client" />
|
<InputLabel for="client" value="Client" />
|
||||||
<ClientDropdown
|
<ClientDropdown
|
||||||
:createClient="createClient"
|
:createClient="createClient"
|
||||||
:clients="clients"
|
:clients="activeClients"
|
||||||
class="mt-2"
|
class="mt-2"
|
||||||
v-model="project.client_id">
|
v-model="project.client_id">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ export const useClientsStore = defineStore('clients', () => {
|
|||||||
clientResponse.value = await handleApiRequestNotifications(
|
clientResponse.value = await handleApiRequestNotifications(
|
||||||
() =>
|
() =>
|
||||||
api.getClients({
|
api.getClients({
|
||||||
|
queries: {
|
||||||
|
archived: 'all',
|
||||||
|
},
|
||||||
params: {
|
params: {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user