@konfuzio/document-validation-ui 0.1.19-dev.2 → 0.1.19
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/.eslintrc.js +10 -10
- package/.prettierrc.json +1 -1
- package/LICENSE +21 -21
- package/README.md +24 -24
- package/cypress.config.js +13 -13
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/dist/js/chunk-vendors.js +1 -1
- package/dist/js/chunk-vendors.js.map +1 -1
- package/jest.config.js +4 -4
- package/package.json +66 -66
- package/src/api.js +82 -82
- package/src/assets/images/AcceptedCheckMark.vue +8 -8
- package/src/assets/images/AcceptedUser.vue +8 -8
- package/src/assets/images/ActionIcon.vue +60 -60
- package/src/assets/images/ArrowDownKey.vue +11 -11
- package/src/assets/images/ArrowUpKey.vue +11 -11
- package/src/assets/images/CategoryIconImg.vue +13 -13
- package/src/assets/images/CheckMark.vue +8 -8
- package/src/assets/images/DraggableIcon.vue +14 -14
- package/src/assets/images/EditDocIcon.vue +12 -12
- package/src/assets/images/EmptyStateImg.vue +129 -129
- package/src/assets/images/ErrorIcon.vue +28 -28
- package/src/assets/images/EyeIcon.vue +11 -11
- package/src/assets/images/FileNameNotSavedImage.vue +26 -26
- package/src/assets/images/FileNameSavedImage.vue +14 -14
- package/src/assets/images/FitZoomIcon.vue +16 -16
- package/src/assets/images/GridIcon.vue +16 -16
- package/src/assets/images/KeyboardIcon.vue +16 -16
- package/src/assets/images/MagicWandIcon.vue +16 -16
- package/src/assets/images/MinusIcon.vue +13 -13
- package/src/assets/images/NotFoundIcon.vue +16 -16
- package/src/assets/images/NotOptimizedIllustration.vue +651 -651
- package/src/assets/images/PlusIcon.vue +13 -13
- package/src/assets/images/QuestionMark.vue +12 -12
- package/src/assets/images/ServerImage.vue +73 -73
- package/src/assets/images/SettingsIcon.vue +14 -14
- package/src/assets/images/SplitLines.vue +18 -18
- package/src/assets/images/SplitZigZag.vue +49 -49
- package/src/assets/images/StarIcon.vue +16 -16
- package/src/assets/images/StatusImg.vue +14 -14
- package/src/assets/images/TranslateArrows.vue +33 -33
- package/src/assets/scss/ann_set_table_options.scss +26 -26
- package/src/assets/scss/annotation_details.scss +141 -141
- package/src/assets/scss/choose_label_set_modal.scss +65 -65
- package/src/assets/scss/document_action_bar.scss +37 -37
- package/src/assets/scss/document_annotations.scss +558 -558
- package/src/assets/scss/document_category.scss +85 -85
- package/src/assets/scss/document_dashboard.scss +52 -52
- package/src/assets/scss/document_edit.scss +410 -410
- package/src/assets/scss/document_error.scss +81 -81
- package/src/assets/scss/document_name.scss +60 -60
- package/src/assets/scss/document_page.scss +12 -12
- package/src/assets/scss/document_thumbnails.scss +41 -41
- package/src/assets/scss/document_toolbar.scss +111 -111
- package/src/assets/scss/document_top_bar.scss +171 -171
- package/src/assets/scss/document_viewport_modal.scss +25 -25
- package/src/assets/scss/documents_list.scss +141 -141
- package/src/assets/scss/edit_page_thumbnail.scss +53 -53
- package/src/assets/scss/empty_state.scss +34 -34
- package/src/assets/scss/extracting_data.scss +35 -35
- package/src/assets/scss/imports.scss +1 -1
- package/src/assets/scss/multi_ann_table_overlay.scss +38 -38
- package/src/assets/scss/multi_ann_table_popup.scss +12 -12
- package/src/assets/scss/new_annotation.scss +102 -102
- package/src/assets/scss/scrolling_document.scss +19 -19
- package/src/assets/scss/theme.scss +801 -801
- package/src/assets/scss/variables.scss +66 -66
- package/src/components/App.cy.js +7 -7
- package/src/components/App.vue +187 -187
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +152 -152
- package/src/components/DocumentAnnotations/AnnotationContent.vue +210 -210
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +251 -251
- package/src/components/DocumentAnnotations/AnnotationRow.vue +752 -752
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -89
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +186 -186
- package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +441 -441
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +534 -534
- package/src/components/DocumentAnnotations/DocumentLabel.vue +189 -189
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +193 -193
- package/src/components/DocumentAnnotations/EmptyState.vue +21 -21
- package/src/components/DocumentAnnotations/ExtractingData.vue +41 -41
- package/src/components/DocumentAnnotations/LoadingAnnotations.vue +43 -43
- package/src/components/DocumentAnnotations/LoadingLabels.vue +43 -43
- package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +338 -338
- package/src/components/DocumentAnnotations/index.js +8 -8
- package/src/components/DocumentCategory.vue +281 -281
- package/src/components/DocumentDashboard.vue +170 -170
- package/src/components/DocumentEdit/DocumentEdit.cy.js +541 -541
- package/src/components/DocumentEdit/DocumentEdit.vue +503 -503
- package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -55
- package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -114
- package/src/components/DocumentEdit/EditPages.vue +161 -161
- package/src/components/DocumentEdit/EditSidebar.vue +154 -154
- package/src/components/DocumentEdit/RenameAndCategorize.vue +184 -184
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -53
- package/src/components/DocumentEdit/SplitInfoBar.vue +21 -21
- package/src/components/DocumentEdit/index.js +4 -4
- package/src/components/DocumentModals/DocumentErrorModal.vue +58 -58
- package/src/components/DocumentModals/NotOptimizedViewportModal.vue +51 -51
- package/src/components/DocumentPage/ActionBar.vue +48 -48
- package/src/components/DocumentPage/AnnSetTableOptions.vue +111 -111
- package/src/components/DocumentPage/BoxSelection.vue +152 -152
- package/src/components/DocumentPage/DocumentPage.cy.js +92 -92
- package/src/components/DocumentPage/DocumentPage.vue +568 -568
- package/src/components/DocumentPage/DocumentToolbar.cy.js +215 -215
- package/src/components/DocumentPage/DocumentToolbar.vue +228 -228
- package/src/components/DocumentPage/DummyPage.vue +55 -55
- package/src/components/DocumentPage/MultiAnnSelection.vue +371 -371
- package/src/components/DocumentPage/NewAnnotation.vue +308 -308
- package/src/components/DocumentPage/ScrollingDocument.vue +149 -149
- package/src/components/DocumentPage/ScrollingPage.vue +179 -179
- package/src/components/DocumentPage/index.js +5 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +67 -67
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +132 -132
- package/src/components/DocumentThumbnails/LoadingThumbnail.vue +25 -25
- package/src/components/DocumentThumbnails/index.js +1 -1
- package/src/components/DocumentTopBar/DocumentName.vue +236 -236
- package/src/components/DocumentTopBar/DocumentTopBar.cy.js +222 -222
- package/src/components/DocumentTopBar/DocumentTopBar.vue +202 -202
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +183 -183
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +74 -74
- package/src/components/DocumentTopBar/index.js +3 -3
- package/src/components/DocumentsList/DocumentsList.vue +121 -121
- package/src/components/DocumentsList/index.js +1 -1
- package/src/components/ErrorMessage.vue +40 -40
- package/src/components/index.js +1 -1
- package/src/constants.js +5 -5
- package/src/directives/scroll.js +28 -28
- package/src/i18n.js +22 -22
- package/src/icons.js +45 -45
- package/src/locales/de.json +148 -148
- package/src/locales/en.json +148 -148
- package/src/main.js +26 -26
- package/src/store/category.js +191 -191
- package/src/store/display.js +311 -311
- package/src/store/document.js +1438 -1438
- package/src/store/edit.js +316 -316
- package/src/store/index.js +21 -21
- package/src/store/project.js +143 -143
- package/src/store/selection.js +210 -210
- package/src/utils/utils.js +54 -54
- package/vue.config.js +25 -25
|
@@ -1,228 +1,228 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="toolbar-container">
|
|
3
|
-
<div :class="['toolbar', recalculatingAnnotations && 'hidden']">
|
|
4
|
-
<b-tooltip
|
|
5
|
-
:label="tooltipInfo"
|
|
6
|
-
multilined
|
|
7
|
-
:active="editModeDisabled"
|
|
8
|
-
size="is-large"
|
|
9
|
-
class="top-aligned"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
v-if="isEditModeAvailable"
|
|
13
|
-
id="edit-mode-button"
|
|
14
|
-
:class="[
|
|
15
|
-
'icons icons-left',
|
|
16
|
-
editModeDisabled && 'edit-mode-disabled',
|
|
17
|
-
]"
|
|
18
|
-
@click="handleEdit"
|
|
19
|
-
>
|
|
20
|
-
<div class="edit-icon icon">
|
|
21
|
-
<EditDocIcon />
|
|
22
|
-
</div>
|
|
23
|
-
<span class="edit-text">{{ $t("edit") }}</span>
|
|
24
|
-
</div>
|
|
25
|
-
</b-tooltip>
|
|
26
|
-
<div v-if="isEditModeAvailable" class="toolbar-divider" />
|
|
27
|
-
|
|
28
|
-
<div v-if="!publicView" class="download-file icons">
|
|
29
|
-
<b-dropdown aria-role="list" position="is-top-right" scrollable>
|
|
30
|
-
<template #trigger>
|
|
31
|
-
<b-icon icon="download" size="small" class="download-file" />
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<b-dropdown-item
|
|
35
|
-
class="original-file"
|
|
36
|
-
aria-role="listitem"
|
|
37
|
-
@click="handleDownloadFile()"
|
|
38
|
-
>{{ $t("original_file") }}</b-dropdown-item
|
|
39
|
-
>
|
|
40
|
-
<b-dropdown-item
|
|
41
|
-
class="ocr-file"
|
|
42
|
-
aria-role="listitem"
|
|
43
|
-
@click="handleDownloadFile('ocr')"
|
|
44
|
-
>{{ $t("pdf_file") }}</b-dropdown-item
|
|
45
|
-
>
|
|
46
|
-
</b-dropdown>
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<div v-if="!publicView" class="toolbar-divider" />
|
|
50
|
-
|
|
51
|
-
<div class="icons icons-right">
|
|
52
|
-
<div
|
|
53
|
-
:class="[
|
|
54
|
-
'fit-zoom',
|
|
55
|
-
'icon',
|
|
56
|
-
currentPercentage === 50 && 'zoom-disabled',
|
|
57
|
-
]"
|
|
58
|
-
@click.prevent.stop="fitAuto"
|
|
59
|
-
>
|
|
60
|
-
<FitZoomIcon />
|
|
61
|
-
</div>
|
|
62
|
-
<div
|
|
63
|
-
:class="['zoom-in icon', isZoomInExceeding && 'zoom-disabled']"
|
|
64
|
-
@click.prevent.stop="zoomIn"
|
|
65
|
-
>
|
|
66
|
-
<PlusIcon />
|
|
67
|
-
</div>
|
|
68
|
-
<div
|
|
69
|
-
:class="['zoom-out icon', isZoomOutExceeding && 'zoom-disabled']"
|
|
70
|
-
@click.prevent.stop="zoomOut"
|
|
71
|
-
>
|
|
72
|
-
<MinusIcon />
|
|
73
|
-
</div>
|
|
74
|
-
<div id="zoom-percentage" class="percentage">
|
|
75
|
-
{{ `${currentPercentage}%` }}
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</template>
|
|
81
|
-
|
|
82
|
-
<script>
|
|
83
|
-
import { mapState, mapGetters } from "vuex";
|
|
84
|
-
import FitZoomIcon from "../../assets/images/FitZoomIcon";
|
|
85
|
-
import PlusIcon from "../../assets/images/PlusIcon";
|
|
86
|
-
import MinusIcon from "../../assets/images/MinusIcon";
|
|
87
|
-
import EditDocIcon from "../../assets/images/EditDocIcon";
|
|
88
|
-
import api from "../../api";
|
|
89
|
-
|
|
90
|
-
export default {
|
|
91
|
-
name: "DocumentToolbar",
|
|
92
|
-
components: {
|
|
93
|
-
FitZoomIcon,
|
|
94
|
-
PlusIcon,
|
|
95
|
-
MinusIcon,
|
|
96
|
-
EditDocIcon,
|
|
97
|
-
},
|
|
98
|
-
data() {
|
|
99
|
-
return {
|
|
100
|
-
currentPercentage: 100,
|
|
101
|
-
maxPercentage: 500,
|
|
102
|
-
defaultPercentage: 0.25,
|
|
103
|
-
fitPercentage: 0.5,
|
|
104
|
-
toolbarModalOpen: true,
|
|
105
|
-
editModeDisabled: false,
|
|
106
|
-
tooltipInfo: null,
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
computed: {
|
|
110
|
-
...mapState("display", ["scale"]),
|
|
111
|
-
...mapGetters("edit", ["isEditModeAvailable"]),
|
|
112
|
-
...mapState("document", [
|
|
113
|
-
"selectedDocument",
|
|
114
|
-
"recalculatingAnnotations",
|
|
115
|
-
"publicView",
|
|
116
|
-
]),
|
|
117
|
-
...mapGetters("document", ["documentCannotBeEdited"]),
|
|
118
|
-
isZoomInExceeding() {
|
|
119
|
-
return this.currentPercentage === this.maxPercentage;
|
|
120
|
-
},
|
|
121
|
-
isZoomOutExceeding() {
|
|
122
|
-
return this.currentPercentage === this.defaultPercentage * 100;
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
watch: {
|
|
126
|
-
selectedDocument(newValue) {
|
|
127
|
-
if (this.documentCannotBeEdited(newValue)) {
|
|
128
|
-
this.editModeDisabled = true;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
mounted() {
|
|
133
|
-
if (this.selectedDocument) {
|
|
134
|
-
if (this.documentCannotBeEdited(this.selectedDocument)) {
|
|
135
|
-
this.editModeDisabled = true;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
updated() {
|
|
140
|
-
if (this.selectedDocument.is_reviewed) {
|
|
141
|
-
this.tooltipInfo = this.$t("document_reviewed");
|
|
142
|
-
} else {
|
|
143
|
-
this.tooltipInfo = this.$t("edit_not_available");
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
methods: {
|
|
147
|
-
handleEdit() {
|
|
148
|
-
if (this.editModeDisabled) return;
|
|
149
|
-
this.$store.dispatch("selection/disableSelection");
|
|
150
|
-
this.$store.dispatch("edit/enableEditMode");
|
|
151
|
-
},
|
|
152
|
-
zoomIn() {
|
|
153
|
-
if (this.currentPercentage === this.maxPercentage) return;
|
|
154
|
-
|
|
155
|
-
// exit edit mode of Annotation if changing zoom during editing
|
|
156
|
-
this.cancelAnnotationEditMode();
|
|
157
|
-
this.currentPercentage += this.defaultPercentage * 100;
|
|
158
|
-
this.updateScale(this.scale + this.defaultPercentage);
|
|
159
|
-
},
|
|
160
|
-
zoomOut() {
|
|
161
|
-
if (this.currentPercentage === this.defaultPercentage * 100) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// exit edit mode of Annotation if changing zoom during editing
|
|
166
|
-
this.cancelAnnotationEditMode();
|
|
167
|
-
|
|
168
|
-
this.currentPercentage -= this.defaultPercentage * 100;
|
|
169
|
-
this.updateScale(this.scale - this.defaultPercentage);
|
|
170
|
-
},
|
|
171
|
-
fitAuto() {
|
|
172
|
-
// exit edit mode of Annotation if changing zoom during editing
|
|
173
|
-
this.cancelAnnotationEditMode();
|
|
174
|
-
|
|
175
|
-
// Always set to 50%
|
|
176
|
-
this.currentPercentage = 50;
|
|
177
|
-
this.$store.dispatch("display/updateFit", "all");
|
|
178
|
-
},
|
|
179
|
-
updateScale(scale) {
|
|
180
|
-
this.$store.dispatch("display/updateFit", "custom").then(() => {
|
|
181
|
-
this.$store.dispatch("display/updateScale", { scale });
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
handleDownloadFile(fileType) {
|
|
185
|
-
let fileUrl;
|
|
186
|
-
// get the file name without the extension
|
|
187
|
-
let fileName = this.getFileName(this.selectedDocument.data_file_name);
|
|
188
|
-
|
|
189
|
-
if (fileType === "ocr") {
|
|
190
|
-
fileUrl = this.selectedDocument.file_url;
|
|
191
|
-
fileName = `${fileName}_${fileType}`;
|
|
192
|
-
} else {
|
|
193
|
-
fileUrl = `/doc/show-original/${this.selectedDocument.id}/`;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Automatically download original or ocr files
|
|
197
|
-
return api
|
|
198
|
-
.makeFileRequest(fileUrl)
|
|
199
|
-
.then((myBlob) => {
|
|
200
|
-
const url = URL.createObjectURL(myBlob);
|
|
201
|
-
const link = document.createElement("a");
|
|
202
|
-
link.href = url;
|
|
203
|
-
link.setAttribute("download", fileName);
|
|
204
|
-
link.click();
|
|
205
|
-
URL.revokeObjectURL(link.href);
|
|
206
|
-
})
|
|
207
|
-
.catch((error) => {
|
|
208
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
209
|
-
error,
|
|
210
|
-
serverErrorMessage: this.$t("server_error"),
|
|
211
|
-
defaultErrorMessage: this.$t("error_downloading_file"),
|
|
212
|
-
});
|
|
213
|
-
console.log(error);
|
|
214
|
-
});
|
|
215
|
-
},
|
|
216
|
-
getFileName(fileName) {
|
|
217
|
-
return fileName.split(".").slice(0, -1).join(".");
|
|
218
|
-
},
|
|
219
|
-
cancelAnnotationEditMode() {
|
|
220
|
-
this.$store.dispatch("document/resetEditAnnotation");
|
|
221
|
-
this.$store.dispatch("selection/disableSelection");
|
|
222
|
-
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
</script>
|
|
227
|
-
|
|
228
|
-
<style scoped lang="scss" src="../../assets/scss/document_toolbar.scss"></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div id="toolbar-container">
|
|
3
|
+
<div :class="['toolbar', recalculatingAnnotations && 'hidden']">
|
|
4
|
+
<b-tooltip
|
|
5
|
+
:label="tooltipInfo"
|
|
6
|
+
multilined
|
|
7
|
+
:active="editModeDisabled"
|
|
8
|
+
size="is-large"
|
|
9
|
+
class="top-aligned"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
v-if="isEditModeAvailable"
|
|
13
|
+
id="edit-mode-button"
|
|
14
|
+
:class="[
|
|
15
|
+
'icons icons-left',
|
|
16
|
+
editModeDisabled && 'edit-mode-disabled',
|
|
17
|
+
]"
|
|
18
|
+
@click="handleEdit"
|
|
19
|
+
>
|
|
20
|
+
<div class="edit-icon icon">
|
|
21
|
+
<EditDocIcon />
|
|
22
|
+
</div>
|
|
23
|
+
<span class="edit-text">{{ $t("edit") }}</span>
|
|
24
|
+
</div>
|
|
25
|
+
</b-tooltip>
|
|
26
|
+
<div v-if="isEditModeAvailable" class="toolbar-divider" />
|
|
27
|
+
|
|
28
|
+
<div v-if="!publicView" class="download-file icons">
|
|
29
|
+
<b-dropdown aria-role="list" position="is-top-right" scrollable>
|
|
30
|
+
<template #trigger>
|
|
31
|
+
<b-icon icon="download" size="small" class="download-file" />
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<b-dropdown-item
|
|
35
|
+
class="original-file"
|
|
36
|
+
aria-role="listitem"
|
|
37
|
+
@click="handleDownloadFile()"
|
|
38
|
+
>{{ $t("original_file") }}</b-dropdown-item
|
|
39
|
+
>
|
|
40
|
+
<b-dropdown-item
|
|
41
|
+
class="ocr-file"
|
|
42
|
+
aria-role="listitem"
|
|
43
|
+
@click="handleDownloadFile('ocr')"
|
|
44
|
+
>{{ $t("pdf_file") }}</b-dropdown-item
|
|
45
|
+
>
|
|
46
|
+
</b-dropdown>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div v-if="!publicView" class="toolbar-divider" />
|
|
50
|
+
|
|
51
|
+
<div class="icons icons-right">
|
|
52
|
+
<div
|
|
53
|
+
:class="[
|
|
54
|
+
'fit-zoom',
|
|
55
|
+
'icon',
|
|
56
|
+
currentPercentage === 50 && 'zoom-disabled',
|
|
57
|
+
]"
|
|
58
|
+
@click.prevent.stop="fitAuto"
|
|
59
|
+
>
|
|
60
|
+
<FitZoomIcon />
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
:class="['zoom-in icon', isZoomInExceeding && 'zoom-disabled']"
|
|
64
|
+
@click.prevent.stop="zoomIn"
|
|
65
|
+
>
|
|
66
|
+
<PlusIcon />
|
|
67
|
+
</div>
|
|
68
|
+
<div
|
|
69
|
+
:class="['zoom-out icon', isZoomOutExceeding && 'zoom-disabled']"
|
|
70
|
+
@click.prevent.stop="zoomOut"
|
|
71
|
+
>
|
|
72
|
+
<MinusIcon />
|
|
73
|
+
</div>
|
|
74
|
+
<div id="zoom-percentage" class="percentage">
|
|
75
|
+
{{ `${currentPercentage}%` }}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<script>
|
|
83
|
+
import { mapState, mapGetters } from "vuex";
|
|
84
|
+
import FitZoomIcon from "../../assets/images/FitZoomIcon";
|
|
85
|
+
import PlusIcon from "../../assets/images/PlusIcon";
|
|
86
|
+
import MinusIcon from "../../assets/images/MinusIcon";
|
|
87
|
+
import EditDocIcon from "../../assets/images/EditDocIcon";
|
|
88
|
+
import api from "../../api";
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
name: "DocumentToolbar",
|
|
92
|
+
components: {
|
|
93
|
+
FitZoomIcon,
|
|
94
|
+
PlusIcon,
|
|
95
|
+
MinusIcon,
|
|
96
|
+
EditDocIcon,
|
|
97
|
+
},
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
currentPercentage: 100,
|
|
101
|
+
maxPercentage: 500,
|
|
102
|
+
defaultPercentage: 0.25,
|
|
103
|
+
fitPercentage: 0.5,
|
|
104
|
+
toolbarModalOpen: true,
|
|
105
|
+
editModeDisabled: false,
|
|
106
|
+
tooltipInfo: null,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
computed: {
|
|
110
|
+
...mapState("display", ["scale"]),
|
|
111
|
+
...mapGetters("edit", ["isEditModeAvailable"]),
|
|
112
|
+
...mapState("document", [
|
|
113
|
+
"selectedDocument",
|
|
114
|
+
"recalculatingAnnotations",
|
|
115
|
+
"publicView",
|
|
116
|
+
]),
|
|
117
|
+
...mapGetters("document", ["documentCannotBeEdited"]),
|
|
118
|
+
isZoomInExceeding() {
|
|
119
|
+
return this.currentPercentage === this.maxPercentage;
|
|
120
|
+
},
|
|
121
|
+
isZoomOutExceeding() {
|
|
122
|
+
return this.currentPercentage === this.defaultPercentage * 100;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
watch: {
|
|
126
|
+
selectedDocument(newValue) {
|
|
127
|
+
if (this.documentCannotBeEdited(newValue)) {
|
|
128
|
+
this.editModeDisabled = true;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
mounted() {
|
|
133
|
+
if (this.selectedDocument) {
|
|
134
|
+
if (this.documentCannotBeEdited(this.selectedDocument)) {
|
|
135
|
+
this.editModeDisabled = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
updated() {
|
|
140
|
+
if (this.selectedDocument.is_reviewed) {
|
|
141
|
+
this.tooltipInfo = this.$t("document_reviewed");
|
|
142
|
+
} else {
|
|
143
|
+
this.tooltipInfo = this.$t("edit_not_available");
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
methods: {
|
|
147
|
+
handleEdit() {
|
|
148
|
+
if (this.editModeDisabled) return;
|
|
149
|
+
this.$store.dispatch("selection/disableSelection");
|
|
150
|
+
this.$store.dispatch("edit/enableEditMode");
|
|
151
|
+
},
|
|
152
|
+
zoomIn() {
|
|
153
|
+
if (this.currentPercentage === this.maxPercentage) return;
|
|
154
|
+
|
|
155
|
+
// exit edit mode of Annotation if changing zoom during editing
|
|
156
|
+
this.cancelAnnotationEditMode();
|
|
157
|
+
this.currentPercentage += this.defaultPercentage * 100;
|
|
158
|
+
this.updateScale(this.scale + this.defaultPercentage);
|
|
159
|
+
},
|
|
160
|
+
zoomOut() {
|
|
161
|
+
if (this.currentPercentage === this.defaultPercentage * 100) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// exit edit mode of Annotation if changing zoom during editing
|
|
166
|
+
this.cancelAnnotationEditMode();
|
|
167
|
+
|
|
168
|
+
this.currentPercentage -= this.defaultPercentage * 100;
|
|
169
|
+
this.updateScale(this.scale - this.defaultPercentage);
|
|
170
|
+
},
|
|
171
|
+
fitAuto() {
|
|
172
|
+
// exit edit mode of Annotation if changing zoom during editing
|
|
173
|
+
this.cancelAnnotationEditMode();
|
|
174
|
+
|
|
175
|
+
// Always set to 50%
|
|
176
|
+
this.currentPercentage = 50;
|
|
177
|
+
this.$store.dispatch("display/updateFit", "all");
|
|
178
|
+
},
|
|
179
|
+
updateScale(scale) {
|
|
180
|
+
this.$store.dispatch("display/updateFit", "custom").then(() => {
|
|
181
|
+
this.$store.dispatch("display/updateScale", { scale });
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
handleDownloadFile(fileType) {
|
|
185
|
+
let fileUrl;
|
|
186
|
+
// get the file name without the extension
|
|
187
|
+
let fileName = this.getFileName(this.selectedDocument.data_file_name);
|
|
188
|
+
|
|
189
|
+
if (fileType === "ocr") {
|
|
190
|
+
fileUrl = this.selectedDocument.file_url;
|
|
191
|
+
fileName = `${fileName}_${fileType}`;
|
|
192
|
+
} else {
|
|
193
|
+
fileUrl = `/doc/show-original/${this.selectedDocument.id}/`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Automatically download original or ocr files
|
|
197
|
+
return api
|
|
198
|
+
.makeFileRequest(fileUrl)
|
|
199
|
+
.then((myBlob) => {
|
|
200
|
+
const url = URL.createObjectURL(myBlob);
|
|
201
|
+
const link = document.createElement("a");
|
|
202
|
+
link.href = url;
|
|
203
|
+
link.setAttribute("download", fileName);
|
|
204
|
+
link.click();
|
|
205
|
+
URL.revokeObjectURL(link.href);
|
|
206
|
+
})
|
|
207
|
+
.catch((error) => {
|
|
208
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
209
|
+
error,
|
|
210
|
+
serverErrorMessage: this.$t("server_error"),
|
|
211
|
+
defaultErrorMessage: this.$t("error_downloading_file"),
|
|
212
|
+
});
|
|
213
|
+
console.log(error);
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
getFileName(fileName) {
|
|
217
|
+
return fileName.split(".").slice(0, -1).join(".");
|
|
218
|
+
},
|
|
219
|
+
cancelAnnotationEditMode() {
|
|
220
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
221
|
+
this.$store.dispatch("selection/disableSelection");
|
|
222
|
+
this.$store.dispatch("selection/setSelectedEntities", null);
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
</script>
|
|
227
|
+
|
|
228
|
+
<style scoped lang="scss" src="../../assets/scss/document_toolbar.scss"></style>
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :style="canvasStyle">
|
|
3
|
-
<b-skeleton
|
|
4
|
-
:width="`${scaledViewport.width}px`"
|
|
5
|
-
:height="`${scaledViewport.height}px`"
|
|
6
|
-
/>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
/**
|
|
12
|
-
* This component is used to mimick an actual page's height/width to
|
|
13
|
-
* act as a placeholder (mainly for scrolling) instead of rendering the
|
|
14
|
-
* full page canvas when it's not needed (unfocused pages).
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { mapState } from "vuex";
|
|
18
|
-
import { PIXEL_RATIO } from "../../constants";
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
props: {
|
|
22
|
-
width: {
|
|
23
|
-
default: 0,
|
|
24
|
-
type: Number,
|
|
25
|
-
},
|
|
26
|
-
height: {
|
|
27
|
-
default: 0,
|
|
28
|
-
type: Number,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
computed: {
|
|
32
|
-
...mapState("display", ["scale"]),
|
|
33
|
-
actualSizeViewport() {
|
|
34
|
-
return {
|
|
35
|
-
width: this.width * this.scale,
|
|
36
|
-
height: this.height * this.scale,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
scaledViewport() {
|
|
41
|
-
const { width: actualSizeWidth, height: actualSizeHeight } =
|
|
42
|
-
this.actualSizeViewport;
|
|
43
|
-
const [pixelWidth, pixelHeight] = [actualSizeWidth, actualSizeHeight].map(
|
|
44
|
-
(dim) => Math.ceil(dim / PIXEL_RATIO)
|
|
45
|
-
);
|
|
46
|
-
return { width: pixelWidth, height: pixelHeight };
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
canvasStyle() {
|
|
50
|
-
const { width, height } = this.scaledViewport;
|
|
51
|
-
return `width: ${width}px; height: ${height}px; margin: 0 auto`;
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="canvasStyle">
|
|
3
|
+
<b-skeleton
|
|
4
|
+
:width="`${scaledViewport.width}px`"
|
|
5
|
+
:height="`${scaledViewport.height}px`"
|
|
6
|
+
/>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
/**
|
|
12
|
+
* This component is used to mimick an actual page's height/width to
|
|
13
|
+
* act as a placeholder (mainly for scrolling) instead of rendering the
|
|
14
|
+
* full page canvas when it's not needed (unfocused pages).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { mapState } from "vuex";
|
|
18
|
+
import { PIXEL_RATIO } from "../../constants";
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
props: {
|
|
22
|
+
width: {
|
|
23
|
+
default: 0,
|
|
24
|
+
type: Number,
|
|
25
|
+
},
|
|
26
|
+
height: {
|
|
27
|
+
default: 0,
|
|
28
|
+
type: Number,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
computed: {
|
|
32
|
+
...mapState("display", ["scale"]),
|
|
33
|
+
actualSizeViewport() {
|
|
34
|
+
return {
|
|
35
|
+
width: this.width * this.scale,
|
|
36
|
+
height: this.height * this.scale,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
scaledViewport() {
|
|
41
|
+
const { width: actualSizeWidth, height: actualSizeHeight } =
|
|
42
|
+
this.actualSizeViewport;
|
|
43
|
+
const [pixelWidth, pixelHeight] = [actualSizeWidth, actualSizeHeight].map(
|
|
44
|
+
(dim) => Math.ceil(dim / PIXEL_RATIO)
|
|
45
|
+
);
|
|
46
|
+
return { width: pixelWidth, height: pixelHeight };
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
canvasStyle() {
|
|
50
|
+
const { width, height } = this.scaledViewport;
|
|
51
|
+
return `width: ${width}px; height: ${height}px; margin: 0 auto`;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
</script>
|