@konfuzio/document-validation-ui 0.1.29-dev.0 → 0.1.29-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.29-dev.0",
3
+ "version": "0.1.29-dev.2",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -516,8 +516,6 @@
516
516
  padding: 6px;
517
517
 
518
518
  .decline-icon {
519
- height: 24px;
520
- width: 24px;
521
519
  padding: 6px;
522
520
  color: $red;
523
521
  vertical-align: middle;
@@ -621,6 +621,20 @@
621
621
  margin: 0 !important;
622
622
  }
623
623
 
624
+ .icon.is-24 {
625
+ svg {
626
+ height: 24px;
627
+ width: 24px;
628
+ }
629
+ }
630
+
631
+ .icon.is-12 {
632
+ svg {
633
+ height: 12px;
634
+ width: 12px;
635
+ }
636
+ }
637
+
624
638
  .icon.is-small,
625
639
  .button .icon.is-small {
626
640
  width: 14px;
@@ -42,7 +42,7 @@
42
42
  type="is-ghost"
43
43
  @click.stop="decline"
44
44
  >
45
- <b-icon icon="xmark" class="decline-icon" />
45
+ <b-icon icon="xmark" size="is-24" class="decline-icon" />
46
46
  </b-button>
47
47
  <b-button
48
48
  v-if="acceptBtn"
@@ -62,7 +62,7 @@
62
62
  <b-button type="is-ghost" class="missing-btn" @click.stop="markAsMissing">
63
63
  <span v-if="showText">{{ $t("missing_annotation") }}</span>
64
64
  <b-tooltip v-else position="is-left" :label="$t('missing_annotation')">
65
- <b-icon icon="xmark" size="small" class="button-icon" />
65
+ <b-icon icon="xmark" size="is-small" class="button-icon" />
66
66
  </b-tooltip>
67
67
  </b-button>
68
68
  <b-button
@@ -72,7 +72,7 @@
72
72
  >
73
73
  <span v-if="showText">{{ $t("search_in_document") }}</span>
74
74
  <b-tooltip v-else position="is-left" :label="$t('search_in_document')">
75
- <b-icon icon="search" size="small" class="button-icon" />
75
+ <b-icon icon="search" size="is-small" class="button-icon" />
76
76
  </b-tooltip>
77
77
  </b-button>
78
78
  </div>
@@ -86,7 +86,7 @@
86
86
  >
87
87
  <span v-if="showText">{{ $t("restore") }}</span>
88
88
  <b-tooltip v-else position="is-left" :label="$t('restore')">
89
- <b-icon icon="trash-arrow-up" size="small" class="button-icon" />
89
+ <b-icon icon="trash-arrow-up" size="is-small" class="button-icon" />
90
90
  </b-tooltip>
91
91
  </b-button>
92
92
  </div>
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <div id="annotation-filters">
3
- <b-switch v-model="feedbackNeeded" class="is-small">{{
3
+ <b-switch v-model="annotationFilters.showFeedbackNeeded" class="is-small">{{
4
4
  $t("human_feedback_needed")
5
5
  }}</b-switch>
6
- <b-switch v-model="missingAnnotations" class="is-small">{{
6
+ <b-switch v-model="annotationFilters.showEmpty" class="is-small">{{
7
7
  $t("label_missing_annotations")
8
8
  }}</b-switch>
9
- <b-switch v-model="acceptedAnnotations" class="is-small">{{
9
+ <b-switch v-model="annotationFilters.showAccepted" class="is-small">{{
10
10
  $t("accepted_annotations")
11
11
  }}</b-switch>
12
12
  </div>
@@ -15,42 +15,8 @@
15
15
  import { mapState } from "vuex";
16
16
  export default {
17
17
  name: "AnnotationFilters",
18
- data() {
19
- return {
20
- feedbackNeeded: true,
21
- missingAnnotations: true,
22
- acceptedAnnotations: true,
23
- originalAnnotationSets: [],
24
- };
25
- },
26
18
  computed: {
27
- ...mapState("document", ["annotationSets"]),
28
- },
29
- watch: {
30
- feedbackNeeded() {
31
- this.filterAnnotations();
32
- },
33
- missingAnnotations() {
34
- this.filterAnnotations();
35
- },
36
- acceptedAnnotations() {
37
- this.filterAnnotations();
38
- },
39
- },
40
- mounted() {
41
- this.originalAnnotationSets = JSON.parse(
42
- JSON.stringify(this.annotationSets)
43
- );
44
- },
45
- methods: {
46
- filterAnnotations() {
47
- this.$store.dispatch("document/filterAnnotations", {
48
- originalAnnotationSets: this.originalAnnotationSets,
49
- showEmpty: this.missingAnnotations,
50
- showFeedbackNeeded: this.feedbackNeeded,
51
- showAccepted: this.acceptedAnnotations,
52
- });
53
- },
19
+ ...mapState("document", ["annotationSets", "annotationFilters"]),
54
20
  },
55
21
  };
56
22
  </script>
@@ -7,7 +7,7 @@
7
7
 
8
8
  <!-- When document data is still loading -->
9
9
  <div
10
- v-else-if="!annotationSets || loading"
10
+ v-else-if="!getAnnotationsFiltered.annotationSets || loading"
11
11
  class="document-annotations-loading"
12
12
  >
13
13
  <div
@@ -20,7 +20,10 @@
20
20
  </div>
21
21
 
22
22
  <!-- When there's no annotation sets -->
23
- <div v-else-if="annotationSets.length === 0" class="empty-annotation-sets">
23
+ <div
24
+ v-else-if="getAnnotationsFiltered.annotationSets.length === 0"
25
+ class="empty-annotation-sets"
26
+ >
24
27
  <EmptyState />
25
28
  </div>
26
29
 
@@ -51,7 +54,9 @@
51
54
  </div>
52
55
  </div>
53
56
  <div
54
- v-for="(annotationSet, indexGroup) in annotationSets"
57
+ v-for="(
58
+ annotationSet, indexGroup
59
+ ) in getAnnotationsFiltered.annotationSets"
55
60
  :key="indexGroup"
56
61
  :class="[
57
62
  'annotation-set-group',
@@ -65,6 +70,7 @@
65
70
  :icon="
66
71
  annotationSetsAccordion[indexGroup] ? 'angle-up' : 'angle-down'
67
72
  "
73
+ size="is-12"
68
74
  />
69
75
  {{
70
76
  `${annotationSet.label_set.name} ${numberOfAnnotationSetGroup(
@@ -178,13 +184,11 @@ export default {
178
184
  computed: {
179
185
  ...mapState("display", ["showAnnSetTable"]),
180
186
  ...mapState("document", [
187
+ "annotationSets",
181
188
  "documentId",
182
189
  "recalculatingAnnotations",
183
- "missingAnnotations",
184
190
  "publicView",
185
- "annotations",
186
191
  "editAnnotation",
187
- "annotationSets",
188
192
  "loading",
189
193
  "labels",
190
194
  "selectedDocument",
@@ -193,6 +197,7 @@ export default {
193
197
  ]),
194
198
  ...mapGetters("document", [
195
199
  "numberOfAnnotationSetGroup",
200
+ "getAnnotationsFiltered",
196
201
  "emptyLabels",
197
202
  "notCorrectAnnotations",
198
203
  "annotationSetsInTable",
@@ -219,7 +224,10 @@ export default {
219
224
  }
220
225
  },
221
226
  annotationSets(newAnnotationSets, oldAnnotationSets) {
222
- this.loadAccordions(newAnnotationSets, oldAnnotationSets);
227
+ this.loadAccordions(
228
+ this.getAnnotationsFiltered.annotationSets,
229
+ oldAnnotationSets
230
+ );
223
231
  },
224
232
  sidebarAnnotationSelected(annotation) {
225
233
  if (annotation) {
@@ -237,8 +245,8 @@ export default {
237
245
  },
238
246
  created() {
239
247
  window.addEventListener("keydown", this.keyDownHandler);
240
- if (this.annotationSets) {
241
- this.loadAccordions(this.annotationSets);
248
+ if (this.getAnnotationsFiltered.annotationSets) {
249
+ this.loadAccordions(this.getAnnotationsFiltered.annotationSets);
242
250
  }
243
251
  },
244
252
  destroyed() {
@@ -348,7 +356,7 @@ export default {
348
356
  }
349
357
  });
350
358
 
351
- const currentAnnotation = this.annotations.find(
359
+ const currentAnnotation = this.getAnnotationsFiltered.annotations.find(
352
360
  (ann) => ann.id === this.editAnnotation.id
353
361
  );
354
362
 
@@ -488,9 +496,10 @@ export default {
488
496
  // Check for ENTER or DELETE
489
497
  // Accept annotation
490
498
  if (event.key === "Enter") {
491
- if (!this.annotations || !this.editAnnotation) return;
499
+ if (!this.getAnnotationsFiltered.annotations || !this.editAnnotation)
500
+ return;
492
501
 
493
- const currentAnn = this.annotations.find(
502
+ const currentAnn = this.getAnnotationsFiltered.annotations.find(
494
503
  (a) => a.id === this.editAnnotation.id
495
504
  );
496
505
 
@@ -180,8 +180,33 @@ export default {
180
180
  },
181
181
 
182
182
  computed: {
183
- ...mapState("display", ["currentPage", "showAnnSetTable"]),
184
- ...mapGetters("document", ["isNegative"]),
183
+ ...mapState("selection", ["isSelecting", "selectedEntities"]),
184
+ ...mapState("display", [
185
+ "scale",
186
+ "categorizeModalIsActive",
187
+ "searchEnabled",
188
+ "currentPage",
189
+ "showAnnSetTable",
190
+ ]),
191
+ ...mapState("document", [
192
+ "documentAnnotationSelected",
193
+ "recalculatingAnnotations",
194
+ "editAnnotation",
195
+ "selectedDocument",
196
+ "publicView",
197
+ ]),
198
+ ...mapState("edit", ["editMode"]),
199
+ ...mapGetters("display", ["visiblePageRange", "bboxToRect"]),
200
+ ...mapGetters("selection", ["isSelectionValid", "isElementSelected"]),
201
+ ...mapGetters("document", [
202
+ "getAnnotationsFiltered",
203
+ "isAnnotationInEditMode",
204
+ "isDocumentReadyToBeReviewed",
205
+ "entitiesOnSelection",
206
+ "isDocumentReviewed",
207
+ "labelOfAnnotation",
208
+ "isNegative",
209
+ ]),
185
210
 
186
211
  isBoxSelection() {
187
212
  return this.selection && !this.isSelecting && this.isElementSelected;
@@ -254,8 +279,8 @@ export default {
254
279
  */
255
280
  pageAnnotations() {
256
281
  const annotations = [];
257
- if (this.annotations) {
258
- this.annotations.map((annotation) => {
282
+ if (this.getAnnotationsFiltered.annotations) {
283
+ this.getAnnotationsFiltered.annotations.map((annotation) => {
259
284
  if (
260
285
  annotation.span.find(
261
286
  (span) => span.page_index + 1 === this.page.number
@@ -287,31 +312,6 @@ export default {
287
312
  this.page.number
288
313
  );
289
314
  },
290
-
291
- ...mapState("selection", ["isSelecting", "selectedEntities"]),
292
- ...mapState("display", [
293
- "scale",
294
- "categorizeModalIsActive",
295
- "searchEnabled",
296
- ]),
297
- ...mapState("document", [
298
- "documentAnnotationSelected",
299
- "recalculatingAnnotations",
300
- "annotations",
301
- "editAnnotation",
302
- "selectedDocument",
303
- "publicView",
304
- ]),
305
- ...mapState("edit", ["editMode"]),
306
- ...mapGetters("display", ["visiblePageRange", "bboxToRect"]),
307
- ...mapGetters("selection", ["isSelectionValid", "isElementSelected"]),
308
- ...mapGetters("document", [
309
- "isAnnotationInEditMode",
310
- "isDocumentReadyToBeReviewed",
311
- "entitiesOnSelection",
312
- "isDocumentReviewed",
313
- "labelOfAnnotation",
314
- ]),
315
315
  },
316
316
  watch: {
317
317
  recalculatingAnnotations(newState) {
@@ -29,13 +29,13 @@
29
29
  class="search-document icons"
30
30
  @click="toggleSearch"
31
31
  >
32
- <b-icon icon="search" size="small" class="search-icon" />
32
+ <b-icon icon="search" size="is-small" class="search-icon" />
33
33
  </div>
34
34
 
35
35
  <div v-if="!publicView" class="download-file icons">
36
36
  <b-dropdown aria-role="list" position="is-top-right" scrollable>
37
37
  <template #trigger>
38
- <b-icon icon="download" size="small" class="download-file" />
38
+ <b-icon icon="download" size="is-small" class="download-file" />
39
39
  </template>
40
40
 
41
41
  <b-dropdown-item
@@ -86,7 +86,6 @@ export default {
86
86
  },
87
87
  watch: {
88
88
  search(search) {
89
- console.log("search", search);
90
89
  this.$store.dispatch("display/setCurrentSearch", search);
91
90
  if (search.length >= this.minSearchLength) {
92
91
  this.$store.dispatch("display/startSearchLoading");
@@ -162,11 +162,12 @@ export default {
162
162
  },
163
163
  getPreviousAndNextDocuments() {
164
164
  // Only consider documents who have a status of "ready"
165
- const filteredDocuments = this.documentsInProject.filter(
165
+ const filteredDocuments =
166
+ this.documentsInProject; /*this.documentsInProject.filter(
166
167
  (document) =>
167
168
  (this.reviewFilter && this.isDocumentReadyToBeReviewed(document)) ||
168
169
  this.waitingForSplittingConfirmation(document)
169
- );
170
+ );*/
170
171
 
171
172
  if (!filteredDocuments) return;
172
173
 
@@ -35,6 +35,11 @@ const state = {
35
35
  serverError: false,
36
36
  splittingSuggestions: null,
37
37
  enableGroupingFeature: true,
38
+ annotationFilters: {
39
+ showFeedbackNeeded: true,
40
+ showEmpty: true,
41
+ showAccepted: true,
42
+ },
38
43
  };
39
44
 
40
45
  const getters = {
@@ -291,37 +296,41 @@ const getters = {
291
296
  return foundLabel;
292
297
  },
293
298
 
294
- /* Process annotations and extract labels and sets */
295
- processAnnotationSets:
296
- (state, getters) =>
297
- (
298
- annotationSets,
299
- showEmpty = true,
300
- showFeedbackNeeded = true,
301
- showAccepted = true
302
- ) => {
303
- // group annotations for sidebar
304
- let annotations = [];
305
- let labels = [];
306
- let processedAnnotationSets = [];
307
- let processedLabels = [];
308
- annotationSets.forEach((annotationSet) => {
299
+ getAnnotationsFiltered: (state) => {
300
+ // group annotations for sidebar
301
+ let annotations = [];
302
+ let labels = [];
303
+ let processedAnnotationSets = [];
304
+ let processedLabels = [];
305
+
306
+ if (state.annotationSets) {
307
+ state.annotationSets.forEach((annotationSet) => {
309
308
  labels = [];
310
309
  annotationSet.labels.forEach((label) => {
311
310
  const labelAnnotations = [];
312
311
  let addLabel = false;
313
- if (!showEmpty || !showFeedbackNeeded || !showAccepted) {
312
+ if (
313
+ !state.annotationFilters.showEmpty ||
314
+ !state.annotationFilters.showFeedbackNeeded ||
315
+ !state.annotationFilters.showAccepted
316
+ ) {
314
317
  if (!label.annotations || label.annotations.length === 0) {
315
- if (showEmpty) {
318
+ if (state.annotationFilters.showEmpty) {
316
319
  addLabel = true;
317
320
  }
318
321
  } else {
319
322
  label.annotations.forEach((annotation) => {
320
- if (showFeedbackNeeded && annotation.revised === false) {
323
+ if (
324
+ state.annotationFilters.showFeedbackNeeded &&
325
+ annotation.revised === false
326
+ ) {
321
327
  labelAnnotations.push(annotation);
322
328
  addLabel = true;
323
329
  }
324
- if (showAccepted && annotation.revised === true) {
330
+ if (
331
+ state.annotationFilters.showAccepted &&
332
+ annotation.revised === true
333
+ ) {
325
334
  labelAnnotations.push(annotation);
326
335
  addLabel = true;
327
336
  }
@@ -334,25 +343,48 @@ const getters = {
334
343
  }
335
344
  if (addLabel) {
336
345
  labels.push({ ...label, annotations: labelAnnotations });
337
- let addProcessedLabel = true;
338
- processedLabels.forEach((processedLabel) => {
339
- if (processedLabel.id === label.id) {
340
- addProcessedLabel = false;
341
- return;
342
- }
343
- });
344
346
  processedLabels.push(label);
345
347
  }
346
348
  annotations.push(...labelAnnotations);
347
349
  });
348
350
  processedAnnotationSets.push({ ...annotationSet, labels });
349
351
  });
350
- return {
351
- annotationSets: processedAnnotationSets,
352
- labels: processedLabels,
353
- annotations,
354
- };
355
- },
352
+ }
353
+
354
+ return {
355
+ annotationSets: processedAnnotationSets,
356
+ labels: processedLabels,
357
+ annotations,
358
+ };
359
+ },
360
+
361
+ /* Process annotations and extract labels and sets */
362
+ processAnnotationSets: () => (annotationSets) => {
363
+ // group annotations for sidebar
364
+ let annotations = [];
365
+ let labels = [];
366
+ let processedAnnotationSets = [];
367
+ let processedLabels = [];
368
+
369
+ annotationSets.forEach((annotationSet) => {
370
+ labels = [];
371
+ annotationSet.labels.forEach((label) => {
372
+ const labelAnnotations = [];
373
+
374
+ // add annotations to the document array
375
+ labelAnnotations.push(...label.annotations);
376
+ labels.push({ ...label, annotations: labelAnnotations });
377
+ processedLabels.push(label);
378
+ annotations.push(...labelAnnotations);
379
+ });
380
+ processedAnnotationSets.push({ ...annotationSet, labels });
381
+ });
382
+ return {
383
+ annotationSets: processedAnnotationSets,
384
+ labels: processedLabels,
385
+ annotations,
386
+ };
387
+ },
356
388
 
357
389
  /* Checks if there are annotations correct in the document */
358
390
  documentHasCorrectAnnotations: (state) => {
@@ -816,21 +848,6 @@ const actions = {
816
848
  setSplittingSuggestions: ({ commit }, value) => {
817
849
  commit("SET_SPLITTING_SUGGESTIONS", value);
818
850
  },
819
- filterAnnotations: (
820
- { commit, getters },
821
- { originalAnnotationSets, showEmpty, showFeedbackNeeded, showAccepted }
822
- ) => {
823
- const { labels, annotations, annotationSets } =
824
- getters.processAnnotationSets(
825
- originalAnnotationSets,
826
- showEmpty,
827
- showFeedbackNeeded,
828
- showAccepted
829
- );
830
- commit("SET_ANNOTATION_SETS", annotationSets);
831
- commit("SET_ANNOTATIONS", annotations);
832
- commit("SET_LABELS", labels);
833
- },
834
851
 
835
852
  /**
836
853
  * Actions that use HTTP requests always return the axios promise,