forked from AkkomaGang/admin-fe
Add infinite scroll
This commit is contained in:
parent
05916e6666
commit
bb2e4c8d02
5 changed files with 268 additions and 41 deletions
6
src/api/reports.js
Normal file
6
src/api/reports.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import { reports } from './reportsData'
|
||||||
|
|
||||||
|
export function fetchReports(index, size) {
|
||||||
|
const response = reports.slice(index, index + size)
|
||||||
|
return response
|
||||||
|
}
|
218
src/api/reportsData.js
Normal file
218
src/api/reportsData.js
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
export const reports = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #1', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #2',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '3',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #3',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '4',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #4', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '5',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #5',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '6',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #6',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '7',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #7', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '8',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #8',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '9',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #9',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '10',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #10', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '11',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #11',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '12',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #12',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '13',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #13', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '14',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #14',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '15',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #15',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '16',
|
||||||
|
timestamp: '2019/4/12',
|
||||||
|
local: true,
|
||||||
|
from: 'John', // actor nickname
|
||||||
|
object: 'Bob', // user nickname
|
||||||
|
header: 'Report #16', // content
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
||||||
|
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '17',
|
||||||
|
timestamp: '2019/4/1',
|
||||||
|
local: true,
|
||||||
|
from: 'Max',
|
||||||
|
object: 'Vic',
|
||||||
|
header: 'Report #17',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [
|
||||||
|
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
||||||
|
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '18',
|
||||||
|
timestamp: '2019/2/28',
|
||||||
|
local: true,
|
||||||
|
from: 'Tim',
|
||||||
|
object: 'Jen',
|
||||||
|
header: 'Report #18',
|
||||||
|
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||||
|
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
||||||
|
}
|
||||||
|
]
|
|
@ -1,50 +1,35 @@
|
||||||
|
import { fetchReports } from '@/api/reports'
|
||||||
|
|
||||||
const reports = {
|
const reports = {
|
||||||
state: {
|
state: {
|
||||||
fetchedReports: [
|
fetchedReports: [],
|
||||||
{
|
indexOfLastShownReport: 0,
|
||||||
id: '1',
|
size: 3,
|
||||||
timestamp: '2019/4/12',
|
loading: true
|
||||||
local: true,
|
|
||||||
from: 'John', // actor nickname
|
|
||||||
object: 'Bob', // user nickname
|
|
||||||
header: 'Report #1', // content
|
|
||||||
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
||||||
notes: [
|
|
||||||
{ author: 'Nick', text: 'Lorem ipsum', timestamp: '2019/4/13' },
|
|
||||||
{ author: 'Val', text: 'dolor sit amet', timestamp: '2019/4/13' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
timestamp: '2019/4/1',
|
|
||||||
local: true,
|
|
||||||
from: 'Max',
|
|
||||||
object: 'Vic',
|
|
||||||
header: 'Report #2',
|
|
||||||
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
||||||
notes: [
|
|
||||||
{ author: 'Tony', text: 'consectetur adipiscing elit', timestamp: '2019/4/2' },
|
|
||||||
{ author: 'Zac', text: 'sed do eiusmod tempor incididunt', timestamp: '2019/4/3' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
timestamp: '2019/2/28',
|
|
||||||
local: true,
|
|
||||||
from: 'Tim',
|
|
||||||
object: 'Jen',
|
|
||||||
header: 'Report #3',
|
|
||||||
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
||||||
notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', timestamp: '2019/3/1' }]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
SET_REPORTS: (state, reports) => {
|
||||||
|
state.fetchedReports = state.fetchedReports.concat(reports)
|
||||||
|
},
|
||||||
SET_REPORT: (state, { index, report }) => {
|
SET_REPORT: (state, { index, report }) => {
|
||||||
state.fetchedReports[index] = report
|
state.fetchedReports[index] = report
|
||||||
|
},
|
||||||
|
SET_LOADING: (state, status) => {
|
||||||
|
state.loading = status
|
||||||
|
},
|
||||||
|
SET_INDEX: (state) => {
|
||||||
|
state.indexOfLastShownReport = state.indexOfLastShownReport + state.size
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
async FetchReports({ commit, state, getters }) {
|
||||||
|
commit('SET_LOADING', true)
|
||||||
|
const response = fetchReports(state.indexOfLastShownReport, state.size)
|
||||||
|
|
||||||
|
commit('SET_REPORTS', response)
|
||||||
|
commit('SET_INDEX')
|
||||||
|
commit('SET_LOADING', false)
|
||||||
|
},
|
||||||
async AddNote({ commit, state, getters }, { reportId, note }) {
|
async AddNote({ commit, state, getters }, { reportId, note }) {
|
||||||
const report = state.fetchedReports.find(report => report.id === reportId)
|
const report = state.fetchedReports.find(report => report.id === reportId)
|
||||||
report.notes = [...report.notes, note]
|
report.notes = [...report.notes, note]
|
||||||
|
|
|
@ -48,11 +48,11 @@ const users = {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async FetchUsers({ commit, state, getters }, { page }) {
|
async FetchUsers({ commit, state, getters }, { page }) {
|
||||||
|
commit('SET_LOADING', true)
|
||||||
|
|
||||||
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
||||||
const response = await fetchUsers(filters, getters.authHost, getters.token, page)
|
const response = await fetchUsers(filters, getters.authHost, getters.token, page)
|
||||||
|
|
||||||
commit('SET_LOADING', true)
|
|
||||||
|
|
||||||
loadUsers(commit, page, response.data)
|
loadUsers(commit, page, response.data)
|
||||||
},
|
},
|
||||||
async ToggleUserActivation({ commit, getters }, nickname) {
|
async ToggleUserActivation({ commit, getters }, nickname) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h1>{{ $t('reports.reports') }}</h1>
|
<h1>{{ $t('reports.reports') }}</h1>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<el-timeline class="timeline">
|
<el-timeline class="timeline">
|
||||||
<timeline-item v-for="item in reports" :item="item" :key="item.id"/>
|
<timeline-item v-loading="loading" v-for="item in reports" :item="item" :key="item.id"/>
|
||||||
</el-timeline>
|
</el-timeline>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,9 +15,27 @@ import TimelineItem from './components/TimelineItem'
|
||||||
export default {
|
export default {
|
||||||
components: { TimelineItem },
|
components: { TimelineItem },
|
||||||
computed: {
|
computed: {
|
||||||
|
loading() {
|
||||||
|
return this.$store.state.users.loading
|
||||||
|
},
|
||||||
reports() {
|
reports() {
|
||||||
return this.$store.state.reports.fetchedReports
|
return this.$store.state.reports.fetchedReports
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$store.dispatch('FetchReports')
|
||||||
|
this.scroll(this.reports)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
scroll(reports) {
|
||||||
|
window.onscroll = () => {
|
||||||
|
const bottomOfWindow = document.documentElement.scrollHeight - document.documentElement.scrollTop === document.documentElement.clientHeight
|
||||||
|
|
||||||
|
if (bottomOfWindow) {
|
||||||
|
this.$store.dispatch('FetchReports')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue