-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(#951): Filter uncovered records (#1156) This PR allows filtering of records by uncovered by rules * perf: initialize text classification with load rules definition * chore: remove fetch rules from common filters * persist uncovered_by_rules filter * condition and selected filter state * allow remove from "remove all filters" * test FilterUncoveredByRules * uncovered filter display condition * checkbox label copy * update snapshot Co-authored-by: Francisco Aranda <francisco@recogn.ai> (cherry picked from commit 6510f4c)
- Loading branch information
Francisco Aranda
committed
Feb 17, 2022
1 parent
9e14d05
commit 0649f2a
Showing
7 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
frontend/components/commons/header/filters/FilterUncoveredByRules.vue
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,40 @@ | ||
<template> | ||
<ReCheckbox | ||
@change="changeUncoveredByRules" | ||
class="re-checkbox--dark" | ||
:value="filter.selected" | ||
> | ||
Only records not covered by rules | ||
</ReCheckbox> | ||
</template> | ||
|
||
<script> | ||
import { TextClassificationDataset } from "@/models/TextClassification"; | ||
export default { | ||
props: { | ||
dataset: { | ||
type: TextClassificationDataset, | ||
required: true, | ||
}, | ||
filter: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
methods: { | ||
async changeUncoveredByRules() { | ||
const rulesId = this.dataset.rules.map((r) => r.query); | ||
this.$emit("apply", this.filter, !this.filter.selected ? rulesId : []); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.re-checkbox { | ||
flex-direction: row-reverse; | ||
::v-deep .checkbox-label { | ||
margin-left: 1em; | ||
} | ||
} | ||
</style> |
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
26 changes: 26 additions & 0 deletions
26
frontend/specs/components/filters/FilterUncoveredByRules.spec.js
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,26 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import FilterUncoveredByRules from "@/components/commons/header/filters/FilterUncoveredByRules"; | ||
|
||
function mountFilterUncoveredByRules() { | ||
return mount(FilterUncoveredByRules, { | ||
propsData: { | ||
dataset: { | ||
task: "TextClassification", | ||
rules: ["alta", "baja"], | ||
}, | ||
filter: { | ||
selected: true, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
describe("FilterUncoveredByRules", () => { | ||
let spy = jest.spyOn(console, "error"); | ||
afterEach(() => spy.mockReset()); | ||
|
||
test("renders properly", () => { | ||
const wrapper = mountFilterUncoveredByRules(); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
frontend/specs/components/filters/__snapshots__/FilterUncoveredByRules.spec.js.snap
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,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FilterUncoveredByRules renders properly 1`] = ` | ||
<recheckbox value="true" class="re-checkbox--dark"> | ||
Only records not covered by rules | ||
</recheckbox> | ||
`; |
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