@konfuzio/document-validation-ui 0.1.14 → 0.1.15

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.
Files changed (101) hide show
  1. package/README.md +12 -0
  2. package/cypress.config.js +13 -0
  3. package/dist/css/app.css +1 -1
  4. package/dist/index.html +1 -1
  5. package/dist/js/app.js +1 -1
  6. package/dist/js/app.js.map +1 -1
  7. package/dist/js/chunk-vendors.js +3 -3
  8. package/dist/js/chunk-vendors.js.map +1 -1
  9. package/package.json +5 -1
  10. package/src/api.js +53 -23
  11. package/src/assets/images/DraggableIcon.vue +14 -0
  12. package/src/assets/images/GridIcon.vue +16 -0
  13. package/src/assets/images/MagicWandIcon.vue +16 -0
  14. package/src/assets/images/NotFoundIcon.vue +16 -0
  15. package/src/assets/images/ServerImage.vue +19 -9
  16. package/src/assets/images/SettingsIcon.vue +14 -0
  17. package/src/assets/images/SplitZigZag.vue +47 -14
  18. package/src/assets/images/StarIcon.vue +16 -0
  19. package/src/assets/scss/ann_set_table_options.scss +26 -0
  20. package/src/assets/scss/annotation_details.scss +86 -71
  21. package/src/assets/scss/choose_label_set_modal.scss +1 -1
  22. package/src/assets/scss/document_annotations.scss +242 -229
  23. package/src/assets/scss/document_category.scss +12 -7
  24. package/src/assets/scss/document_dashboard.scss +7 -2
  25. package/src/assets/scss/document_edit.scss +151 -173
  26. package/src/assets/scss/document_name.scss +0 -2
  27. package/src/assets/scss/document_thumbnails.scss +1 -1
  28. package/src/assets/scss/document_toolbar.scss +23 -1
  29. package/src/assets/scss/document_top_bar.scss +40 -1
  30. package/src/assets/scss/edit_page_thumbnail.scss +53 -0
  31. package/src/assets/scss/multi_ann_table_overlay.scss +38 -0
  32. package/src/assets/scss/new_annotation.scss +17 -3
  33. package/src/assets/scss/scrolling_document.scss +1 -1
  34. package/src/assets/scss/theme.scss +801 -0
  35. package/src/assets/scss/variables.scss +5 -663
  36. package/src/components/App.cy.js +7 -0
  37. package/src/components/App.vue +98 -11
  38. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +168 -0
  39. package/src/components/DocumentAnnotations/AnnotationContent.vue +50 -84
  40. package/src/components/DocumentAnnotations/AnnotationDetails.vue +37 -12
  41. package/src/components/DocumentAnnotations/AnnotationRow.vue +244 -199
  42. package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -0
  43. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +4 -2
  44. package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +295 -0
  45. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +195 -146
  46. package/src/components/DocumentAnnotations/DocumentLabel.vue +46 -9
  47. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +59 -88
  48. package/src/components/DocumentAnnotations/ExtractingData.vue +18 -6
  49. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +337 -0
  50. package/src/components/DocumentAnnotations/index.js +1 -1
  51. package/src/components/DocumentCategory.vue +89 -65
  52. package/src/components/DocumentDashboard.vue +59 -48
  53. package/src/components/DocumentEdit/DocumentEdit.vue +302 -105
  54. package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -0
  55. package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -0
  56. package/src/components/DocumentEdit/EditPages.vue +60 -103
  57. package/src/components/DocumentEdit/EditSidebar.vue +101 -48
  58. package/src/components/DocumentEdit/{SplitOverview.vue → RenameAndCategorize.vue} +15 -13
  59. package/src/components/DocumentEdit/SidebarButtons.vue +53 -0
  60. package/src/components/DocumentEdit/SplitInfoBar.vue +21 -0
  61. package/src/components/DocumentEdit/index.js +1 -1
  62. package/src/components/{DocumentError.vue → DocumentModals/DocumentErrorModal.vue} +9 -8
  63. package/src/components/{NotOptimizedViewportModal.vue → DocumentModals/NotOptimizedViewportModal.vue} +2 -2
  64. package/src/components/DocumentPage/ActionBar.vue +3 -3
  65. package/src/components/DocumentPage/AnnSetTableOptions.vue +110 -0
  66. package/src/components/DocumentPage/BoxSelection.vue +4 -1
  67. package/src/components/DocumentPage/DocumentPage.vue +92 -68
  68. package/src/components/DocumentPage/DocumentToolbar.vue +105 -16
  69. package/src/components/DocumentPage/DummyPage.vue +9 -7
  70. package/src/components/DocumentPage/MultiAnnSelection.vue +96 -27
  71. package/src/components/DocumentPage/NewAnnotation.vue +31 -35
  72. package/src/components/DocumentPage/ScrollingDocument.vue +46 -5
  73. package/src/components/DocumentPage/ScrollingPage.vue +5 -6
  74. package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +64 -0
  75. package/src/components/DocumentThumbnails/DocumentThumbnails.vue +53 -13
  76. package/src/components/DocumentTopBar/DocumentName.vue +16 -4
  77. package/src/components/DocumentTopBar/DocumentTopBar.vue +86 -15
  78. package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +99 -72
  79. package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +6 -3
  80. package/src/components/DocumentsList/DocumentsList.vue +6 -2
  81. package/src/components/index.js +1 -0
  82. package/src/constants.js +2 -1
  83. package/src/icons.js +45 -0
  84. package/src/locales/de.json +48 -21
  85. package/src/locales/en.json +37 -11
  86. package/src/locales/es.json +41 -13
  87. package/src/main.js +5 -66
  88. package/src/store/category.js +20 -36
  89. package/src/store/display.js +74 -1
  90. package/src/store/document.js +305 -109
  91. package/src/store/edit.js +160 -61
  92. package/src/store/project.js +46 -16
  93. package/src/store/selection.js +42 -10
  94. package/src/utils/utils.js +36 -0
  95. package/dist/css/chunk-vendors.css +0 -5
  96. package/src/assets/scss/categorize_modal.scss +0 -45
  97. package/src/assets/scss/main.scss +0 -24
  98. package/src/components/DocumentAnnotations/ActionButtons.vue +0 -250
  99. package/src/components/DocumentAnnotations/CategorizeModal.vue +0 -219
  100. package/src/components/DocumentAnnotations/RejectedLabels.vue +0 -96
  101. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -253
@@ -4,7 +4,11 @@
4
4
  :active="tooltipIsShown || dropdownIsDisabled"
5
5
  size="is-large"
6
6
  position="is-bottom"
7
- :class="[editMode ? 'right-aligned full-height-tooltip' : 'left-aligned']"
7
+ :class="[
8
+ editMode
9
+ ? 'right-aligned full-height-tooltip'
10
+ : 'left-aligned full-height-tooltip',
11
+ ]"
8
12
  :close-delay="tooltipCloseDelay"
9
13
  >
10
14
  <template #content>
@@ -17,6 +21,7 @@
17
21
  selectedDocument.is_reviewed && 'disabled',
18
22
  ]"
19
23
  aria-role="list"
24
+ scrollable
20
25
  :disabled="dropdownIsDisabled"
21
26
  >
22
27
  <template #trigger>
@@ -29,11 +34,7 @@
29
34
  {{ $t("category") }}
30
35
  </p>
31
36
  <div class="category-name">
32
- {{
33
- !splitMode
34
- ? categoryName(selectedDocument.category)
35
- : categoryName(updatedDocument[index].category)
36
- }}
37
+ {{ setCategoryDefaultText }}
37
38
  </div>
38
39
  </div>
39
40
  <div :class="[!splitMode && 'caret-section']">
@@ -74,9 +75,11 @@ export default {
74
75
  },
75
76
  page: {
76
77
  type: Object,
78
+ default: null,
77
79
  },
78
80
  index: {
79
81
  type: Number,
82
+ default: 0,
80
83
  },
81
84
  },
82
85
  data() {
@@ -84,15 +87,12 @@ export default {
84
87
  currentProjectCategories: [],
85
88
  categoryError: false,
86
89
  tooltipIsShown: false,
87
- dropdownIsDisabled: false,
88
90
  tooltipCloseDelay: 0,
91
+ dropdownIsDisabled: false,
89
92
  };
90
93
  },
91
94
  computed: {
92
- ...mapGetters("category", {
93
- categoryName: "categoryName",
94
- projectHasSingleCategory: "projectHasSingleCategory",
95
- }),
95
+ ...mapGetters("category", ["categoryName", "projectHasSingleCategory"]),
96
96
  ...mapGetters("document", [
97
97
  "documentCannotBeEdited",
98
98
  "documentHasCorrectAnnotations",
@@ -100,54 +100,91 @@ export default {
100
100
  ...mapState("document", ["selectedDocument", "annotations"]),
101
101
  ...mapState("category", ["categories"]),
102
102
  ...mapState("edit", ["editMode", "updatedDocument"]),
103
- },
104
- watch: {
105
- categories(newValue) {
106
- newValue.map((category) => {
107
- if (category.project === this.selectedDocument.project) {
108
- const found = this.currentProjectCategories.find(
109
- (cat) => cat.id === category.id
103
+
104
+ setCategoryDefaultText() {
105
+ if (!this.splitMode) {
106
+ return this.categoryName(this.selectedDocument.category);
107
+ } else {
108
+ const missingCategory = this.updatedDocument.find(
109
+ (item) => !item.category
110
+ );
111
+
112
+ // if there is just 1 category in the project,
113
+ // and one or more sub-documents has no category,
114
+ // assign the only category by default
115
+ if (this.projectHasSingleCategory() && missingCategory) {
116
+ const updatedValuesForDocuments = this.updatedDocument.map(
117
+ (document) => {
118
+ if (!document.category && this.categories) {
119
+ document.category = this.categories[0].id;
120
+ }
121
+
122
+ return document;
123
+ }
110
124
  );
111
- if (found) return;
112
125
 
113
- this.currentProjectCategories.push(category);
126
+ // update the store state
127
+ // so that if the changes are saved the data sent to the API is updated
128
+ // instead of only handling the category name in this component
129
+ this.$store.dispatch(
130
+ "edit/setUpdatedDocument",
131
+ updatedValuesForDocuments
132
+ );
114
133
  }
115
- });
116
- },
117
- annotations(newValue) {
118
- if (newValue) {
119
- this.showTooltip();
134
+
135
+ const categoryName = this.categoryName(
136
+ this.updatedDocument[this.index].category
137
+ );
138
+
139
+ return categoryName ? categoryName : this.$t("choose_category");
120
140
  }
121
141
  },
122
142
  },
143
+ watch: {
144
+ categories() {
145
+ this.handleCategories();
146
+ },
147
+ annotations() {
148
+ this.checkIfDropdownIsDisabled();
149
+ this.setTooltipText();
150
+ },
151
+ },
123
152
  mounted() {
124
153
  if (this.categories) {
125
- this.categories.map((category) => {
126
- if (category.project === this.selectedDocument.project) {
127
- const found = this.currentProjectCategories.find(
128
- (cat) => cat.id === category.id
129
- );
130
- if (found) return;
131
-
132
- this.currentProjectCategories.push(category);
133
- }
134
- });
154
+ this.handleCategories();
135
155
  }
136
156
 
137
157
  if (this.projectHasSingleCategory()) {
138
158
  this.tooltipIsShown = true;
139
159
  }
140
-
141
- this.showTooltip();
142
-
143
- this.$nextTick(() => {
144
- this.setTooltipText();
145
- });
146
160
  },
147
161
  updated() {
148
162
  this.setTooltipText();
163
+ this.checkIfDropdownIsDisabled();
149
164
  },
150
165
  methods: {
166
+ handleCategories() {
167
+ this.categories.map((category) => {
168
+ if (category.project === this.selectedDocument.project) {
169
+ const found = this.currentProjectCategories.find(
170
+ (cat) => cat.id === category.id
171
+ );
172
+ if (found) return;
173
+ this.currentProjectCategories.push(category);
174
+ }
175
+ });
176
+ },
177
+ checkIfDropdownIsDisabled() {
178
+ if (
179
+ this.projectHasSingleCategory() ||
180
+ this.documentCannotBeEdited(this.selectedDocument) ||
181
+ (this.documentHasCorrectAnnotations() && !this.splitMode)
182
+ ) {
183
+ this.dropdownIsDisabled = true;
184
+ } else {
185
+ this.dropdownIsDisabled = false;
186
+ }
187
+ },
151
188
  // The current category name will change
152
189
  // depending on if we are on edit mode or not
153
190
  handleOptionInDropdownDisabled(category) {
@@ -159,7 +196,7 @@ export default {
159
196
 
160
197
  handleChangeCategory(category) {
161
198
  // handling the category change will be different based on
162
- // the dropdown being on the topbar or the split overview
199
+ // the dropdown being on the topbar or the Rename and Categorize view
163
200
  const updatedCategory = {
164
201
  category: category.id,
165
202
  };
@@ -183,39 +220,26 @@ export default {
183
220
  return;
184
221
  }
185
222
 
186
- // Send the category ID to the split overview
223
+ // Send the category ID to the Rename and Categorize view
187
224
  // to update the new document category
188
225
  this.$emit("category-change", this.page, category.id);
189
226
  },
190
227
 
191
- showTooltip() {
192
- if (
193
- this.documentCannotBeEdited(this.selectedDocument) ||
194
- (this.documentHasCorrectAnnotations() && !this.splitMode)
195
- ) {
196
- this.dropdownIsDisabled = true;
197
- } else {
198
- this.dropdownIsDisabled = false;
199
- }
200
- },
201
-
202
228
  setTooltipText() {
203
229
  // Text set from innerHTML vs 'label' due to html tag in locales file string
204
230
  let tooltipText;
205
- if (this.projectHasSingleCategory()) {
206
- tooltipText = this.$t("single_category_in_project");
231
+ let tooltipDelay = 0;
207
232
 
208
- this.tooltipCloseDelay = 5000;
209
- } else {
210
- this.tooltipCloseDelay = 0;
211
-
212
- if (this.documentHasCorrectAnnotations()) {
213
- tooltipText = this.$t("approved_annotations");
214
- } else {
215
- tooltipText = this.$t("edit_not_available");
216
- }
233
+ if (this.documentCannotBeEdited(this.selectedDocument)) {
234
+ tooltipText = this.$t("edit_not_available");
235
+ } else if (this.documentHasCorrectAnnotations()) {
236
+ tooltipText = this.$t("approved_annotations");
237
+ } else if (this.projectHasSingleCategory()) {
238
+ tooltipText = this.$t("single_category_in_project");
239
+ tooltipDelay = 5000;
217
240
  }
218
241
 
242
+ this.tooltipCloseDelay = tooltipDelay;
219
243
  this.$refs.tooltipContent.innerHTML = tooltipText;
220
244
  },
221
245
  },
@@ -1,22 +1,21 @@
1
1
  <template>
2
2
  <div class="dashboard">
3
3
  <DocumentTopBar />
4
- <div :class="['dashboard-viewer', editMode ? 'edit-mode' : '']">
5
- <DocumentThumbnails
6
- v-if="!editMode"
7
- ref="documentPages"
8
- />
9
- <ScrollingDocument
10
- ref="scrollingDocument"
11
- class="dashboard-document"
12
- />
13
- <DocumentAnnotations
14
- v-if="!editMode"
15
- ref="annotations"
4
+ <div :class="['dashboard-viewer', renameAndCategorize ? 'edit-mode' : '']">
5
+ <DocumentThumbnails v-if="!editMode" ref="documentPages" />
6
+ <ScrollingDocument ref="scrollingDocument" class="dashboard-document" />
7
+ <DocumentAnnotations v-if="!editMode" ref="annotations" />
8
+ <DocumentEdit v-if="editMode" ref="editView" />
9
+
10
+ <MultiAnnotationTableOverlay
11
+ v-if="showAnnSetTable"
12
+ :left="documentContainerLeftPadding"
13
+ :width="documentContainerWidth"
16
14
  />
17
- <DocumentEdit
18
- v-else
19
- ref="editView"
15
+ <ChooseLabelSetModal
16
+ v-if="showChooseLabelSetModal && showChooseLabelSetModal.show"
17
+ :is-multiple-annotations="showChooseLabelSetModal.isMultipleAnnotations"
18
+ @finish="showChooseLabelSetModal.finish"
20
19
  />
21
20
 
22
21
  <transition name="slide-fade">
@@ -29,22 +28,13 @@
29
28
  </div>
30
29
  </transition>
31
30
  </div>
32
- <div
33
- v-if="showDocumentError"
34
- class="error-modal"
35
- >
36
- <DocumentError />
31
+ <div v-if="showDocumentError" class="error-modal">
32
+ <DocumentErrorModal />
37
33
  </div>
38
- <div
39
- v-if="!optimalResolution"
40
- class="not-optimized"
41
- >
34
+ <div v-if="!optimalResolution" class="not-optimized">
42
35
  <NotOptimizedViewportModal />
43
36
  </div>
44
- <div
45
- v-if="!isMinimumWidth"
46
- class="not-supported"
47
- >
37
+ <div v-if="!isMinimumWidth" class="not-supported">
48
38
  <div class="text">
49
39
  {{ $t("resolution_not_supported") }}
50
40
  </div>
@@ -57,11 +47,15 @@ import { mapGetters, mapState } from "vuex";
57
47
  import { DocumentTopBar } from "./DocumentTopBar";
58
48
  import { ScrollingDocument } from "./DocumentPage";
59
49
  import { DocumentThumbnails } from "./DocumentThumbnails";
60
- import { DocumentAnnotations } from "./DocumentAnnotations";
50
+ import {
51
+ DocumentAnnotations,
52
+ MultiAnnotationTableOverlay,
53
+ } from "./DocumentAnnotations";
61
54
  import { DocumentEdit } from "./DocumentEdit";
62
55
  import ErrorMessage from "./ErrorMessage";
63
- import NotOptimizedViewportModal from "./NotOptimizedViewportModal";
64
- import DocumentError from "./DocumentError";
56
+ import NotOptimizedViewportModal from "../components/DocumentModals/NotOptimizedViewportModal";
57
+ import DocumentErrorModal from "../components/DocumentModals/DocumentErrorModal";
58
+ import ChooseLabelSetModal from "../components/DocumentAnnotations/ChooseLabelSetModal";
65
59
 
66
60
  /**
67
61
  * This component shows the PDF pages in a scrolling component and
@@ -77,7 +71,17 @@ export default {
77
71
  DocumentEdit,
78
72
  ErrorMessage,
79
73
  NotOptimizedViewportModal,
80
- DocumentError
74
+ DocumentErrorModal,
75
+ MultiAnnotationTableOverlay,
76
+ ChooseLabelSetModal,
77
+ },
78
+ data() {
79
+ return {
80
+ resizeObserver: null,
81
+ unwatchSelectedDocument: null,
82
+ documentContainerLeftPadding: 0,
83
+ documentContainerWidth: 0,
84
+ };
81
85
  },
82
86
  computed: {
83
87
  ...mapState("display", [
@@ -85,17 +89,21 @@ export default {
85
89
  "fit",
86
90
  "optimalResolution",
87
91
  "pageWidthScale",
88
- "currentPage"
92
+ "currentPage",
93
+ "showAnnSetTable",
94
+ "showChooseLabelSetModal",
89
95
  ]),
90
96
  ...mapState("document", [
91
97
  "showActionError",
92
98
  "showDocumentError",
93
99
  "errorMessageWidth",
94
- "selectedDocument"
100
+ "selectedDocument",
101
+ "splittingSuggestions",
95
102
  ]),
96
- ...mapState("edit", ["editMode"]),
97
- ...mapGetters("display", ["isMinimumWidth"])
103
+ ...mapState("edit", ["editMode", "renameAndCategorize"]),
104
+ ...mapGetters("display", ["isMinimumWidth"]),
98
105
  },
106
+
99
107
  watch: {
100
108
  selectedDocument(newDocument, oldDocument) {
101
109
  if (newDocument && !oldDocument) {
@@ -104,7 +112,12 @@ export default {
104
112
  } else if (newDocument) {
105
113
  this.onDocumentResize();
106
114
  }
107
- }
115
+ },
116
+ fit(newFit, oldFit) {
117
+ if (newFit !== oldFit) {
118
+ this.onDocumentResize();
119
+ }
120
+ },
108
121
  },
109
122
  mounted() {
110
123
  this.resizeObserver = new ResizeObserver(this.onDocumentResize);
@@ -114,12 +127,6 @@ export default {
114
127
  this.resizeObserver.unobserve(this.$refs.scrollingDocument.$el);
115
128
  }
116
129
  },
117
- data() {
118
- return {
119
- resizeObserver: null,
120
- unwatchSelectedDocument: null
121
- };
122
- },
123
130
  methods: {
124
131
  elementsWidth() {
125
132
  let elementsWidth = 1;
@@ -135,6 +142,10 @@ export default {
135
142
  return elementsWidth;
136
143
  },
137
144
  onDocumentResize() {
145
+ this.documentContainerLeftPadding =
146
+ this.$refs.scrollingDocument.$el.getBoundingClientRect().left;
147
+ this.documentContainerWidth =
148
+ this.$refs.scrollingDocument.$el.offsetWidth;
138
149
  this.$store.dispatch(
139
150
  "display/updateOptimalResolution",
140
151
  this.$el.offsetWidth
@@ -144,16 +155,16 @@ export default {
144
155
  elementsWidth: this.elementsWidth(),
145
156
  client: {
146
157
  width: this.$el.clientWidth,
147
- height: this.$el.clientHeight
158
+ height: this.$el.clientHeight,
148
159
  },
149
160
  viewport: {
150
161
  width: this.selectedDocument.pages[0].size[0],
151
- height: this.selectedDocument.pages[0].size[1]
152
- }
162
+ height: this.selectedDocument.pages[0].size[1],
163
+ },
153
164
  });
154
165
  }
155
- }
156
- }
166
+ },
167
+ },
157
168
  };
158
169
  </script>
159
170
  <style scoped lang="scss" src="../assets/scss/document_dashboard.scss"></style>