@konfuzio/document-validation-ui 0.1.5-pre-release-1 → 0.1.5-styles-refactor
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/dist/css/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/api.js +31 -21
- package/src/assets/images/ServerImage.vue +7 -6
- package/src/assets/scss/main.scss +666 -7
- package/src/assets/scss/variables.scss +0 -657
- package/src/components/App.vue +3 -2
- package/src/components/DocumentAnnotations/AnnotationContent.vue +1 -1
- package/src/components/DocumentEdit/DocumentEdit.vue +9 -13
- package/src/components/DocumentPage/DocumentPage.vue +9 -7
- package/src/components/DocumentPage/ScrollingDocument.vue +32 -2
- package/src/components/DocumentPage/ScrollingPage.vue +4 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +14 -11
- package/src/store/display.js +7 -0
- package/src/store/document.js +17 -12
- package/src/store/edit.js +2 -2
|
@@ -438,19 +438,21 @@ export default {
|
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
440
|
const image = new Image();
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
if (process.env.NODE_ENV === "test") {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
api
|
|
445
|
+
.makeImageRequest(
|
|
446
|
+
`${this.page.image_url}?${this.selectedDocument.downloaded_at}`
|
|
447
|
+
)
|
|
447
448
|
.then((myBlob) => {
|
|
448
449
|
image.src = URL.createObjectURL(myBlob);
|
|
449
450
|
image.onload = () => {
|
|
450
451
|
// set image only when it is loaded
|
|
451
452
|
this.image = image;
|
|
452
453
|
};
|
|
453
|
-
})
|
|
454
|
+
})
|
|
455
|
+
.catch((error) => {});
|
|
454
456
|
},
|
|
455
457
|
|
|
456
458
|
/**
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<ScrollingPage
|
|
14
14
|
v-for="page in editMode ? documentPagesListForEditMode : pages"
|
|
15
15
|
:key="page.number"
|
|
16
|
+
ref="scrollingPage"
|
|
16
17
|
:page="page"
|
|
17
18
|
:client-height="clientHeight"
|
|
18
19
|
:scroll-top="scrollTop"
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
</div>
|
|
30
31
|
</template>
|
|
31
32
|
<script>
|
|
32
|
-
import { mapState } from "vuex";
|
|
33
|
+
import { mapState, mapGetters } from "vuex";
|
|
33
34
|
import scroll from "../../directives/scroll";
|
|
34
35
|
import ScrollingPage from "./ScrollingPage";
|
|
35
36
|
import Toolbar from "./DocumentToolbar";
|
|
@@ -49,6 +50,8 @@ export default {
|
|
|
49
50
|
return {
|
|
50
51
|
scrollTop: 0,
|
|
51
52
|
clientHeight: 0,
|
|
53
|
+
isScolling: false,
|
|
54
|
+
scrollTimeout: null,
|
|
52
55
|
};
|
|
53
56
|
},
|
|
54
57
|
|
|
@@ -59,7 +62,13 @@ export default {
|
|
|
59
62
|
"loading",
|
|
60
63
|
]),
|
|
61
64
|
...mapState("edit", ["editMode", "documentPagesListForEditMode"]),
|
|
62
|
-
...mapState("display", [
|
|
65
|
+
...mapState("display", [
|
|
66
|
+
"scale",
|
|
67
|
+
"documentActionBar",
|
|
68
|
+
"pageChangedFromThumbnail",
|
|
69
|
+
"currentPage",
|
|
70
|
+
]),
|
|
71
|
+
...mapGetters("display", ["visiblePageRange"]),
|
|
63
72
|
|
|
64
73
|
pages() {
|
|
65
74
|
if (this.selectedDocument) {
|
|
@@ -85,6 +94,9 @@ export default {
|
|
|
85
94
|
this.scrollTop = 0;
|
|
86
95
|
},
|
|
87
96
|
},
|
|
97
|
+
mounted() {
|
|
98
|
+
this.$refs.scrollingDocument.addEventListener("scroll", this.handleScroll);
|
|
99
|
+
},
|
|
88
100
|
|
|
89
101
|
methods: {
|
|
90
102
|
updateScrollBounds() {
|
|
@@ -102,6 +114,24 @@ export default {
|
|
|
102
114
|
|
|
103
115
|
this.$refs.scrollingDocument.scroll(scrollX, scrollY);
|
|
104
116
|
},
|
|
117
|
+
handleScroll() {
|
|
118
|
+
if (this.pages.length === 1) return;
|
|
119
|
+
|
|
120
|
+
this.isScrolling = true;
|
|
121
|
+
|
|
122
|
+
clearTimeout(this.scrollTimeout);
|
|
123
|
+
|
|
124
|
+
this.scrollTimeout = setTimeout(() => {
|
|
125
|
+
this.isScrolling = false;
|
|
126
|
+
|
|
127
|
+
if (
|
|
128
|
+
this.pageChangedFromThumbnail &&
|
|
129
|
+
this.visiblePageRange[1] === this.currentPage
|
|
130
|
+
) {
|
|
131
|
+
this.$store.dispatch("display/setPageChangedFromThumbnail", false);
|
|
132
|
+
}
|
|
133
|
+
}, 300);
|
|
134
|
+
},
|
|
105
135
|
},
|
|
106
136
|
};
|
|
107
137
|
</script>
|
|
@@ -44,10 +44,12 @@ export default {
|
|
|
44
44
|
previousFocusedAnnotation: null,
|
|
45
45
|
previousY: null,
|
|
46
46
|
pageBeingLoaded: false,
|
|
47
|
+
isScrolling: false,
|
|
47
48
|
};
|
|
48
49
|
},
|
|
49
50
|
|
|
50
51
|
computed: {
|
|
52
|
+
...mapState("display", ["pageChangedFromThumbnail"]),
|
|
51
53
|
...mapGetters("display", ["visiblePageRange", "bboxToRect"]),
|
|
52
54
|
...mapGetters("document", ["scrollDocumentToAnnotation"]),
|
|
53
55
|
|
|
@@ -117,15 +119,12 @@ export default {
|
|
|
117
119
|
}
|
|
118
120
|
},
|
|
119
121
|
isElementFocused(focused) {
|
|
120
|
-
if (!this.loading && focused) {
|
|
122
|
+
if (!this.loading && focused && !this.pageChangedFromThumbnail) {
|
|
121
123
|
this.$store.dispatch("display/updateCurrentPage", this.page.number);
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
currentPage(number) {
|
|
125
|
-
if (
|
|
126
|
-
(this.page.number === number || this.page.number === number) &&
|
|
127
|
-
!this.isElementFocused
|
|
128
|
-
) {
|
|
127
|
+
if (this.page.number === number && !this.isElementFocused) {
|
|
129
128
|
this.$emit("page-jump", this.elementTop, 0);
|
|
130
129
|
}
|
|
131
130
|
},
|
|
@@ -62,7 +62,7 @@ export default {
|
|
|
62
62
|
},
|
|
63
63
|
data() {
|
|
64
64
|
return {
|
|
65
|
-
thumbnailClicked:
|
|
65
|
+
thumbnailClicked: null,
|
|
66
66
|
previousScrollPosition: 0,
|
|
67
67
|
};
|
|
68
68
|
},
|
|
@@ -76,9 +76,10 @@ export default {
|
|
|
76
76
|
},
|
|
77
77
|
watch: {
|
|
78
78
|
currentPage(newPage) {
|
|
79
|
-
if (newPage
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
if (!newPage) return;
|
|
80
|
+
|
|
81
|
+
// handle thumbnail selection when scrolling the document
|
|
82
|
+
this.scrollToThumbnail(newPage);
|
|
82
83
|
},
|
|
83
84
|
},
|
|
84
85
|
mounted() {
|
|
@@ -94,27 +95,29 @@ export default {
|
|
|
94
95
|
methods: {
|
|
95
96
|
/* Change page if not the currently open and not in modal */
|
|
96
97
|
changePage(pageNumber) {
|
|
97
|
-
this.thumbnailClicked =
|
|
98
|
+
this.thumbnailClicked = pageNumber;
|
|
98
99
|
|
|
99
100
|
if (
|
|
100
101
|
!this.loading &&
|
|
101
102
|
!this.recalculatingAnnotations &&
|
|
102
103
|
pageNumber != this.currentPage
|
|
103
104
|
) {
|
|
104
|
-
this.$store.dispatch(
|
|
105
|
-
|
|
106
|
-
parseInt(pageNumber, 10)
|
|
107
|
-
);
|
|
105
|
+
this.$store.dispatch("display/setPageChangedFromThumbnail", true);
|
|
106
|
+
this.$store.dispatch("display/updateCurrentPage", pageNumber);
|
|
108
107
|
}
|
|
109
108
|
},
|
|
110
109
|
|
|
111
|
-
scrollToThumbnail() {
|
|
110
|
+
scrollToThumbnail(page) {
|
|
112
111
|
// select only the active thumbnail
|
|
113
112
|
const selectedPage = this.$refs.docPage.filter((image) =>
|
|
114
113
|
image.className.includes("selected")
|
|
115
114
|
);
|
|
116
115
|
|
|
117
|
-
if (
|
|
116
|
+
if (page == this.thumbnailClicked) {
|
|
117
|
+
this.thumbnailClicked = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!this.thumbnailClicked && selectedPage && selectedPage[0]) {
|
|
118
121
|
selectedPage[0].scrollIntoView();
|
|
119
122
|
}
|
|
120
123
|
},
|
package/src/store/display.js
CHANGED
|
@@ -29,6 +29,7 @@ const state = {
|
|
|
29
29
|
interactionBlocked: false,
|
|
30
30
|
documentActionBar: null, // document action bar properties
|
|
31
31
|
categorizeModalIsActive: false,
|
|
32
|
+
pageChangedFromThumbnail: false,
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
const getters = {
|
|
@@ -209,6 +210,9 @@ const actions = {
|
|
|
209
210
|
setCategorizeModalIsActive: ({ commit }, value) => {
|
|
210
211
|
commit("SET_CATEGORIZE_MODAL_IS_ACTIVE", value);
|
|
211
212
|
},
|
|
213
|
+
setPageChangedFromThumbnail: ({ commit }, value) => {
|
|
214
|
+
commit("SET_PAGE_CHANGED_FROM_THUMBNAIL", value);
|
|
215
|
+
},
|
|
212
216
|
};
|
|
213
217
|
|
|
214
218
|
const mutations = {
|
|
@@ -235,6 +239,9 @@ const mutations = {
|
|
|
235
239
|
SET_CATEGORIZE_MODAL_IS_ACTIVE: (state, value) => {
|
|
236
240
|
state.categorizeModalIsActive = value;
|
|
237
241
|
},
|
|
242
|
+
SET_PAGE_CHANGED_FROM_THUMBNAIL: (state, value) => {
|
|
243
|
+
state.pageChangedFromThumbnail = value;
|
|
244
|
+
},
|
|
238
245
|
};
|
|
239
246
|
|
|
240
247
|
export default {
|
package/src/store/document.js
CHANGED
|
@@ -811,16 +811,20 @@ const actions = {
|
|
|
811
811
|
},
|
|
812
812
|
|
|
813
813
|
fetchMissingAnnotations: ({ commit, state, getters }) => {
|
|
814
|
-
return
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
814
|
+
return new Promise((resolve, reject) => {
|
|
815
|
+
return HTTP.get(
|
|
816
|
+
`/missing-annotations/?document=${state.documentId}&limit=100`
|
|
817
|
+
)
|
|
818
|
+
.then((response) => {
|
|
819
|
+
commit("SET_MISSING_ANNOTATIONS", response.data.results);
|
|
820
|
+
commit("SET_FINISHED_REVIEW", getters.isDocumentReviewFinished());
|
|
821
|
+
resolve(true);
|
|
822
|
+
})
|
|
823
|
+
.catch((error) => {
|
|
824
|
+
reject(error.response);
|
|
825
|
+
console.log(error);
|
|
826
|
+
});
|
|
827
|
+
});
|
|
824
828
|
},
|
|
825
829
|
|
|
826
830
|
addMissingAnnotations: ({ commit, dispatch }, missingAnnotations) => {
|
|
@@ -842,7 +846,7 @@ const actions = {
|
|
|
842
846
|
},
|
|
843
847
|
|
|
844
848
|
deleteMissingAnnotation: ({ commit, getters, dispatch }, id) => {
|
|
845
|
-
return new Promise((resolve) => {
|
|
849
|
+
return new Promise((resolve, reject) => {
|
|
846
850
|
return HTTP.delete(`/missing-annotations/${id}/`)
|
|
847
851
|
.then((response) => {
|
|
848
852
|
if (response.status === 204) {
|
|
@@ -851,7 +855,7 @@ const actions = {
|
|
|
851
855
|
}
|
|
852
856
|
})
|
|
853
857
|
.catch((error) => {
|
|
854
|
-
|
|
858
|
+
reject(error.response);
|
|
855
859
|
console.log(error);
|
|
856
860
|
});
|
|
857
861
|
});
|
|
@@ -899,6 +903,7 @@ const actions = {
|
|
|
899
903
|
}
|
|
900
904
|
})
|
|
901
905
|
.catch((error) => {
|
|
906
|
+
reject(error.response);
|
|
902
907
|
console.log(error);
|
|
903
908
|
});
|
|
904
909
|
});
|
package/src/store/edit.js
CHANGED
|
@@ -149,7 +149,7 @@ const actions = {
|
|
|
149
149
|
dispatch("document/startRecalculatingAnnotations", null, {
|
|
150
150
|
root: true,
|
|
151
151
|
});
|
|
152
|
-
return new Promise((resolve) => {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
153
|
HTTP.post(
|
|
154
154
|
`/documents/${rootState.document.documentId}/postprocess/`,
|
|
155
155
|
editedDocument
|
|
@@ -171,7 +171,7 @@ const actions = {
|
|
|
171
171
|
}
|
|
172
172
|
})
|
|
173
173
|
.catch((error) => {
|
|
174
|
-
|
|
174
|
+
reject(error.response);
|
|
175
175
|
console.log(error);
|
|
176
176
|
});
|
|
177
177
|
});
|