From b87945c42f690ab667fcd50e723754603db6e52d Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 28 Sep 2019 01:35:58 +0300 Subject: [PATCH] Add ability to switch between all reports and grouped reports (with stubbed data) --- src/store/modules/reports.js | 17 +- .../reports/components/GroupedReport.vue | 120 ++++++++++++ src/views/reports/components/ReportCard.vue | 89 +++++++++ src/views/reports/index.vue | 182 +++++++++++++++++- 4 files changed, 394 insertions(+), 14 deletions(-) create mode 100644 src/views/reports/components/GroupedReport.vue create mode 100644 src/views/reports/components/ReportCard.vue diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js index 8ff3a909..b5321847 100644 --- a/src/store/modules/reports.js +++ b/src/store/modules/reports.js @@ -3,8 +3,8 @@ import { changeState, changeStatusScope, deleteStatus, fetchReports, filterRepor const reports = { state: { fetchedReports: [], + groupReports: true, idOfLastReport: '', - page_limit: 5, stateFilter: '', loading: true }, @@ -20,6 +20,9 @@ const reports = { }, SET_REPORTS_FILTER: (state, filter) => { state.stateFilter = filter + }, + SET_REPORTS_GROUPING: (state) => { + state.groupReports = !state.groupReports } }, actions: { @@ -42,20 +45,18 @@ const reports = { }, async FetchReports({ commit, getters, state }) { commit('SET_LOADING', true) - - const response = state.stateFilter.length === 0 + const { data } = state.stateFilter.length === 0 ? await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token) : await filterReports(state.stateFilter, state.page_limit, state.idOfLastReport, getters.authHost, getters.token) - const reports = state.fetchedReports.concat(response.data.reports) - const id = reports.length > 0 ? reports[reports.length - 1].id : state.idOfLastReport - - commit('SET_REPORTS', reports) - commit('SET_LAST_REPORT_ID', id) + commit('SET_REPORTS', data.reports) commit('SET_LOADING', false) }, SetFilter({ commit }, filter) { commit('SET_REPORTS_FILTER', filter) + }, + ToggleReportsGrouping({ commit }) { + commit('SET_REPORTS_GROUPING') } } } diff --git a/src/views/reports/components/GroupedReport.vue b/src/views/reports/components/GroupedReport.vue new file mode 100644 index 00000000..ef2dc6ce --- /dev/null +++ b/src/views/reports/components/GroupedReport.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/src/views/reports/components/ReportCard.vue b/src/views/reports/components/ReportCard.vue new file mode 100644 index 00000000..62fa1945 --- /dev/null +++ b/src/views/reports/components/ReportCard.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/src/views/reports/index.vue b/src/views/reports/index.vue index 928e2b2f..f35ab2e3 100644 --- a/src/views/reports/index.vue +++ b/src/views/reports/index.vue @@ -3,12 +3,15 @@

{{ $t('reports.reports') }}

- + Group reports by statuses
- + + + +
@@ -29,14 +32,181 @@