@konfuzio/document-validation-ui 0.1.12-dev.1 → 0.1.12-dev.3

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.12-dev.1",
3
+ "version": "0.1.12-dev.3",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -85,22 +85,10 @@ export default {
85
85
  },
86
86
 
87
87
  watch: {
88
- editAnnotation(newAnnotation, oldAnnotation) {
88
+ isAnnotationBeingEdited(newState, oldState) {
89
89
  // verify if new annotation in edit mode is not this one and if this
90
90
  // one was selected before so we set the state to the previous one (like a cancel)
91
-
92
- if (
93
- !newAnnotation &&
94
- oldAnnotation &&
95
- oldAnnotation.id === this.annotation.id
96
- ) {
97
- this.handleCancel(true);
98
- } else if (
99
- newAnnotation &&
100
- oldAnnotation &&
101
- newAnnotation.id === this.annotation.id &&
102
- newAnnotation.id !== oldAnnotation.id
103
- ) {
91
+ if (!newState && oldState) {
104
92
  this.handleCancel();
105
93
  }
106
94
  },
@@ -171,14 +159,8 @@ export default {
171
159
  }
172
160
  }
173
161
  },
174
- handleCancel(wasOutsideClick = false) {
175
- if (wasOutsideClick) {
176
- this.setText(this.span.offset_string);
177
- } else {
178
- this.$store.dispatch("selection/disableSelection");
179
- this.$store.dispatch("document/endLoading");
180
- }
181
-
162
+ handleCancel() {
163
+ this.setText(this.span.offset_string);
182
164
  this.isLoading = false;
183
165
  if (this.$refs.contentEditable) {
184
166
  this.$refs.contentEditable.blur();
@@ -227,19 +227,33 @@ export default {
227
227
  },
228
228
  watch: {
229
229
  sidebarAnnotationSelected(newSidebarAnnotationSelected) {
230
- if (
231
- newSidebarAnnotationSelected &&
232
- this.annotation &&
233
- this.annotation.id === newSidebarAnnotationSelected.annotation.id
234
- ) {
230
+ if (!newSidebarAnnotationSelected) return;
231
+
232
+ let annotationSelected;
233
+
234
+ if (newSidebarAnnotationSelected.annotation) {
235
+ annotationSelected = newSidebarAnnotationSelected.annotation;
236
+ } else {
237
+ annotationSelected = newSidebarAnnotationSelected;
238
+ }
239
+
240
+ if (this.annotation && this.annotation.id === annotationSelected.id) {
235
241
  clearTimeout(this.annotationAnimationTimeout);
236
242
 
243
+ let timeout;
244
+
245
+ if (!newSidebarAnnotationSelected.trigger) {
246
+ timeout = 600;
247
+ } else {
248
+ timeout = 1200;
249
+ }
250
+
237
251
  this.isSelected = true;
238
252
  // remove annotation selection after some time
239
253
  this.annotationAnimationTimeout = setTimeout(() => {
240
254
  this.$store.dispatch("document/setSidebarAnnotationSelected", null);
241
255
  this.isSelected = false;
242
- }, 1500);
256
+ }, timeout);
243
257
 
244
258
  // Check if sidebarAnnotationSelected changed from a click or hover
245
259
  if (newSidebarAnnotationSelected.trigger === "click") {
@@ -109,9 +109,18 @@ export default {
109
109
  !this.showAnnotationsGroup &&
110
110
  newSidebarAnnotationSelected
111
111
  ) {
112
+ let annotationSelected;
113
+
114
+ if (newSidebarAnnotationSelected.annotation) {
115
+ annotationSelected = newSidebarAnnotationSelected.annotation;
116
+ } else {
117
+ annotationSelected = newSidebarAnnotationSelected;
118
+ }
119
+
112
120
  const annotation = this.label.annotations.find(
113
- (ann) => ann.id === newSidebarAnnotationSelected.id
121
+ (ann) => ann.id === annotationSelected.id
114
122
  );
123
+
115
124
  if (annotation) {
116
125
  this.showAnnotationsGroup = true;
117
126
  this.$store.dispatch("document/setSidebarAnnotationSelected", null);
@@ -104,6 +104,33 @@ export default {
104
104
  if (!this.splitMode) {
105
105
  return this.categoryName(this.selectedDocument.category);
106
106
  } else {
107
+ const missingCategory = this.updatedDocument.find(
108
+ (item) => !item.category
109
+ );
110
+
111
+ // if there is just 1 category in the project,
112
+ // and one or more sub-documents has no category,
113
+ // assign the only category by default
114
+ if (this.projectHasSingleCategory() && missingCategory) {
115
+ const updatedValuesForDocuments = this.updatedDocument.map(
116
+ (document) => {
117
+ if (!document.category && this.categories) {
118
+ document.category = this.categories[0].id;
119
+ }
120
+
121
+ return document;
122
+ }
123
+ );
124
+
125
+ // update the store state
126
+ // so that if the changes are saved the data sent to the API is updated
127
+ // instead of only handling the category name in this component
128
+ this.$store.dispatch(
129
+ "edit/setUpdatedDocument",
130
+ updatedValuesForDocuments
131
+ );
132
+ }
133
+
107
134
  const categoryName = this.categoryName(
108
135
  this.updatedDocument[this.index].category
109
136
  );
@@ -1,14 +1,16 @@
1
1
  <template>
2
2
  <section class="document-error-modal">
3
- <b-modal v-model="isModalActive" :width="400">
3
+ <b-modal
4
+ v-model="isModalActive"
5
+ :width="400"
6
+ can-cancel="['x']"
7
+ :on-cancel="closeModal"
8
+ >
4
9
  <section class="modal-card-body">
5
10
  <div class="header">
6
11
  <div class="error-icon">
7
12
  <ErrorIcon class="icon" />
8
13
  </div>
9
- <div class="btn-container" type="button" @click="closeModal">
10
- <b-icon icon="xmark" class="close-btn" size="is-small" />
11
- </div>
12
14
  </div>
13
15
  <div class="content">
14
16
  <h3>{{ $t("document_error_title") }}</h3>