@konfuzio/document-validation-ui 0.1.2-pre-release-2 → 0.1.2-pre-release-4

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,7 +1,8 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.2-pre-release-2",
3
+ "version": "0.1.2-pre-release-4",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
+ "main": "src/main.js",
5
6
  "scripts": {
6
7
  "serve": "vue-cli-service serve",
7
8
  "build": "vue-cli-service build --name DocumentValidationUi ./src/main.js",
@@ -462,6 +462,12 @@ button {
462
462
  .b-tooltip {
463
463
  .tooltip-content {
464
464
  background-color: $dark-blue !important;
465
+
466
+ a {
467
+ color: $white;
468
+ text-decoration: underline;
469
+ font-weight: 500;
470
+ }
465
471
  }
466
472
 
467
473
  &.left-aligned {
@@ -498,6 +504,14 @@ button {
498
504
  right: 0 !important;
499
505
  }
500
506
  }
507
+
508
+ &.full-height-tooltip {
509
+ height: 100%;
510
+
511
+ .tooltip-content {
512
+ right: 0 !important;
513
+ }
514
+ }
501
515
  }
502
516
 
503
517
  &.width-184 {
@@ -528,12 +542,6 @@ button {
528
542
  &::before {
529
543
  border-bottom-color: $dark-blue !important;
530
544
  }
531
-
532
- a {
533
- color: $white;
534
- text-decoration: underline;
535
- font-weight: 500;
536
- }
537
545
  }
538
546
  }
539
547
 
@@ -649,6 +657,10 @@ button {
649
657
  justify-content: center;
650
658
  align-items: center;
651
659
  }
660
+
661
+ &.is-disabled {
662
+ cursor: not-allowed;
663
+ }
652
664
  }
653
665
 
654
666
  .b-table {
@@ -20,7 +20,7 @@
20
20
 
21
21
  <b-tooltip
22
22
  multilined
23
- :active="singleCategoryInProject"
23
+ :active="tooltipIsShown"
24
24
  size="is-large"
25
25
  position="is-bottom"
26
26
  class="bottom-aligned"
@@ -34,9 +34,9 @@
34
34
  aria-role="list"
35
35
  :class="[
36
36
  'categorize-dropdown',
37
- singleCategoryInProject && 'dropdown-disabled',
37
+ projectHasSingleCategory() && 'dropdown-disabled',
38
38
  ]"
39
- :disabled="singleCategoryInProject"
39
+ :disabled="tooltipIsShown"
40
40
  >
41
41
  <template #trigger>
42
42
  <div class="category-dropdown">
@@ -44,7 +44,7 @@
44
44
  <span v-if="selectedCategory">{{
45
45
  selectedCategory.name
46
46
  }}</span>
47
- <span v-else-if="singleCategoryInProject">{{
47
+ <span v-else-if="projectHasSingleCategory()">{{
48
48
  categories[0].name
49
49
  }}</span>
50
50
  <span v-else>{{ $t("choose_category") }}</span>
@@ -100,18 +100,14 @@ export default {
100
100
  show: false,
101
101
  selectedCategory: null, // category selected in dropdown
102
102
  documentCategory: null, // category associated to document
103
+ tooltipIsShown: false,
103
104
  };
104
105
  },
105
106
  computed: {
106
107
  ...mapState("category", ["categories"]),
107
108
  ...mapState("document", ["selectedDocument"]),
108
- ...mapGetters("category", ["category"]),
109
+ ...mapGetters("category", ["category", "projectHasSingleCategory"]),
109
110
  ...mapGetters("document", ["categorizationIsConfirmed"]),
110
-
111
- singleCategoryInProject() {
112
- // if only 1 category in the project, we don't enable the dropdown
113
- return this.categories && this.categories.length === 1;
114
- },
115
111
  },
116
112
  watch: {
117
113
  selectedDocument(newValue) {
@@ -138,6 +134,10 @@ export default {
138
134
  this.$nextTick(() => {
139
135
  this.setTooltipText();
140
136
  });
137
+
138
+ if (this.projectHasSingleCategory()) {
139
+ this.tooltipIsShown = true;
140
+ }
141
141
  },
142
142
  updated() {
143
143
  this.setTooltipText();
@@ -152,7 +152,7 @@ export default {
152
152
  if (this.selectedDocument.category) {
153
153
  category = this.category(this.selectedDocument.category);
154
154
  this.documentCategory = category;
155
- } else if (this.categories && this.categories.length === 1) {
155
+ } else if (this.projectHasSingleCategory()) {
156
156
  category = this.category(this.categories[0].id);
157
157
  } else {
158
158
  category = category;
@@ -174,7 +174,7 @@ export default {
174
174
  this.documentCategory &&
175
175
  this.selectedCategory.id !== this.documentCategory.id) ||
176
176
  (this.selectedCategory && !this.documentCategory) ||
177
- (this.selectedCategory && this.singleCategoryInProject)
177
+ (this.selectedCategory && this.projectHasSingleCategory)
178
178
  ) {
179
179
  const updatedCategory = {
180
180
  category: this.selectedCategory.id,
@@ -194,6 +194,7 @@ export default {
194
194
  })
195
195
  .finally(() => {
196
196
  this.$store.dispatch("document/endRecalculatingAnnotations");
197
+ this.$store.dispatch("document/setCategorizeModalIsActive", false);
197
198
  });
198
199
  } else {
199
200
  // if same category, then just accept it
@@ -205,7 +206,7 @@ export default {
205
206
  },
206
207
  setTooltipText() {
207
208
  // Text set from innerHTML vs 'label' due to html tag in locales file string
208
- if (this.singleCategoryInProject && this.show) {
209
+ if (this.projectHasSingleCategory() && this.show) {
209
210
  this.$refs.tooltipContent.innerHTML = this.$t(
210
211
  "single_category_in_project"
211
212
  );
@@ -1,50 +1,62 @@
1
1
  <template>
2
- <b-dropdown
3
- :class="[
4
- 'category-chooser',
5
- splitMode && 'split-mode',
6
- selectedDocument.is_reviewed && 'disabled',
7
- ]"
8
- aria-role="list"
9
- :disabled="selectedDocument.is_reviewed"
2
+ <b-tooltip
3
+ multilined
4
+ :active="tooltipIsShown"
5
+ size="is-large"
6
+ position="is-bottom"
7
+ :class="[editMode ? 'right-aligned full-height-tooltip' : 'left-aligned']"
8
+ :close-delay="5000"
10
9
  >
11
- <template #trigger>
12
- <div class="category-drop-down">
13
- <div class="icon">
14
- <CategoryIcon />
15
- </div>
16
- <div class="category-info">
17
- <p v-if="!splitMode" class="category-title">
18
- {{ $t("category") }}
19
- </p>
20
- <div class="category-name">
21
- {{
22
- !splitMode
23
- ? categoryName(selectedDocument.category)
24
- : categoryName(updatedDocument[index].category)
25
- }}
10
+ <template #content>
11
+ <div ref="tooltipContent"></div>
12
+ </template>
13
+ <b-dropdown
14
+ :class="[
15
+ 'category-chooser',
16
+ splitMode && 'split-mode',
17
+ selectedDocument.is_reviewed && 'disabled',
18
+ ]"
19
+ aria-role="list"
20
+ :disabled="selectedDocument.is_reviewed || tooltipIsShown"
21
+ >
22
+ <template #trigger>
23
+ <div class="category-drop-down">
24
+ <div class="icon">
25
+ <CategoryIcon />
26
+ </div>
27
+ <div class="category-info">
28
+ <p v-if="!splitMode" class="category-title">
29
+ {{ $t("category") }}
30
+ </p>
31
+ <div class="category-name">
32
+ {{
33
+ !splitMode
34
+ ? categoryName(selectedDocument.category)
35
+ : categoryName(updatedDocument[index].category)
36
+ }}
37
+ </div>
38
+ </div>
39
+ <div :class="[!splitMode && 'caret-section']">
40
+ <b-icon
41
+ icon="angle-down"
42
+ size="is-small"
43
+ :class="['caret', splitMode && 'split-mode-caret']"
44
+ />
26
45
  </div>
27
46
  </div>
28
- <div :class="[!splitMode && 'caret-section']">
29
- <b-icon
30
- icon="angle-down"
31
- size="is-small"
32
- :class="['caret', splitMode && 'split-mode-caret']"
33
- />
34
- </div>
35
- </div>
36
- </template>
47
+ </template>
37
48
 
38
- <b-dropdown-item
39
- v-for="category in currentProjectCategories"
40
- :key="category.id"
41
- aria-role="listitem"
42
- :disabled="handleOptionInDropdownDisabled(category)"
43
- @click="handleChangeCategory(category)"
44
- >
45
- <span>{{ category.name }}</span>
46
- </b-dropdown-item>
47
- </b-dropdown>
49
+ <b-dropdown-item
50
+ v-for="category in currentProjectCategories"
51
+ :key="category.id"
52
+ aria-role="listitem"
53
+ :disabled="handleOptionInDropdownDisabled(category)"
54
+ @click="handleChangeCategory(category)"
55
+ >
56
+ <span>{{ category.name }}</span>
57
+ </b-dropdown-item>
58
+ </b-dropdown>
59
+ </b-tooltip>
48
60
  </template>
49
61
 
50
62
  <script>
@@ -71,15 +83,17 @@ export default {
71
83
  return {
72
84
  currentProjectCategories: [],
73
85
  categoryError: false,
86
+ tooltipIsShown: false,
74
87
  };
75
88
  },
76
89
  computed: {
77
90
  ...mapGetters("category", {
78
91
  categoryName: "categoryName",
92
+ projectHasSingleCategory: "projectHasSingleCategory",
79
93
  }),
80
94
  ...mapState("document", ["selectedDocument"]),
81
95
  ...mapState("category", ["categories"]),
82
- ...mapState("edit", ["updatedDocument"]),
96
+ ...mapState("edit", ["editMode", "updatedDocument"]),
83
97
  },
84
98
  watch: {
85
99
  categories(newValue) {
@@ -108,6 +122,17 @@ export default {
108
122
  }
109
123
  });
110
124
  }
125
+
126
+ if (this.projectHasSingleCategory()) {
127
+ this.tooltipIsShown = true;
128
+ }
129
+
130
+ this.$nextTick(() => {
131
+ this.setTooltipText();
132
+ });
133
+ },
134
+ updated() {
135
+ this.setTooltipText();
111
136
  },
112
137
  methods: {
113
138
  // The current category name will change
@@ -149,6 +174,15 @@ export default {
149
174
  // to update the new document category
150
175
  this.$emit("category-change", this.page, category.id);
151
176
  },
177
+
178
+ setTooltipText() {
179
+ // Text set from innerHTML vs 'label' due to html tag in locales file string
180
+ if (this.projectHasSingleCategory()) {
181
+ this.$refs.tooltipContent.innerHTML = this.$t(
182
+ "single_category_in_project"
183
+ );
184
+ }
185
+ },
152
186
  },
153
187
  };
154
188
  </script>
@@ -25,7 +25,7 @@
25
25
  <div class="split-documents">
26
26
  <div
27
27
  class="image-container"
28
- @click="handlePageChange(page.pages[0].page_number)"
28
+ @click="handlePageChange(page.pages[0].number)"
29
29
  >
30
30
  <div
31
31
  :class="['thumbnail', page.pages.length > 1 && 'page-stack']"
@@ -165,7 +165,7 @@ export default {
165
165
  // returns the first thumbnail in the pages array
166
166
  // for each new document
167
167
  const image = this.documentPagesListForEditMode.find(
168
- (p) => p.page_number === page.pages[0].page_number
168
+ (p) => p.number === page.pages[0].number
169
169
  );
170
170
 
171
171
  return `${image.thumbnail_url}?${image.updated_at}`;
@@ -1,7 +1,10 @@
1
1
  <template>
2
2
  <div
3
3
  ref="pdfContainer"
4
- :class="['pdf-page-container', categorizeModalIsActive && 'pointer-cursor']"
4
+ :class="[
5
+ 'pdf-page-container',
6
+ (categorizeModalIsActive || editMode) && 'pointer-cursor',
7
+ ]"
5
8
  >
6
9
  <NewAnnotation
7
10
  v-if="newAnnotation && newAnnotation.length && !editAnnotation"
@@ -273,6 +276,11 @@ export default {
273
276
  this.closePopups(true);
274
277
  }
275
278
  },
279
+ page(newValue, oldValue) {
280
+ if (newValue.image_url !== oldValue.image_url) {
281
+ this.drawPage(true);
282
+ }
283
+ },
276
284
  },
277
285
  mounted() {
278
286
  if (
@@ -297,7 +305,7 @@ export default {
297
305
  },
298
306
 
299
307
  onMouseDown(event) {
300
- if (this.categorizeModalIsActive) return;
308
+ if (this.categorizeModalIsActive || this.editMode) return;
301
309
 
302
310
  this.closePopups();
303
311
 
@@ -1,8 +1,7 @@
1
1
  <template>
2
2
  <div>
3
- <DocumentPage v-if="editMode" :page="page" />
4
3
  <DummyPage
5
- v-else-if="!loadedPage || !pageInVisibleRange(page)"
4
+ v-if="!loadedPage || !pageInVisibleRange(page)"
6
5
  :width="page.size[0]"
7
6
  :height="page.size[1]"
8
7
  />
@@ -53,6 +52,9 @@ export default {
53
52
  ...mapGetters("document", ["scrollDocumentToAnnotation"]),
54
53
 
55
54
  loadedPage() {
55
+ if (this.editMode) {
56
+ return this.page;
57
+ }
56
58
  let loadedPage = null;
57
59
  if (this.page && this.pages) {
58
60
  loadedPage = this.pages.find((p) => p.number === this.page.number);
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <span class="file-name-section">
12
12
  <span
13
- :class="['document-name', isEditable ? 'is-editable' : '']"
13
+ :class="['document-name', isEditable && 'is-editable']"
14
14
  :contenteditable="isEditable"
15
15
  @input="handleInput"
16
16
  @paste="handlePaste"
@@ -12,7 +12,7 @@
12
12
 
13
13
  <DocumentName :data-file-name="selectedDocument.data_file_name" />
14
14
 
15
- <div class="right-bar-components">
15
+ <div v-if="!recalculatingAnnotations" class="right-bar-components">
16
16
  <div
17
17
  v-if="!editMode && (!publicView || !selectedDocument.is_reviewed)"
18
18
  class="keyboard-actions-info"
@@ -113,5 +113,5 @@
113
113
  "error_creating_multi_ann": "Nicht alle Annotationen wurden erfolgreich erstellt.",
114
114
  "disabled_finish_review": "Der Abschluss der Dokumentenprüfung ist erst möglich, nachdem alle Annotationen überarbeitet wurden, unabhängig davon, ob sie akzeptiert oder abgelehnt wurden.",
115
115
  "no_multi_ann_labelset_model": "Es gibt keine verfügbaren Label Sets, die mehrfach in diesem Dokument zu finden sind. Weitere Informationen finden Sie unter <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>diesem Link</a>.",
116
- "single_category_in_project": "Das aktuelle Projekt hat nur eine Kategorie, die diesem Dokument bereits zugeordnet ist. Um sie ändern zu können, sollte die neue zuerst dem Projekt hinzugefügt werden. Einzelheiten dazu finden Sie unter <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>diesem Link</a>."
116
+ "single_category_in_project": "Das aktuelle Projekt hat nur eine Kategorie. Um sie ändern zu können, sollte die neue zuerst dem Projekt hinzugefügt werden. Einzelheiten dazu finden Sie unter <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>diesem Link</a>."
117
117
  }
@@ -113,5 +113,5 @@
113
113
  "error_creating_multi_ann": "Not all annotation sets were created successfully.",
114
114
  "disabled_finish_review": "Finishing the document review is only possible after all annotations have been revised, whether they are accepted or rejected.",
115
115
  "no_multi_ann_labelset_model": "There are no available label sets that can be found multiple times in this document. For more details, you can visit <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>this link</a>.",
116
- "single_category_in_project": "The current project has only one category, which is already assigned to this document. To be able to change it, the new one should be first added to the project. For details on how to do this, visit <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>this link</a>."
116
+ "single_category_in_project": "The current project has only one category. To be able to change it, the new one should be first added to the project. For details on how to do this, visit <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>this link</a>."
117
117
  }
@@ -112,5 +112,5 @@
112
112
  "error_creating_multi_ann": "No todos los grupos de anotaciones fueron creados de manera exitosa.",
113
113
  "disabled_finish_review": "Solo es posible finalizar la revisión del documento si todas las anotaciones han sido revisadas, ya sea aceptadas o rechazadas.",
114
114
  "no_multi_ann_labelset_model": "En este documento no hay grupos de etiquetas múltiples disponibles. Para más información, haz clic en <a href='https://help.konfuzio.com/tutorials/advanced-document-extraction/index.html#multiple-annotation-sets' target='_blank'>este enlace</a>.",
115
- "single_category_in_project": "Este proyecto solo tiene una categoría, la cual se ha asignado a este documento. Para poder modificarla, es necesario agregar esta nueva categoría al proyecto. Para más información, visita <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>este enlace</a>."
115
+ "single_category_in_project": "Este proyecto solo tiene una categoría. Para poder modificarla, es necesario agregar esta nueva categoría al proyecto. Para más información, visita <a href='https://help.konfuzio.com/modules/categories/index.html#add-a-category' target='_blank'>este enlace</a>."
116
116
  }
@@ -32,6 +32,10 @@ const getters = {
32
32
  }
33
33
  return null;
34
34
  },
35
+
36
+ projectHasSingleCategory: (state) => () => {
37
+ return state.categories && state.categories.length === 1;
38
+ },
35
39
  };
36
40
 
37
41
  const actions = {
@@ -760,10 +760,16 @@ const actions = {
760
760
  HTTP.patch(`/documents/${state.documentId}/`, updatedDocument)
761
761
  .then((response) => {
762
762
  if (response.status === 200) {
763
- commit("SET_SELECTED_DOCUMENT", response.data);
764
- commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
763
+ if (updatedDocument.data_file_name) {
764
+ // if the only change was the file name, don't reload the page
765
+ // only update the file name for the selectedDocument
766
+ commit("UPDATE_FILE_NAME", response.data.data_file_name);
767
+ } else {
768
+ commit("SET_SELECTED_DOCUMENT", response.data);
769
+ commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
765
770
 
766
- dispatch("pollDocumentEndpoint");
771
+ dispatch("pollDocumentEndpoint");
772
+ }
767
773
 
768
774
  resolve(true);
769
775
  }
@@ -1125,6 +1131,9 @@ const mutations = {
1125
1131
  SET_CATEGORIZE_MODAL_IS_ACTIVE: (state, value) => {
1126
1132
  state.categorizeModalIsActive = value;
1127
1133
  },
1134
+ UPDATE_FILE_NAME: (state, value) => {
1135
+ state.selectedDocument.data_file_name = value;
1136
+ },
1128
1137
  };
1129
1138
 
1130
1139
  export default {
package/src/store/edit.js CHANGED
@@ -94,7 +94,7 @@ const actions = {
94
94
  if (direction === "left") {
95
95
  state.documentPagesListForEditMode.push({
96
96
  id: page.id,
97
- page_number: page.number,
97
+ number: page.number,
98
98
  angle: -90,
99
99
  thumbnail_url: page.thumbnail_url,
100
100
  updated_at: page.updated_at,
@@ -104,7 +104,7 @@ const actions = {
104
104
  if (direction === "right") {
105
105
  state.documentPagesListForEditMode.push({
106
106
  id: page.id,
107
- page_number: page.number,
107
+ number: page.number,
108
108
  angle: 90,
109
109
  thumbnail_url: page.thumbnail_url,
110
110
  updated_at: page.updated_at,