diff --git a/src/store/api/people.js b/src/store/api/people.js index 13d632bbf..350979f70 100644 --- a/src/store/api/people.js +++ b/src/store/api/people.js @@ -1,4 +1,5 @@ import client from '@/store/api/client' +import { buildQueryString } from '@/lib/query' export default { getOrganisation() { @@ -370,28 +371,40 @@ export default { return client.pget(path) }, - getDayTable(year, month, productionId) { - let path = `/api/data/persons/time-spents/day-table/${year}/${month}` - if (productionId) path += `?project_id=${productionId}` - return client.pget(path) + getDayTable(year, month, productionId, studioId) { + const path = `/api/data/persons/time-spents/day-table/${year}/${month}` + const params = { + project_id: productionId, + studio_id: studioId + } + return client.pget(buildQueryString(path, params)) }, - getWeekTable(year, month, productionId) { - let path = `/api/data/persons/time-spents/week-table/${year}` - if (productionId) path += `?project_id=${productionId}` - return client.pget(path) + getWeekTable(year, month, productionId, studioId) { + const path = `/api/data/persons/time-spents/week-table/${year}` + const params = { + project_id: productionId, + studio_id: studioId + } + return client.pget(buildQueryString(path, params)) }, - getMonthTable(year, month, productionId) { - let path = `/api/data/persons/time-spents/month-table/${year}` - if (productionId) path += `?project_id=${productionId}` - return client.pget(path) + getMonthTable(year, month, productionId, studioId) { + const path = `/api/data/persons/time-spents/month-table/${year}` + const params = { + project_id: productionId, + studio_id: studioId + } + return client.pget(buildQueryString(path, params)) }, - getYearTable(year, month, productionId) { - let path = '/api/data/persons/time-spents/year-table' - if (productionId) path += `?project_id=${productionId}` - return client.pget(path) + getYearTable(year, month, productionId, studioId) { + const path = '/api/data/persons/time-spents/year-table' + const params = { + project_id: productionId, + studio_id: studioId + } + return client.pget(buildQueryString(path, params)) }, getAggregatedPersonTimeSpents( @@ -401,7 +414,8 @@ export default { month, week, day, - productionId + productionId, + studioId ) { let path = `/api/data/persons/${personId}/time-spents/` @@ -415,11 +429,11 @@ export default { path += `day/${year}/${month}/${day}` } - if (productionId) { - path += `?project_id=${productionId}` + const params = { + project_id: productionId, + studio_id: studioId } - - return client.pget(path) + return client.pget(buildQueryString(path, params)) }, getPersonQuotaShots( diff --git a/src/store/modules/people.js b/src/store/modules/people.js index 506f1e30f..3026d83e1 100644 --- a/src/store/modules/people.js +++ b/src/store/modules/people.js @@ -387,7 +387,7 @@ const actions = { loadAggregatedPersonTimeSpents( {}, - { personId, detailLevel, year, month, week, day, productionId } + { personId, detailLevel, year, month, week, day, productionId, studioId } ) { return peopleApi.getAggregatedPersonTimeSpents( personId, @@ -396,7 +396,8 @@ const actions = { month, week, day, - productionId + productionId, + studioId ) }, @@ -482,7 +483,10 @@ const actions = { commit(SET_PERSON_TASKS_SCROLL_POSITION, scrollPosition) }, - async loadTimesheets({ commit }, { detailLevel, year, month, productionId }) { + async loadTimesheets( + { commit }, + { detailLevel, year, month, productionId, studioId } + ) { const monthString = String(month).padStart(2, '0') let getTableFn switch (detailLevel) { @@ -498,7 +502,7 @@ const actions = { default: getTableFn = peopleApi.getMonthTable } - const table = await getTableFn(year, monthString, productionId) + const table = await getTableFn(year, monthString, productionId, studioId) if (detailLevel === 'day') { const dayOffs = await peopleApi.getDaysOff(year, monthString) commit(PEOPLE_SET_DAY_OFFS, dayOffs)