@konfuzio/document-validation-ui 0.1.10-dev.9 → 0.1.11-dev.0

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.
Files changed (38) hide show
  1. package/dist/css/app.css +1 -1
  2. package/dist/index.html +1 -1
  3. package/dist/js/app.js +1 -1
  4. package/dist/js/app.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/assets/scss/document_edit.scss +2 -0
  7. package/src/assets/scss/document_name.scss +0 -2
  8. package/src/assets/scss/document_top_bar.scss +22 -0
  9. package/src/assets/scss/new_annotation.scss +3 -0
  10. package/src/assets/scss/theme.scss +533 -523
  11. package/src/components/App.vue +23 -8
  12. package/src/components/DocumentAnnotations/AnnotationContent.vue +33 -18
  13. package/src/components/DocumentAnnotations/AnnotationRow.vue +21 -60
  14. package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +3 -2
  15. package/src/components/DocumentAnnotations/EmptyAnnotation.vue +1 -5
  16. package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +1 -1
  17. package/src/components/DocumentDashboard.vue +8 -0
  18. package/src/components/DocumentEdit/DocumentEdit.vue +20 -11
  19. package/src/components/DocumentEdit/EditConfirmationModal.vue +1 -0
  20. package/src/components/DocumentEdit/EditPageThumbnail.vue +1 -3
  21. package/src/components/DocumentEdit/EditSidebar.vue +8 -3
  22. package/src/components/DocumentPage/DocumentPage.vue +0 -18
  23. package/src/components/DocumentPage/DocumentToolbar.vue +1 -0
  24. package/src/components/DocumentPage/MultiAnnSelection.vue +4 -26
  25. package/src/components/DocumentPage/NewAnnotation.vue +4 -22
  26. package/src/components/DocumentTopBar/DocumentName.vue +3 -1
  27. package/src/components/DocumentTopBar/DocumentTopBar.vue +81 -2
  28. package/src/components/DocumentsList/DocumentsList.vue +1 -6
  29. package/src/locales/de.json +3 -2
  30. package/src/locales/en.json +2 -1
  31. package/src/locales/es.json +2 -1
  32. package/src/store/category.js +19 -35
  33. package/src/store/display.js +7 -0
  34. package/src/store/document.js +29 -5
  35. package/src/store/edit.js +27 -15
  36. package/src/store/project.js +31 -1
  37. package/src/utils/utils.js +18 -1
  38. package/src/components/DocumentPage/MultiAnnotationTablePopup.vue +0 -226
@@ -259,15 +259,7 @@ export default {
259
259
  this.loading = false;
260
260
  });
261
261
  },
262
- disableLabelSetModalShowing() {
263
- // timeout to stop propagation of click event
264
- setTimeout(() => {
265
- this.isAnnSetModalShowing = false;
266
- }, 500);
267
- },
268
262
  chooseLabelSet(labelSet) {
269
- this.disableLabelSetModalShowing();
270
-
271
263
  const newSet = {
272
264
  label_set: labelSet,
273
265
  labels: labelSet.labels,
@@ -277,20 +269,10 @@ export default {
277
269
  this.selectedSet = newSet;
278
270
  },
279
271
  openAnnotationSetCreation() {
280
- this.isAnnSetModalShowing = true;
281
-
282
- this.$buefy.modal.open({
283
- parent: this.$parent,
284
- component: ChooseLabelSetModal,
285
- hasModalCard: true,
286
- trapFocus: true,
287
- canCancel: false,
288
- onCancel: this.disableLabelSetModalShowing,
289
- customClass: "dv-ui-theme invisible-parent-modal",
290
- events: {
291
- labelSet: this.chooseLabelSet,
292
- close: this.disableLabelSetModalShowing,
293
- },
272
+ this.$store.dispatch("display/showChooseLabelSetModal", {
273
+ show: true,
274
+ isMultipleAnnotations: true,
275
+ finish: this.chooseLabelSet,
294
276
  });
295
277
  },
296
278
  setTooltipText() {
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <div class="document-name-component">
2
+ <div
3
+ :class="['document-name-component', editMode && 'document-name-edit-mode']"
4
+ >
3
5
  <div class="document-icon">
4
6
  <ServerImage
5
7
  :height="'22px'"
@@ -10,7 +10,36 @@
10
10
  />
11
11
  </div>
12
12
 
13
- <DocumentName :data-file-name="selectedDocument.data_file_name" />
13
+ <div
14
+ :class="[
15
+ 'center-bar-components',
16
+ recalculatingAnnotations && 'single-component',
17
+ ]"
18
+ >
19
+ <div
20
+ :class="[
21
+ 'left-arrow navigation-arrow',
22
+ !previousDocument && 'navigation-disabled',
23
+ ]"
24
+ type="button"
25
+ @click="navigateToDocument(previousDocument)"
26
+ >
27
+ <b-icon icon="angle-left" size="is-small" />
28
+ </div>
29
+
30
+ <DocumentName :data-file-name="selectedDocument.data_file_name" />
31
+
32
+ <div
33
+ :class="[
34
+ 'right-arrow navigation-arrow',
35
+ !nextDocument && 'navigation-disabled',
36
+ ]"
37
+ type="button"
38
+ @click="navigateToDocument(nextDocument)"
39
+ >
40
+ <b-icon icon="angle-right" size="is-small" />
41
+ </div>
42
+ </div>
14
43
 
15
44
  <div v-if="!recalculatingAnnotations" class="right-bar-components">
16
45
  <div
@@ -87,6 +116,8 @@ export default {
87
116
  data() {
88
117
  return {
89
118
  categoryError: false,
119
+ previousDocument: null,
120
+ nextDocument: null,
90
121
  };
91
122
  },
92
123
  computed: {
@@ -98,7 +129,19 @@ export default {
98
129
  ]),
99
130
  ...mapState("category", ["categories"]),
100
131
  ...mapState("edit", ["editMode"]),
101
- ...mapGetters("document", ["isDocumentReviewed"]),
132
+ ...mapState("project", ["documentsInProject"]),
133
+ ...mapGetters("document", [
134
+ "isDocumentReviewed",
135
+ "isDocumentReadyToBeReviewed",
136
+ "waitingForSplittingConfirmation",
137
+ ]),
138
+ },
139
+ watch: {
140
+ documentsInProject(newValue) {
141
+ if (newValue && this.selectedDocument) {
142
+ this.getPreviousAndNextDocuments();
143
+ }
144
+ },
102
145
  },
103
146
  created() {
104
147
  window.addEventListener("resize", this.handleResize);
@@ -120,6 +163,42 @@ export default {
120
163
  handleResize() {
121
164
  this.setComponentWidth(this.$refs.documentTopBar.offsetWidth);
122
165
  },
166
+ getPreviousAndNextDocuments() {
167
+ // Only consider documents who have a status of "ready"
168
+ const filteredDocuments = this.documentsInProject.filter(
169
+ (document) =>
170
+ this.isDocumentReadyToBeReviewed(document) ||
171
+ this.waitingForSplittingConfirmation(document)
172
+ );
173
+
174
+ if (!filteredDocuments) return;
175
+
176
+ const found = filteredDocuments.find(
177
+ (document) => document.id === this.selectedDocument.id
178
+ );
179
+
180
+ const indexOfCurrentDocument = filteredDocuments.indexOf(found);
181
+
182
+ if (!(indexOfCurrentDocument < 0)) {
183
+ this.previousDocument = filteredDocuments[indexOfCurrentDocument - 1];
184
+ this.nextDocument = filteredDocuments[indexOfCurrentDocument + 1];
185
+ } else {
186
+ this.previousDocument = filteredDocuments[0];
187
+ this.nextDocument = filteredDocuments[1];
188
+ }
189
+ },
190
+ navigateToDocument(document) {
191
+ if (!document) return;
192
+
193
+ this.$store.dispatch("document/changeCurrentDocument", document.id);
194
+
195
+ if (this.editMode) {
196
+ // Reset edit mode when changing the document,
197
+ // in case the change was made from the arrows in the Edit Mode
198
+ // so that the user does not get stuck in this interface
199
+ this.$store.dispatch("edit/disableEditMode");
200
+ }
201
+ },
123
202
  },
124
203
  };
125
204
  </script>
@@ -110,12 +110,7 @@ export default {
110
110
  },
111
111
  methods: {
112
112
  changeDocument(documentId) {
113
- if (getURLQueryParam("document") || getURLPath("docs")) {
114
- navigateToNewDocumentURL(this.selectedDocument.id, documentId);
115
- } else {
116
- this.$store.dispatch("document/setDocId", documentId);
117
- this.$store.dispatch("document/fetchDocument");
118
- }
113
+ this.$store.dispatch("document/changeCurrentDocument", documentId);
119
114
  },
120
115
  requestTrialAccess() {
121
116
  window.open("https://konfuzio.com", "_blank");
@@ -57,7 +57,7 @@
57
57
  "reorder": "Sortieren",
58
58
  "rotate": "Rotieren",
59
59
  "edit_error": "Die Änderungen konnten nicht gespeichert werden. Bitte versuchen Sie es später erneut.",
60
- "select_pages": "Sie können nun Seiten drehen, neu sortieren und Dokumente splitten.",
60
+ "select_pages": "Sie können nun Seiten drehen, neu sortieren und Dokumente teilen.",
61
61
  "edit_document": "Dokument bearbeiten (Early Access)",
62
62
  "edit_early_access": "Sie sind einer der Nutzer, die Zugang zu diesen Funktionalitäten vor dem offiziellen Erscheinungstermin erhalten.",
63
63
  "selected": "ausgewählt",
@@ -131,5 +131,6 @@
131
131
  "edit_label": "Label editieren",
132
132
  "delete_label": "Label löschen",
133
133
  "table": "Tabelle",
134
- "prepare_document": "Dokument vorbereiten"
134
+ "prepare_document": "Dokument vorbereiten",
135
+ "delete_table": "Tabelle löschen"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "missing_from_document": "Missing from the document",
132
132
  "edit_label": "Edit label",
133
133
  "delete_label": "Delete label",
134
- "table": "Table"
134
+ "table": "Table",
135
+ "delete_table": "Delete table"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "table": "Tabla",
132
132
  "new_multi_ann_description": "Seleccione un modelo de datos de los existentes, luego deseleccione las etiquetas que no existen en este documento.",
133
133
  "new_multi_ann_title": "Crear múltiples anotaciones",
134
- "prepare_document": "Prepare el documento"
134
+ "prepare_document": "Prepare el documento",
135
+ "delete_table": "Eliminar tabla"
135
136
  }
@@ -3,7 +3,7 @@ import myImports from "../api";
3
3
  const HTTP = myImports.HTTP;
4
4
 
5
5
  const state = {
6
- documentsInProject: [],
6
+ createAvailableListOfDocuments: false,
7
7
  documentsAvailableToReview: [], // filtered by user
8
8
  categories: null,
9
9
  };
@@ -39,37 +39,21 @@ const getters = {
39
39
  };
40
40
 
41
41
  const actions = {
42
- setDocumentsInProject: ({ commit }, documents) => {
43
- commit("SET_DOCUMENTS_IN_PROJECT", documents);
44
- },
45
42
  setDocumentsAvailableToReview: ({ commit }, documentsAvailableToReview) => {
46
43
  commit("SET_AVAILABLE_DOCUMENTS", documentsAvailableToReview);
47
44
  },
48
45
  setCategories: ({ commit }, categories) => {
49
46
  commit("SET_CATEGORIES", categories);
50
47
  },
51
- /**
52
- * Actions that use HTTP requests always return the axios promise,
53
- * so they can be `await`ed (useful to set the `loading` status).
54
- */
55
- fetchDocumentList: ({ commit, rootState }, categoryId) => {
56
- return HTTP.get(
57
- `documents/?category=${categoryId}&assignee=${rootState.project.currentUser}&limit=100`
58
- )
59
- .then((response) => {
60
- if (response.data.results) {
61
- commit("SET_DOCUMENTS_IN_PROJECT", response.data.results);
62
- }
63
- })
64
- .catch((error) => {
65
- console.log(error, "Could not fetch document list from the backend");
66
- });
67
- },
68
48
 
69
49
  createAvailableDocumentsList: (
70
- { commit, state, dispatch, rootGetters },
50
+ { commit, state, dispatch, rootState, rootGetters },
71
51
  { categoryId, user, poll }
72
52
  ) => {
53
+ if (!state.createAvailableListOfDocuments) return;
54
+
55
+ const parameters = `category=${categoryId}`;
56
+
73
57
  const sleep = (duration) =>
74
58
  new Promise((resolve) => setTimeout(resolve, duration));
75
59
 
@@ -80,10 +64,10 @@ const actions = {
80
64
  let errors = 0;
81
65
  count += 1;
82
66
 
83
- return dispatch("fetchDocumentList", categoryId).then(() => {
84
- for (let i = 0; i < state.documentsInProject.length; i++) {
67
+ return dispatch("project/fetchDocumentList", parameters).then(() => {
68
+ for (let i = 0; i < rootState.project.documentsInProject.length; i++) {
85
69
  const found = state.documentsAvailableToReview.find(
86
- (doc) => doc.id === state.documentsInProject[i].id
70
+ (doc) => doc.id === rootState.project.documentsInProject[i].id
87
71
  );
88
72
 
89
73
  if (found) {
@@ -92,14 +76,17 @@ const actions = {
92
76
  continue;
93
77
  } else if (
94
78
  rootGetters["document/isDocumentReadyToBeReviewed"](
95
- state.documentsInProject[i]
79
+ rootState.project.documentsInProject[i]
96
80
  )
97
81
  ) {
98
82
  // add available doc to the end of the array
99
- commit("ADD_AVAILABLE_DOCUMENT", state.documentsInProject[i]);
83
+ commit(
84
+ "ADD_AVAILABLE_DOCUMENT",
85
+ rootState.project.documentsInProject[i]
86
+ );
100
87
  } else if (
101
88
  rootGetters["document/documentHadErrorDuringExtraction"](
102
- state.documentsInProject[i]
89
+ rootState.project.documentsInProject[i]
103
90
  )
104
91
  ) {
105
92
  dispatch("document/setDocumentError", null, { root: true });
@@ -118,10 +105,10 @@ const actions = {
118
105
  // And if the difference is due to errors or to docs not ready
119
106
  if (
120
107
  poll &&
121
- state.documentsInProject.length !==
108
+ rootState.project.documentsInProject.length !==
122
109
  state.documentsAvailableToReview.length &&
123
110
  state.documentsAvailableToReview.length + errors !==
124
- state.documentsInProject.length
111
+ rootState.project.documentsInProject.length
125
112
  ) {
126
113
  if (count >= 10) return true;
127
114
 
@@ -137,8 +124,8 @@ const actions = {
137
124
 
138
125
  // Poll as long as the lengths are different
139
126
  if (
140
- state.documentsInProject.length === 0 ||
141
- state.documentsInProject.length !==
127
+ rootState.project.documentsInProject.length === 0 ||
128
+ rootState.project.documentsInProject.length !==
142
129
  state.documentsAvailableToReview.length
143
130
  ) {
144
131
  let duration;
@@ -169,9 +156,6 @@ const actions = {
169
156
  };
170
157
 
171
158
  const mutations = {
172
- SET_DOCUMENTS_IN_PROJECT: (state, documents) => {
173
- state.documentsInProject = documents;
174
- },
175
159
  SET_AVAILABLE_DOCUMENTS: (state, documentsAvailableToReview) => {
176
160
  state.documentsAvailableToReview = documentsAvailableToReview;
177
161
  },
@@ -31,6 +31,7 @@ const state = {
31
31
  categorizeModalIsActive: false,
32
32
  pageChangedFromThumbnail: false,
33
33
  showAnnSetTable: null,
34
+ showChooseLabelSetModal: null,
34
35
  };
35
36
 
36
37
  const getters = {
@@ -236,6 +237,9 @@ const actions = {
236
237
  showAnnSetTable({ commit }, tableSet) {
237
238
  commit("SET_ANN_SET_TABLE", tableSet);
238
239
  },
240
+ showChooseLabelSetModal({ commit }, options) {
241
+ commit("SET_SHOW_CHOOSE_LABEL_SET_MODAL", options);
242
+ },
239
243
  toggleAnnSetTable({ commit }, tableSet) {
240
244
  commit("TOGGLE_ANN_SET_TABLE", tableSet);
241
245
  },
@@ -286,6 +290,9 @@ const mutations = {
286
290
  SET_PAGE_CHANGED_FROM_THUMBNAIL: (state, value) => {
287
291
  state.pageChangedFromThumbnail = value;
288
292
  },
293
+ SET_SHOW_CHOOSE_LABEL_SET_MODAL: (state, options) => {
294
+ state.showChooseLabelSetModal = options;
295
+ },
289
296
  };
290
297
 
291
298
  export default {
@@ -1,5 +1,10 @@
1
1
  import myImports from "../api";
2
- import { sleep } from "../utils/utils";
2
+ import {
3
+ sleep,
4
+ getURLQueryParam,
5
+ navigateToNewDocumentURL,
6
+ getURLPath,
7
+ } from "../utils/utils";
3
8
 
4
9
  const HTTP = myImports.HTTP;
5
10
  const documentPollDuration = 1000;
@@ -758,13 +763,18 @@ const actions = {
758
763
  await dispatch("category/fetchCategories", projectId, {
759
764
  root: true,
760
765
  });
766
+
767
+ // get list of documents not reviewed
768
+ await dispatch("project/fetchDocumentList", "is_reviewed=false", {
769
+ root: true,
770
+ });
761
771
  }
762
- if (categoryId) {
772
+ if (categoryId && rootState.category.createAvailableListOfDocuments) {
763
773
  await dispatch(
764
774
  "category/createAvailableDocumentsList",
765
775
  {
766
776
  categoryId,
767
- user: rootState.project.currentUser,
777
+ user: rootState.project.currentUser.username,
768
778
  poll: pollDocumentList,
769
779
  },
770
780
  {
@@ -1063,7 +1073,7 @@ const actions = {
1063
1073
  { error, serverErrorMessage, defaultErrorMessage }
1064
1074
  ) => {
1065
1075
  // check type of error
1066
- if (error && error.status === 500) {
1076
+ if (error && error.status >= 500 && error.status < 600) {
1067
1077
  dispatch("setErrorMessage", serverErrorMessage);
1068
1078
  commit("SET_SERVER_ERROR", true);
1069
1079
  } else if (error.data && error.data.length > 0) {
@@ -1083,11 +1093,25 @@ const actions = {
1083
1093
 
1084
1094
  contactSupport: ({ rootState }, error) => {
1085
1095
  const url = "https://konfuzio.com/support/";
1086
- const params = `project=${rootState.project.projectId}&email=${rootState.project.currentUser}&issue=${error}`;
1096
+ const params = `project=${rootState.project.projectId}&email=${rootState.project.currentUser.username}&issue=${error}`;
1087
1097
  const fullUrl = `${url}?${params}`;
1088
1098
 
1089
1099
  window.open(fullUrl, "_blank");
1090
1100
  },
1101
+
1102
+ changeCurrentDocument: ({ commit, state, dispatch }, newDocumentId) => {
1103
+ // reset splitting suggestions
1104
+ if (state.splittingSuggestions) {
1105
+ commit("SET_SPLITTING_SUGGESTIONS", null);
1106
+ }
1107
+
1108
+ if (getURLQueryParam("document") || getURLPath("d")) {
1109
+ navigateToNewDocumentURL(state.selectedDocument.id, newDocumentId);
1110
+ } else {
1111
+ commit("SET_DOC_ID", newDocumentId);
1112
+ dispatch("fetchDocument");
1113
+ }
1114
+ },
1091
1115
  };
1092
1116
 
1093
1117
  const mutations = {
package/src/store/edit.js CHANGED
@@ -10,7 +10,7 @@ const HTTP = myImports.HTTP;
10
10
  const state = {
11
11
  editMode: false,
12
12
  renameAndCategorize: false,
13
- isMultipleSelection: false,
13
+ isMultipleSelection: true,
14
14
  pagesForPostprocess: [],
15
15
  selectedPages: [],
16
16
  updatedDocument: [],
@@ -28,12 +28,19 @@ const getters = {
28
28
  (page) => page.angle !== 0
29
29
  );
30
30
 
31
- let foundReorderedPage;
32
-
33
- state.pagesForPostprocess.map((page) => {
34
- foundReorderedPage = rootState.document.selectedDocument.pages.find(
35
- (p) => p.id === page.id && p.number !== page.number
36
- );
31
+ let foundReorderedPage = false;
32
+
33
+ state.pagesForPostprocess.map((page, index) => {
34
+ if (
35
+ (page.id === rootState.document.selectedDocument.pages[index].id &&
36
+ page.number !==
37
+ rootState.document.selectedDocument.pages[index].number) ||
38
+ (page.id !== rootState.document.selectedDocument.pages[index].id &&
39
+ page.number ===
40
+ rootState.document.selectedDocument.pages[index].number)
41
+ ) {
42
+ foundReorderedPage = true;
43
+ }
37
44
  });
38
45
 
39
46
  return (
@@ -113,12 +120,12 @@ const actions = {
113
120
  },
114
121
 
115
122
  rotatePage: ({ state, commit }, { page, direction }) => {
116
- if (state.pagesForPostprocess.find((p) => p.id === page[0].id)) {
123
+ if (state.pagesForPostprocess.find((p) => p.id === page.id)) {
117
124
  const pagesForPostprocess = state.pagesForPostprocess.map((p) => {
118
125
  let rotatedAngle;
119
126
  if (direction === "left") {
120
127
  rotatedAngle = p.angle - 90;
121
- if (p.id === page[0].id) {
128
+ if (p.id === page.id) {
122
129
  if (rotatedAngle === -270) {
123
130
  rotatedAngle = 90;
124
131
  }
@@ -131,7 +138,7 @@ const actions = {
131
138
  }
132
139
  if (direction === "right") {
133
140
  rotatedAngle = p.angle + 90;
134
- if (p.id === page[0].id) {
141
+ if (p.id === page.id) {
135
142
  if (rotatedAngle === 270) {
136
143
  rotatedAngle = -90;
137
144
  }
@@ -219,7 +226,7 @@ const actions = {
219
226
 
220
227
  commit("SET_SUBMIT_EDIT_CHANGES", false);
221
228
 
222
- if (newId !== oldId) {
229
+ if (newId != oldId) {
223
230
  if (getURLQueryParam("document") || getURLPath("docs")) {
224
231
  navigateToNewDocumentURL(oldId, newId);
225
232
  } else {
@@ -231,12 +238,17 @@ const actions = {
231
238
  root: true,
232
239
  });
233
240
  }
241
+ } else {
242
+ dispatch("document/setSelectedDocument", response.data[0], {
243
+ root: true,
244
+ });
245
+
246
+ dispatch("document/pollDocumentEndpoint", null, {
247
+ root: true,
248
+ });
234
249
  }
235
-
236
- resolve(null);
237
- } else {
238
- resolve(response);
239
250
  }
251
+ resolve(response);
240
252
  })
241
253
  .catch((error) => {
242
254
  reject(error.response);
@@ -4,6 +4,8 @@ const HTTP = myImports.HTTP;
4
4
  const state = {
5
5
  projectId: null,
6
6
  currentUser: null,
7
+ documentsListPath: null,
8
+ documentsInProject: null,
7
9
  };
8
10
 
9
11
  const getters = {
@@ -65,7 +67,7 @@ const actions = {
65
67
  fetchCurrentUser: ({ commit }) => {
66
68
  return HTTP.get(`/auth/me/`)
67
69
  .then((response) => {
68
- commit("SET_CURRENT_USER", response.data.username);
70
+ commit("SET_CURRENT_USER", response.data);
69
71
  })
70
72
  .catch((error) => {
71
73
  console.log(error);
@@ -75,6 +77,28 @@ const actions = {
75
77
  setCurrentUser: ({ commit }, currentUser) => {
76
78
  commit("SET_CURRENT_USER", currentUser);
77
79
  },
80
+
81
+ setDocumentsListPath: ({ commit }, path) => {
82
+ commit("SET_DOCUMENTS_LIST_PATH", path);
83
+ },
84
+
85
+ setDocumentsInProject: ({ commit }, documents) => {
86
+ commit("SET_DOCUMENTS_IN_PROJECT", documents);
87
+ },
88
+
89
+ fetchDocumentList: ({ commit, state }, parameters) => {
90
+ return HTTP.get(
91
+ `documents/?project=${state.projectId}&assignee=${state.currentUser.username}&limit=100&${parameters}`
92
+ )
93
+ .then((response) => {
94
+ if (response.data.results) {
95
+ commit("SET_DOCUMENTS_IN_PROJECT", response.data.results);
96
+ }
97
+ })
98
+ .catch((error) => {
99
+ console.log(error, "Could not fetch document list from the backend");
100
+ });
101
+ },
78
102
  };
79
103
 
80
104
  const mutations = {
@@ -84,6 +108,12 @@ const mutations = {
84
108
  SET_CURRENT_USER: (state, currentUser) => {
85
109
  state.currentUser = currentUser;
86
110
  },
111
+ SET_DOCUMENTS_LIST_PATH: (state, path) => {
112
+ state.documentsListPath = path;
113
+ },
114
+ SET_DOCUMENTS_IN_PROJECT: (state, documents) => {
115
+ state.documentsInProject = documents;
116
+ },
87
117
  };
88
118
 
89
119
  export default {
@@ -15,7 +15,7 @@ export function getURLQueryParam(param) {
15
15
  export function getURLPath(value) {
16
16
  const path = window.location.pathname;
17
17
 
18
- if (!path.includes(value)) return;
18
+ if (!path.includes(`/${value}/`)) return;
19
19
 
20
20
  const id = path.split(value)[1].split("/")[1];
21
21
 
@@ -30,6 +30,23 @@ export function navigateToNewDocumentURL(oldId, newId) {
30
30
  window.location.replace(newUrl);
31
31
  }
32
32
 
33
+ export function navigateToDocumentsList(path, projectId, userId) {
34
+ if (!path) return;
35
+
36
+ const lastCharOfString = path.charAt(path.length - 1);
37
+ let slash = "/";
38
+
39
+ if (lastCharOfString === slash) {
40
+ slash = "";
41
+ }
42
+
43
+ const parameters = `?project=${projectId}&is_reviewed__exact=0&assignee__id__exact=${userId}`;
44
+
45
+ const newPath = `${path}${slash}${parameters}`;
46
+
47
+ window.location.pathname = newPath;
48
+ }
49
+
33
50
  export function isElementArray(element) {
34
51
  return Array.isArray(element);
35
52
  }