@konfuzio/document-validation-ui 0.1.10-dev.11 → 0.1.10-dev.13

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.
@@ -71,13 +71,19 @@ export default {
71
71
  required: false,
72
72
  default: "en",
73
73
  },
74
+ // eslint-disable-next-line vue/prop-name-casing
75
+ documents_list_path: {
76
+ type: String,
77
+ required: false,
78
+ default: "",
79
+ },
74
80
  },
75
81
  computed: {
76
82
  documentId() {
77
83
  if (getURLQueryParam("document")) {
78
84
  return getURLQueryParam("document");
79
- } else if (getURLPath("docs")) {
80
- return getURLPath("docs");
85
+ } else if (getURLPath("d")) {
86
+ return getURLPath("d");
81
87
  } else if (process.env.VUE_APP_DOCUMENT_ID) {
82
88
  return process.env.VUE_APP_DOCUMENT_ID;
83
89
  } else if (this.document) {
@@ -118,6 +124,15 @@ export default {
118
124
  showDocumentsList() {
119
125
  return process.env.VUE_APP_SHOW_DOCUMENTS_LIST;
120
126
  },
127
+ documentsListPath() {
128
+ if (process.env.VUE_APP_DOCUMENTS_LIST_PATH) {
129
+ return process.env.VUE_APP_DOCUMENTS_LIST_PATH;
130
+ } else if (this.documents_list_path && this.documents_list_path !== "") {
131
+ return this.documents_list_path;
132
+ } else {
133
+ return null;
134
+ }
135
+ },
121
136
  },
122
137
  created() {
123
138
  // Sentry config
@@ -160,6 +175,10 @@ export default {
160
175
  this.$store.dispatch("project/setProjectId", this.projectId),
161
176
  this.$store.dispatch("document/setDocId", this.documentId),
162
177
  this.$store.dispatch("document/setPublicView", this.isPublicView),
178
+ this.$store.dispatch(
179
+ "project/setDocumentsListPath",
180
+ this.documentsListPath
181
+ ),
163
182
  ]).finally(() => {
164
183
  this.$store.dispatch("document/fetchDocument");
165
184
  });
@@ -4,7 +4,7 @@
4
4
  ref="modal"
5
5
  v-model="show"
6
6
  :can-cancel="['x', 'outside']"
7
- class="modal-absolute modal-400 modal-no-footer"
7
+ class="modal-absolute modal-400 modal-no-footer model-overflow-visible"
8
8
  :on-cancel="close"
9
9
  >
10
10
  <section class="modal-card-body">
@@ -149,7 +149,7 @@ export default {
149
149
  }
150
150
  );
151
151
 
152
- this.$emit("labelSet", this.selectedLabelSet);
152
+ this.$emit("finish", this.selectedLabelSet);
153
153
  this.close();
154
154
  },
155
155
  setSelectedLabelSet(labelSet) {
@@ -157,6 +157,7 @@ export default {
157
157
  this.selectedLabelSet = labelSet;
158
158
  },
159
159
  close() {
160
+ this.$store.dispatch("display/showChooseLabelSetModal", null);
160
161
  this.$emit("close");
161
162
  },
162
163
  createLabelsList(labels) {
@@ -111,7 +111,7 @@ export default {
111
111
  spanSelection(newValue) {
112
112
  if (!newValue) return;
113
113
 
114
- // // Check if the bbox has no string
114
+ // Check if the bbox has no string
115
115
  if (newValue[0] && !newValue[0].offset_string) {
116
116
  this.$store.dispatch("document/resetEditAnnotation");
117
117
  this.$store.dispatch("selection/disableSelection");
@@ -100,7 +100,7 @@ import AnnotationRow from "../DocumentAnnotations/AnnotationRow";
100
100
  import DraggableIcon from "../../assets/images/DraggableIcon";
101
101
 
102
102
  export default {
103
- name: "MultiAnnotationTablePopup",
103
+ name: "MultiAnnotationTableOverlay",
104
104
  components: {
105
105
  AnnotationRow,
106
106
  DraggableIcon,
@@ -12,6 +12,11 @@
12
12
  :left="documentContainerLeftPadding"
13
13
  :width="documentContainerWidth"
14
14
  />
15
+ <ChooseLabelSetModal
16
+ v-if="showChooseLabelSetModal && showChooseLabelSetModal.show"
17
+ :is-multiple-annotations="showChooseLabelSetModal.isMultipleAnnotations"
18
+ @finish="showChooseLabelSetModal.finish"
19
+ />
15
20
 
16
21
  <transition name="slide-fade">
17
22
  <div
@@ -50,6 +55,7 @@ import { DocumentEdit } from "./DocumentEdit";
50
55
  import ErrorMessage from "./ErrorMessage";
51
56
  import NotOptimizedViewportModal from "../components/DocumentModals/NotOptimizedViewportModal";
52
57
  import DocumentErrorModal from "../components/DocumentModals/DocumentErrorModal";
58
+ import ChooseLabelSetModal from "../components/DocumentAnnotations/ChooseLabelSetModal";
53
59
 
54
60
  /**
55
61
  * This component shows the PDF pages in a scrolling component and
@@ -67,6 +73,7 @@ export default {
67
73
  NotOptimizedViewportModal,
68
74
  DocumentErrorModal,
69
75
  MultiAnnotationTableOverlay,
76
+ ChooseLabelSetModal,
70
77
  },
71
78
  data() {
72
79
  return {
@@ -84,6 +91,7 @@ export default {
84
91
  "pageWidthScale",
85
92
  "currentPage",
86
93
  "showAnnSetTable",
94
+ "showChooseLabelSetModal",
87
95
  ]),
88
96
  ...mapState("document", [
89
97
  "showActionError",
@@ -27,8 +27,7 @@
27
27
  <div v-if="!renameAndCategorize" class="sidebar">
28
28
  <EditSidebar
29
29
  :split-suggestions-enabled="splitSuggestionsEnabled"
30
- @rotate-left="rotatePage"
31
- @rotate-right="rotatePage"
30
+ @rotate="rotatePage"
32
31
  @rotate-all-left="handleRotationsToTheLeft"
33
32
  @rotate-all-right="handleRotationsToTheRight"
34
33
  @handle-splitting-suggestions="applySplittingSuggestions"
@@ -46,6 +45,7 @@ import RenameAndCategorize from "./RenameAndCategorize";
46
45
  import EditPages from "./EditPages";
47
46
  import SplitInfoBar from "./SplitInfoBar";
48
47
  import EditConfirmationModal from "./EditConfirmationModal";
48
+ import { navigateToDocumentsList } from "../../utils/utils";
49
49
 
50
50
  /**
51
51
  * This component shows a document thumbnail grid view and sidebar, to be able to edit the document.
@@ -85,6 +85,7 @@ export default {
85
85
  "selectedPages",
86
86
  "submitEditChanges",
87
87
  ]),
88
+ ...mapState("project", ["projectId", "documentsListPath"]),
88
89
  ...mapGetters("edit", ["documentShouldBePostprocessed"]),
89
90
  },
90
91
  watch: {
@@ -169,13 +170,11 @@ export default {
169
170
 
170
171
  /** ROTATE */
171
172
  rotatePage(direction) {
172
- const page = this.selectedPages.map((page) => {
173
- return page;
174
- });
175
-
176
- this.$store.dispatch("edit/rotatePage", {
177
- page,
178
- direction,
173
+ this.selectedPages.forEach((page) => {
174
+ this.$store.dispatch("edit/rotatePage", {
175
+ page,
176
+ direction,
177
+ });
179
178
  });
180
179
  },
181
180
  handleRotationsToTheLeft() {
@@ -386,6 +385,8 @@ export default {
386
385
  defaultErrorMessage: this.$t("edit_error"),
387
386
  });
388
387
  });
388
+
389
+ navigateToDocumentsList(this.documentsListPath, this.projectId);
389
390
  } else {
390
391
  // Check if only the category changes:
391
392
  const newCategory = this.updatedDocument[0].category;
@@ -129,10 +129,10 @@ export default {
129
129
  },
130
130
  methods: {
131
131
  rotateLeft() {
132
- this.$emit("rotate-left", "left");
132
+ this.$emit("rotate", "left");
133
133
  },
134
134
  rotateRight() {
135
- this.$emit("rotate-right", "right");
135
+ this.$emit("rotate", "right");
136
136
  },
137
137
  rotateAllLeft() {
138
138
  this.$emit("rotate-all-left");
@@ -18,14 +18,6 @@
18
18
  :container-height="scaledViewport.height"
19
19
  @close="closePopups"
20
20
  />
21
- <MultiAnnotationTablePopup
22
- v-if="newMultiAnnotationSetTable"
23
- :table-position="newMultiAnnotationSetTable.position"
24
- :page-size="scaledViewport"
25
- :label-set="newMultiAnnotationSetTable.labelSet"
26
- :grouped-entities="newMultiAnnotationSetTable.entities"
27
- @close="closePopups"
28
- />
29
21
 
30
22
  <AnnSetTableOptions v-if="showAnnSetTable" :page="page" />
31
23
 
@@ -117,7 +109,6 @@
117
109
  :page="page"
118
110
  @buttonEnter="onElementEnter"
119
111
  @buttonLeave="onElementLeave"
120
- @finished="handleMultiAnnSelectionFinished"
121
112
  />
122
113
  </v-layer>
123
114
  </v-stage>
@@ -136,7 +127,6 @@ import api from "../../api";
136
127
  import BoxSelection from "./BoxSelection";
137
128
  import MultiAnnSelection from "./MultiAnnSelection";
138
129
  import NewAnnotation from "./NewAnnotation";
139
- import MultiAnnotationTablePopup from "./MultiAnnotationTablePopup";
140
130
  import AnnSetTableOptions from "./AnnSetTableOptions";
141
131
 
142
132
  export default {
@@ -145,7 +135,6 @@ export default {
145
135
  BoxSelection,
146
136
  MultiAnnSelection,
147
137
  NewAnnotation,
148
- MultiAnnotationTablePopup,
149
138
  AnnSetTableOptions,
150
139
  },
151
140
 
@@ -160,7 +149,6 @@ export default {
160
149
  return {
161
150
  image: null,
162
151
  newAnnotation: [],
163
- newMultiAnnotationSetTable: null,
164
152
  };
165
153
  },
166
154
 
@@ -393,7 +381,6 @@ export default {
393
381
  },
394
382
 
395
383
  handleFocusedAnnotation(annotation, trigger) {
396
- this.$store.dispatch("document/resetEditAnnotation");
397
384
  this.$store.dispatch("document/setSidebarAnnotationSelected", {
398
385
  annotation,
399
386
  trigger,
@@ -461,10 +448,6 @@ export default {
461
448
  this.$refs.stage.$el.style.cursor = "inherit";
462
449
  },
463
450
 
464
- handleMultiAnnSelectionFinished(newMultiAnnotationSetTable) {
465
- this.newMultiAnnotationSetTable = newMultiAnnotationSetTable;
466
- },
467
-
468
451
  /**
469
452
  * Konva draws pages like this.
470
453
  */
@@ -557,7 +540,6 @@ export default {
557
540
  };
558
541
  },
559
542
  closePopups(closeNewAnnotaton) {
560
- this.newMultiAnnotationSetTable = null;
561
543
  if (closeNewAnnotaton) {
562
544
  this.newAnnotation = [];
563
545
  }
@@ -132,34 +132,12 @@ export default {
132
132
  },
133
133
  methods: {
134
134
  openMultiAnnotationModal() {
135
- this.$buefy.modal.open({
136
- parent: this.$parent,
137
- component: ChooseLabelSetModal,
138
- hasModalCard: true,
139
- trapFocus: true,
140
- canCancel: false,
141
- customClass: "dv-ui-theme invisible-parent-modal",
142
- props: { isMultipleAnnotations: true },
143
- events: {
144
- labelSet: this.submitAnnotations,
145
- },
135
+ this.$store.dispatch("display/showChooseLabelSetModal", {
136
+ show: true,
137
+ isMultipleAnnotations: true,
138
+ finish: this.submitAnnotations,
146
139
  });
147
140
  },
148
- chooseLabelSet(labelSet) {
149
- // TODO: deprecated with new multi ann set table
150
- const tableSelection = {
151
- labelSet,
152
- position: {
153
- x: this.selection.start.x,
154
- y: this.selection.start.y,
155
- width: this.selection.end.x - this.selection.start.x,
156
- height: this.selection.end.y - this.selection.start.y,
157
- },
158
- entities: this.entities,
159
- };
160
- this.$store.dispatch("selection/disableSelection");
161
- this.$emit("finished", tableSelection);
162
- },
163
141
 
164
142
  async submitAnnotations(labelSet) {
165
143
  const columns = labelSet.labels.map((label) => {
@@ -259,15 +259,7 @@ export default {
259
259
  this.loading = false;
260
260
  });
261
261
  },
262
- disableLabelSetModalShowing() {
263
- // timeout to stop propagation of click event
264
- setTimeout(() => {
265
- this.isAnnSetModalShowing = false;
266
- }, 500);
267
- },
268
262
  chooseLabelSet(labelSet) {
269
- this.disableLabelSetModalShowing();
270
-
271
263
  const newSet = {
272
264
  label_set: labelSet,
273
265
  labels: labelSet.labels,
@@ -277,20 +269,10 @@ export default {
277
269
  this.selectedSet = newSet;
278
270
  },
279
271
  openAnnotationSetCreation() {
280
- this.isAnnSetModalShowing = true;
281
-
282
- this.$buefy.modal.open({
283
- parent: this.$parent,
284
- component: ChooseLabelSetModal,
285
- hasModalCard: true,
286
- trapFocus: true,
287
- canCancel: false,
288
- onCancel: this.disableLabelSetModalShowing,
289
- customClass: "dv-ui-theme invisible-parent-modal",
290
- events: {
291
- labelSet: this.chooseLabelSet,
292
- close: this.disableLabelSetModalShowing,
293
- },
272
+ this.$store.dispatch("display/showChooseLabelSetModal", {
273
+ show: true,
274
+ isMultipleAnnotations: true,
275
+ finish: this.chooseLabelSet,
294
276
  });
295
277
  },
296
278
  setTooltipText() {
@@ -57,7 +57,7 @@
57
57
  "reorder": "Sortieren",
58
58
  "rotate": "Rotieren",
59
59
  "edit_error": "Die Änderungen konnten nicht gespeichert werden. Bitte versuchen Sie es später erneut.",
60
- "select_pages": "Sie können nun Seiten drehen, neu sortieren und Dokumente splitten.",
60
+ "select_pages": "Sie können nun Seiten drehen, neu sortieren und Dokumente teilen.",
61
61
  "edit_document": "Dokument bearbeiten (Early Access)",
62
62
  "edit_early_access": "Sie sind einer der Nutzer, die Zugang zu diesen Funktionalitäten vor dem offiziellen Erscheinungstermin erhalten.",
63
63
  "selected": "ausgewählt",
@@ -131,5 +131,6 @@
131
131
  "edit_label": "Label editieren",
132
132
  "delete_label": "Label löschen",
133
133
  "table": "Tabelle",
134
- "prepare_document": "Dokument vorbereiten"
134
+ "prepare_document": "Dokument vorbereiten",
135
+ "delete_table": "Tabelle löschen"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "missing_from_document": "Missing from the document",
132
132
  "edit_label": "Edit label",
133
133
  "delete_label": "Delete label",
134
- "table": "Table"
134
+ "table": "Table",
135
+ "delete_table": "Delete table"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "table": "Tabla",
132
132
  "new_multi_ann_description": "Seleccione un modelo de datos de los existentes, luego deseleccione las etiquetas que no existen en este documento.",
133
133
  "new_multi_ann_title": "Crear múltiples anotaciones",
134
- "prepare_document": "Prepare el documento"
134
+ "prepare_document": "Prepare el documento",
135
+ "delete_table": "Eliminar tabla"
135
136
  }
@@ -31,6 +31,7 @@ const state = {
31
31
  categorizeModalIsActive: false,
32
32
  pageChangedFromThumbnail: false,
33
33
  showAnnSetTable: null,
34
+ showChooseLabelSetModal: null,
34
35
  };
35
36
 
36
37
  const getters = {
@@ -236,6 +237,9 @@ const actions = {
236
237
  showAnnSetTable({ commit }, tableSet) {
237
238
  commit("SET_ANN_SET_TABLE", tableSet);
238
239
  },
240
+ showChooseLabelSetModal({ commit }, options) {
241
+ commit("SET_SHOW_CHOOSE_LABEL_SET_MODAL", options);
242
+ },
239
243
  toggleAnnSetTable({ commit }, tableSet) {
240
244
  commit("TOGGLE_ANN_SET_TABLE", tableSet);
241
245
  },
@@ -286,6 +290,9 @@ const mutations = {
286
290
  SET_PAGE_CHANGED_FROM_THUMBNAIL: (state, value) => {
287
291
  state.pageChangedFromThumbnail = value;
288
292
  },
293
+ SET_SHOW_CHOOSE_LABEL_SET_MODAL: (state, options) => {
294
+ state.showChooseLabelSetModal = options;
295
+ },
289
296
  };
290
297
 
291
298
  export default {
@@ -1063,7 +1063,7 @@ const actions = {
1063
1063
  { error, serverErrorMessage, defaultErrorMessage }
1064
1064
  ) => {
1065
1065
  // check type of error
1066
- if (error && error.status === 500) {
1066
+ if (error && error.status >= 500 && error.status < 600) {
1067
1067
  dispatch("setErrorMessage", serverErrorMessage);
1068
1068
  commit("SET_SERVER_ERROR", true);
1069
1069
  } else if (error.data && error.data.length > 0) {
package/src/store/edit.js CHANGED
@@ -10,7 +10,7 @@ const HTTP = myImports.HTTP;
10
10
  const state = {
11
11
  editMode: false,
12
12
  renameAndCategorize: false,
13
- isMultipleSelection: false,
13
+ isMultipleSelection: true,
14
14
  pagesForPostprocess: [],
15
15
  selectedPages: [],
16
16
  updatedDocument: [],
@@ -113,12 +113,12 @@ const actions = {
113
113
  },
114
114
 
115
115
  rotatePage: ({ state, commit }, { page, direction }) => {
116
- if (state.pagesForPostprocess.find((p) => p.id === page[0].id)) {
116
+ if (state.pagesForPostprocess.find((p) => p.id === page.id)) {
117
117
  const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
118
118
  let rotatedAngle;
119
119
  if (direction === "left") {
120
120
  rotatedAngle = p.angle - 90;
121
- if (p.id === page[0].id) {
121
+ if (p.id === page.id) {
122
122
  if (rotatedAngle === -270) {
123
123
  rotatedAngle = 90;
124
124
  }
@@ -131,7 +131,7 @@ const actions = {
131
131
  }
132
132
  if (direction === "right") {
133
133
  rotatedAngle = p.angle + 90;
134
- if (p.id === page[0].id) {
134
+ if (p.id === page.id) {
135
135
  if (rotatedAngle === 270) {
136
136
  rotatedAngle = -90;
137
137
  }
@@ -271,6 +271,7 @@ const mutations = {
271
271
  },
272
272
  ADD_SELECTED_PAGE: (state, selectedPage) => {
273
273
  state.selectedPages.push(selectedPage);
274
+ console.log(state.selectedPages);
274
275
  },
275
276
  SET_SHOW_EDIT_CONFIRMATION_MODAL: (state, value) => {
276
277
  state.showEditConfirmationModal = value;
@@ -4,6 +4,7 @@ const HTTP = myImports.HTTP;
4
4
  const state = {
5
5
  projectId: null,
6
6
  currentUser: null,
7
+ documentsListPath: null,
7
8
  };
8
9
 
9
10
  const getters = {
@@ -75,6 +76,10 @@ const actions = {
75
76
  setCurrentUser: ({ commit }, currentUser) => {
76
77
  commit("SET_CURRENT_USER", currentUser);
77
78
  },
79
+
80
+ setDocumentsListPath: ({ commit }, path) => {
81
+ commit("SET_DOCUMENTS_LIST_PATH", path);
82
+ },
78
83
  };
79
84
 
80
85
  const mutations = {
@@ -84,6 +89,9 @@ const mutations = {
84
89
  SET_CURRENT_USER: (state, currentUser) => {
85
90
  state.currentUser = currentUser;
86
91
  },
92
+ SET_DOCUMENTS_LIST_PATH: (state, path) => {
93
+ state.documentsListPath = path;
94
+ },
87
95
  };
88
96
 
89
97
  export default {
@@ -15,7 +15,7 @@ export function getURLQueryParam(param) {
15
15
  export function getURLPath(value) {
16
16
  const path = window.location.pathname;
17
17
 
18
- if (!path.includes(value)) return;
18
+ if (!path.includes(`/${value}/`)) return;
19
19
 
20
20
  const id = path.split(value)[1].split("/")[1];
21
21
 
@@ -30,6 +30,16 @@ export function navigateToNewDocumentURL(oldId, newId) {
30
30
  window.location.replace(newUrl);
31
31
  }
32
32
 
33
+ export function navigateToDocumentsList(path, projectId) {
34
+ if (!path) return;
35
+
36
+ const parameters = `?project=${projectId}&is_reviewed__exact=0`;
37
+
38
+ const newPath = `${path}/${parameters}`;
39
+
40
+ window.location.pathname = newPath;
41
+ }
42
+
33
43
  export function isElementArray(element) {
34
44
  return Array.isArray(element);
35
45
  }