Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ticket list #1189

Merged
merged 13 commits into from
May 18, 2023
3 changes: 3 additions & 0 deletions desk/src/assets/icons/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions desk/src/assets/icons/dot-horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions desk/src/components/MinimalSwitch.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<Switch
:class="enabled ? 'bg-gray-900' : 'bg-gray-300'"
class="relative inline-flex h-[16px] w-[26px] items-center rounded-full transition"
>
<span
:class="enabled ? 'translate-x-3' : 'translate-x-0.5'"
class="switch-inner inline-block rounded-full bg-white transition"
/>
</Switch>
</template>

<script setup lang="ts">
import { Switch } from "@headlessui/vue";

defineProps({
enabled: {
type: Boolean,
required: true,
},
});
</script>

<style scoped>
.switch-inner {
height: 12px;
width: 12px;
box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.05);
}
</style>
21 changes: 12 additions & 9 deletions desk/src/composables/listManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ListOptions = {
pageLength?: number;
start?: number;
cache?: boolean | string | Array<string>;
auto?: boolean;
};

type MetaData = {
Expand All @@ -36,6 +37,7 @@ export function createListManager(options: ListOptions) {
const pageLength = ref(options.pageLength);
const start = ref(options.start);
const cache = options.cache;
const auto = options.auto;
const filterManager = useListFilters();

const list = createListResource({
Expand All @@ -48,7 +50,6 @@ export function createListManager(options: ListOptions) {
pageLength: pageLength.value,
start: start.value,
cache,
auto: false,
onSuccess() {
meta.submit({
doctype,
Expand All @@ -60,6 +61,13 @@ export function createListManager(options: ListOptions) {
},
});

list.updateArgs = () => {
filters.value = filterManager.queryFilters();
orderBy.value = filterManager.queryOrderBy();

list.reload();
};

Object.assign(list, {
totalCount: ref(0),
totalPages: ref(0),
Expand All @@ -83,15 +91,10 @@ export function createListManager(options: ListOptions) {
},
});

function updateArgs() {
filters.value = filterManager.queryFilters();
orderBy.value = filterManager.queryOrderBy();

list.reload();
if (auto) {
list.updateArgs();
watch(route, list.updateArgs);
}

onMounted(updateArgs);
watch(route, updateArgs);

return list;
}
2 changes: 1 addition & 1 deletion desk/src/pages/desk/AgentRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div v-if="initialized">
<div class="flex h-screen w-screen">
<SideBar />
<router-view class="z-0 grow" />
<router-view class="z-0 grow overflow-auto" />
</div>
</div>
</template>
Expand Down
Loading
Loading