@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,338 +1,338 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="multi-ann-table-overlay"
|
|
4
|
-
:style="{
|
|
5
|
-
left: `${left}px`,
|
|
6
|
-
width: `${width === 0 ? '100%' : `${width}px`}`,
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
9
|
-
<b-table
|
|
10
|
-
ref="table"
|
|
11
|
-
class="multi-ann-set-table dark-header header-32"
|
|
12
|
-
detail-icon="faScissors"
|
|
13
|
-
:data="rows"
|
|
14
|
-
:sticky-header="true"
|
|
15
|
-
:narrowed="true"
|
|
16
|
-
:bordered="false"
|
|
17
|
-
draggable-column
|
|
18
|
-
@columndragstart="columndragstart"
|
|
19
|
-
@columndrop="columndrop"
|
|
20
|
-
@columndragover="columndragover"
|
|
21
|
-
@columndragleave="columndragleave"
|
|
22
|
-
>
|
|
23
|
-
<b-table-column
|
|
24
|
-
v-for="(item, index) in isLoading ? [columns[0]] : columns"
|
|
25
|
-
:key="index"
|
|
26
|
-
:field="item.field"
|
|
27
|
-
:label="item.label.name"
|
|
28
|
-
>
|
|
29
|
-
<template #header="{ column }">
|
|
30
|
-
<b-dropdown
|
|
31
|
-
:ref="getDropdownReference(item)"
|
|
32
|
-
aria-role="list"
|
|
33
|
-
class="header-dropdown"
|
|
34
|
-
position="is-top-right"
|
|
35
|
-
:close-on-click="false"
|
|
36
|
-
scrollable
|
|
37
|
-
@active-change="(e) => onDropdownChange(item, e)"
|
|
38
|
-
>
|
|
39
|
-
<template #trigger="{ active }">
|
|
40
|
-
<DraggableIcon v-if="!isLoading" class="draggable" />
|
|
41
|
-
<span v-if="!isLoading" :class="active ? 'active' : ''"
|
|
42
|
-
>{{ column.label }}
|
|
43
|
-
</span>
|
|
44
|
-
<b-icon
|
|
45
|
-
v-if="!isLoading"
|
|
46
|
-
:icon="active ? 'angle-up' : 'angle-down'"
|
|
47
|
-
size="is-small"
|
|
48
|
-
class="arrow"
|
|
49
|
-
/>
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<div v-if="editingLabels.length === 0">
|
|
53
|
-
<b-dropdown-item aria-role="listitem" @click="editLabel(item)"
|
|
54
|
-
><span>{{ $t("edit_label") }}</span></b-dropdown-item
|
|
55
|
-
>
|
|
56
|
-
<b-dropdown-item
|
|
57
|
-
aria-role="listitem"
|
|
58
|
-
class="delete-action"
|
|
59
|
-
@click="deleteColumn(item)"
|
|
60
|
-
>
|
|
61
|
-
<span>{{ $t("delete_label") }}</span></b-dropdown-item
|
|
62
|
-
>
|
|
63
|
-
</div>
|
|
64
|
-
<div v-else>
|
|
65
|
-
<b-dropdown-item
|
|
66
|
-
v-for="label in editingLabels"
|
|
67
|
-
:key="label.id"
|
|
68
|
-
aria-role="listitem"
|
|
69
|
-
:disabled="label.disabled"
|
|
70
|
-
><span @click="!label.disabled && changeLabel(item, label)">{{
|
|
71
|
-
label.name
|
|
72
|
-
}}</span></b-dropdown-item
|
|
73
|
-
>
|
|
74
|
-
</div>
|
|
75
|
-
</b-dropdown>
|
|
76
|
-
</template>
|
|
77
|
-
|
|
78
|
-
<template #default="props">
|
|
79
|
-
<div class="annotations-table">
|
|
80
|
-
<b-skeleton v-if="isLoading" width="98%" height="90%" />
|
|
81
|
-
<AnnotationRow
|
|
82
|
-
v-if="!isLoading"
|
|
83
|
-
:annotation="props.row[item.field]"
|
|
84
|
-
:label="item.label"
|
|
85
|
-
:annotation-set="item.annotationSet"
|
|
86
|
-
:show-label="false"
|
|
87
|
-
:show-buttons="false"
|
|
88
|
-
:is-small="true"
|
|
89
|
-
:from-table="true"
|
|
90
|
-
/>
|
|
91
|
-
</div>
|
|
92
|
-
</template>
|
|
93
|
-
</b-table-column>
|
|
94
|
-
</b-table>
|
|
95
|
-
</div>
|
|
96
|
-
</template>
|
|
97
|
-
|
|
98
|
-
<script>
|
|
99
|
-
import { mapState } from "vuex";
|
|
100
|
-
import AnnotationRow from "../DocumentAnnotations/AnnotationRow";
|
|
101
|
-
import DraggableIcon from "../../assets/images/DraggableIcon";
|
|
102
|
-
|
|
103
|
-
export default {
|
|
104
|
-
name: "MultiAnnotationTableOverlay",
|
|
105
|
-
components: {
|
|
106
|
-
AnnotationRow,
|
|
107
|
-
DraggableIcon,
|
|
108
|
-
},
|
|
109
|
-
props: {
|
|
110
|
-
left: {
|
|
111
|
-
type: Number,
|
|
112
|
-
required: false,
|
|
113
|
-
default: 0,
|
|
114
|
-
},
|
|
115
|
-
width: {
|
|
116
|
-
type: Number,
|
|
117
|
-
required: false,
|
|
118
|
-
default: 0,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
data() {
|
|
122
|
-
return {
|
|
123
|
-
rows: [],
|
|
124
|
-
columns: [],
|
|
125
|
-
orderedAnnotations: [],
|
|
126
|
-
editingLabels: [],
|
|
127
|
-
openDropdown: null,
|
|
128
|
-
draggingColumnIndex: null,
|
|
129
|
-
isLoading: false,
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
computed: {
|
|
133
|
-
...mapState("display", ["showAnnSetTable"]),
|
|
134
|
-
...mapState("document", ["annotations"]),
|
|
135
|
-
},
|
|
136
|
-
watch: {
|
|
137
|
-
showAnnSetTable() {
|
|
138
|
-
this.handleColumns();
|
|
139
|
-
this.handleRows();
|
|
140
|
-
},
|
|
141
|
-
annotations() {
|
|
142
|
-
// if there's a change in the annotations content, we update the table
|
|
143
|
-
this.handleColumns();
|
|
144
|
-
this.handleRows();
|
|
145
|
-
},
|
|
146
|
-
columns(columns) {
|
|
147
|
-
if (!columns || (columns && columns.length === 0)) {
|
|
148
|
-
this.$store.dispatch("selection/disableSelection");
|
|
149
|
-
this.$store.dispatch("document/resetEditAnnotation");
|
|
150
|
-
this.$store.dispatch("display/showAnnSetTable", null);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
mounted() {
|
|
155
|
-
this.handleColumns();
|
|
156
|
-
this.handleRows();
|
|
157
|
-
},
|
|
158
|
-
methods: {
|
|
159
|
-
getDropdownReference(column) {
|
|
160
|
-
return `editDropdown_${column.field}`;
|
|
161
|
-
},
|
|
162
|
-
handleColumns() {
|
|
163
|
-
this.columns = [];
|
|
164
|
-
const labelAlreadyExists = (label) => {
|
|
165
|
-
return (
|
|
166
|
-
this.columns.length > 0 &&
|
|
167
|
-
this.columns.find((a) => a.field === `${label.id}`) != undefined
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
this.showAnnSetTable.forEach((annotationSet) => {
|
|
172
|
-
annotationSet.labels.forEach((label) => {
|
|
173
|
-
if (!labelAlreadyExists(label) && label.annotations.length > 0) {
|
|
174
|
-
const column = {
|
|
175
|
-
field: `${label.id}`,
|
|
176
|
-
label: label,
|
|
177
|
-
annotationSet,
|
|
178
|
-
centered: false,
|
|
179
|
-
};
|
|
180
|
-
this.columns.push(column);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
handleRows() {
|
|
187
|
-
this.rows = [];
|
|
188
|
-
this.orderedAnnotations = [];
|
|
189
|
-
|
|
190
|
-
this.showAnnSetTable.forEach((annotationSet) => {
|
|
191
|
-
let row = {};
|
|
192
|
-
let toAdd = false; // to not push empty labels
|
|
193
|
-
|
|
194
|
-
annotationSet.labels.forEach((label) => {
|
|
195
|
-
if (label.annotations.length > 0) {
|
|
196
|
-
row[label.id] = label.annotations[0];
|
|
197
|
-
this.orderedAnnotations.push(label.annotations[0]);
|
|
198
|
-
toAdd = true;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
if (toAdd) {
|
|
202
|
-
this.rows.push(row);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
|
|
207
|
-
async editLabel(column) {
|
|
208
|
-
this.$store
|
|
209
|
-
.dispatch(
|
|
210
|
-
"project/fetchLabelSetDetails",
|
|
211
|
-
column.annotationSet.label_set.id
|
|
212
|
-
)
|
|
213
|
-
.then(async (labelSet) => {
|
|
214
|
-
this.editingLabels = [];
|
|
215
|
-
|
|
216
|
-
labelSet.labels.forEach((label) => {
|
|
217
|
-
const dropdownLabel = {
|
|
218
|
-
...label,
|
|
219
|
-
disabled:
|
|
220
|
-
this.columns.find((column) => column.label.id === label.id) !==
|
|
221
|
-
undefined,
|
|
222
|
-
};
|
|
223
|
-
this.editingLabels.push(dropdownLabel);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
async changeLabel(column, label) {
|
|
229
|
-
this.isLoading = true;
|
|
230
|
-
this.closeDropdown(column);
|
|
231
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
232
|
-
const annotationToUpdate = this.rows[i][column.label.id];
|
|
233
|
-
await this.$store
|
|
234
|
-
.dispatch("document/updateAnnotation", {
|
|
235
|
-
annotationId: annotationToUpdate.id,
|
|
236
|
-
updatedValues: { label: label.id },
|
|
237
|
-
})
|
|
238
|
-
.catch((error) => {
|
|
239
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
240
|
-
error,
|
|
241
|
-
serverErrorMessage: this.$t("server_error"),
|
|
242
|
-
defaultErrorMessage: this.$t("edit_error"),
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
this.isLoading = false;
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
async deleteColumn(column) {
|
|
250
|
-
this.isLoading = true;
|
|
251
|
-
this.closeDropdown(column);
|
|
252
|
-
|
|
253
|
-
const annotationsToDelete = [];
|
|
254
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
255
|
-
const annotationToDelete = this.rows[i][column.label.id];
|
|
256
|
-
if (annotationToDelete && annotationToDelete.id) {
|
|
257
|
-
annotationsToDelete.push(annotationToDelete);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
annotationsToDelete.forEach(async (annotationToDelete) => {
|
|
262
|
-
await this.$store
|
|
263
|
-
.dispatch("document/deleteAnnotation", {
|
|
264
|
-
annotationId: annotationToDelete.id,
|
|
265
|
-
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
266
|
-
})
|
|
267
|
-
.catch((error) => {
|
|
268
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
269
|
-
error,
|
|
270
|
-
serverErrorMessage: this.$t("server_error"),
|
|
271
|
-
defaultErrorMessage: this.$t("edit_error"),
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
this.isLoading = false;
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
onDropdownChange(column, open) {
|
|
280
|
-
this.editingLabels = [];
|
|
281
|
-
this.$store.dispatch("selection/disableSelection");
|
|
282
|
-
this.$store.dispatch("document/resetEditAnnotation");
|
|
283
|
-
if (open) {
|
|
284
|
-
if (
|
|
285
|
-
this.openDropdown &&
|
|
286
|
-
this.$refs[this.getDropdownReference(column)].length > 0
|
|
287
|
-
) {
|
|
288
|
-
this.$refs[this.openDropdown][0].toggle();
|
|
289
|
-
}
|
|
290
|
-
this.openDropdown = this.getDropdownReference(column);
|
|
291
|
-
} else {
|
|
292
|
-
if (this.openDropdown === this.getDropdownReference(column)) {
|
|
293
|
-
this.openDropdown = null;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
closeDropdown(column) {
|
|
299
|
-
if (
|
|
300
|
-
this.openDropdown &&
|
|
301
|
-
this.$refs[this.getDropdownReference(column)].length > 0
|
|
302
|
-
) {
|
|
303
|
-
this.$refs[this.getDropdownReference(column)][0].toggle();
|
|
304
|
-
this.openDropdown = null;
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
columndragstart(payload) {
|
|
309
|
-
this.draggingColumnIndex = payload.index;
|
|
310
|
-
payload.event.dataTransfer.effectAllowed = "copy";
|
|
311
|
-
},
|
|
312
|
-
columndragover(payload) {
|
|
313
|
-
payload.event.dataTransfer.dropEffect = "copy";
|
|
314
|
-
payload.event.target.closest("th").classList.add("is-selected");
|
|
315
|
-
payload.event.preventDefault();
|
|
316
|
-
},
|
|
317
|
-
columndragleave(payload) {
|
|
318
|
-
payload.event.target.closest("th").classList.remove("is-selected");
|
|
319
|
-
payload.event.preventDefault();
|
|
320
|
-
},
|
|
321
|
-
async columndrop(payload) {
|
|
322
|
-
payload.event.target.closest("th").classList.remove("is-selected");
|
|
323
|
-
const droppedOnColumnIndex = payload.index;
|
|
324
|
-
|
|
325
|
-
const draggingColumn = this.columns[this.draggingColumnIndex];
|
|
326
|
-
const droppedColumn = this.columns[droppedOnColumnIndex];
|
|
327
|
-
|
|
328
|
-
await this.changeLabel(draggingColumn, droppedColumn.label);
|
|
329
|
-
await this.changeLabel(droppedColumn, draggingColumn.label);
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
</script>
|
|
334
|
-
<style
|
|
335
|
-
scoped
|
|
336
|
-
lang="scss"
|
|
337
|
-
src="../../assets/scss/multi_ann_table_overlay.scss"
|
|
338
|
-
></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="multi-ann-table-overlay"
|
|
4
|
+
:style="{
|
|
5
|
+
left: `${left}px`,
|
|
6
|
+
width: `${width === 0 ? '100%' : `${width}px`}`,
|
|
7
|
+
}"
|
|
8
|
+
>
|
|
9
|
+
<b-table
|
|
10
|
+
ref="table"
|
|
11
|
+
class="multi-ann-set-table dark-header header-32"
|
|
12
|
+
detail-icon="faScissors"
|
|
13
|
+
:data="rows"
|
|
14
|
+
:sticky-header="true"
|
|
15
|
+
:narrowed="true"
|
|
16
|
+
:bordered="false"
|
|
17
|
+
draggable-column
|
|
18
|
+
@columndragstart="columndragstart"
|
|
19
|
+
@columndrop="columndrop"
|
|
20
|
+
@columndragover="columndragover"
|
|
21
|
+
@columndragleave="columndragleave"
|
|
22
|
+
>
|
|
23
|
+
<b-table-column
|
|
24
|
+
v-for="(item, index) in isLoading ? [columns[0]] : columns"
|
|
25
|
+
:key="index"
|
|
26
|
+
:field="item.field"
|
|
27
|
+
:label="item.label.name"
|
|
28
|
+
>
|
|
29
|
+
<template #header="{ column }">
|
|
30
|
+
<b-dropdown
|
|
31
|
+
:ref="getDropdownReference(item)"
|
|
32
|
+
aria-role="list"
|
|
33
|
+
class="header-dropdown"
|
|
34
|
+
position="is-top-right"
|
|
35
|
+
:close-on-click="false"
|
|
36
|
+
scrollable
|
|
37
|
+
@active-change="(e) => onDropdownChange(item, e)"
|
|
38
|
+
>
|
|
39
|
+
<template #trigger="{ active }">
|
|
40
|
+
<DraggableIcon v-if="!isLoading" class="draggable" />
|
|
41
|
+
<span v-if="!isLoading" :class="active ? 'active' : ''"
|
|
42
|
+
>{{ column.label }}
|
|
43
|
+
</span>
|
|
44
|
+
<b-icon
|
|
45
|
+
v-if="!isLoading"
|
|
46
|
+
:icon="active ? 'angle-up' : 'angle-down'"
|
|
47
|
+
size="is-small"
|
|
48
|
+
class="arrow"
|
|
49
|
+
/>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<div v-if="editingLabels.length === 0">
|
|
53
|
+
<b-dropdown-item aria-role="listitem" @click="editLabel(item)"
|
|
54
|
+
><span>{{ $t("edit_label") }}</span></b-dropdown-item
|
|
55
|
+
>
|
|
56
|
+
<b-dropdown-item
|
|
57
|
+
aria-role="listitem"
|
|
58
|
+
class="delete-action"
|
|
59
|
+
@click="deleteColumn(item)"
|
|
60
|
+
>
|
|
61
|
+
<span>{{ $t("delete_label") }}</span></b-dropdown-item
|
|
62
|
+
>
|
|
63
|
+
</div>
|
|
64
|
+
<div v-else>
|
|
65
|
+
<b-dropdown-item
|
|
66
|
+
v-for="label in editingLabels"
|
|
67
|
+
:key="label.id"
|
|
68
|
+
aria-role="listitem"
|
|
69
|
+
:disabled="label.disabled"
|
|
70
|
+
><span @click="!label.disabled && changeLabel(item, label)">{{
|
|
71
|
+
label.name
|
|
72
|
+
}}</span></b-dropdown-item
|
|
73
|
+
>
|
|
74
|
+
</div>
|
|
75
|
+
</b-dropdown>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<template #default="props">
|
|
79
|
+
<div class="annotations-table">
|
|
80
|
+
<b-skeleton v-if="isLoading" width="98%" height="90%" />
|
|
81
|
+
<AnnotationRow
|
|
82
|
+
v-if="!isLoading"
|
|
83
|
+
:annotation="props.row[item.field]"
|
|
84
|
+
:label="item.label"
|
|
85
|
+
:annotation-set="item.annotationSet"
|
|
86
|
+
:show-label="false"
|
|
87
|
+
:show-buttons="false"
|
|
88
|
+
:is-small="true"
|
|
89
|
+
:from-table="true"
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
</b-table-column>
|
|
94
|
+
</b-table>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script>
|
|
99
|
+
import { mapState } from "vuex";
|
|
100
|
+
import AnnotationRow from "../DocumentAnnotations/AnnotationRow";
|
|
101
|
+
import DraggableIcon from "../../assets/images/DraggableIcon";
|
|
102
|
+
|
|
103
|
+
export default {
|
|
104
|
+
name: "MultiAnnotationTableOverlay",
|
|
105
|
+
components: {
|
|
106
|
+
AnnotationRow,
|
|
107
|
+
DraggableIcon,
|
|
108
|
+
},
|
|
109
|
+
props: {
|
|
110
|
+
left: {
|
|
111
|
+
type: Number,
|
|
112
|
+
required: false,
|
|
113
|
+
default: 0,
|
|
114
|
+
},
|
|
115
|
+
width: {
|
|
116
|
+
type: Number,
|
|
117
|
+
required: false,
|
|
118
|
+
default: 0,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
data() {
|
|
122
|
+
return {
|
|
123
|
+
rows: [],
|
|
124
|
+
columns: [],
|
|
125
|
+
orderedAnnotations: [],
|
|
126
|
+
editingLabels: [],
|
|
127
|
+
openDropdown: null,
|
|
128
|
+
draggingColumnIndex: null,
|
|
129
|
+
isLoading: false,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
computed: {
|
|
133
|
+
...mapState("display", ["showAnnSetTable"]),
|
|
134
|
+
...mapState("document", ["annotations"]),
|
|
135
|
+
},
|
|
136
|
+
watch: {
|
|
137
|
+
showAnnSetTable() {
|
|
138
|
+
this.handleColumns();
|
|
139
|
+
this.handleRows();
|
|
140
|
+
},
|
|
141
|
+
annotations() {
|
|
142
|
+
// if there's a change in the annotations content, we update the table
|
|
143
|
+
this.handleColumns();
|
|
144
|
+
this.handleRows();
|
|
145
|
+
},
|
|
146
|
+
columns(columns) {
|
|
147
|
+
if (!columns || (columns && columns.length === 0)) {
|
|
148
|
+
this.$store.dispatch("selection/disableSelection");
|
|
149
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
150
|
+
this.$store.dispatch("display/showAnnSetTable", null);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
mounted() {
|
|
155
|
+
this.handleColumns();
|
|
156
|
+
this.handleRows();
|
|
157
|
+
},
|
|
158
|
+
methods: {
|
|
159
|
+
getDropdownReference(column) {
|
|
160
|
+
return `editDropdown_${column.field}`;
|
|
161
|
+
},
|
|
162
|
+
handleColumns() {
|
|
163
|
+
this.columns = [];
|
|
164
|
+
const labelAlreadyExists = (label) => {
|
|
165
|
+
return (
|
|
166
|
+
this.columns.length > 0 &&
|
|
167
|
+
this.columns.find((a) => a.field === `${label.id}`) != undefined
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
this.showAnnSetTable.forEach((annotationSet) => {
|
|
172
|
+
annotationSet.labels.forEach((label) => {
|
|
173
|
+
if (!labelAlreadyExists(label) && label.annotations.length > 0) {
|
|
174
|
+
const column = {
|
|
175
|
+
field: `${label.id}`,
|
|
176
|
+
label: label,
|
|
177
|
+
annotationSet,
|
|
178
|
+
centered: false,
|
|
179
|
+
};
|
|
180
|
+
this.columns.push(column);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
handleRows() {
|
|
187
|
+
this.rows = [];
|
|
188
|
+
this.orderedAnnotations = [];
|
|
189
|
+
|
|
190
|
+
this.showAnnSetTable.forEach((annotationSet) => {
|
|
191
|
+
let row = {};
|
|
192
|
+
let toAdd = false; // to not push empty labels
|
|
193
|
+
|
|
194
|
+
annotationSet.labels.forEach((label) => {
|
|
195
|
+
if (label.annotations.length > 0) {
|
|
196
|
+
row[label.id] = label.annotations[0];
|
|
197
|
+
this.orderedAnnotations.push(label.annotations[0]);
|
|
198
|
+
toAdd = true;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (toAdd) {
|
|
202
|
+
this.rows.push(row);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
async editLabel(column) {
|
|
208
|
+
this.$store
|
|
209
|
+
.dispatch(
|
|
210
|
+
"project/fetchLabelSetDetails",
|
|
211
|
+
column.annotationSet.label_set.id
|
|
212
|
+
)
|
|
213
|
+
.then(async (labelSet) => {
|
|
214
|
+
this.editingLabels = [];
|
|
215
|
+
|
|
216
|
+
labelSet.labels.forEach((label) => {
|
|
217
|
+
const dropdownLabel = {
|
|
218
|
+
...label,
|
|
219
|
+
disabled:
|
|
220
|
+
this.columns.find((column) => column.label.id === label.id) !==
|
|
221
|
+
undefined,
|
|
222
|
+
};
|
|
223
|
+
this.editingLabels.push(dropdownLabel);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
async changeLabel(column, label) {
|
|
229
|
+
this.isLoading = true;
|
|
230
|
+
this.closeDropdown(column);
|
|
231
|
+
for (let i = 0; i < this.rows.length; i++) {
|
|
232
|
+
const annotationToUpdate = this.rows[i][column.label.id];
|
|
233
|
+
await this.$store
|
|
234
|
+
.dispatch("document/updateAnnotation", {
|
|
235
|
+
annotationId: annotationToUpdate.id,
|
|
236
|
+
updatedValues: { label: label.id },
|
|
237
|
+
})
|
|
238
|
+
.catch((error) => {
|
|
239
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
240
|
+
error,
|
|
241
|
+
serverErrorMessage: this.$t("server_error"),
|
|
242
|
+
defaultErrorMessage: this.$t("edit_error"),
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
this.isLoading = false;
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
async deleteColumn(column) {
|
|
250
|
+
this.isLoading = true;
|
|
251
|
+
this.closeDropdown(column);
|
|
252
|
+
|
|
253
|
+
const annotationsToDelete = [];
|
|
254
|
+
for (let i = 0; i < this.rows.length; i++) {
|
|
255
|
+
const annotationToDelete = this.rows[i][column.label.id];
|
|
256
|
+
if (annotationToDelete && annotationToDelete.id) {
|
|
257
|
+
annotationsToDelete.push(annotationToDelete);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
annotationsToDelete.forEach(async (annotationToDelete) => {
|
|
262
|
+
await this.$store
|
|
263
|
+
.dispatch("document/deleteAnnotation", {
|
|
264
|
+
annotationId: annotationToDelete.id,
|
|
265
|
+
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
266
|
+
})
|
|
267
|
+
.catch((error) => {
|
|
268
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
269
|
+
error,
|
|
270
|
+
serverErrorMessage: this.$t("server_error"),
|
|
271
|
+
defaultErrorMessage: this.$t("edit_error"),
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
this.isLoading = false;
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
onDropdownChange(column, open) {
|
|
280
|
+
this.editingLabels = [];
|
|
281
|
+
this.$store.dispatch("selection/disableSelection");
|
|
282
|
+
this.$store.dispatch("document/resetEditAnnotation");
|
|
283
|
+
if (open) {
|
|
284
|
+
if (
|
|
285
|
+
this.openDropdown &&
|
|
286
|
+
this.$refs[this.getDropdownReference(column)].length > 0
|
|
287
|
+
) {
|
|
288
|
+
this.$refs[this.openDropdown][0].toggle();
|
|
289
|
+
}
|
|
290
|
+
this.openDropdown = this.getDropdownReference(column);
|
|
291
|
+
} else {
|
|
292
|
+
if (this.openDropdown === this.getDropdownReference(column)) {
|
|
293
|
+
this.openDropdown = null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
closeDropdown(column) {
|
|
299
|
+
if (
|
|
300
|
+
this.openDropdown &&
|
|
301
|
+
this.$refs[this.getDropdownReference(column)].length > 0
|
|
302
|
+
) {
|
|
303
|
+
this.$refs[this.getDropdownReference(column)][0].toggle();
|
|
304
|
+
this.openDropdown = null;
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
columndragstart(payload) {
|
|
309
|
+
this.draggingColumnIndex = payload.index;
|
|
310
|
+
payload.event.dataTransfer.effectAllowed = "copy";
|
|
311
|
+
},
|
|
312
|
+
columndragover(payload) {
|
|
313
|
+
payload.event.dataTransfer.dropEffect = "copy";
|
|
314
|
+
payload.event.target.closest("th").classList.add("is-selected");
|
|
315
|
+
payload.event.preventDefault();
|
|
316
|
+
},
|
|
317
|
+
columndragleave(payload) {
|
|
318
|
+
payload.event.target.closest("th").classList.remove("is-selected");
|
|
319
|
+
payload.event.preventDefault();
|
|
320
|
+
},
|
|
321
|
+
async columndrop(payload) {
|
|
322
|
+
payload.event.target.closest("th").classList.remove("is-selected");
|
|
323
|
+
const droppedOnColumnIndex = payload.index;
|
|
324
|
+
|
|
325
|
+
const draggingColumn = this.columns[this.draggingColumnIndex];
|
|
326
|
+
const droppedColumn = this.columns[droppedOnColumnIndex];
|
|
327
|
+
|
|
328
|
+
await this.changeLabel(draggingColumn, droppedColumn.label);
|
|
329
|
+
await this.changeLabel(droppedColumn, draggingColumn.label);
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
</script>
|
|
334
|
+
<style
|
|
335
|
+
scoped
|
|
336
|
+
lang="scss"
|
|
337
|
+
src="../../assets/scss/multi_ann_table_overlay.scss"
|
|
338
|
+
></style>
|