Skip to content

Commit 6a90461

Browse files
committed
Tidy/simplify
1 parent 577fabe commit 6a90461

File tree

6 files changed

+44
-69
lines changed

6 files changed

+44
-69
lines changed

src/components/cylc/Drawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3838
<v-list-item-title>Dashboard</v-list-item-title>
3939
</v-list-item>
4040

41-
<v-divider class="" />
41+
<v-divider/>
4242

4343
<v-list-item>
4444
<v-list-item-title>Workflows</v-list-item-title>

src/components/cylc/TaskFilter.vue

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
data-cy="filter-id"
2929
clearable
3030
placeholder="Filter by ID"
31-
v-model="localValue.id"
31+
v-model="model.id"
3232
ref="filterIDInput"
3333
/>
3434
</v-col>
@@ -38,45 +38,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3838
class="mb-2 mb-md-0"
3939
>
4040
<TaskFilterSelect
41-
v-model="localValue.states"
41+
v-model="model.states"
4242
type="task state"
43-
:items="$options.allStates"
43+
:items="TaskStateNames"
4444
data-cy="filter task state"
4545
placeholder="Filter by task state"
4646
/>
4747
</v-col>
4848
</v-row>
4949
</template>
5050

51-
<script>
51+
<script setup>
5252
import { TaskStateNames } from '@/model/TaskState.model'
5353
import TaskFilterSelect from '@/components/cylc/TaskFilterSelect.vue'
5454
55-
export default {
56-
name: 'TaskFilter',
55+
/** @type {import('vue').Ref<{ id: string?, states: string[]? }>} */
56+
const model = defineModel({
57+
type: Object,
58+
required: true,
59+
})
5760
58-
components: {
59-
TaskFilterSelect
60-
},
61-
62-
props: {
63-
modelValue: {
64-
type: Object,
65-
required: true
66-
} // { id, states }
67-
},
68-
69-
computed: {
70-
localValue: {
71-
get () {
72-
return this.modelValue
73-
},
74-
set (value) {
75-
// Update 'modelValue' prop by notifying parent component's v-model for this component
76-
this.$emit('update:modelValue', value)
77-
}
78-
}
79-
},
80-
allStates: TaskStateNames,
81-
}
8261
</script>

src/components/cylc/TaskFilterSelect.vue

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
:items="items"
44
clearable
55
multiple
6-
v-model="localValue"
6+
v-model="model"
77
>
88
<template #prepend-item>
9-
<v-list-item
10-
@click="selectAll"
11-
>
12-
Select All
13-
</v-list-item>
9+
<v-select-actions>
10+
<v-btn
11+
@click="selectAll()"
12+
data-cy="task-filter-select-all"
13+
>
14+
Select All
15+
</v-btn>
16+
</v-select-actions>
17+
<v-divider/>
1418
</template>
1519

1620
<template #item="{ item, props }">
@@ -33,7 +37,7 @@
3337
<v-chip
3438
v-if="index < maxVisibleStates"
3539
closable
36-
@click:close="removeItem(item.raw)"
40+
@click:close="removeItem(index)"
3741
size="small"
3842
:close-icon="mdiClose"
3943
>
@@ -55,24 +59,18 @@
5559
v-if="index === maxVisibleStates"
5660
class="text-grey text-caption"
5761
>
58-
(+{{ localValue.length - maxVisibleStates }})
62+
(+{{ model.length - maxVisibleStates }})
5963
</span>
6064
</template>
6165
</v-select>
6266
</template>
6367

6468
<script setup>
65-
import { computed } from 'vue'
6669
import { mdiClose } from '@mdi/js'
6770
import Task from '@/components/cylc/Task.vue'
6871
import Workflowicon from '@/components/cylc/gscan/WorkflowIcon.vue'
6972
7073
const props = defineProps({
71-
/** Array of selected states */
72-
modelValue: {
73-
type: Array,
74-
default: () => [],
75-
},
7674
items: {
7775
type: Array,
7876
required: true,
@@ -83,24 +81,16 @@ const props = defineProps({
8381
},
8482
})
8583
86-
const emit = defineEmits(['update:modelValue'])
87-
88-
const localValue = computed({
89-
get () {
90-
return props.modelValue
91-
},
92-
set (val) {
93-
emit('update:modelValue', val)
94-
}
95-
})
84+
/** Array of selected states */
85+
const model = defineModel({ type: Array })
9686
9787
const maxVisibleStates = 4
9888
99-
function removeItem (key) {
100-
localValue.value = localValue.value.filter(item => item !== key)
89+
function removeItem (index) {
90+
model.value.splice(index, 1)
10191
}
10292
10393
function selectAll () {
104-
localValue.value = props.items
94+
model.value = props.items
10595
}
10696
</script>

src/components/cylc/analysis/TimeSeries.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3333
ref="selectTasks"
3434
>
3535
<template v-slot:prepend-item>
36-
<v-card-actions class="mt-n2">
36+
<v-select-actions>
3737
<v-btn @click="selectSearchResults">
3838
Select all
3939
</v-btn>
4040
<v-btn @click="deselectSearchResults">
4141
Deselect all
4242
</v-btn>
43-
</v-card-actions>
43+
</v-select-actions>
4444
<v-divider/>
4545
</template>
4646
</v-autocomplete>

src/plugins/vuetify.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { VCombobox } from 'vuetify/components/VCombobox'
2222
import { VSelect } from 'vuetify/components/VSelect'
2323
import { VTextarea } from 'vuetify/components/VTextarea'
2424
import { VTextField } from 'vuetify/components/VTextField'
25+
import { VCardActions } from 'vuetify/components/VCard'
2526
import colors from 'vuetify/util/colors'
2627
import { mdiClose } from '@mdi/js'
2728
import { useReducedAnimation } from '@/composables/localStorage'
@@ -75,11 +76,20 @@ export const vuetifyOptions = {
7576
mdi
7677
}
7778
},
79+
aliases: {
80+
VSelectActions: VCardActions,
81+
},
7882
defaults: {
7983
VTooltip: {
8084
activator: 'parent',
8185
location: 'bottom',
8286
},
87+
VList: {
88+
slim: true,
89+
},
90+
VSelectActions: {
91+
class: 'mt-n2'
92+
},
8393
...inputDefaults
8494
},
8595
}

tests/e2e/specs/tree.cy.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,14 @@ describe('Tree view', () => {
267267

268268
it('Provides a select all functionality', () => {
269269
cy.visit('/#/tree/one')
270-
cy
271-
.get('[data-cy="filter task state"]')
270+
cy.get('[data-cy="filter task state"]')
272271
.get('.v-list-item--active')
273272
.should('have.length', 0)
274-
cy
275-
.get('[data-cy="filter task state"]')
273+
cy.get('[data-cy="filter task state"]')
276274
.click()
277-
.get('.v-list-item')
278-
.contains('Select All')
279-
.click({ force: true })
280-
cy
281-
.get('[data-cy="filter task state"]')
275+
.get('[data-cy=task-filter-select-all]')
276+
.click()
277+
cy.get('[data-cy="filter task state"]')
282278
.get('.v-list-item--active')
283279
.should('have.length', 8)
284280
})

0 commit comments

Comments
 (0)