@konfuzio/document-validation-ui 0.1.59-dev.3 → 0.1.60-dev.0

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 (65) hide show
  1. package/cypress.config.js +6 -6
  2. package/dist/css/app.css +1 -1
  3. package/dist/index.html +1 -1
  4. package/dist/js/app.js +1 -1
  5. package/dist/js/app.js.map +1 -1
  6. package/dist/js/chunk-vendors.js +23 -66
  7. package/dist/js/chunk-vendors.js.map +1 -1
  8. package/jest.config.js +2 -22
  9. package/package.json +38 -32
  10. package/src/api.js +12 -0
  11. package/src/assets/scss/ann_set_table_options.scss +4 -4
  12. package/src/assets/scss/annotation_action_buttons.scss +7 -7
  13. package/src/assets/scss/annotation_details.scss +9 -9
  14. package/src/assets/scss/choose_label_set_modal.scss +5 -5
  15. package/src/assets/scss/document_action_bar.scss +3 -3
  16. package/src/assets/scss/document_annotations.scss +43 -45
  17. package/src/assets/scss/document_category.scss +8 -8
  18. package/src/assets/scss/document_dashboard.scss +1 -1
  19. package/src/assets/scss/document_edit.scss +30 -30
  20. package/src/assets/scss/document_error.scss +6 -6
  21. package/src/assets/scss/document_name.scss +6 -6
  22. package/src/assets/scss/document_page.scss +3 -3
  23. package/src/assets/scss/document_search_bar.scss +7 -7
  24. package/src/assets/scss/document_set_chooser.scss +3 -3
  25. package/src/assets/scss/document_thumbnails.scss +7 -7
  26. package/src/assets/scss/document_toolbar.scss +10 -10
  27. package/src/assets/scss/document_top_bar.scss +11 -11
  28. package/src/assets/scss/document_viewport_modal.scss +3 -3
  29. package/src/assets/scss/documents_list.scss +12 -11
  30. package/src/assets/scss/edit_page_thumbnail.scss +6 -6
  31. package/src/assets/scss/empty_state.scss +4 -4
  32. package/src/assets/scss/error_page.scss +2 -2
  33. package/src/assets/scss/extracting_data.scss +3 -3
  34. package/src/assets/scss/imports.scss +1 -0
  35. package/src/assets/scss/multi_ann_table_overlay.scss +3 -3
  36. package/src/assets/scss/multi_ann_table_popup.scss +1 -1
  37. package/src/assets/scss/new_annotation.scss +19 -25
  38. package/src/assets/scss/scrolling_document.scss +1 -1
  39. package/src/assets/scss/theme.scss +52 -64
  40. package/src/assets/scss/variables.scss +0 -2
  41. package/src/components/App.vue +14 -9
  42. package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +6 -4
  43. package/src/components/DocumentAnnotations/AnnotationContent.vue +52 -25
  44. package/src/components/DocumentAnnotations/AnnotationRow.vue +50 -106
  45. package/src/components/DocumentAnnotations/DocumentAnnotations.vue +6 -12
  46. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +70 -31
  47. package/src/components/DocumentDashboard.vue +17 -12
  48. package/src/components/DocumentEdit/EditPages.vue +46 -51
  49. package/src/components/DocumentPage/BoxSelection.vue +49 -16
  50. package/src/components/DocumentPage/DocumentPage.vue +153 -56
  51. package/src/components/DocumentPage/DocumentToolbar.vue +15 -5
  52. package/src/components/DocumentPage/EditAnnotation.vue +372 -0
  53. package/src/components/DocumentPage/{AnnotationPopup.vue → NewAnnotation.vue} +94 -122
  54. package/src/components/DocumentPage/ScrollingPage.vue +10 -2
  55. package/src/components/DocumentThumbnails/LoadingThumbnail.vue +6 -3
  56. package/src/components/DocumentTopBar/DocumentTopBar.vue +2 -4
  57. package/src/constants.js +7 -1
  58. package/src/i18n.js +5 -2
  59. package/src/main.js +16 -14
  60. package/src/store/display.js +24 -38
  61. package/src/store/document.js +6 -1
  62. package/src/store/index.js +8 -5
  63. package/src/store/selection.js +76 -152
  64. package/src/components/DocumentPage/PlaceholderSelection.vue +0 -51
  65. package/src/components/DocumentPage/SpanSelection.vue +0 -259
@@ -1,24 +1,10 @@
1
1
  <!-- eslint-disable vue/no-v-html -->
2
2
  <template>
3
- <div
4
- class="annotation-popup"
5
- :style="{
6
- left: `${left}px`,
7
- top: `${top}px`,
8
- height: `${heightOfPopup}px`,
9
- }"
10
- >
11
- <div v-if="!editAnnotation">
12
- <div v-if="spanLoading" class="popup-input">
13
- <b-icon icon="spinner" class="fa-spin loading-icon-size spinner" />
14
- </div>
15
- <input
16
- v-else
17
- v-model="textFromEntities"
18
- class="popup-input"
19
- type="text"
20
- />
3
+ <div class="annotation-popup" :style="{ left: `${left}px`, top: `${top}px` }">
4
+ <div v-if="!textFromEntities" class="popup-input">
5
+ <b-icon icon="spinner" class="fa-spin loading-icon-size spinner" />
21
6
  </div>
7
+ <input v-else v-model="textFromEntities" class="popup-input" type="text" />
22
8
  <b-dropdown
23
9
  v-model="selectedSet"
24
10
  :disabled="!textFromEntities"
@@ -41,19 +27,17 @@
41
27
  ]"
42
28
  type="is-text"
43
29
  >
44
- <span class="input-text">
45
- {{
46
- selectedSet
47
- ? `${selectedSet.label_set.name} ${
48
- selectedSet.id
49
- ? numberOfAnnotationSetGroup(selectedSet)
50
- : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t(
51
- "new"
52
- )})`
53
- }`
54
- : $t("select_annotation_set")
55
- }}</span
56
- >
30
+ {{
31
+ selectedSet
32
+ ? `${selectedSet.label_set.name} ${
33
+ selectedSet.id
34
+ ? numberOfAnnotationSetGroup(selectedSet)
35
+ : `${numberOfLabelSetGroup(selectedSet.label_set)} (${$t(
36
+ "new"
37
+ )})`
38
+ }`
39
+ : $t("select_annotation_set")
40
+ }}
57
41
  <span class="caret-icon">
58
42
  <b-icon icon="angle-down" size="is-small" class="caret" />
59
43
  </span>
@@ -88,6 +72,7 @@
88
72
  size="is-large"
89
73
  position="is-bottom"
90
74
  class="bottom-aligned"
75
+ :close-delay="5000"
91
76
  >
92
77
  <template #content>
93
78
  <div
@@ -114,13 +99,13 @@
114
99
  ]"
115
100
  type="is-text"
116
101
  >
117
- <span class="input-text">{{
102
+ {{
118
103
  selectedLabel
119
104
  ? selectedLabel.name
120
105
  : labels && labels.length === 0
121
106
  ? $t("no_labels_to_choose")
122
107
  : $t("select_label")
123
- }}</span>
108
+ }}
124
109
  <span class="caret-icon">
125
110
  <b-icon icon="angle-down" size="is-small" class="caret" />
126
111
  </span>
@@ -159,12 +144,15 @@
159
144
  * This component is used to show a popup
160
145
  * for creating a new annotation.
161
146
  */
147
+ const heightOfPopup = 192;
148
+ const margin = 12;
149
+ const widthOfPopup = 205;
162
150
 
163
151
  import { mapGetters, mapState } from "vuex";
164
152
 
165
153
  export default {
166
154
  props: {
167
- spans: {
155
+ newAnnotation: {
168
156
  required: true,
169
157
  type: Array,
170
158
  },
@@ -183,9 +171,6 @@ export default {
183
171
  },
184
172
  data() {
185
173
  return {
186
- heightOfPopup: 192,
187
- margin: 12,
188
- widthOfPopup: 205,
189
174
  selectedLabel: null,
190
175
  selectedSet: null,
191
176
  labels: null,
@@ -195,48 +180,51 @@ export default {
195
180
  };
196
181
  },
197
182
  computed: {
198
- ...mapState("document", ["annotationSets", "documentId", "editAnnotation"]),
183
+ ...mapState("document", ["annotationSets", "documentId"]),
199
184
  ...mapGetters("document", [
200
185
  "numberOfAnnotationSetGroup",
201
186
  "numberOfLabelSetGroup",
202
187
  "labelsFilteredForAnnotationCreation",
203
188
  ]),
204
189
  ...mapState("display", ["showBranding"]),
205
- ...mapGetters("display", ["clientToBbox", "bboxToRect"]),
206
- ...mapState("selection", ["spanSelection", "selection", "spanLoading"]),
190
+ ...mapGetters("display", ["clientToBbox"]),
191
+ ...mapState("selection", ["spanSelection", "selection"]),
207
192
  top() {
208
193
  if (this.selection && this.selection.end) {
209
- const top = this.selection.end.y + this.margin;
194
+ const top = this.selection.end.y + margin;
210
195
  //check if the popup will not go off the container on the top
211
- return top + this.heightOfPopup < this.containerHeight
196
+ return top + heightOfPopup < this.containerHeight
212
197
  ? top
213
- : this.selection.end.y - this.heightOfPopup;
198
+ : this.selection.end.y - heightOfPopup;
214
199
  } else {
215
- const normalizedSpan = this.bboxToRect(this.page, this.spans[0]);
216
- const top = normalizedSpan.y - this.heightOfPopup; // subtract the height of the popup plus some margin
200
+ const top = this.newAnnotation[0].scaled.y - heightOfPopup; // subtract the height of the popup plus some margin
217
201
 
218
202
  //check if the popup will not go off the container on the top
219
- return normalizedSpan.y > this.heightOfPopup
203
+ return this.newAnnotation[0].scaled.y > heightOfPopup
220
204
  ? top
221
- : normalizedSpan.y + normalizedSpan.height + this.margin;
205
+ : this.newAnnotation[0].scaled.y +
206
+ this.newAnnotation[0].scaled.height +
207
+ margin;
222
208
  }
223
209
  },
224
210
  left() {
225
211
  if (this.selection && this.selection.start && this.selection.end) {
226
212
  const left = this.selection.start.x;
227
213
  //check if the popup will not go off the container on the right
228
- return left + this.widthOfPopup < this.containerWidth
214
+ return left + widthOfPopup < this.containerWidth
229
215
  ? left
230
- : this.containerWidth - this.widthOfPopup;
216
+ : this.containerWidth - widthOfPopup;
217
+ return this.selection.start.x;
231
218
  } else {
232
- const normalizedSpan = this.bboxToRect(this.page, this.spans[0]);
233
219
  const left =
234
- normalizedSpan.x + normalizedSpan.width / 2 - this.widthOfPopup / 2; // add the entity half width to be centered and then subtract half the width of the popup
220
+ this.newAnnotation[0].scaled.x +
221
+ this.newAnnotation[0].scaled.width / 2 -
222
+ widthOfPopup / 2; // add the entity half width to be centered and then subtract half the width of the popup
235
223
 
236
224
  //check if the popup will not go off the container
237
- if (left + this.widthOfPopup > this.containerWidth) {
225
+ if (left + widthOfPopup > this.containerWidth) {
238
226
  // on the right side
239
- return this.containerWidth - this.widthOfPopup;
227
+ return this.containerWidth - widthOfPopup;
240
228
  } else {
241
229
  // on the left side
242
230
  return left > 0 ? left : 0;
@@ -244,8 +232,10 @@ export default {
244
232
  }
245
233
  },
246
234
  textFromEntities() {
235
+ if (!this.spanSelection) return;
236
+
247
237
  let text = "";
248
- this.spans.forEach((span) => {
238
+ this.spanSelection.forEach((span) => {
249
239
  text = `${text} ${span.offset_string}`;
250
240
  });
251
241
 
@@ -253,23 +243,17 @@ export default {
253
243
  },
254
244
  },
255
245
  watch: {
256
- selectedSet(newValue, oldValue) {
246
+ selectedSet(newValue) {
257
247
  this.selectedLabel = null;
258
248
  this.labels = this.labelsFilteredForAnnotationCreation(newValue);
259
- if (oldValue === null && this.editAnnotation) {
260
- this.selectedLabel = this.editAnnotation.label;
261
- } else if (this.labels.length === 1) {
249
+ if (this.labels.length === 1) {
262
250
  this.selectedLabel = this.labels[0];
263
251
  }
264
252
  },
265
253
  },
266
254
  mounted() {
267
255
  this.setsList = this.orderedSetList([...this.annotationSets]);
268
-
269
- if (this.editAnnotation) {
270
- this.heightOfPopup = 142;
271
- this.selectedSet = this.editAnnotation.annotationSet;
272
- } else if (this.setsList.length === 1) {
256
+ if (this.setsList.length === 1) {
273
257
  this.selectedSet = this.setsList[0];
274
258
  }
275
259
 
@@ -278,7 +262,7 @@ export default {
278
262
  document.body.addEventListener("click", this.clickOutside);
279
263
  }, 200);
280
264
  },
281
- unmounted() {
265
+ destroyed() {
282
266
  document.body.removeEventListener("click", this.clickOutside);
283
267
  },
284
268
  methods: {
@@ -299,73 +283,61 @@ export default {
299
283
  return setsList;
300
284
  },
301
285
  close() {
302
- if (this.editAnnotation) {
303
- this.$store.dispatch("document/resetEditAnnotation");
304
- }
305
- this.$store.dispatch("selection/disableSelection");
286
+ this.$store.dispatch("selection/setSelectedEntities", null);
287
+ this.$store.dispatch("selection/endSelection");
306
288
  this.$emit("close");
307
289
  },
308
290
  save() {
309
- if (this.editAnnotation) {
310
- this.loading = true;
311
- this.$store.dispatch("document/setEditAnnotation", {
312
- id: this.editAnnotation.id,
313
- index: this.editAnnotation.index,
314
- label: this.selectedLabel,
315
- labelSet: this.selectedSet.label_set,
316
- annotationSet: this.selectedSet,
317
- pageNumber: this.editAnnotation.pageNumber,
318
- });
319
-
320
- document.getElementById("save-ann").click();
321
-
322
- return;
323
- } else {
324
- this.loading = true;
291
+ this.loading = true;
292
+ const span = this.newAnnotation.flatMap((ann) => {
293
+ return {
294
+ ...ann.original,
295
+ offset_string: ann.original.offset_string,
296
+ };
297
+ });
325
298
 
326
- let selection_bbox = null;
299
+ let selection_bbox = null;
327
300
 
328
- if (this.selection && this.selection.start && this.selection.end) {
329
- selection_bbox = this.clientToBbox(
330
- this.page,
331
- this.selection.start,
332
- this.selection.end
333
- );
334
- }
301
+ if (this.selection && this.selection.start && this.selection.end) {
302
+ selection_bbox = this.clientToBbox(
303
+ this.page,
304
+ this.selection.start,
305
+ this.selection.end
306
+ );
307
+ }
335
308
 
336
- const annotationToCreate = {
337
- document: this.documentId,
338
- span: this.spans,
339
- label: this.selectedLabel.id,
340
- is_correct: true,
341
- revised: false,
342
- };
309
+ const annotationToCreate = {
310
+ document: this.documentId,
311
+ span: span,
312
+ label: this.selectedLabel.id,
313
+ is_correct: true,
314
+ revised: false,
315
+ };
343
316
 
344
- if (selection_bbox) {
345
- annotationToCreate.selection_bbox = selection_bbox;
346
- }
317
+ if (selection_bbox) {
318
+ annotationToCreate.selection_bbox = selection_bbox;
319
+ }
347
320
 
348
- if (this.selectedSet.id) {
349
- annotationToCreate.annotation_set = this.selectedSet.id;
350
- } else {
351
- annotationToCreate.label_set = this.selectedSet.label_set.id;
352
- }
353
- this.$store
354
- .dispatch("document/createAnnotation", {
355
- annotation: annotationToCreate,
356
- })
357
- .catch((error) => {
358
- this.$store.dispatch("document/createErrorMessage", {
359
- error,
360
- serverErrorMessage: this.$t("server_error"),
361
- defaultErrorMessage: this.$t("error_creating_annotation"),
362
- });
363
- })
364
- .finally(() => {
365
- this.close();
366
- this.loading = false;
367
- });
321
+ if (this.selectedSet.id) {
322
+ annotationToCreate.annotation_set = this.selectedSet.id;
323
+ } else {
324
+ annotationToCreate.label_set = this.selectedSet.label_set.id;
368
325
  }
326
+ this.$store
327
+ .dispatch("document/createAnnotation", {
328
+ annotation: annotationToCreate,
329
+ })
330
+ .catch((error) => {
331
+ this.$store.dispatch("document/createErrorMessage", {
332
+ error,
333
+ serverErrorMessage: this.$t("server_error"),
334
+ defaultErrorMessage: this.$t("error_creating_annotation"),
335
+ });
336
+ })
337
+ .finally(() => {
338
+ this.close();
339
+ this.loading = false;
340
+ });
369
341
  },
370
342
  chooseLabelSet(labelSet) {
371
343
  // check if there's already a new entry for that label set to be created
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div>
2
+ <div v-observe-visibility="visibilityChanged">
3
3
  <DummyPage
4
- v-if="!loadedPage || !pageInVisibleRange(page)"
4
+ v-if="!loadedPage"
5
5
  :width="page.size[0]"
6
6
  :height="page.size[1]"
7
7
  />
@@ -179,6 +179,14 @@ export default {
179
179
  this.pageBeingLoaded = false;
180
180
  });
181
181
  },
182
+ visibilityChanged(isVisible) {
183
+ if (isVisible && !this.loadedPage && !this.pageBeingLoaded) {
184
+ this.loadPage();
185
+ }
186
+ if (!isVisible && this.loadedPage) {
187
+ this.$store.dispatch("document/unloadDocumentPage", this.page.number);
188
+ }
189
+ },
182
190
  pageInVisibleRange(page) {
183
191
  return (
184
192
  this.currentPage === page.number ||
@@ -1,6 +1,9 @@
1
1
  <template>
2
- <div class="loading-thumbnail">
3
- <b-skeleton width="40px" height="57px" />
2
+ <div>
3
+ <b-skeleton
4
+ width="40px"
5
+ height="57px"
6
+ />
4
7
  </div>
5
8
  </template>
6
9
 
@@ -11,7 +14,7 @@
11
14
  */
12
15
 
13
16
  export default {
14
- name: "LoadingThumbnail",
17
+ name: "LoadingThumbnail"
15
18
  };
16
19
  </script>
17
20
 
@@ -159,7 +159,7 @@ export default {
159
159
  created() {
160
160
  window.addEventListener("resize", this.handleResize);
161
161
  },
162
- unmounted() {
162
+ destroyed() {
163
163
  window.removeEventListener("resize", this.handleResize);
164
164
  },
165
165
  mounted() {
@@ -174,9 +174,7 @@ export default {
174
174
  this.$store.dispatch("document/setErrorMessageWidth", width);
175
175
  },
176
176
  handleResize() {
177
- if (this.$refs.documentTopBar) {
178
- this.setComponentWidth(this.$refs.documentTopBar.offsetWidth);
179
- }
177
+ this.setComponentWidth(this.$refs.documentTopBar.offsetWidth);
180
178
  },
181
179
  getPreviousAndNextDocuments(filteredDocuments) {
182
180
  if (!filteredDocuments) return;
package/src/constants.js CHANGED
@@ -2,4 +2,10 @@ export const PIXEL_RATIO = window.devicePixelRatio || 1;
2
2
  export const VIEWPORT_RATIO = 0.98;
3
3
  export const MINIMUM_APP_WIDTH = 600;
4
4
  export const MINIMUM_OPTIMIZED_APP_WIDTH = 950;
5
- export const TEXT_BREAKPOINT_WIDTH = 1800;
5
+ export const TEXT_BREAKPOINT_WIDTH = (locale) => {
6
+ if (locale === "en") {
7
+ return 1350;
8
+ } else {
9
+ return 1800;
10
+ }
11
+ };
package/src/i18n.js CHANGED
@@ -1,4 +1,7 @@
1
- import { createI18n } from "vue-i18n";
1
+ import Vue from "vue";
2
+ import VueI18n from "vue-i18n";
3
+
4
+ Vue.use(VueI18n);
2
5
 
3
6
  function loadLocaleMessages() {
4
7
  const locales = require.context(
@@ -17,7 +20,7 @@ function loadLocaleMessages() {
17
20
  return messages;
18
21
  }
19
22
 
20
- export const i18n = createI18n({
23
+ export default new VueI18n({
21
24
  locale: process.env.VUE_APP_LOCALE || "en",
22
25
  fallbackLocale: "en",
23
26
  messages: loadLocaleMessages(),
package/src/main.js CHANGED
@@ -1,26 +1,28 @@
1
1
  import App from "./components/App";
2
- import { createApp } from "vue";
2
+ import Vue from "vue";
3
3
  import Buefy from "buefy";
4
4
  import VueKonva from "vue-konva";
5
- import { i18n } from "./i18n";
6
- import { store } from "./store";
7
- import VueObserveVisibility from "vue3-observe-visibility";
5
+ import i18n from "./i18n";
6
+ import store from "./store";
7
+ import VueObserveVisibility from "vue-observe-visibility";
8
8
  import Icons from "./icons";
9
+ import VueSplit from "vue-split-panel";
9
10
 
10
- const app = createApp();
11
-
12
- app.component("App", App);
13
- app.component("VueFontawesome", Icons);
14
- app.use(VueKonva);
15
- app.use(Buefy, {
11
+ Vue.component("VueFontawesome", Icons);
12
+ Vue.component("App", App);
13
+ Vue.use(VueKonva);
14
+ Vue.use(Buefy, {
16
15
  defaultIconPack: "fas",
17
16
  defaultIconComponent: "vue-fontawesome",
18
17
  });
19
- app.use(VueObserveVisibility);
20
- app.use(store);
21
- app.use(i18n);
18
+ Vue.use(VueObserveVisibility);
19
+ Vue.use(VueSplit);
22
20
 
23
21
  /**
24
22
  * Main entrypoint for the App
25
23
  */
26
- app.mount("#app");
24
+ new Vue({
25
+ i18n,
26
+ store,
27
+ el: "#app",
28
+ });
@@ -113,43 +113,32 @@ const getters = {
113
113
  * image rendering.
114
114
  */
115
115
  imageScale: (state) => (page) => {
116
- if (
117
- page.size &&
118
- page.size.length > 0 &&
119
- page.original_size &&
120
- page.original_size.length > 0
121
- ) {
122
- return new BigNumber(page.size[0]).div(page.original_size[0]).toNumber();
123
- }
124
- return 0;
116
+ return new BigNumber(page.size[0]).div(page.original_size[0]).toNumber();
125
117
  },
126
118
  bboxToPoint:
127
119
  (state, getters) =>
128
120
  (page, point, hasOffset = false) => {
129
- if (page && page.original_size && page.original_size.length > 1) {
130
- const imageScale = getters.imageScale(page);
131
- const { x, y } = point;
132
- const pageHeight = new BigNumber(page.original_size[1]);
133
- const newPoint = {
134
- // left
135
- x: new BigNumber(x)
136
- .minus(hasOffset ? 1 : 0)
137
- .times(state.scale)
138
- .times(imageScale)
139
- .div(PIXEL_RATIO)
140
- .toNumber(),
141
- // top
142
- y: pageHeight
143
- .minus(new BigNumber(y))
144
- .minus(hasOffset ? 17.1 : 0)
145
- .times(state.scale)
146
- .times(imageScale)
147
- .div(PIXEL_RATIO)
148
- .toNumber(),
149
- };
150
- return newPoint;
151
- }
152
- return { x: 0, y: 0 };
121
+ const imageScale = getters.imageScale(page);
122
+ const { x, y } = point;
123
+ const pageHeight = new BigNumber(page.original_size[1]);
124
+ const newPoint = {
125
+ // left
126
+ x: new BigNumber(x)
127
+ .minus(hasOffset ? 1 : 0)
128
+ .times(state.scale)
129
+ .times(imageScale)
130
+ .div(PIXEL_RATIO)
131
+ .toNumber(),
132
+ // top
133
+ y: pageHeight
134
+ .minus(new BigNumber(y))
135
+ .minus(hasOffset ? 17.1 : 0)
136
+ .times(state.scale)
137
+ .times(imageScale)
138
+ .div(PIXEL_RATIO)
139
+ .toNumber(),
140
+ };
141
+ return newPoint;
153
142
  },
154
143
  bboxToRect:
155
144
  (state, getters) =>
@@ -270,11 +259,8 @@ const actions = {
270
259
  commit("SET_SCALE", autoScale);
271
260
  break;
272
261
  case "all": {
273
- commit(
274
- "SET_SCALE",
275
- getters.pageWidthScale(elementsWidth, client.width, viewport.width) -
276
- 0.5
277
- );
262
+ const widthScale = getters.pageWidthScale(elementsWidth, client.width, viewport.width);
263
+ commit("SET_SCALE", widthScale);
278
264
  break;
279
265
  }
280
266
  case "custom": {
@@ -1134,7 +1134,6 @@ const actions = {
1134
1134
  // Check if we first open the document dashboard or the edit mode
1135
1135
  if (
1136
1136
  !state.publicView &&
1137
- state.selectedDocument &&
1138
1137
  (!state.selectedDocument.category ||
1139
1138
  (!state.selectedDocument.category_is_revised &&
1140
1139
  !getters.documentHasCorrectAnnotations &&
@@ -1542,6 +1541,9 @@ const actions = {
1542
1541
  showAcceptedAnnotations({ commit }, show) {
1543
1542
  commit("SET_SHOW_ACCEPTED_ANNOTATIONS", show);
1544
1543
  },
1544
+ unloadDocumentPage: ({ commit }, pageNumber) => {
1545
+ commit("REMOVE_PAGE", pageNumber);
1546
+ },
1545
1547
  };
1546
1548
 
1547
1549
  const mutations = {
@@ -1815,6 +1817,9 @@ const mutations = {
1815
1817
  SET_SHOW_FEEDBACK_NEEDED_ANNOTATIONS: (state, show) => {
1816
1818
  state.annotationFilters.showFeedbackNeeded = show;
1817
1819
  },
1820
+ REMOVE_PAGE: (state, pageNumber) => {
1821
+ state.pages = state.pages.filter((p) => p.number !== pageNumber);
1822
+ },
1818
1823
  };
1819
1824
 
1820
1825
  export default {
@@ -1,4 +1,5 @@
1
- import { createStore } from "vuex";
1
+ import Vue from "vue";
2
+ import Vuex from "vuex";
2
3
 
3
4
  import display from "./display";
4
5
  import document from "./document";
@@ -7,13 +8,15 @@ import project from "./project";
7
8
  import selection from "./selection";
8
9
  import edit from "./edit";
9
10
 
10
- export const store = createStore({
11
+ Vue.use(Vuex);
12
+
13
+ export default new Vuex.Store({
11
14
  modules: {
12
15
  display,
13
16
  document,
14
17
  category,
15
18
  project,
16
19
  selection,
17
- edit,
18
- },
19
- });
20
+ edit
21
+ }
22
+ });