Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert class components to options components for filter #254

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/components/entity/filter/CustomFilterFacetPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";

@Component({
components: {},
})
export default class CustomFilterFacetPanel extends Vue {
@Prop({ default: "" }) title!: string;
export default {
components: {},
props: {
title: {
type: String,
default: ""
}
}
}
</script>
90 changes: 46 additions & 44 deletions src/components/entity/filter/EntityFilterChips.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,52 @@ export interface EntityChips {
filterString: string | boolean;
filterField: string;
}

@Component({
computed: {
...mapGetters(["getEntityFilters", "mdiClose"]),
},
methods: {
...mapActions(["toggleEntityFilter"]),
},
})
export default class EntityFilterChips extends Vue {
getEntityFilters!: IEntityFilter;

get activeEntityFilters(): EntityChips[] {
var chips: EntityChips[] = [];
Object.keys(this.getEntityFilters).forEach((key) => {
if (Array.isArray(this.getEntityFilters[key])) {
chips.push(
...(this.getEntityFilters[key] as string[]).map((item) => {
return { filterField: key, filterString: item };
})
);
} else if (
typeof this.getEntityFilters[key] === "string" &&
this.getEntityFilters[key] !== ""
) {
let prefix = "";
if (key.startsWith("date")) {
prefix = key === "date_min" ? "From: " : "To: ";
}
chips.push({
filterField: key,
filterString: (prefix + this.getEntityFilters[key]) as string,
});
} else if (this.getEntityFilters[key]) {
chips.push({
filterField: key,
filterString:
export default {
computed: {
...mapGetters({
getEntityFilters: "getEntityFilters",
mdiClose: "mdiClose"
}),
activeEntityFilters: {
get(): EntityChips[] {
var chips: EntityChips[] = [];
Object.keys(this.getEntityFilters).forEach((key) => {
if (Array.isArray(this.getEntityFilters[key])) {
chips.push(
...(this.getEntityFilters[key] as string[]).map((item) => {
return { filterField: key, filterString: item };
})
);
} else if (
typeof this.getEntityFilters[key] === "string" &&
this.getEntityFilters[key] !== ""
) {
let prefix = "";
if (key.startsWith("date")) {
prefix = key === "date_min" ? "From: " : "To: ";
}
chips.push({
filterField: key,
filterString: (prefix + this.getEntityFilters[key]) as string,
});
} else if (this.getEntityFilters[key]) {
chips.push({
filterField: key,
filterString:
key === "show_expired"
? "Show Inactive Credentials"
: (key as string),
});
}
});
return chips;
}
? "Show Inactive Credentials"
: (key as string),
});
}
});
return chips;
}
},
},
methods: {
...mapActions({
toggleEntityFilter: "toggleEntityFilter"
}),
}
}
</script>
25 changes: 9 additions & 16 deletions src/components/entity/filter/EntityFilterDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,21 @@
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { mapGetters } from "vuex";
import EntityFilterFacetPanels from "@/components/entity/filter/EntityFilterFacetPanels.vue";

interface Data {
dialog: boolean;
}

@Component({
components: {
EntityFilterFacetPanels,
},
computed: {
...mapGetters(["loading", "mdiFilterOutline", "mdiClose"]),
},
})
export default class EntityFilterDialog extends Vue {
data(): Data {
return {
dialog: false,
};
}
export default {
data(): Data {
return {
dialog: false,
};
},
computed: {
...mapGetters(["loading", "mdiFilterOutline", "mdiClose"]),
}
}
</script>

Expand Down
45 changes: 27 additions & 18 deletions src/components/entity/filter/EntityFilterFacetPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";

import { IEntityFacetField } from "@/interfaces/entity-filter.interface";

import EntityFilterFacets from "@/components/entity/filter/EntityFilterFacets.vue";
Expand All @@ -32,21 +30,32 @@ interface Data {
show: boolean;
}

@Component({
components: {
EntityFilterFacets,
},
})
export default class EntityFilterFacetPanel extends Vue {
@Prop({ default: "" }) entityType!: string;
@Prop({ default: () => [] }) filterField!: string;
@Prop({ default: () => [] }) fields!: IEntityFacetField[];
@Prop({ default: () => [] }) more!: IEntityFacetField[];

data(): Data {
return {
show: false,
};
}
export default {
data(): Data {
return {
show: false,
}
},
components: {
EntityFilterFacets,
},
props: {
entityType: {
type: String,
default: "",
},
filterField: {
type: String,
default: () => [],
},
fields: {
type: Array<IEntityFacetField>,
default: () => [],
},
more: {
type: Array<IEntityFacetField>,
default: () => [],
}
}
}
</script>
127 changes: 59 additions & 68 deletions src/components/entity/filter/EntityFilterFacetPanels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { mapActions, mapGetters } from "vuex";

import {
Expand All @@ -257,73 +256,65 @@ interface Data {
panels: number[];
}

@Component({
components: {
Dialog,
EntityFilterFacetPanel,
CustomFilterFacetPanel,
},
computed: {
...mapGetters([
"searchTopicFacets",
"getAuthorities",
"getCredentialTypes",
"getRegistrationTypes",
"getEntityFilters",
"mdiCalendar",
"mdiInformationOutline",
]),
},
methods: {
...mapActions(["setFilter"]),
},
})
export default class EntityFilterFacetPanels extends Vue {
@Prop({ default: "" }) entityType!: string;
getAuthorities!: Array<IEntityFacetField>;
getCredentialTypes!: Array<IEntityFacetField>;
getRegistrationTypes!: Array<IEntityFacetField>;
getEntityFilters!: IEntityFilter;
setFilter!: (filter: IEntityFilter) => void;
isEntityFilterActive: (
filterField: string,
getEntityFilters: IEntityFilter,
filterString?: string
) => boolean = isEntityFilterActive;
data(): Data {
return {
menuFrom: false,
menuTo: false,
fromDate: "",
toDate: "",
panels: [0, 1, 2, 4],
};
}
toggleShowExpired(newVal: boolean): void {
var currFilters = { ...this.getEntityFilters };
currFilters.show_expired = !newVal;
this.setFilter(currFilters);
}
resetMinDate(): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_min = "";
this.setFilter(currFilters);
}
resetMaxDate(): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_max = "";
this.setFilter(currFilters);
}
handleMinDateChange(newVal: string): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_min = newVal;
this.setFilter(currFilters);
}
handleMaxDateChange(newVal: string): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_max = newVal;
this.setFilter(currFilters);
}
export default {
props: {
entityType: {
type: String,
default: ""
}
},
data(): Data {
return {
menuFrom: false,
menuTo: false,
fromDate: "",
toDate: "",
panels: [0, 1, 2, 4],
};
},
computed: {
...mapGetters({
searchTopicFacets: "searchTopicFacets",
getAuthorities: "getAuthorities",
getCredentialTypes: "getCredentialTypes",
getRegistrationTypes: "getRegistrationTypes",
getEntityFilters: "getEntityFilters",
mdiCalendar: "mdiCalendar",
mdiInformationOutline: "mdiInformationOutline",
}),
},
methods: {
isEntityFilterActive,
...mapActions({
setFilter: "setFilter"
}),
toggleShowExpired(newVal: boolean): void {
var currFilters = { ...this.getEntityFilters };
currFilters.show_expired = !newVal;
this.setFilter(currFilters);
},
resetMinDate(): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_min = "";
this.setFilter(currFilters);
},
resetMaxDate(): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_max = "";
this.setFilter(currFilters);
},
handleMinDateChange(newVal: string): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_min = newVal;
this.setFilter(currFilters);
},
handleMaxDateChange(newVal: string): void {
var currFilters = { ...this.getEntityFilters };
currFilters.date_max = newVal;
this.setFilter(currFilters);
}

}
}
</script>

Expand Down
Loading
Loading