Skip to content

Commit

Permalink
[timesheets] fix studio filter
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoPennec committed Jun 7, 2024
1 parent b548aba commit 40e70ad
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
56 changes: 35 additions & 21 deletions src/store/api/people.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import client from '@/store/api/client'
import { buildQueryString } from '@/lib/query'

export default {
getOrganisation() {
Expand Down Expand Up @@ -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(
Expand All @@ -401,7 +414,8 @@ export default {
month,
week,
day,
productionId
productionId,
studioId
) {
let path = `/api/data/persons/${personId}/time-spents/`

Expand All @@ -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(
Expand Down
12 changes: 8 additions & 4 deletions src/store/modules/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -396,7 +396,8 @@ const actions = {
month,
week,
day,
productionId
productionId,
studioId
)
},

Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 40e70ad

Please sign in to comment.