mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
Latest changes from Harvester master - a537c1ae38eb7030542ac371f24ae3336cd9d422
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<script>
|
||||
import { RadioGroup } from '@components/Form/Radio';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterFilterVMSchedule',
|
||||
|
||||
emits: ['change-rows'],
|
||||
|
||||
components: { RadioGroup },
|
||||
|
||||
props: {
|
||||
rows: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
selected: '',
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
scheduleOptions() {
|
||||
const options = this.rows.map(r => r.sourceSchedule).filter(r => r);
|
||||
|
||||
return Array.from(new Set(options));
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSelect(selected) {
|
||||
this.selected = selected;
|
||||
this.filterRows();
|
||||
},
|
||||
|
||||
remove() {
|
||||
this.selected = '';
|
||||
this.filterRows();
|
||||
},
|
||||
|
||||
filterRows() {
|
||||
if (!this.selected) {
|
||||
this.$emit('change-rows', this.rows);
|
||||
|
||||
return;
|
||||
}
|
||||
const filteredRows = this.rows.filter(row => row.sourceSchedule === this.selected);
|
||||
|
||||
this.$emit('change-rows', filteredRows, this.selected);
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
rows: {
|
||||
deep: true,
|
||||
immediate: false,
|
||||
handler() {
|
||||
this.filterRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="vm-schedule-filter">
|
||||
<template>
|
||||
<span v-if="selected" class="banner-item bg-warning">
|
||||
{{ t('harvester.tableHeaders.vmSchedule') }}{{ selected ? ` = ${selected}`: '' }}<i class="icon icon-close ml-5" @click="remove" />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<v-dropdown
|
||||
:triggers="scheduleOptions.length ? ['click'] : []"
|
||||
placement="bottom-end"
|
||||
offset="1"
|
||||
>
|
||||
<button ref="actionDropDown" class="btn bg-primary mr-10">
|
||||
<slot name="title">
|
||||
{{ t('harvester.fields.filterSchedule') }}
|
||||
</slot>
|
||||
</button>
|
||||
|
||||
<template #popper>
|
||||
<div class="filter-popup">
|
||||
<RadioGroup
|
||||
v-model:value="selected"
|
||||
class="mr-10 ml-10"
|
||||
name="model"
|
||||
:options="scheduleOptions"
|
||||
:labels="scheduleOptions"
|
||||
@input="onSelect"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</v-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.vm-schedule-filter {
|
||||
display: inline-block;
|
||||
|
||||
.banner-item {
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin-right: 10px;
|
||||
padding: 6px;
|
||||
border-radius: 2px;
|
||||
|
||||
i {
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
.filter-popup {
|
||||
width: max-content;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user