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

[ENH] Add assessment tool categorization workflow #574

Merged
merged 47 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1df0468
Added lintfix script to package.json
rmanaem Oct 12, 2023
0a37a10
Added assessment column table
rmanaem Oct 12, 2023
8fb4cd3
Added tool group dropdown and assessment tool table
rmanaem Oct 12, 2023
7e54fcb
Prevent duplicate tools from being created
surchs Oct 12, 2023
55aafd8
Updated test
surchs Oct 13, 2023
4a71e4a
Added functionality for highlighting selected tool
surchs Oct 13, 2023
cb22d7f
don't need clicks
surchs Oct 13, 2023
17a7367
Added capability to map column to tool
surchs Oct 13, 2023
bd91e5b
Basic layout
surchs Oct 16, 2023
9c01367
First attempt at getting tool list from store
surchs Oct 16, 2023
0d74fed
Pass id with tool
surchs Oct 16, 2023
8f7ec5f
Pass tool by identifier
surchs Oct 16, 2023
98f9c79
WIP: fire mutation for createTool
surchs Oct 16, 2023
8e22338
Toolgroup component can handle state and store
surchs Oct 16, 2023
8113dd5
Added store mutation for creating tools
surchs Oct 17, 2023
410d9cb
Add columnToToolMap in the store
surchs Oct 17, 2023
29dc8d0
WIP: adding failing test as reminder
surchs Oct 17, 2023
f4b41a2
Add mutation for mapping column to tool
surchs Oct 17, 2023
391868b
Implement column to tool mapping mutation
surchs Oct 17, 2023
fcc9f83
Add simplistic initialization of column2Tool Map
surchs Oct 17, 2023
7bd666d
Refactored store functions and tests
surchs Oct 17, 2023
ea0dbc8
Refactor unit tests to follow updated store column getter
surchs Oct 17, 2023
d3ebcf8
[FIX] column no longer styled if selectedTool is null
surchs Oct 17, 2023
715f0dc
[FIX] deselecting dropdown no longer crashes app
surchs Oct 17, 2023
aeef78f
Add the toolgroup workflow to the categorization page
surchs Oct 17, 2023
d87e193
Add test to protect against null-crash
surchs Oct 17, 2023
dcf8cab
[ENH] Prevent page from advancing if not all columns mapped
surchs Oct 17, 2023
9722f13
Merge branch 'master' into feat-566
surchs Oct 17, 2023
5e245d2
[ENH] no elements render unless one column selected
surchs Oct 18, 2023
610e899
[FIX] adjust nextPage unit test to new logic
surchs Oct 18, 2023
61abe3a
Adding a simple page test I can understand
surchs Oct 19, 2023
4bf950e
Provide a super silly tool component
surchs Oct 19, 2023
7650527
First basic store integration
surchs Oct 19, 2023
81f3bdf
[WIP] we're not yet passing props correctly
surchs Oct 19, 2023
42fc3ba
Add getter for columns mapped to tools
surchs Oct 20, 2023
457a87c
Parseing unique values for tool columns
surchs Oct 20, 2023
e161615
Single annot component + test
surchs Oct 20, 2023
2717700
Tool missing value button exists
surchs Oct 20, 2023
f4a8116
single tool component emits missing value event
surchs Oct 20, 2023
502ed0d
Parent tool component fires mutation when child emits
surchs Oct 20, 2023
3c88725
Adding this here does something
surchs Oct 20, 2023
cd4f8f1
Apply first round of review suggestions
surchs Oct 24, 2023
76356fb
Second round of review edits
surchs Oct 24, 2023
37538f2
Refactor tool group mutation name
surchs Oct 24, 2023
578832c
Make the component use good props
surchs Oct 24, 2023
c606474
Complete the refactor
surchs Oct 24, 2023
3783ed2
Merge branch 'master' into feat-566
surchs Oct 24, 2023
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
4 changes: 2 additions & 2 deletions components/annot-columns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
data-cy="mappedColumns"
class="d-flex justify-content-between align-items-center"
:key="columnName"
v-for="columnName of getMappedColumns(activeCategory)">
v-for="columnName of getColumnsForCategory(activeCategory)">
{{ columnName }} {{ getColumnDescription(columnName) }}
<b-button
:data-cy="'remove_' + columnName"
Expand Down Expand Up @@ -57,7 +57,7 @@

computed: {
...mapGetters([
"getMappedColumns",
"getColumnsForCategory",
"getColumnDescription"
])
},
Expand Down
4 changes: 2 additions & 2 deletions components/annot-continuous-values.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<b-tabs content-class="mt-3">

<b-tab
v-for="(columnName, index) in getMappedColumns(activeCategory)"
v-for="(columnName, index) in getColumnsForCategory(activeCategory)"
:key="columnName"
:active="0 === index"
:title="columnName">
Expand Down Expand Up @@ -93,7 +93,7 @@

"getHarmonizedPreview",
"getHeuristic",
"getMappedColumns",
"getColumnsForCategory",
"getTransformOptions",
"getUniqueValues"
])
Expand Down
59 changes: 59 additions & 0 deletions components/annot-single-tool.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>

<div>
<b-table
striped
:data-cy="('tool-annotation-for-' + name)"
:fields="toolFields"
:items="uniqueColumnValues">
<template #cell(missing_value)="row">
<b-button
:data-cy="'missingValueButton_' + row.index"
variant="danger"
@click="emitMissingValue(row.item['column'], row.item['value']) ">
{{ uiText.missingValueButton }}
</b-button>
</template>
</b-table>

</div>

</template>

<script>
import { mapGetters } from "vuex";

export default {
data() {
return {
uiText: {

instructions: "Annotate each unique value",
missingValueButton: "Mark as missing",
saveButton: "Save Annotation"
},
toolFields: [
"column",
"value",
"missing_value"
]
};
},
props: {

name: { type: String, required: true },
uniqueColumnValues: { type: Array, required: true }
},
computed: {
...mapGetters([
"getSelectedTools"
])
},
methods: {
emitMissingValue(column, value) {
this.$emit("declareMissing", {column, value});
}
}
};

</script>
53 changes: 53 additions & 0 deletions components/annot-tool-groups.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>

<div>

<b-card
no-body
class="annotation-card">
<b-tabs content-class="mt-3" fill>
<b-tab
v-for="({label, identifier}, index) in getSelectedTools"
:key="index"
:title="label">
<annot-single-tool
:name="identifier"
:uniqueColumnValues="provideUniqueValues(identifier)"
@declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
</b-tab>

</b-tabs>

</b-card>

</div>

</template>

<script>
import { mapGetters, mapMutations } from "vuex";

export default {
computed: {
...mapGetters([
"getSelectedTools",
"getColumnsForTool",
"getUniqueColumnValues"
])
},
methods: {
...mapMutations([

"changeMissingStatus"
]),
provideUniqueValues(identifier) {
const toolColumns = this.getColumnsForTool(identifier);
return toolColumns
.map(column => this.getUniqueColumnValues(column)
.map(value => ({"column": column, "value": value})))
.flat();
}
}
};

</script>
127 changes: 127 additions & 0 deletions components/category-toolgroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<template>
<div>
<b-row>
<b-col cols="6">
<v-select
v-if="tableRows.length > 0"
data-cy="toolgroup-select"
:options="toolTerms"
outlined
@input="selectTool"
:selectable="(option) => !getSelectedTools.some(el => el.identifier.includes(option.identifier))" />
</b-col>
</b-row>
<b-row>
<b-col>
<b-table
v-if="getSelectedTools.length > 0"
data-cy="assessment-tool-table"
outlined
selectable
head-variant="dark"
:items="getSelectedTools"
select-mode="single"
selected-variant=""
:fields="[{ key: 'label' }]"
@row-selected="highlightRow"
:tbody-tr-class="styleTableRow"
thead-class="hidden" />

</b-col>
<b-col>
<b-table
v-if="tableRows.length > 0"
data-cy="assessment-column-table"
outlined
head-variant="dark"
:items="tableRows"
selected-variant=""
thead-class="hidden"
@row-clicked="mapColumn"
:tbody-tr-class="styleRow" />
</b-col>
</b-row>
</div>
</template>

<script>

import { mapGetters, mapState, mapMutations } from 'vuex';

export default {
data() {
return {
selectedTool: {
tool: null,
identifier: null
}
};

},

computed: {
...mapGetters([
'getColumnsForCategory',
'getSelectedTools'
]),

...mapState([

"toolTerms",
"columnToToolMap"
]),
tableRows() {
return this.getColumnsForCategory('Assessment Tool').map(column => ({
column: column
}));
}
},
methods: {
...mapMutations([

"createAssessmentTool",
"alterColumnToToolMapping"
]),
selectTool(selectedTool) {
if ( selectedTool !== null ) {
this.createAssessmentTool({
identifier: selectedTool.identifier,
label: selectedTool.label
});
}
},
highlightRow(rows) {
if ( 0 !== rows.length ) {
this.selectedTool = rows[0];
}
},

styleTableRow(p_row) {
if (p_row.identifier === this.selectedTool.identifier) {
return "selected-tool";
}
return "";
},
mapColumn(row) {
this.alterColumnToToolMapping({columnName: row.column, toolIdentifier: this.selectedTool.identifier});
},
styleRow(p_row) {
if (
(this.columnToToolMap[p_row.column] !== null) &&
(this.columnToToolMap[p_row.column] === this.selectedTool.identifier)
) {
return "selected-tool";
} else {
return "";
}
}
}
};
</script>
<style>

.selected-tool {
background-color: red !important;
}

</style>
2 changes: 1 addition & 1 deletion cypress/component/annot-columns.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import annotColumns from "~/components/annot-columns.vue";
const store = {
commit: () => {},
getters: {
getMappedColumns: () => (activeCategory) => {
getColumnsForCategory: () => (activeCategory) => {
return [
"column1",
"column2",
Expand Down
6 changes: 3 additions & 3 deletions cypress/component/annot-continuous-values.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Continuous values component", () => {

return store.state.dataDictionary.annotated[p_column].transformationHeuristic;
},
getMappedColumns: () => (p_activeCategory) => {
getColumnsForCategory: () => (p_activeCategory) => {

return ["column1"];
},
Expand Down Expand Up @@ -153,7 +153,7 @@ describe("Continuous values component", () => {

// Setup
store.state.dataDictionary.annotated["column2"] = { transformationHeuristic: "" };
store.getters.getMappedColumns = () => (p_activeCategory) => {
store.getters.getColumnsForCategory = () => (p_activeCategory) => {

return ["column1", "column2"];
};
Expand Down Expand Up @@ -196,7 +196,7 @@ describe("Continuous values component", () => {

// Setup
store.state.dataDictionary.annotated["column2"] = { transformationHeuristic: "" };
store.getters.getMappedColumns = () => (p_activeCategory) => {
store.getters.getColumnsForCategory = () => (p_activeCategory) => {

return ["column1", "column2"];
};
Expand Down
Loading
Loading