Skip to content

Commit

Permalink
chore: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Dec 4, 2024
1 parent 72964bc commit ec1507b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 4 additions & 0 deletions desk/src/components/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export { default as ThumbsUpIcon } from "./ThumbsUpIcon.vue";
export { default as ThumbsUpFilledIcon } from "./ThumbsUpFilledIcon.vue";
export { default as ThumbsDownIcon } from "./ThumbsDownIcon.vue";
export { default as ThumbsDownFilledIcon } from "./ThumbsDownFilledIcon.vue";
export { default as AscendingIcon } from "./AscendingIcon.vue";
export { default as DescendingIcon } from "./DescendingIcon.vue";
export { default as SortIcon } from "./SortIcon.vue";
export { default as DragIcon } from "./DragIcon.vue";
2 changes: 1 addition & 1 deletion desk/src/components/view-controls/QuickFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const listViewActions = inject("listViewActions");
const { list, quickFilters } = listViewData;
function applyQuickFilter(filter, value) {
let filters = { ...list.params.filters };
let filters = { ...list.params?.filters };
let field = filter.name;
if (value) {
Expand Down
26 changes: 15 additions & 11 deletions desk/src/components/view-controls/SortBy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"
>
<AscendingIcon v-if="sort.direction == 'asc'" class="h-4" />
<DesendingIcon v-else class="h-4" />
<DescendingIcon v-else class="h-4" />
</Button>
<Autocomplete
class="!w-32"
Expand Down Expand Up @@ -166,15 +166,16 @@
</template>

<script setup>
import { computed, inject, nextTick, onMounted } from "vue";
import { createResource, NestedPopover } from "frappe-ui";
import { computed, inject } from "vue";
import { NestedPopover } from "frappe-ui";
import { useSortable } from "@vueuse/integrations/useSortable";
import Autocomplete from "@/components/frappe-ui/Autocomplete.vue";
import AscendingIcon from "@/components/icons/AscendingIcon.vue";
import DescendingIcon from "@/components/icons/DescendingIcon.vue";
import SortIcon from "@/components/icons/SortIcon.vue";
import DragIcon from "@/components/icons/DragIcon.vue";
import {
AscendingIcon,
DescendingIcon,
SortIcon,
DragIcon,
} from "@/components/icons";
const props = defineProps({
hideLabel: {
Expand All @@ -194,11 +195,14 @@ const sortValues = computed({
if (!list) return new Set();
let allSortValues = list.params?.order_by;
if (!allSortValues || !sortOptions.data) return new Set();
if (allSortValues.trim() === "modified desc") return new Set();
// if (allSortValues.trim() === "modified desc") return new Set();
// allSortValues = removeDuplicateSorts();
allSortValues = allSortValues.split(", ").map((sortValue) => {
const [fieldname, direction] = sortValue.split(" ");
return { fieldname, direction };
});
// allSortValues = removeDuplicateSorts();
return new Set(allSortValues);
},
set: (value) => {
Expand All @@ -208,8 +212,8 @@ const sortValues = computed({
const options = computed(() => {
if (!sortOptions.data) return [];
if (!sortValues.size) return sortOptions.data;
const selectedOptions = [...sortValues.data].map((sort) => sort.fieldname);
if (!sortValues.value.size) return sortOptions.data;
const selectedOptions = [...sortValues.value].map((sort) => sort.fieldname);
restartSort();
return sortOptions.data.filter((option) => {
return !selectedOptions.includes(option.value);
Expand Down

0 comments on commit ec1507b

Please sign in to comment.