@konfuzio/document-validation-ui 0.1.5-automatic-document-splitting-3 → 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 +5 -4
- package/src/assets/images/SplitZigZag.vue +14 -47
- package/src/assets/scss/document_category.scss +1 -0
- package/src/assets/scss/document_dashboard.scss +0 -6
- package/src/assets/scss/document_edit.scss +46 -131
- package/src/assets/scss/main.scss +666 -7
- package/src/assets/scss/variables.scss +0 -719
- package/src/components/App.vue +3 -2
- package/src/components/DocumentAnnotations/CategorizeModal.vue +2 -22
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +3 -11
- package/src/components/DocumentCategory.vue +5 -13
- package/src/components/DocumentDashboard.vue +6 -17
- package/src/components/DocumentEdit/DocumentEdit.vue +78 -220
- package/src/components/DocumentEdit/EditPages.vue +18 -29
- package/src/components/DocumentEdit/EditSidebar.vue +45 -95
- package/src/components/DocumentEdit/SplitOverview.vue +5 -4
- package/src/components/{DocumentModals/DocumentErrorModal.vue → DocumentError.vue} +4 -3
- package/src/components/DocumentPage/DocumentPage.vue +9 -7
- package/src/components/DocumentPage/ScrollingDocument.vue +34 -4
- package/src/components/DocumentPage/ScrollingPage.vue +4 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +14 -11
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +20 -6
- package/src/components/{DocumentModals/NotOptimizedViewportModal.vue → NotOptimizedViewportModal.vue} +2 -2
- package/src/locales/de.json +2 -15
- package/src/locales/en.json +1 -15
- package/src/locales/es.json +1 -14
- package/src/store/display.js +7 -0
- package/src/store/document.js +16 -41
- package/src/store/edit.js +50 -68
- package/src/store/project.js +14 -14
- package/src/assets/images/MagicWandIcon.vue +0 -16
- package/src/assets/images/StarIcon.vue +0 -16
- package/src/assets/scss/splitting_confirmation_modal.scss +0 -41
- package/src/components/DocumentEdit/EditConfirmationModal.vue +0 -54
- package/src/components/DocumentEdit/SidebarButtons.vue +0 -53
- package/src/components/DocumentEdit/SplitInfoBar.vue +0 -19
- package/src/components/DocumentModals/SplittingSuggestionsModal.vue +0 -121
|
@@ -105,18 +105,9 @@ export default {
|
|
|
105
105
|
},
|
|
106
106
|
computed: {
|
|
107
107
|
...mapState("category", ["categories"]),
|
|
108
|
-
...mapState("document", [
|
|
109
|
-
"selectedDocument",
|
|
110
|
-
"categorizeModalIsActive",
|
|
111
|
-
"splittingSuggestions",
|
|
112
|
-
]),
|
|
108
|
+
...mapState("document", ["selectedDocument"]),
|
|
113
109
|
...mapGetters("category", ["category", "projectHasSingleCategory"]),
|
|
114
110
|
...mapGetters("document", ["categorizationIsConfirmed"]),
|
|
115
|
-
|
|
116
|
-
singleCategoryInProject() {
|
|
117
|
-
// if only 1 category in the project, we don't enable the dropdown
|
|
118
|
-
return this.categories && this.categories.length === 1;
|
|
119
|
-
},
|
|
120
111
|
},
|
|
121
112
|
watch: {
|
|
122
113
|
selectedDocument(newValue) {
|
|
@@ -136,13 +127,6 @@ export default {
|
|
|
136
127
|
show(newValue) {
|
|
137
128
|
this.$store.dispatch("display/setCategorizeModalIsActive", newValue);
|
|
138
129
|
},
|
|
139
|
-
categorizeModalIsActive(newValue) {
|
|
140
|
-
// Show modal after split suggestion modal
|
|
141
|
-
// if no category confirmed
|
|
142
|
-
if (newValue) {
|
|
143
|
-
this.show = newValue && !this.categorizationIsConfirmed;
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
130
|
},
|
|
147
131
|
mounted() {
|
|
148
132
|
this.setDocumentValues();
|
|
@@ -175,11 +159,7 @@ export default {
|
|
|
175
159
|
}
|
|
176
160
|
|
|
177
161
|
this.selectedCategory = category;
|
|
178
|
-
this.
|
|
179
|
-
|
|
180
|
-
// By default, if the document has no category, the categorize modal is shown
|
|
181
|
-
// But if there is a category, we also need to check if there are splitting suggestions or not
|
|
182
|
-
this.show = !category || (category && !this.splittingSuggestions);
|
|
162
|
+
this.show = !this.categorizationIsConfirmed;
|
|
183
163
|
}
|
|
184
164
|
},
|
|
185
165
|
canCloseModal() {
|
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
<!-- When there's no annotations in the label -->
|
|
16
16
|
<div v-else-if="annotationSets.length === 0">
|
|
17
|
-
<CategorizeModal
|
|
18
|
-
v-if="!publicView && !waitingForSplittingConfirmation(selectedDocument)"
|
|
19
|
-
/>
|
|
17
|
+
<CategorizeModal v-if="!publicView" />
|
|
20
18
|
<EmptyState />
|
|
21
19
|
</div>
|
|
22
20
|
|
|
@@ -27,9 +25,7 @@
|
|
|
27
25
|
missingAnnotations.length && !publicView && 'showing-rejected',
|
|
28
26
|
]"
|
|
29
27
|
>
|
|
30
|
-
<CategorizeModal
|
|
31
|
-
v-if="!publicView && !waitingForSplittingConfirmation(selectedDocument)"
|
|
32
|
-
/>
|
|
28
|
+
<CategorizeModal v-if="!publicView" />
|
|
33
29
|
<div
|
|
34
30
|
v-for="(annotationSet, indexGroup) in annotationSets"
|
|
35
31
|
:key="indexGroup"
|
|
@@ -127,13 +123,9 @@ export default {
|
|
|
127
123
|
"loading",
|
|
128
124
|
"labels",
|
|
129
125
|
"selectedDocument",
|
|
130
|
-
"splittingSuggestions",
|
|
131
126
|
]),
|
|
132
127
|
...mapGetters("category", ["category"]),
|
|
133
|
-
...mapGetters("document", [
|
|
134
|
-
"numberOfAnnotationSetGroup",
|
|
135
|
-
"waitingForSplittingConfirmation",
|
|
136
|
-
]),
|
|
128
|
+
...mapGetters("document", ["numberOfAnnotationSetGroup"]),
|
|
137
129
|
isAnnotationBeingEdited() {
|
|
138
130
|
return this.editAnnotation && this.editAnnotation.id;
|
|
139
131
|
},
|
|
@@ -29,7 +29,11 @@
|
|
|
29
29
|
{{ $t("category") }}
|
|
30
30
|
</p>
|
|
31
31
|
<div class="category-name">
|
|
32
|
-
{{
|
|
32
|
+
{{
|
|
33
|
+
!splitMode
|
|
34
|
+
? categoryName(selectedDocument.category)
|
|
35
|
+
: categoryName(updatedDocument[index].category)
|
|
36
|
+
}}
|
|
33
37
|
</div>
|
|
34
38
|
</div>
|
|
35
39
|
<div :class="[!splitMode && 'caret-section']">
|
|
@@ -98,18 +102,6 @@ export default {
|
|
|
98
102
|
...mapState("document", ["selectedDocument", "annotations"]),
|
|
99
103
|
...mapState("category", ["categories"]),
|
|
100
104
|
...mapState("edit", ["editMode", "updatedDocument"]),
|
|
101
|
-
|
|
102
|
-
setCategoryDefaultText() {
|
|
103
|
-
if (!this.splitMode) {
|
|
104
|
-
return this.categoryName(this.selectedDocument.category);
|
|
105
|
-
} else {
|
|
106
|
-
const categoryName = this.categoryName(
|
|
107
|
-
this.updatedDocument[this.index].category
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return categoryName ? categoryName : this.$t("choose_category");
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
105
|
},
|
|
114
106
|
watch: {
|
|
115
107
|
categories(newValue) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="dashboard">
|
|
3
3
|
<DocumentTopBar />
|
|
4
|
-
<div :class="['dashboard-viewer',
|
|
4
|
+
<div :class="['dashboard-viewer', editMode ? 'edit-mode' : '']">
|
|
5
5
|
<DocumentThumbnails v-if="!editMode" ref="documentPages" />
|
|
6
6
|
<ScrollingDocument ref="scrollingDocument" class="dashboard-document" />
|
|
7
7
|
<DocumentAnnotations v-if="!editMode" ref="annotations" />
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</transition>
|
|
19
19
|
</div>
|
|
20
20
|
<div v-if="showDocumentError" class="error-modal">
|
|
21
|
-
<
|
|
21
|
+
<DocumentError />
|
|
22
22
|
</div>
|
|
23
23
|
<div v-if="!optimalResolution" class="not-optimized">
|
|
24
24
|
<NotOptimizedViewportModal />
|
|
@@ -28,13 +28,6 @@
|
|
|
28
28
|
{{ $t("resolution_not_supported") }}
|
|
29
29
|
</div>
|
|
30
30
|
</div>
|
|
31
|
-
<div
|
|
32
|
-
v-if="
|
|
33
|
-
selectedDocument && waitingForSplittingConfirmation(selectedDocument)
|
|
34
|
-
"
|
|
35
|
-
>
|
|
36
|
-
<SplittingSuggestionsModal />
|
|
37
|
-
</div>
|
|
38
31
|
</div>
|
|
39
32
|
</template>
|
|
40
33
|
|
|
@@ -46,9 +39,8 @@ import { DocumentThumbnails } from "./DocumentThumbnails";
|
|
|
46
39
|
import { DocumentAnnotations } from "./DocumentAnnotations";
|
|
47
40
|
import { DocumentEdit } from "./DocumentEdit";
|
|
48
41
|
import ErrorMessage from "./ErrorMessage";
|
|
49
|
-
import NotOptimizedViewportModal from "
|
|
50
|
-
import
|
|
51
|
-
import SplittingSuggestionsModal from "../components/DocumentModals/SplittingSuggestionsModal";
|
|
42
|
+
import NotOptimizedViewportModal from "./NotOptimizedViewportModal";
|
|
43
|
+
import DocumentError from "./DocumentError";
|
|
52
44
|
|
|
53
45
|
/**
|
|
54
46
|
* This component shows the PDF pages in a scrolling component and
|
|
@@ -64,8 +56,7 @@ export default {
|
|
|
64
56
|
DocumentEdit,
|
|
65
57
|
ErrorMessage,
|
|
66
58
|
NotOptimizedViewportModal,
|
|
67
|
-
|
|
68
|
-
SplittingSuggestionsModal,
|
|
59
|
+
DocumentError,
|
|
69
60
|
},
|
|
70
61
|
data() {
|
|
71
62
|
return {
|
|
@@ -86,11 +77,9 @@ export default {
|
|
|
86
77
|
"showDocumentError",
|
|
87
78
|
"errorMessageWidth",
|
|
88
79
|
"selectedDocument",
|
|
89
|
-
"splittingSuggestions",
|
|
90
80
|
]),
|
|
91
|
-
...mapState("edit", ["editMode"
|
|
81
|
+
...mapState("edit", ["editMode"]),
|
|
92
82
|
...mapGetters("display", ["isMinimumWidth"]),
|
|
93
|
-
...mapGetters("document", ["waitingForSplittingConfirmation"]),
|
|
94
83
|
},
|
|
95
84
|
watch: {
|
|
96
85
|
selectedDocument(newDocument, oldDocument) {
|
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
<div :class="['document-edit', splitOverview && 'split-overview-component']">
|
|
3
3
|
<div v-if="!splitOverview" class="pages-section">
|
|
4
4
|
<EditPages
|
|
5
|
-
:splitting-lines="
|
|
6
|
-
:split-suggestions-enabled="splitSuggestionsEnabled"
|
|
5
|
+
:active-splitting-lines="activeSplittingLines"
|
|
7
6
|
@change-page="changePage"
|
|
8
7
|
@handle-splitting-lines="handleSplittingLines"
|
|
9
8
|
@check-move="checkMove"
|
|
10
9
|
@handle-drag-end="handleDragEnd"
|
|
11
10
|
/>
|
|
12
|
-
<div class="info-bar">
|
|
13
|
-
<SplitInfoBar v-if="splitSuggestionsEnabled" />
|
|
14
|
-
</div>
|
|
15
11
|
</div>
|
|
16
12
|
<div v-else class="split-overview-section">
|
|
17
13
|
<SplitOverview
|
|
@@ -26,13 +22,8 @@
|
|
|
26
22
|
@rotate-right="rotatePage"
|
|
27
23
|
@rotate-all-left="handleRotationsToTheLeft"
|
|
28
24
|
@rotate-all-right="handleRotationsToTheRight"
|
|
29
|
-
@handle-splitting-suggestions="applySplittingSuggestions"
|
|
30
|
-
:split-suggestions-enabled="splitSuggestionsEnabled"
|
|
31
25
|
/>
|
|
32
26
|
</div>
|
|
33
|
-
<div class="confirmation-modal-container">
|
|
34
|
-
<EditConfirmationModal @save-changes="saveEditChanges" />
|
|
35
|
-
</div>
|
|
36
27
|
</div>
|
|
37
28
|
</template>
|
|
38
29
|
<script>
|
|
@@ -40,8 +31,6 @@ import { mapState } from "vuex";
|
|
|
40
31
|
import EditSidebar from "./EditSidebar";
|
|
41
32
|
import SplitOverview from "./SplitOverview";
|
|
42
33
|
import EditPages from "./EditPages";
|
|
43
|
-
import SplitInfoBar from "./SplitInfoBar";
|
|
44
|
-
import EditConfirmationModal from "./EditConfirmationModal";
|
|
45
34
|
|
|
46
35
|
/**
|
|
47
36
|
* This component shows a document thumbnail grid view and sidebar, to be able to edit the document.
|
|
@@ -52,29 +41,22 @@ export default {
|
|
|
52
41
|
EditSidebar,
|
|
53
42
|
SplitOverview,
|
|
54
43
|
EditPages,
|
|
55
|
-
SplitInfoBar,
|
|
56
|
-
EditConfirmationModal,
|
|
57
44
|
},
|
|
58
45
|
data() {
|
|
59
46
|
return {
|
|
60
|
-
fileName:
|
|
47
|
+
fileName: [],
|
|
61
48
|
fileExtension: null,
|
|
62
|
-
|
|
49
|
+
activeSplittingLines: [],
|
|
63
50
|
dragging: false,
|
|
64
51
|
prevPageAtIndex: null,
|
|
65
|
-
splitSuggestionsEnabled: false,
|
|
66
52
|
};
|
|
67
53
|
},
|
|
68
54
|
computed: {
|
|
69
|
-
...mapState("document", [
|
|
70
|
-
"recalculatingAnnotations",
|
|
71
|
-
"selectedDocument",
|
|
72
|
-
"splittingSuggestions",
|
|
73
|
-
]),
|
|
55
|
+
...mapState("document", ["recalculatingAnnotations", "selectedDocument"]),
|
|
74
56
|
...mapState("display", ["currentPage"]),
|
|
75
57
|
...mapState("edit", [
|
|
76
58
|
"editMode",
|
|
77
|
-
"
|
|
59
|
+
"documentPagesListForEditMode",
|
|
78
60
|
"updatedDocument",
|
|
79
61
|
"splitOverview",
|
|
80
62
|
"selectedPages",
|
|
@@ -83,7 +65,6 @@ export default {
|
|
|
83
65
|
watch: {
|
|
84
66
|
pages() {
|
|
85
67
|
if (!this.selectedDocument) return;
|
|
86
|
-
|
|
87
68
|
this.setPages();
|
|
88
69
|
},
|
|
89
70
|
splitOverview(newValue) {
|
|
@@ -91,18 +72,9 @@ export default {
|
|
|
91
72
|
this.splitFileNameFromExtension();
|
|
92
73
|
}
|
|
93
74
|
},
|
|
94
|
-
|
|
75
|
+
documentPagesListForEditMode(newValue) {
|
|
95
76
|
if (newValue) {
|
|
96
|
-
this.
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
splittingLines(newValue) {
|
|
100
|
-
const aiSplit = newValue.find((item) => item.origin === "AI");
|
|
101
|
-
|
|
102
|
-
// If there are no AI suggestions left, because of being manually removed by the user
|
|
103
|
-
// the Smart Split switch should be turned off
|
|
104
|
-
if (!aiSplit) {
|
|
105
|
-
this.splitSuggestionsEnabled = false;
|
|
77
|
+
this.saveUpdatedDocument();
|
|
106
78
|
}
|
|
107
79
|
},
|
|
108
80
|
},
|
|
@@ -114,30 +86,16 @@ export default {
|
|
|
114
86
|
if (!this.selectedDocument) {
|
|
115
87
|
return;
|
|
116
88
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.$store.dispatch(
|
|
120
|
-
|
|
121
|
-
|
|
89
|
+
// set array of pages only with the data we need
|
|
90
|
+
const pages = this.createDocumentPagesListForEditMode();
|
|
91
|
+
this.$store.dispatch("edit/setDocumentPagesListForEditMode", pages);
|
|
92
|
+
// create array to handle the splitting
|
|
93
|
+
// length - 1 because of how many lines to split we need (last one not necessary)
|
|
94
|
+
this.activeSplittingLines = new Array(
|
|
95
|
+
this.selectedDocument.pages.length - 1
|
|
122
96
|
);
|
|
123
|
-
|
|
124
|
-
// Create array with placeholder data for the splitting points
|
|
125
|
-
if (this.selectedDocument.pages.length > 0) {
|
|
126
|
-
this.selectedDocument.pages.map((page) => {
|
|
127
|
-
if (page.number === this.selectedDocument.pages.length) {
|
|
128
|
-
this.setSplittingArray(page.number, null);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
this.setSplittingArray(0, null);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
if (this.splittingSuggestions) {
|
|
135
|
-
this.splitSuggestionsEnabled = true;
|
|
136
|
-
this.setAutomaticSplitting();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
97
|
},
|
|
140
|
-
|
|
98
|
+
createDocumentPagesListForEditMode() {
|
|
141
99
|
return this.selectedDocument.pages.map((page) => {
|
|
142
100
|
return {
|
|
143
101
|
id: page.id,
|
|
@@ -179,127 +137,72 @@ export default {
|
|
|
179
137
|
},
|
|
180
138
|
|
|
181
139
|
/** SPLIT */
|
|
182
|
-
setAutomaticSplitting() {
|
|
183
|
-
// map over splitting suggestions to find the page number based on the page id
|
|
184
|
-
// to update the splittingLines array with this data
|
|
185
|
-
|
|
186
|
-
this.splittingSuggestions.map((item) => {
|
|
187
|
-
const firstPage = this.selectedDocument.pages.find(
|
|
188
|
-
(page) => page.id === item.pages[0].id
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
if (firstPage.number === 1 && item.pages.length > 1) {
|
|
192
|
-
// only add the active splitting line from the 1st page of the second document
|
|
193
|
-
// since it's the first splitting point
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
this.handleSplittingLines(firstPage.number, "AI");
|
|
198
|
-
});
|
|
199
|
-
},
|
|
200
|
-
applySplittingSuggestions(value) {
|
|
201
|
-
// Show information bar
|
|
202
|
-
this.splitSuggestionsEnabled = value;
|
|
203
|
-
|
|
204
|
-
// Apply or remove split lines
|
|
205
|
-
this.setAutomaticSplitting();
|
|
206
|
-
},
|
|
207
|
-
setSplittingArray(pageNumber, splittingOrigin) {
|
|
208
|
-
// This function sets the splittingLines array
|
|
209
|
-
// based on splitting suggestions or no suggestions
|
|
210
|
-
this.splittingLines.push({
|
|
211
|
-
page: pageNumber,
|
|
212
|
-
origin: splittingOrigin,
|
|
213
|
-
});
|
|
214
|
-
},
|
|
215
140
|
splitFileNameFromExtension() {
|
|
216
|
-
if (!this.selectedDocument)
|
|
141
|
+
if (!this.selectedDocument && !this.selectedDocument.data_file_name)
|
|
142
|
+
return;
|
|
217
143
|
|
|
218
144
|
// Save the file name and the extension in different variables
|
|
219
145
|
// to be used in the next step of the splitting
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.fileExtension = this.selectedDocument.data_file_name
|
|
229
|
-
.split(".")
|
|
230
|
-
.at(-1);
|
|
231
|
-
}
|
|
146
|
+
this.fileName = this.selectedDocument.data_file_name
|
|
147
|
+
.split(".")
|
|
148
|
+
.slice(0, -1)
|
|
149
|
+
.join(".");
|
|
150
|
+
|
|
151
|
+
this.fileExtension = this.selectedDocument.data_file_name
|
|
152
|
+
.split(".")
|
|
153
|
+
.at(-1);
|
|
232
154
|
},
|
|
233
|
-
handleSplittingLines(page
|
|
234
|
-
//
|
|
235
|
-
// Add page number
|
|
236
|
-
// Or replace it with 0 (to keep the same index
|
|
237
|
-
const found = this.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const newPage = { page: page, origin: origin };
|
|
241
|
-
const removedPage = { page: 0, origin: origin };
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
page === this.splittingLines.length ||
|
|
245
|
-
(!this.splitSuggestionsEnabled && !found && origin === "AI")
|
|
246
|
-
) {
|
|
247
|
-
// check if it's the last item to keep unchanged
|
|
248
|
-
// Or if splitting is switched off, but some of the suggestion lines
|
|
249
|
-
// were removed manually
|
|
250
|
-
return;
|
|
251
|
-
} else if (this.splitSuggestionsEnabled && origin === "AI") {
|
|
252
|
-
// if manual suggestions were added but we enable automatic splitting,
|
|
253
|
-
// this last one takes over
|
|
254
|
-
this.splittingLines.splice(page - 1, 1, newPage);
|
|
255
|
-
} else if (found) {
|
|
256
|
-
// If splitting is switched off and we have manual splits,
|
|
257
|
-
// those should stay unchanged
|
|
258
|
-
if (!this.splitSuggestionsEnabled && found.origin !== origin) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
155
|
+
handleSplittingLines(page) {
|
|
156
|
+
// For splitting line purposes
|
|
157
|
+
// Add page number to specific index
|
|
158
|
+
// Or replace it with 0 (to keep the same index) if it exists
|
|
159
|
+
const found = this.activeSplittingLines.find(
|
|
160
|
+
(item) => item === page.number
|
|
161
|
+
);
|
|
261
162
|
|
|
262
|
-
|
|
163
|
+
if (found) {
|
|
164
|
+
this.activeSplittingLines.splice(page.number - 1, 1, 0);
|
|
263
165
|
} else {
|
|
264
|
-
this.
|
|
166
|
+
this.activeSplittingLines.splice(page.number - 1, 1, page.number);
|
|
265
167
|
}
|
|
266
168
|
|
|
267
|
-
this.
|
|
169
|
+
this.saveUpdatedDocument();
|
|
268
170
|
},
|
|
269
|
-
|
|
171
|
+
saveUpdatedDocument() {
|
|
270
172
|
this.splitFileNameFromExtension();
|
|
271
173
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const newDocuments = this.createEachNewDocument(
|
|
277
|
-
clickedLines,
|
|
278
|
-
clickedLines.length
|
|
174
|
+
// Check how many sub docs we have
|
|
175
|
+
const subDocuments = this.activeSplittingLines.filter(
|
|
176
|
+
(item) => item !== 0
|
|
279
177
|
);
|
|
280
178
|
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
for (let i = 0; i < length; i++) {
|
|
288
|
-
const
|
|
289
|
-
name: this.
|
|
290
|
-
category: this.
|
|
291
|
-
pages: this.
|
|
179
|
+
// Create array of objects
|
|
180
|
+
// with a fixed size based on how many sub documents are currently
|
|
181
|
+
const pageObjectArray = new Array(subDocuments.length + 1);
|
|
182
|
+
|
|
183
|
+
// Loop over the created array
|
|
184
|
+
// for each iteration we create the page object with the correponding data
|
|
185
|
+
for (let i = 0; i < pageObjectArray.length; i++) {
|
|
186
|
+
const pageObject = {
|
|
187
|
+
name: this.handleFileName(i),
|
|
188
|
+
category: this.selectedDocument.category,
|
|
189
|
+
pages: this.handleSubPages(i, subDocuments),
|
|
292
190
|
};
|
|
293
191
|
|
|
294
|
-
// we replace the "undefined" with the created object
|
|
295
|
-
|
|
192
|
+
// Then we replace the "undefined" with the created object
|
|
193
|
+
pageObjectArray.splice(i, 1, pageObject);
|
|
296
194
|
}
|
|
297
195
|
|
|
298
|
-
|
|
196
|
+
// Set the state to the created array
|
|
197
|
+
this.$store.dispatch("edit/setUpdatedDocument", pageObjectArray);
|
|
299
198
|
},
|
|
300
|
-
|
|
199
|
+
handleFileName(index) {
|
|
301
200
|
let newFileName;
|
|
302
201
|
|
|
202
|
+
// Return original file name,
|
|
203
|
+
// file name + copy,
|
|
204
|
+
// or file name + copy + number
|
|
205
|
+
// based on where the object will be located in the array
|
|
303
206
|
if (index === 0) {
|
|
304
207
|
newFileName = this.selectedDocument.data_file_name;
|
|
305
208
|
} else if (index === 1) {
|
|
@@ -309,95 +212,50 @@ export default {
|
|
|
309
212
|
}
|
|
310
213
|
return newFileName;
|
|
311
214
|
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// get the index of the new document in the splitting suggestions
|
|
315
|
-
// to return its category
|
|
316
|
-
const i = this.indexOfSplittingSuggestion(index, clickedLines);
|
|
317
|
-
|
|
318
|
-
return this.splittingSuggestions[i].category;
|
|
319
|
-
} else {
|
|
320
|
-
return this.selectedDocument.category;
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
handleNewDocumentPages(index, clickedLines) {
|
|
324
|
-
// assign the correct pages to each new document
|
|
215
|
+
handleSubPages(index, splittingLine) {
|
|
216
|
+
// assign the correct pages to each object
|
|
325
217
|
let pages;
|
|
326
218
|
|
|
327
219
|
if (index === 0) {
|
|
328
|
-
pages = this.
|
|
220
|
+
pages = this.documentPagesListForEditMode.slice(
|
|
221
|
+
0,
|
|
222
|
+
splittingLine[index]
|
|
223
|
+
);
|
|
329
224
|
} else {
|
|
330
|
-
if (!
|
|
331
|
-
pages = this.
|
|
225
|
+
if (!splittingLine[index]) {
|
|
226
|
+
pages = this.documentPagesListForEditMode.slice(
|
|
227
|
+
splittingLine[index - 1]
|
|
228
|
+
);
|
|
332
229
|
} else {
|
|
333
|
-
pages = this.
|
|
334
|
-
|
|
335
|
-
|
|
230
|
+
pages = this.documentPagesListForEditMode.slice(
|
|
231
|
+
splittingLine[index - 1],
|
|
232
|
+
splittingLine[index]
|
|
336
233
|
);
|
|
337
234
|
}
|
|
338
235
|
}
|
|
339
|
-
|
|
340
236
|
return pages;
|
|
341
237
|
},
|
|
342
|
-
indexOfSplittingSuggestion(index, clickedLines) {
|
|
343
|
-
const foundPage = this.selectedDocument.pages.find(
|
|
344
|
-
(page) => page.number === clickedLines[index].page
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
const singleSplittingSuggestion = this.splittingSuggestions.find(
|
|
348
|
-
(item) => item.pages[0].id === foundPage.id
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
return this.splittingSuggestions.indexOf(singleSplittingSuggestion);
|
|
352
|
-
},
|
|
353
238
|
|
|
354
239
|
/** SORT */
|
|
355
240
|
checkMove(e) {
|
|
356
241
|
// Save the page placed originally where the page we are dragging will go
|
|
357
|
-
this.prevPageAtIndex = this.
|
|
242
|
+
this.prevPageAtIndex = this.documentPagesListForEditMode.find(
|
|
358
243
|
(page) =>
|
|
359
|
-
this.
|
|
244
|
+
this.documentPagesListForEditMode.indexOf(page) ===
|
|
360
245
|
e.draggedContext.futureIndex
|
|
361
246
|
);
|
|
362
247
|
},
|
|
363
248
|
handleDragEnd() {
|
|
364
249
|
// Update page numbers
|
|
365
|
-
const pages = this.
|
|
366
|
-
const index = this.
|
|
250
|
+
const pages = this.documentPagesListForEditMode.map((page) => {
|
|
251
|
+
const index = this.documentPagesListForEditMode.indexOf(page);
|
|
367
252
|
return {
|
|
368
253
|
...page,
|
|
369
254
|
number: index + 1,
|
|
370
255
|
};
|
|
371
256
|
});
|
|
372
257
|
|
|
373
|
-
this.$store.dispatch("edit/
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
/** SUBMIT CHANGES */
|
|
377
|
-
// Send update request to the backend
|
|
378
|
-
saveEditChanges() {
|
|
379
|
-
this.$store
|
|
380
|
-
.dispatch("edit/editDocument", this.updatedDocument)
|
|
381
|
-
.catch((error) => {
|
|
382
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
383
|
-
error,
|
|
384
|
-
serverErrorMessage: this.$t("server_error"),
|
|
385
|
-
defaultErrorMessage: this.$t("edit_error"),
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
this.closeEditMode();
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
closeEditMode() {
|
|
393
|
-
this.$store.dispatch("edit/disableEditMode");
|
|
394
|
-
this.$store.dispatch("edit/setSplitOverview", false);
|
|
395
|
-
this.$store.dispatch("edit/setUpdatedDocument", null);
|
|
396
|
-
this.$store.dispatch("edit/setSelectedPages", null);
|
|
397
|
-
this.$nextTick(() => {
|
|
398
|
-
// reset to first page
|
|
399
|
-
this.$store.dispatch("display/updateCurrentPage", 1);
|
|
400
|
-
});
|
|
258
|
+
this.$store.dispatch("edit/setDocumentPagesListForEditMode", pages);
|
|
401
259
|
},
|
|
402
260
|
},
|
|
403
261
|
};
|