Skip to content

Commit

Permalink
Merge pull request #336 from konfuzio-ai/quick-fixes
Browse files Browse the repository at this point in the history
Overall bug fixes
  • Loading branch information
PedroDinis authored Oct 16, 2023
2 parents eb31b24 + feeb902 commit 01f9988
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 69 deletions.
22 changes: 16 additions & 6 deletions src/assets/images/TranslateArrows.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<template>
<svg id="exchange" xmlns="http://www.w3.org/2000/svg"
<svg
id="exchange"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
>
<path v-if="translation" fill="#1A1A1A" d="M18,10a1,1,0,0,0-1-1H5.41l2.3-2.29A1,1,0,0,0,6.29,5.29l-4,4a1,1,0,0,0-.21,1.09A1,1,0,0,0,3,11H17A1,1,0,0,0,18,10Zm3.92,3.62A1,1,0,0,0,21,13H7a1,1,0,0,0,0,2H18.59l-2.3,2.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l4-4A1,1,0,0,0,21.92,13.62Z"></path>
<path v-else fill="#E1E1E1" d="M18,10a1,1,0,0,0-1-1H5.41l2.3-2.29A1,1,0,0,0,6.29,5.29l-4,4a1,1,0,0,0-.21,1.09A1,1,0,0,0,3,11H17A1,1,0,0,0,18,10Zm3.92,3.62A1,1,0,0,0,21,13H7a1,1,0,0,0,0,2H18.59l-2.3,2.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l4-4A1,1,0,0,0,21.92,13.62Z"></path>
</svg>
>
<path
v-if="translation"
fill="#1A1A1A"
d="M18,10a1,1,0,0,0-1-1H5.41l2.3-2.29A1,1,0,0,0,6.29,5.29l-4,4a1,1,0,0,0-.21,1.09A1,1,0,0,0,3,11H17A1,1,0,0,0,18,10Zm3.92,3.62A1,1,0,0,0,21,13H7a1,1,0,0,0,0,2H18.59l-2.3,2.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l4-4A1,1,0,0,0,21.92,13.62Z"
></path>
<path
v-else
fill="#E1E1E1"
d="M18,10a1,1,0,0,0-1-1H5.41l2.3-2.29A1,1,0,0,0,6.29,5.29l-4,4a1,1,0,0,0-.21,1.09A1,1,0,0,0,3,11H17A1,1,0,0,0,18,10Zm3.92,3.62A1,1,0,0,0,21,13H7a1,1,0,0,0,0,2H18.59l-2.3,2.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l4-4A1,1,0,0,0,21.92,13.62Z"
></path>
</svg>
</template>

<script>
Expand All @@ -20,4 +30,4 @@ export default {
},
},
};
</script>
</script>
2 changes: 2 additions & 0 deletions src/assets/scss/new_annotation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
width: 100%;
justify-content: space-between;
position: relative;
text-wrap: wrap;
text-align: left;

.caret-icon {
position: absolute;
Expand Down
8 changes: 6 additions & 2 deletions src/components/DocumentAnnotations/DocumentAnnotations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@

<div v-if="annotationSet.labels.length === 0" class="no-labels">
<span> {{ $t("no_labels_in_set") }}</span>
<span v-if="!publicView && !isDocumentReviewed" v-html="$t('link_to_add_labels')"></span>
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-if="isDocumentEditable" v-html="$t('link_to_add_labels')" />
</div>

<div
Expand Down Expand Up @@ -178,6 +179,9 @@ export default {
isAnnotationBeingEdited() {
return this.editAnnotation && this.editAnnotation.id;
},
isDocumentEditable() {
return !this.publicView && !this.isDocumentReviewed;
},
},
watch: {
editAnnotation(newValue) {
Expand Down Expand Up @@ -266,7 +270,7 @@ export default {
keyDownHandler(event) {
// only allow keyboard navigation if we are not in public view mode
if (this.publicView || this.isDocumentReviewed) return;
if (!this.isDocumentEditable) return;
// Exit edit mode and navigation
if (event.key === "Escape") {
Expand Down
73 changes: 44 additions & 29 deletions src/components/DocumentCategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
:class="[
'category-chooser',
splitMode && 'split-mode',
selectedDocument.is_reviewed && 'disabled',
isDocumentReviewed && 'disabled',
]"
aria-role="list"
scrollable
Expand Down Expand Up @@ -60,7 +60,9 @@
@click="handleChangeCategory(category)"
>
<span>{{ category.name }}</span>
<span v-if="splitMode && category.confidence >= 0">{{ ` (${ category.confidence }%)` }}</span>
<span v-if="splitMode && category.confidence >= 0">{{
` (${category.confidence}%)`
}}</span>
</b-dropdown-item>
</b-dropdown>
</b-tooltip>
Expand All @@ -79,14 +81,14 @@ export default {
splitMode: {
type: Boolean,
},
page: {
type: Object,
default: null,
},
index: {
type: Number,
default: 0,
},
page: {
type: Object,
default: null,
},
index: {
type: Number,
default: 0,
},
},
data() {
return {
Expand All @@ -101,6 +103,7 @@ export default {
...mapGetters("document", [
"documentCannotBeEdited",
"documentHasCorrectAnnotations",
"isDocumentReviewed",
]),
...mapState("document", ["selectedDocument", "annotations"]),
...mapState("category", ["categories"]),
Expand All @@ -117,7 +120,7 @@ export default {
// if there is just 1 category in the project,
// and one or more sub-documents has no category,
// assign the only category by default
if (this.projectHasSingleCategory() && missingCategory) {
if (this.projectHasSingleCategory && missingCategory) {
const updatedValuesForDocuments = this.updatedDocument.map(
(document) => {
if (!document.category && this.categories) {
Expand Down Expand Up @@ -146,14 +149,18 @@ export default {
},
setCategoryConfidence() {
if (!this.updatedDocument[this.index].categories || !this.categoryName(
this.updatedDocument[this.index].category
)) return;
if (
!this.updatedDocument[this.index].categories ||
!this.categoryName(this.updatedDocument[this.index].category)
)
return;
const found = this.updatedDocument[this.index].categories.find(
(category) => category.id === this.updatedDocument[this.index].category
);
const found = this.updatedDocument[this.index].categories.find(category => category.id === this.updatedDocument[this.index].category);
return this.handleCategoryConfidence(found.confidence);
}
},
},
watch: {
annotations() {
Expand All @@ -162,7 +169,7 @@ export default {
},
},
mounted() {
if (this.projectHasSingleCategory()) {
if (this.projectHasSingleCategory) {
this.tooltipIsShown = true;
}
},
Expand All @@ -174,23 +181,31 @@ export default {
listOfCategories() {
let list;
if(this.splitMode && this.updatedDocument[this.index].categories) {
list = this.handleCategories(this.updatedDocument[this.index].categories);
if (this.splitMode && this.updatedDocument[this.index].categories) {
list = this.handleCategories(
this.updatedDocument[this.index].categories
);
} else if (this.categories) {
const filtered = this.categories.filter(category => category.project === this.selectedDocument.project)
const filtered = this.categories.filter(
(category) => category.project === this.selectedDocument.project
);
list = this.handleCategories(filtered);
}
return list;
},
handleCategories(categories) {
return categories.map((category) => {
return {id: category.id, name: this.categoryName(category.id), confidence: this.handleCategoryConfidence(category.confidence)};
});
return {
id: category.id,
name: this.categoryName(category.id),
confidence: this.handleCategoryConfidence(category.confidence),
};
});
},
handleCategoryConfidence(confidence) {
if(!confidence) {
if(confidence === 0) return confidence.toFixed(2);
if (!confidence) {
if (confidence === 0) return confidence.toFixed(2);
return;
}
Expand All @@ -199,9 +214,9 @@ export default {
},
checkIfDropdownIsDisabled() {
if (
this.projectHasSingleCategory() ||
this.projectHasSingleCategory ||
this.documentCannotBeEdited(this.selectedDocument) ||
(this.documentHasCorrectAnnotations() && !this.splitMode)
(this.documentHasCorrectAnnotations && !this.splitMode)
) {
this.dropdownIsDisabled = true;
} else {
Expand Down Expand Up @@ -253,9 +268,9 @@ export default {
if (this.documentCannotBeEdited(this.selectedDocument)) {
tooltipText = this.$t("edit_not_available");
} else if (this.documentHasCorrectAnnotations()) {
} else if (this.documentHasCorrectAnnotations) {
tooltipText = this.$t("approved_annotations");
} else if (this.projectHasSingleCategory()) {
} else if (this.projectHasSingleCategory) {
tooltipText = this.$t("single_category_in_project");
tooltipDelay = 5000;
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DocumentPage/DocumentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ export default {
if (
annotation.span.find(
(span) => span.page_index + 1 === this.page.number
) && !this.isNegative(annotation)
) &&
!this.isNegative(annotation)
) {
annotations.push(annotation);
}
Expand Down Expand Up @@ -385,6 +386,8 @@ export default {
if (trigger && trigger === "click") {
this.closePopups(true);
} else {
this.onElementEnter();
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/store/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getters = {
return null;
},

projectHasSingleCategory: (state) => () => {
projectHasSingleCategory: (state) => {
return state.categories && state.categories.length === 1;
},
};
Expand Down
Loading

0 comments on commit 01f9988

Please sign in to comment.