Skip to content

Commit 6ea2dbd

Browse files
committed
adding code to fill the filters with options from URLs if any
1 parent 78b2094 commit 6ea2dbd

File tree

8 files changed

+348
-239
lines changed

8 files changed

+348
-239
lines changed

src/components/Loaders/Loaders.vue

Lines changed: 226 additions & 227 deletions
Large diffs are not rendered by default.

src/components/Registry/ApplyFilterButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class="align-center justify-center"
99
opacity="0.8"
1010
>
11-
<Loaders />
11+
<Loaders v-if="getLoadingStatus" />
1212
</v-overlay>
1313
</div>
1414
</v-fade-transition>

src/components/Registry/FilterComponents/MetricsToolFilter.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<SelectComponent
3+
v-model="model"
34
:disabled="disabled"
45
:format="true"
56
:item-list="toolsList"
@@ -19,6 +20,7 @@ import { storeToRefs } from "pinia";
1920
export default {
2021
name: "MetricsToolFilter",
2122
components: { SelectComponent },
23+
emits: ["input"],
2224
setup() {
2325
const advancedSearchStore = useAdvancedSearchStore();
2426
const { getRecordTypeSelected } = storeToRefs(advancedSearchStore);
@@ -36,6 +38,14 @@ export default {
3638
};
3739
},
3840
computed: {
41+
model: {
42+
get() {
43+
return this.itemSelected;
44+
},
45+
set(value) {
46+
this.$emit("input", value);
47+
},
48+
},
3949
//Disable this filter if benchmark is selected
4050
disabled() {
4151
if (
@@ -57,6 +67,14 @@ export default {
5767
},
5868
mounted() {
5969
this.getTools();
70+
71+
//Pre-fill selected values from the URL in the component if any
72+
this.$nextTick(() => {
73+
let filterArr = this.advancedSearchStore.toolsSelected["toolNames"];
74+
if (filterArr && filterArr.length) {
75+
this.itemValue = this.advancedSearchStore.toolsSelected["toolNames"];
76+
}
77+
});
6078
},
6179
methods: {
6280
selectedValue(item) {

src/components/Registry/FilterComponents/ObjectTypeFilter.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<SelectComponent
3+
v-model="model"
34
:disabled="disabled"
45
:item-list="getObjectTypes"
56
:item-value="itemValue"
@@ -17,6 +18,7 @@ import { useAdvancedSearchStore } from "@/stores/advancedSearch.js";
1718
export default {
1819
name: "ObjectTypeFilter",
1920
components: { SelectComponent },
21+
emits: ["input"],
2022
setup() {
2123
const store = useObjectTypesStore();
2224
const advancedSearchStore = useAdvancedSearchStore();
@@ -40,6 +42,14 @@ export default {
4042
};
4143
},
4244
computed: {
45+
model: {
46+
get() {
47+
return this.itemSelected;
48+
},
49+
set(value) {
50+
this.$emit("input", value);
51+
},
52+
},
4353
//Disable this filter if benchmark is selected
4454
disabled() {
4555
if (
@@ -65,6 +75,15 @@ export default {
6575
},
6676
mounted() {
6777
this.store.fetchObjectTypes();
78+
79+
//Pre-fill selected values from the URL in the component if any
80+
this.$nextTick(() => {
81+
let filterArr = this.advancedSearchStore.objectTypeSelected["objectType"];
82+
if (filterArr && filterArr.length) {
83+
this.itemValue =
84+
this.advancedSearchStore.objectTypeSelected["objectType"];
85+
}
86+
});
6887
},
6988
methods: {
7089
selectedValue(item) {

src/components/Registry/FilterComponents/OrganisationsFilter.vue

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<SelectComponent
3+
v-model="model"
34
:item-list="organisationsList"
45
:item-value="itemValue"
56
:label="labelText"
@@ -15,16 +16,11 @@ import SelectComponent from "@/components/Registry/UtilComponents/SelectComponen
1516
export default {
1617
name: "OrganisationsFilter",
1718
components: { SelectComponent },
19+
emits: ["input"],
1820
setup() {
1921
const advancedSearchStore = useAdvancedSearchStore();
2022
return { advancedSearchStore };
2123
},
22-
props: {
23-
value: {
24-
type: Array,
25-
default: () => [],
26-
},
27-
},
2824
data: () => {
2925
return {
3026
organisationsList: [],
@@ -36,7 +32,16 @@ export default {
3632
labelText: "Filter Metrics and/or Benchmarks by Organisation",
3733
};
3834
},
39-
35+
computed: {
36+
model: {
37+
get() {
38+
return this.itemSelected;
39+
},
40+
set(value) {
41+
this.$emit("input", value);
42+
},
43+
},
44+
},
4045
watch: {
4146
itemSelected(newValue) {
4247
if (newValue.length) {
@@ -52,6 +57,16 @@ export default {
5257
5358
mounted() {
5459
this.getOrganisations();
60+
61+
//Pre-fill selected values from the URL in the component if any
62+
this.$nextTick(() => {
63+
let filterArr =
64+
this.advancedSearchStore.organisationSelected["organisations"];
65+
if (filterArr && filterArr.length) {
66+
this.itemValue =
67+
this.advancedSearchStore.organisationSelected["organisations"];
68+
}
69+
});
5570
},
5671
5772
methods: {

src/components/Registry/FilterComponents/SelectRecordType.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<SelectComponent
3+
v-model="model"
34
:item-list="itemList"
45
:item-value="itemValue"
56
:label="labelText"
@@ -15,6 +16,7 @@ import SelectComponent from "@/components/Registry/UtilComponents/SelectComponen
1516
export default {
1617
name: "SelectRecordType",
1718
components: { SelectComponent },
19+
emits: ["input"],
1820
data: () => {
1921
return {
2022
itemSelected: [],
@@ -28,11 +30,30 @@ export default {
2830
const advancedSearchStore = useAdvancedSearchStore();
2931
return { advancedSearchStore };
3032
},
33+
computed: {
34+
model: {
35+
get() {
36+
return this.itemSelected;
37+
},
38+
set(value) {
39+
this.$emit("input", value);
40+
},
41+
},
42+
},
3143
watch: {
3244
itemSelected(newValue) {
3345
this.advancedSearchStore.recordTypeSelected = newValue;
46+
this.recordTypeValues(newValue);
3447
},
3548
},
49+
mounted() {
50+
//Pre-fill selected values from the URL in the component if any
51+
this.$nextTick(() => {
52+
if (this.advancedSearchStore.recordTypeSelected.length) {
53+
this.recordTypeValues(this.advancedSearchStore.recordTypeSelected);
54+
}
55+
});
56+
},
3657
3758
methods: {
3859
selectedValue(item) {
@@ -42,6 +63,14 @@ export default {
4263
});
4364
this.itemSelected = itemIds;
4465
},
66+
67+
recordTypeValues(item) {
68+
let itemNames = item.map((e) => {
69+
if (e === "metric_ids") return "Metrics";
70+
else if (e === "benchmark_ids") return "Benchmarks";
71+
});
72+
this.itemValue = itemNames;
73+
},
4574
},
4675
};
4776
</script>

src/components/Registry/FilterComponents/SubjectFilter.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<SelectComponent
3+
v-model="model"
34
:item-list="subjectsList"
45
:item-value="itemValue"
56
:label="labelText"
@@ -15,6 +16,7 @@ import SelectComponent from "@/components/Registry/UtilComponents/SelectComponen
1516
export default {
1617
name: "SubjectFilter",
1718
components: { SelectComponent },
19+
emits: ["input"],
1820
setup() {
1921
const advancedSearchStore = useAdvancedSearchStore();
2022
return { advancedSearchStore };
@@ -31,6 +33,17 @@ export default {
3133
};
3234
},
3335
36+
computed: {
37+
model: {
38+
get() {
39+
return this.itemSelected;
40+
},
41+
set(value) {
42+
this.$emit("input", value);
43+
},
44+
},
45+
},
46+
3447
watch: {
3548
itemSelected(newValue) {
3649
if (newValue.length) {
@@ -46,6 +59,14 @@ export default {
4659
4760
mounted() {
4861
this.getSubjects();
62+
63+
//Pre-fill selected values from the URL in the component if any
64+
this.$nextTick(() => {
65+
let filterArr = this.advancedSearchStore.subjectSelected["subjects"];
66+
if (filterArr && filterArr.length) {
67+
this.itemValue = this.advancedSearchStore.subjectSelected["subjects"];
68+
}
69+
});
4970
},
5071
5172
methods: {

src/components/Registry/UtilComponents/SelectComponent.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default {
5757
mixins: [stringUtils],
5858
data: () => {
5959
return {
60-
model: [],
60+
// model: [],
6161
};
6262
},
6363
props: {
@@ -88,6 +88,14 @@ export default {
8888
},
8989
emits: ["input"],
9090
computed: {
91+
model: {
92+
get() {
93+
return this.itemValue;
94+
},
95+
set(value) {
96+
this.$emit("input", value);
97+
},
98+
},
9199
cleanTextList() {
92100
return this.itemList.map((item) => {
93101
if (this.format) {
@@ -104,9 +112,9 @@ export default {
104112
this.model = [];
105113
}
106114
},
107-
model(newValue) {
108-
this.$emit("input", newValue);
109-
},
115+
// model(newValue) {
116+
// this.$emit("input", newValue);
117+
// },
110118
},
111119
methods: {
112120
capitalize,

0 commit comments

Comments
 (0)