-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move task filter controls into own component
- Loading branch information
Showing
7 changed files
with
141 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!-- | ||
Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<!-- Controls for filtering tasks in views. --> | ||
|
||
<template> | ||
<v-row no-gutters> | ||
<v-col | ||
cols="12" | ||
md="6" | ||
class="pr-md-2 mb-2 mb-md-0" | ||
> | ||
<v-text-field | ||
data-cy="filter-task-name" | ||
clearable | ||
dense | ||
flat | ||
hide-details | ||
outlined | ||
placeholder="Filter by task name" | ||
v-model="localValue.name" | ||
ref="filterNameInput" | ||
></v-text-field> | ||
</v-col> | ||
<v-col | ||
cols="12" | ||
md="6" | ||
class="mb-2 mb-md-0" | ||
> | ||
<v-select | ||
data-cy="filter-task-states" | ||
:items="allStates" | ||
clearable | ||
dense | ||
flat | ||
hide-details | ||
multiple | ||
outlined | ||
placeholder="Filter by task state" | ||
v-model="localValue.states" | ||
> | ||
<template v-slot:item="slotProps"> | ||
<Task :task="{ state: slotProps.item }" /> | ||
<span class="ml-2">{{ slotProps.item }}</span> | ||
</template> | ||
<template v-slot:selection="slotProps"> | ||
<div class="mr-2" v-if="slotProps.index >= 0 && slotProps.index < maxVisibleStates"> | ||
<Task :task="{ state: slotProps.item }" /> | ||
</div> | ||
<span | ||
v-if="slotProps.index === maxVisibleStates" | ||
class="grey--text caption" | ||
> | ||
(+{{ localValue.states.length - maxVisibleStates }}) | ||
</span> | ||
</template> | ||
</v-select> | ||
</v-col> | ||
</v-row> | ||
</template> | ||
|
||
<script> | ||
import Task from '@/components/cylc/Task' | ||
import { TaskStateUserOrder } from '@/model/TaskState.model' | ||
export default { | ||
name: 'TaskFilter', | ||
components: { | ||
Task | ||
}, | ||
props: { | ||
value: Object // { name, states } | ||
}, | ||
data () { | ||
return { | ||
maxVisibleStates: 4, | ||
allStates: TaskStateUserOrder.map(ts => ts.name) | ||
} | ||
}, | ||
computed: { | ||
localValue: { | ||
get () { | ||
return this.value | ||
}, | ||
set (value) { | ||
// Update 'value' prop by notifying parent component's v-model for this component | ||
this.$emit('input', value) | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.