Skip to content

Commit 380a717

Browse files
committed
refactor(desk): use icons in v-checkbox
1 parent 44d5fdc commit 380a717

File tree

8 files changed

+67
-61
lines changed

8 files changed

+67
-61
lines changed

packages/desktop/components.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare module '@vue/runtime-core' {
1515
VCardHead: typeof import('./components/v-card-head.vue')['default']
1616
VCardTitle: typeof import('./components/v-card-title.vue')['default']
1717
VChart: typeof import('./components/v-chart.vue')['default']
18-
VCheckbox: typeof import('./components/v-checkbox.vue')['default']
18+
VCheckbox: typeof import('./components/VCheckbox.vue')['default']
1919
VCode: typeof import('./components/v-code.vue')['default']
2020
VContainer: typeof import('./components/v-container.vue')['default']
2121
VDialog: typeof import('./components/v-dialog.vue')['default']
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script lang="ts">
2+
export default {
3+
inheritAttrs: true,
4+
}
5+
</script>
6+
7+
<script setup lang="ts">
8+
import { useVariant } from '@composables/use-variant'
9+
import { useVModel } from 'vue-wind/composables/v-model'
10+
11+
// Props & Emits
12+
const props = defineProps({
13+
modelValue: {
14+
type: [String, Number, Boolean] as any,
15+
default: null,
16+
},
17+
label: {
18+
type: String,
19+
default: null,
20+
},
21+
color: {
22+
type: String,
23+
default: 'accent',
24+
},
25+
})
26+
27+
const emit = defineEmits(['update:modelValue'])
28+
29+
// model
30+
const model = useVModel(props, 'modelValue', emit)
31+
32+
// color
33+
34+
const colorVariant = useVariant(props, 'color', {
35+
accent: 'text-accent',
36+
_shared: 'cursor-pointer',
37+
})
38+
</script>
39+
<template>
40+
<label class="flex items-center">
41+
<input v-model="model" type="checkbox" class="hidden" />
42+
43+
<v-icon
44+
v-if="model"
45+
:class="colorVariant.classes"
46+
:style="colorVariant.styles"
47+
name="square-check"
48+
class="cursor-pointer"
49+
/>
50+
51+
<v-icon v-else name="fa-regular fa-square" class="cursor-pointer text-t-secondary" />
52+
53+
<span v-if="label" class="text-t-secondary block font-bold ml-2">{{ label }}</span>
54+
</label>
55+
</template>

packages/desktop/components/v-checkbox.vue

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/desktop/modules/collection-column/components/CcColumn.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const relation = computed(() => {
163163
<v-card-title>
164164
{{ $t('editEntity', [$t('column')]) }}
165165
</v-card-title>
166-
<v-btn text color="danger" class="ml-auto" @click="deleteColumn">
166+
<v-btn mode="text" color="danger" class="ml-auto" @click="deleteColumn">
167167
<v-icon name="trash" />
168168
</v-btn>
169169
</v-card-head>
@@ -206,7 +206,7 @@ const relation = computed(() => {
206206
<v-btn
207207
v-bind="attrs"
208208
:color="option.color || 'accent'"
209-
size="w-4 h-4"
209+
size="xs"
210210
/>
211211

212212
<v-input v-model="option.name" class="ml-4">
@@ -225,25 +225,25 @@ const relation = computed(() => {
225225
<v-card class="py-4 px-2" color="b-primary">
226226
<v-btn
227227
color="accent"
228-
size="w-4 h-4"
228+
size="xs"
229229
class="mb-4"
230230
@click="option.color = 'accent'"
231231
/>
232232
<v-btn
233233
color="info"
234-
size="w-4 h-4"
234+
size="xs"
235235
class="mb-4"
236236
@click="option.color = 'info'"
237237
/>
238238
<v-btn
239239
color="danger"
240-
size="w-4 h-4"
240+
size="xs"
241241
class="mb-4"
242242
@click="option.color = 'danger'"
243243
/>
244244
<v-btn
245245
color="warn"
246-
size="w-4 h-4"
246+
size="xs"
247247
class="mb-4"
248248
@click="option.color = 'warn'"
249249
/>

packages/desktop/modules/collection-column/store.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ref, watch, WatchStopHandle } from 'vue'
22
import { defineStore } from 'pinia'
33
import debounce from 'lodash/debounce'
44

5-
import { useStore as useWorkspace } from '@modules/workspace/store'
65
import { useStore as useCollection } from '@modules/collection/store'
76

87
import Column from '@core/entities/column'
@@ -18,7 +17,6 @@ interface StoreItem {
1817
export const useStore = defineStore('column', () => {
1918
const items = ref<StoreItem[]>([])
2019

21-
const workspace = useWorkspace()
2220
const collection = useCollection()
2321

2422
async function set(collectionId: string, forceUpdate = false) {
@@ -128,13 +126,7 @@ export const useStore = defineStore('column', () => {
128126

129127
if (!item || !data) return
130128

131-
await collection.update({
132-
workspaceId: workspace.currentId!,
133-
collectionId,
134-
data: {
135-
columns: item.columns,
136-
},
137-
})
129+
await collection.update(collectionId, { columns: item.columns }, false)
138130
}
139131

140132
async function destroy(collectionId: string, columnId: string) {

packages/desktop/modules/collection/components/CTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ onKeyStroke('Delete', async () => {
363363
class="px-4 py-2"
364364
select:no-chevron
365365
menu:offset-y
366-
color="none"
366+
input:color="none"
367367
flat
368368
/>
369369
</v-td>

packages/desktop/modules/collection/store.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import Collection from '@core/entities/collection'
66
import { useStore as useWorkspace } from '@modules/workspace/store'
77
import { useCase } from '@composables/use-case'
88

9-
import UpdateCollectionsDTO from '@core/use-cases/update-collection/update-collection.dto'
10-
import CreateCollectionDTO from '@core/use-cases/create-collection/create-collection.dto'
11-
import DeleteCollectionsDTO from '@core/use-cases/delete-collection/delete-collection.dto'
129
import ShowCollectionsDTO from '@core/use-cases/show-collection/show-collection.dto'
1310
import { useViewStore } from '@modules/view/store'
1411
import { useItemStore } from '@modules/item/store'
@@ -58,7 +55,7 @@ export const useStore = defineStore('collection', () => {
5855
return response.data
5956
}
6057

61-
async function update(id: string, payload: Partial<Collection>) {
58+
async function update(id: string, payload: Partial<Collection>, release = true) {
6259
const index = collections.value.findIndex((c) => c.id === id)
6360

6461
const response = await useCase('update-collection', {
@@ -71,7 +68,7 @@ export const useStore = defineStore('collection', () => {
7168
collections.value.splice(index, 1, response.data)
7269
}
7370

74-
releaseCollection(id)
71+
if (release) releaseCollection(id)
7572

7673
return response.data
7774
}

packages/examples/scripts/collections/todos/.is/views.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414
"search": "",
1515
"filters": [],
1616
"columns": [
17-
{
18-
"id": "_actions_left",
19-
"label": "#",
20-
"width": 43
21-
},
2217
{
2318
"label": "Done",
2419
"id": "47dcb1b3-4895-4642-a9f9-c23b0d9b3331",
2520
"options": [],
26-
"width": 92
21+
"width": 52
2722
},
2823
{
2924
"label": "Name",

0 commit comments

Comments
 (0)