@konfuzio/document-validation-ui 0.2.0-dev.2 → 0.2.1-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.2.0-dev.2",
3
+ "version": "0.2.1-dev.0",
4
4
  "repository": "https://github.com/konfuzio-ai/document-validation-ui",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "sass-loader": "^16.0.5",
36
36
  "splitpanes": "^3.1.8",
37
37
  "vue": "^3.5.13",
38
- "vue-i18n": "^10.0.5",
38
+ "vue-i18n": "^10.0.6",
39
39
  "vue-konva": "^3.2.0",
40
40
  "vue3-observe-visibility": "^1.0.3",
41
41
  "vuedraggable": "^4.1.0",
@@ -105,6 +105,7 @@ export default {
105
105
  data() {
106
106
  return {
107
107
  currentPercentage: 100,
108
+ fitWidthScale: 1, // baseline for 100%
108
109
  maxPercentage: 500,
109
110
  defaultPercentage: 0.25,
110
111
  fitPercentage: 0.5,
@@ -136,6 +137,13 @@ export default {
136
137
  this.editModeDisabled = true;
137
138
  }
138
139
  },
140
+ scale(newScale) {
141
+ if (this.fitWidthScale > 0) {
142
+ this.currentPercentage = Math.round((newScale / this.fitWidthScale) * 100);
143
+ } else {
144
+ this.currentPercentage = Math.round(newScale * 100);
145
+ }
146
+ },
139
147
  },
140
148
  mounted() {
141
149
  if (this.selectedDocument) {
@@ -178,12 +186,13 @@ export default {
178
186
  this.updateScale(this.scale - this.defaultPercentage);
179
187
  },
180
188
  fitAuto() {
181
- // exit edit mode of Annotation if changing zoom during editing
182
189
  this.cancelAnnotationEditMode();
183
-
184
- // Always set to 50%
185
- this.currentPercentage = 50;
186
- this.$store.dispatch("display/updateFit", "all");
190
+ this.$store.dispatch("display/updateFit", "all").then(() => {
191
+ this.$nextTick(() => {
192
+ this.fitWidthScale = this.scale;
193
+ this.currentPercentage = 100;
194
+ });
195
+ });
187
196
  },
188
197
  updateScale(scale) {
189
198
  this.$store.dispatch("display/updateFit", "custom").then(() => {
@@ -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 ||
@@ -270,11 +270,8 @@ const actions = {
270
270
  commit("SET_SCALE", autoScale);
271
271
  break;
272
272
  case "all": {
273
- commit(
274
- "SET_SCALE",
275
- getters.pageWidthScale(elementsWidth, client.width, viewport.width) -
276
- 0.5
277
- );
273
+ const widthScale = getters.pageWidthScale(elementsWidth, client.width, viewport.width);
274
+ commit("SET_SCALE", widthScale);
278
275
  break;
279
276
  }
280
277
  case "custom": {
@@ -1604,6 +1604,12 @@ const actions = {
1604
1604
  showAcceptedAnnotations({ commit }, show) {
1605
1605
  commit("SET_SHOW_ACCEPTED_ANNOTATIONS", show);
1606
1606
  },
1607
+ unloadDocumentPage: ({ commit }, pageNumber) => {
1608
+ commit("REMOVE_PAGE", pageNumber);
1609
+ },
1610
+ putNextAnnotationInLabelFirst({ commit }, label) {
1611
+ commit("PUT_NEXT_ANN_IN_LABEL_FIRST", label);
1612
+ },
1607
1613
  setAnnotationAsFirstInLabel({ commit, state }, { label, annotation }) {
1608
1614
  state.annotationSets.forEach((annotationSet) => {
1609
1615
  annotationSet.labels.forEach((labelToFind) => {
@@ -1935,6 +1941,9 @@ const mutations = {
1935
1941
  SET_SHOW_FEEDBACK_NEEDED_ANNOTATIONS: (state, show) => {
1936
1942
  state.annotationFilters.showFeedbackNeeded = show;
1937
1943
  },
1944
+ REMOVE_PAGE: (state, pageNumber) => {
1945
+ state.pages = state.pages.filter((p) => p.number !== pageNumber);
1946
+ },
1938
1947
  };
1939
1948
 
1940
1949
  export default {