@konfuzio/document-validation-ui 0.1.13-dev.0 → 0.1.13-dev.2

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,12 +1,13 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.13-dev.0",
3
+ "version": "0.1.13-dev.2",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
7
7
  "serve": "vue-cli-service serve",
8
8
  "build": "vue-cli-service build --name DocumentValidationUi ./src/main.js",
9
9
  "test:unit": "vue-cli-service test:unit",
10
+ "cypress:open": "cypress open",
10
11
  "i18n:report": "vue-cli-service i18n:report --src \"./src/**/*.?(js|vue)\" --locales \"./src/locales/**/*.json\"",
11
12
  "lint": "vue-cli-service lint",
12
13
  "format": "prettier . --write",
@@ -52,6 +53,8 @@
52
53
  "@vue/test-utils": "^1.1.3",
53
54
  "@vue/vue2-jest": "^27.0.0",
54
55
  "babel-jest": "^27.0.6",
56
+ "cypress": "^12.17.3",
57
+ "dotenv": "^16.3.1",
55
58
  "eslint": "^8.30.0",
56
59
  "eslint-config-prettier": "^8.6.0",
57
60
  "eslint-plugin-vue": "^9.8.0",
@@ -0,0 +1,7 @@
1
+ import App from "./App.vue";
2
+
3
+ describe("<App />", () => {
4
+ it("renders the app", () => {
5
+ cy.mount(App);
6
+ });
7
+ });
@@ -113,6 +113,11 @@ export default {
113
113
  this.onDocumentResize();
114
114
  }
115
115
  },
116
+ fit(newFit, oldFit) {
117
+ if (newFit !== oldFit) {
118
+ this.onDocumentResize();
119
+ }
120
+ },
116
121
  },
117
122
  mounted() {
118
123
  this.resizeObserver = new ResizeObserver(this.onDocumentResize);
@@ -247,11 +247,7 @@ export default {
247
247
  },
248
248
 
249
249
  ...mapState("selection", ["isSelecting", "selectedEntities"]),
250
- ...mapState("display", [
251
- "scale",
252
- "optimalScale",
253
- "categorizeModalIsActive",
254
- ]),
250
+ ...mapState("display", ["scale", "categorizeModalIsActive"]),
255
251
  ...mapState("document", [
256
252
  "documentAnnotationSelected",
257
253
  "recalculatingAnnotations",
@@ -27,7 +27,14 @@
27
27
  class="toolbar-divider"
28
28
  />
29
29
  <div class="icons icons-right">
30
- <div class="fit-zoom icon" @click.prevent.stop="fitAuto">
30
+ <div
31
+ :class="[
32
+ 'fit-zoom',
33
+ 'icon',
34
+ currentPercentage === 50 && 'zoom-disabled',
35
+ ]"
36
+ @click.prevent.stop="fitAuto"
37
+ >
31
38
  <FitZoomIcon />
32
39
  </div>
33
40
  <div
@@ -67,7 +74,6 @@ export default {
67
74
  },
68
75
  data() {
69
76
  return {
70
- defaultScale: null,
71
77
  currentPercentage: 100,
72
78
  maxPercentage: 500,
73
79
  defaultPercentage: 0.25,
@@ -101,8 +107,6 @@ export default {
101
107
  },
102
108
  },
103
109
  mounted() {
104
- this.defaultScale = this.scale;
105
-
106
110
  if (this.selectedDocument) {
107
111
  if (this.documentCannotBeEdited(this.selectedDocument)) {
108
112
  this.editModeDisabled = true;
@@ -127,9 +131,8 @@ export default {
127
131
 
128
132
  // exit edit mode of Annotation if changing zoom during editing
129
133
  this.cancelAnnotationEditMode();
130
-
131
134
  this.currentPercentage += this.defaultPercentage * 100;
132
- this.updateScale((this.defaultScale * this.currentPercentage) / 100);
135
+ this.updateScale(this.scale + this.defaultPercentage);
133
136
  },
134
137
  zoomOut() {
135
138
  if (this.currentPercentage === this.defaultPercentage * 100) {
@@ -140,18 +143,15 @@ export default {
140
143
  this.cancelAnnotationEditMode();
141
144
 
142
145
  this.currentPercentage -= this.defaultPercentage * 100;
143
- this.updateScale((this.defaultScale * this.currentPercentage) / 100);
146
+ this.updateScale(this.scale - this.defaultPercentage);
144
147
  },
145
148
  fitAuto() {
146
- if (this.currentPercentage === 50 || !this.defaultScale) return;
147
-
148
149
  // exit edit mode of Annotation if changing zoom during editing
149
150
  this.cancelAnnotationEditMode();
150
151
 
151
152
  // Always set to 50%
152
- this.updateScale(this.defaultScale * this.fitPercentage);
153
-
154
- this.currentPercentage = this.fitPercentage * 100;
153
+ this.currentPercentage = 50;
154
+ this.$store.dispatch("display/updateFit", "all");
155
155
  },
156
156
  updateScale(scale) {
157
157
  this.$store.dispatch("display/updateFit", "custom").then(() => {
package/src/icons.js ADDED
@@ -0,0 +1,43 @@
1
+ // internal icons
2
+ import { library } from "@fortawesome/fontawesome-svg-core";
3
+ import {
4
+ faArrowUp,
5
+ faAngleRight,
6
+ faAngleLeft,
7
+ faAngleUp,
8
+ faAngleDown,
9
+ faSpinner,
10
+ faPlus,
11
+ faXmark,
12
+ faEllipsisVertical,
13
+ faCircleInfo,
14
+ faArrowRotateLeft,
15
+ faArrowRotateRight,
16
+ faScissors,
17
+ faRepeat,
18
+ faArrowLeft,
19
+ faArrowRight,
20
+ } from "@fortawesome/free-solid-svg-icons";
21
+ import { FontAwesomeIcon as Icons } from "@fortawesome/vue-fontawesome";
22
+
23
+ library.add(
24
+ faArrowUp,
25
+ faAngleRight,
26
+ faAngleLeft,
27
+ faAngleUp,
28
+ faAngleDown,
29
+ faSpinner,
30
+ faXmark,
31
+ faSpinner,
32
+ faPlus,
33
+ faEllipsisVertical,
34
+ faCircleInfo,
35
+ faArrowRotateLeft,
36
+ faArrowRotateRight,
37
+ faScissors,
38
+ faRepeat,
39
+ faArrowLeft,
40
+ faArrowRight
41
+ );
42
+
43
+ export default Icons;
package/src/main.js CHANGED
@@ -1,53 +1,13 @@
1
+ import App from "./components/App";
1
2
  import Vue from "vue";
2
3
  import Buefy from "buefy";
3
4
  import VueKonva from "vue-konva";
4
- import App from "./components/App";
5
5
  import i18n from "./i18n";
6
6
  import store from "./store";
7
- import { library } from "@fortawesome/fontawesome-svg-core";
8
7
  import VueObserveVisibility from "vue-observe-visibility";
8
+ import Icons from "./icons";
9
9
 
10
- // internal icons
11
- import {
12
- faArrowUp,
13
- faAngleRight,
14
- faAngleLeft,
15
- faAngleUp,
16
- faAngleDown,
17
- faSpinner,
18
- faPlus,
19
- faXmark,
20
- faEllipsisVertical,
21
- faCircleInfo,
22
- faArrowRotateLeft,
23
- faArrowRotateRight,
24
- faScissors,
25
- faRepeat,
26
- faArrowLeft,
27
- faArrowRight,
28
- } from "@fortawesome/free-solid-svg-icons";
29
- import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
30
-
31
- library.add(
32
- faArrowUp,
33
- faAngleRight,
34
- faAngleLeft,
35
- faAngleUp,
36
- faAngleDown,
37
- faSpinner,
38
- faXmark,
39
- faSpinner,
40
- faPlus,
41
- faEllipsisVertical,
42
- faCircleInfo,
43
- faArrowRotateLeft,
44
- faArrowRotateRight,
45
- faScissors,
46
- faRepeat,
47
- faArrowLeft,
48
- faArrowRight
49
- );
50
- Vue.component("VueFontawesome", FontAwesomeIcon);
10
+ Vue.component("VueFontawesome", Icons);
51
11
  Vue.component("App", App);
52
12
  Vue.use(VueKonva);
53
13
  Vue.use(Buefy, {
@@ -22,7 +22,6 @@ const floor = (value, precision) => {
22
22
 
23
23
  const state = {
24
24
  scale: undefined,
25
- optimalScale: undefined,
26
25
  fit: "width",
27
26
  currentPage: 1,
28
27
  optimalResolution: true,
@@ -202,6 +201,14 @@ const actions = {
202
201
  const autoScale = Math.min(pageWidthScale, pageHeightScale);
203
202
  commit("SET_SCALE", autoScale);
204
203
  break;
204
+ case "all": {
205
+ commit(
206
+ "SET_SCALE",
207
+ getters.pageWidthScale(elementsWidth, client.width, viewport.width) -
208
+ 0.5
209
+ );
210
+ break;
211
+ }
205
212
  case "custom": {
206
213
  if (scale) {
207
214
  commit("SET_SCALE", scale);