@konfuzio/document-validation-ui 0.1.24-dev.0 → 0.1.24-dev.1
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/dist/js/chunk-vendors.js +1 -1
- package/dist/js/chunk-vendors.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/scss/document_annotations.scss +5 -1
- package/src/assets/scss/document_search_bar.scss +71 -0
- package/src/assets/scss/document_toolbar.scss +2 -1
- package/src/assets/scss/theme.scss +2 -1
- package/src/assets/scss/variables.scss +1 -0
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +10 -0
- package/src/components/DocumentAnnotations/AnnotationRow.vue +11 -6
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +4 -5
- package/src/components/DocumentPage/DocumentPage.cy.js +82 -1
- package/src/components/DocumentPage/DocumentPage.vue +41 -1
- package/src/components/DocumentPage/DocumentToolbar.cy.js +12 -0
- package/src/components/DocumentPage/DocumentToolbar.vue +9 -1
- package/src/components/DocumentPage/NewAnnotation.vue +6 -2
- package/src/components/DocumentPage/ScrollingDocument.vue +6 -0
- package/src/components/DocumentPage/ScrollingPage.vue +26 -4
- package/src/components/DocumentPage/SearchBar.vue +130 -0
- package/src/components/DocumentTopBar/DocumentName.vue +19 -1
- package/src/icons.js +3 -1
- package/src/locales/de.json +7 -1
- package/src/locales/en.json +7 -1
- package/src/locales/es.json +7 -1
- package/src/store/display.js +106 -0
- package/src/store/document.js +1 -2
- package/src/utils/utils.js +9 -0
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
class="edit-btn btn"
|
|
33
33
|
@click="handleEdit"
|
|
34
34
|
>
|
|
35
|
-
{{ $t("
|
|
35
|
+
{{ $t("rename") }}
|
|
36
36
|
</div>
|
|
37
37
|
<div
|
|
38
38
|
v-if="showSaveBtn && !editMode"
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
<span v-else class="cloud-icon"><FileNameNotSaved /></span>
|
|
57
57
|
<span>{{ saved ? $t("saved") : $t("not_saved") }}</span>
|
|
58
58
|
</div>
|
|
59
|
+
|
|
60
|
+
<div
|
|
61
|
+
v-if="showDetailsButton"
|
|
62
|
+
class="details-btn btn"
|
|
63
|
+
@click="openDocumentDetails"
|
|
64
|
+
>
|
|
65
|
+
{{ $t("document_details") }}
|
|
66
|
+
</div>
|
|
59
67
|
</div>
|
|
60
68
|
</template>
|
|
61
69
|
|
|
@@ -63,6 +71,7 @@
|
|
|
63
71
|
import ServerImage from "../../assets/images/ServerImage";
|
|
64
72
|
import FileNameSaved from "../../assets/images/FileNameSavedImage";
|
|
65
73
|
import FileNameNotSaved from "../../assets/images/FileNameNotSavedImage";
|
|
74
|
+
import { isKonfuzioDomain, getDocumentDetailsLink } from "../../utils/utils";
|
|
66
75
|
import { mapGetters, mapState } from "vuex";
|
|
67
76
|
|
|
68
77
|
export default {
|
|
@@ -92,11 +101,17 @@ export default {
|
|
|
92
101
|
saved: false,
|
|
93
102
|
};
|
|
94
103
|
},
|
|
104
|
+
computed: {
|
|
105
|
+
showDetailsButton() {
|
|
106
|
+
return isKonfuzioDomain();
|
|
107
|
+
},
|
|
108
|
+
},
|
|
95
109
|
computed: {
|
|
96
110
|
...mapState("document", [
|
|
97
111
|
"selectedDocument",
|
|
98
112
|
"publicView",
|
|
99
113
|
"recalculatingAnnotations",
|
|
114
|
+
"documentId",
|
|
100
115
|
]),
|
|
101
116
|
...mapState("display", ["optimalResolution"]),
|
|
102
117
|
...mapState("edit", ["editMode"]),
|
|
@@ -229,6 +244,9 @@ export default {
|
|
|
229
244
|
contentNotEditable.blur();
|
|
230
245
|
}
|
|
231
246
|
},
|
|
247
|
+
openDocumentDetails() {
|
|
248
|
+
window.location.href = getDocumentDetailsLink(this.documentId);
|
|
249
|
+
},
|
|
232
250
|
},
|
|
233
251
|
};
|
|
234
252
|
</script>
|
package/src/icons.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
faArrowLeft,
|
|
19
19
|
faArrowRight,
|
|
20
20
|
faDownload,
|
|
21
|
+
faSearch,
|
|
21
22
|
} from "@fortawesome/free-solid-svg-icons";
|
|
22
23
|
import { FontAwesomeIcon as Icons } from "@fortawesome/vue-fontawesome";
|
|
23
24
|
|
|
@@ -39,7 +40,8 @@ library.add(
|
|
|
39
40
|
faRepeat,
|
|
40
41
|
faArrowLeft,
|
|
41
42
|
faArrowRight,
|
|
42
|
-
faDownload
|
|
43
|
+
faDownload,
|
|
44
|
+
faSearch
|
|
43
45
|
);
|
|
44
46
|
|
|
45
47
|
export default Icons;
|
package/src/locales/de.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"set_status": "Setzen Sie bitte einen Status",
|
|
17
17
|
"status_error": "Wir konnten den Status nicht ändern. Bitte versuchen Sie es später erneut.",
|
|
18
18
|
"edit": "Bearbeiten",
|
|
19
|
+
"rename": "Umbenennen",
|
|
19
20
|
"save": "Speichern",
|
|
20
21
|
"autosaving": "Automatisches Speichern...",
|
|
21
22
|
"saved": "Gespeichert",
|
|
@@ -146,5 +147,10 @@
|
|
|
146
147
|
"translated_string_title": "Übersetzter Text",
|
|
147
148
|
"no_translated_string": "Es existiert noch keine Übersetzung.",
|
|
148
149
|
"add_translation": "Klicken Sie zum hinzufügen",
|
|
149
|
-
"edit_translation": "Zum Bearbeiten anklicken"
|
|
150
|
+
"edit_translation": "Zum Bearbeiten anklicken",
|
|
151
|
+
"search": "Suchen",
|
|
152
|
+
"no_results": "Keine Ergebnisse",
|
|
153
|
+
"search_below_minimum": "Mindestens 3 Zeichen",
|
|
154
|
+
"search_in_document": "Suche im Dokument",
|
|
155
|
+
"document_details": "Einzelheiten"
|
|
150
156
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"set_status": "Set a status",
|
|
17
17
|
"status_error": "We couldn’t change the status. Please try again later.",
|
|
18
18
|
"edit": "Edit",
|
|
19
|
+
"rename": "Rename",
|
|
19
20
|
"save": "Save",
|
|
20
21
|
"autosaving": "Auto saving...",
|
|
21
22
|
"saved": "Saved",
|
|
@@ -146,5 +147,10 @@
|
|
|
146
147
|
"translated_string_title": "Translated text",
|
|
147
148
|
"no_translated_string": "No translation exists yet.",
|
|
148
149
|
"add_translation": "Click to add one",
|
|
149
|
-
"edit_translation": "Click to edit"
|
|
150
|
+
"edit_translation": "Click to edit",
|
|
151
|
+
"search": "Search",
|
|
152
|
+
"no_results": "No results",
|
|
153
|
+
"search_below_minimum": "Minimum 3 characters",
|
|
154
|
+
"search_in_document": "Search document",
|
|
155
|
+
"document_details": "Details"
|
|
150
156
|
}
|
package/src/locales/es.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"set_status": "Establecer estado",
|
|
17
17
|
"status_error": "No ha sido posible cambiar el estado del documento. Por favor, inténtelo de nuevo más tarde.",
|
|
18
18
|
"edit": "Editar",
|
|
19
|
+
"rename": "Rebautizar",
|
|
19
20
|
"save": "Guardar",
|
|
20
21
|
"autosaving": "Auto guardando...",
|
|
21
22
|
"saved": "Guardado",
|
|
@@ -146,5 +147,10 @@
|
|
|
146
147
|
"translated_string_title": "Texto traducido",
|
|
147
148
|
"no_translated_string": "Aún no existe traducción.",
|
|
148
149
|
"add_translation": "Clic para agregar",
|
|
149
|
-
"edit_translation": "Clic para editar"
|
|
150
|
+
"edit_translation": "Clic para editar",
|
|
151
|
+
"search": "Buscar",
|
|
152
|
+
"no_results": "Sin resultados",
|
|
153
|
+
"search_below_minimum": "Mínimo 3 caracteres",
|
|
154
|
+
"search_in_document": "Buscar en documento",
|
|
155
|
+
"document_details": "Detalles"
|
|
150
156
|
}
|
package/src/store/display.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
+
import myImports from "../api";
|
|
2
3
|
import {
|
|
3
4
|
PIXEL_RATIO,
|
|
4
5
|
VIEWPORT_RATIO,
|
|
5
6
|
MINIMUM_APP_WIDTH,
|
|
6
7
|
MINIMUM_OPTIMIZED_APP_WIDTH,
|
|
7
8
|
} from "../constants";
|
|
9
|
+
|
|
10
|
+
const HTTP = myImports.HTTP;
|
|
11
|
+
|
|
8
12
|
const debounce = (cb, duration) => {
|
|
9
13
|
let timer;
|
|
10
14
|
return (...args) => {
|
|
@@ -31,6 +35,11 @@ const state = {
|
|
|
31
35
|
pageChangedFromThumbnail: false,
|
|
32
36
|
showAnnSetTable: null,
|
|
33
37
|
showChooseLabelSetModal: null,
|
|
38
|
+
currentSearch: "",
|
|
39
|
+
searchEnabled: false,
|
|
40
|
+
searchResults: [],
|
|
41
|
+
searchLoading: false,
|
|
42
|
+
currentSearchResult: null,
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
const getters = {
|
|
@@ -54,6 +63,28 @@ const getters = {
|
|
|
54
63
|
return [previousPage, state.currentPage, nextPage];
|
|
55
64
|
},
|
|
56
65
|
|
|
66
|
+
searchResultsForPage: (state, getters) => (pageNumber) => {
|
|
67
|
+
if (!state.searchEnabled || state.searchResults.length < 1) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return state.searchResults.filter((r) => r.page_index + 1 === pageNumber);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
currentSearchResultForPage: (state) => (pageNumber) => {
|
|
75
|
+
if (!state.searchEnabled || state.searchResults.length < 1) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const currentResult = state.searchResults[state.currentSearchResult];
|
|
80
|
+
|
|
81
|
+
if (!currentResult || currentResult.page_index !== pageNumber - 1) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return currentResult;
|
|
86
|
+
},
|
|
87
|
+
|
|
57
88
|
/**
|
|
58
89
|
* The proportion between the original size of the page and the
|
|
59
90
|
* image rendering.
|
|
@@ -259,6 +290,62 @@ const actions = {
|
|
|
259
290
|
setPageChangedFromThumbnail: ({ commit }, value) => {
|
|
260
291
|
commit("SET_PAGE_CHANGED_FROM_THUMBNAIL", value);
|
|
261
292
|
},
|
|
293
|
+
|
|
294
|
+
debounceSearch: debounce(({ commit, dispatch }, query) => {
|
|
295
|
+
dispatch("search", query);
|
|
296
|
+
}, 300),
|
|
297
|
+
|
|
298
|
+
startSearchLoading({ commit }) {
|
|
299
|
+
commit("SET_SEARCH_LOADING", true);
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
search({ commit, rootState }, query) {
|
|
303
|
+
// only allow queries that are at least 3 characters long
|
|
304
|
+
if (query.length >= 3) {
|
|
305
|
+
return HTTP.post(`documents/${rootState.document.documentId}/search/`, {
|
|
306
|
+
q: query,
|
|
307
|
+
}).then((response) => {
|
|
308
|
+
commit("SET_SEARCH_RESULTS", response.data.span);
|
|
309
|
+
commit("SET_SEARCH_LOADING", false);
|
|
310
|
+
});
|
|
311
|
+
} else {
|
|
312
|
+
commit("SET_SEARCH_RESULTS", []);
|
|
313
|
+
commit("SET_SEARCH_LOADING", false);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
resetSearch({ commit }) {
|
|
318
|
+
commit("SET_CURRENT_SEARCH", "");
|
|
319
|
+
commit("SET_SEARCH_RESULTS", []);
|
|
320
|
+
commit("SET_SEARCH_LOADING", false);
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
toggleSearch({ commit }) {
|
|
324
|
+
commit("TOGGLE_SEARCH");
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
enableSearch({ commit }, toEnable) {
|
|
328
|
+
commit("ENABLE_SEARCH", toEnable);
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
setCurrentSearch({ commit }, currentSearch) {
|
|
332
|
+
commit("SET_CURRENT_SEARCH", currentSearch);
|
|
333
|
+
},
|
|
334
|
+
|
|
335
|
+
setCurrentSearchResult({ commit, state }, n) {
|
|
336
|
+
let newSearchResult = state.currentSearchResult + n;
|
|
337
|
+
const searchResultsMaxIndex = state.searchResults.length - 1;
|
|
338
|
+
|
|
339
|
+
if (newSearchResult > searchResultsMaxIndex) {
|
|
340
|
+
// once we're at the end of the results, start again
|
|
341
|
+
newSearchResult = 0;
|
|
342
|
+
} else if (newSearchResult < 0) {
|
|
343
|
+
// once we're at the beginning of the results, go to the end
|
|
344
|
+
newSearchResult = searchResultsMaxIndex;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
commit("SET_CURRENT_SEARCH_RESULT", newSearchResult);
|
|
348
|
+
},
|
|
262
349
|
};
|
|
263
350
|
|
|
264
351
|
const mutations = {
|
|
@@ -303,6 +390,25 @@ const mutations = {
|
|
|
303
390
|
SET_SHOW_CHOOSE_LABEL_SET_MODAL: (state, options) => {
|
|
304
391
|
state.showChooseLabelSetModal = options;
|
|
305
392
|
},
|
|
393
|
+
SET_SEARCH_RESULTS: (state, searchResults) => {
|
|
394
|
+
state.currentSearchResult = 0;
|
|
395
|
+
state.searchResults = searchResults;
|
|
396
|
+
},
|
|
397
|
+
SET_SEARCH_LOADING: (state, loading) => {
|
|
398
|
+
state.searchLoading = loading;
|
|
399
|
+
},
|
|
400
|
+
TOGGLE_SEARCH: (state) => {
|
|
401
|
+
state.searchEnabled = !state.searchEnabled;
|
|
402
|
+
},
|
|
403
|
+
ENABLE_SEARCH: (state, toEnable) => {
|
|
404
|
+
state.searchEnabled = toEnable;
|
|
405
|
+
},
|
|
406
|
+
SET_CURRENT_SEARCH: (state, currentSearch) => {
|
|
407
|
+
state.currentSearch = currentSearch;
|
|
408
|
+
},
|
|
409
|
+
SET_CURRENT_SEARCH_RESULT: (state, n) => {
|
|
410
|
+
state.currentSearchResult = n;
|
|
411
|
+
},
|
|
306
412
|
};
|
|
307
413
|
|
|
308
414
|
export default {
|
package/src/store/document.js
CHANGED
|
@@ -663,8 +663,6 @@ const getters = {
|
|
|
663
663
|
return label.annotations;
|
|
664
664
|
});
|
|
665
665
|
|
|
666
|
-
console.log(annotations);
|
|
667
|
-
|
|
668
666
|
return annotations.length === 0 ? true : false;
|
|
669
667
|
},
|
|
670
668
|
};
|
|
@@ -672,6 +670,7 @@ const getters = {
|
|
|
672
670
|
const actions = {
|
|
673
671
|
startLoading: ({ commit }) => {
|
|
674
672
|
commit("SET_LOADING", true);
|
|
673
|
+
commit("display/ENABLE_SEARCH", false, { root: true });
|
|
675
674
|
},
|
|
676
675
|
endLoading: ({ commit }) => {
|
|
677
676
|
commit("SET_LOADING", false);
|
package/src/utils/utils.js
CHANGED
|
@@ -49,6 +49,15 @@ export function navigateToDocumentsList(path, projectId, userId) {
|
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export function isKonfuzioDomain() {
|
|
53
|
+
return window.location.hostname.includes("konfuzio.com");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getDocumentDetailsLink(docId) {
|
|
57
|
+
const domain = window.location.hostname;
|
|
58
|
+
return `https://${domain}/admin/server/document/${docId}/change`;
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
export function isElementArray(element) {
|
|
53
62
|
return Array.isArray(element);
|
|
54
63
|
}
|