Files
luos/resources/assets/js/home/TaskMetrics/ProcessPopover.vue

178 lines
4.2 KiB
Vue
Raw Normal View History

2021-08-12 19:05:50 +00:00
<template>
2021-09-24 21:07:29 +00:00
<div class="pm-tm-view-popover">
2021-08-12 19:05:50 +00:00
<b-popover
:target="target"
ref="popover"
triggers="click"
placement="bottom"
@show="onshow"
>
<template #title>{{ $t("ID_PROCESSES").toUpperCase() }}</template>
<div>
<div class="input-group input-group-sm mb-3">
<span class="input-group-text" id="inputGroup-sizing-sm"
><i class="fas fa-search"></i
></span>
<input
type="text"
class="form-control"
aria-describedby="inputGroup-sizing-sm"
@keyup="search"
v-model="text"
aria-label="search"
2021-08-12 19:05:50 +00:00
/>
</div> <div class="form-check border-bottom">
2021-08-12 19:05:50 +00:00
<input
class="form-check-input"
type="checkbox"
v-model="allColumns"
@change="toogleAllColumns"
id="flexCheckDefault"
2021-08-12 19:05:50 +00:00
/>
<label class="form-check-label" for="flexCheckDefault">
{{ $t("ID_ALL") }}
</label>
</div>
<b-form-group label-for="casesFilter">
2021-08-12 19:05:50 +00:00
<b-form-checkbox-group
v-model="localSelected"
2021-09-22 16:37:52 +00:00
:options="results"
2021-08-12 19:05:50 +00:00
value-field="key"
text-field="value"
name="flavour-2a"
2021-09-24 21:07:29 +00:00
class="process-view-popover"
2021-08-12 19:05:50 +00:00
@change="changeOptions"
stacked
></b-form-checkbox-group>
</b-form-group>
<div class="v-popover-footer">
<div class="float-right">
<b-button @click="onClose" size="sm" variant="danger">
{{ $t("ID_CANCEL") }}</b-button
>
<b-button @click="onSave" size="sm" variant="success">{{
$t("ID_SAVE")
}}</b-button>
</div>
</div>
</div>
</b-popover>
</div>
</template>
<script>
export default {
name: "ProcessPopover",
2021-09-22 16:37:52 +00:00
props: ["target"],
2021-08-12 19:05:50 +00:00
data() {
return {
2021-09-22 16:37:52 +00:00
options: [],
2021-08-12 19:05:50 +00:00
text: "",
2021-09-22 16:37:52 +00:00
results: [],
2021-08-12 19:05:50 +00:00
allColumns: false,
localSelected: [],
};
},
mounted() {
2021-09-22 16:37:52 +00:00
this.results = this.options;
2021-08-12 19:05:50 +00:00
this.localSelected = this.selected;
},
methods: {
/**
2021-08-27 21:29:54 +00:00
* Setter options for fill the popover
* @param {*} options
2021-08-12 19:05:50 +00:00
*/
setOptions(options) {
this.options = options;
2021-09-22 16:37:52 +00:00
this.results = options;
2021-08-12 19:05:50 +00:00
},
/**
2021-08-27 21:29:54 +00:00
* Setter the selected options
* @param {*} options
2021-08-12 19:05:50 +00:00
*/
setSelectedOptions(options) {
this.selected = options;
this.localSelected = options;
},
/**
* Close buton click handler
*/
onClose() {
this.$refs.popover.$emit("close");
this.$emit("closePopover");
},
/**
* Save button click handler
*/
onSave() {
let sels;
sels = _.clone(this.localSelected);
this.$root.$emit("bv::hide::popover");
this.$emit("onUpdateColumnSettings", sels);
},
/**
* Show popover event handler
*/
onshow() {
this.$root.$emit("bv::hide::popover");
},
/**
* Search in the column name
*/
search() {
2021-09-22 16:37:52 +00:00
let txt = this.text.toLowerCase(),
val,
opts = [];
opts = _.filter(this.options, function (o) {
val = o.value.toLowerCase();
return val.search(txt) != -1;
});
this.results = opts;
2021-08-12 19:05:50 +00:00
},
/**
* Toogle all options in popover
*/
toogleAllColumns() {
let res = [];
if (this.allColumns) {
_.each(this.options, function (o) {
res.push(o.key);
});
}
2021-09-25 00:01:50 +00:00
this.localSelected = res;
2021-08-12 19:05:50 +00:00
},
/**
* Handler when change options event
*/
changeOptions() {
let that = this,
res = [];
_.each(this.options, function (o) {
if (
_.findIndex(that.localSelected, function (v) {
return v === o.key;
}) != -1
) {
res.push(o.key);
}
});
this.localSelected = res;
},
},
};
</script>
<style scoped>
.pm-all-view-popover .popover {
max-width: 350px !important;
min-width: 200px !important;
}
.v-popover-footer {
display: flow-root;
}
2021-09-24 21:07:29 +00:00
.process-view-popover {
margin-bottom: 1rem;
overflow-y: auto;
display: block;
max-height: 200px;
}
2021-08-12 19:05:50 +00:00
</style>