Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/api/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { ProjectModel } from '@/models/project.model'
import { PeopleGroupIdOrSlug, PeopleGroupModel } from '@/models/invitation.model'
import { ImageModel } from '@/models/image.model'
import { BaseLocationModel, LocationModel } from '@/models/location.model'
import { NewsModel } from '@/models/news.model'
import { EventModel } from '@/models/event.model'

// HIERARCHY
export async function getHierarchyGroups(organizationCode: string, config = {}) {
Expand Down Expand Up @@ -180,13 +182,13 @@ export async function getSubGroup(
)
}

export async function getGroupProjectsLocation(
export async function getGroupAllLocations(
organizationCode: string,
groupId: PeopleGroupIdOrSlug,
config = {}
) {
return await useAPI<PaginationResult<LocationModel>>(
`organization/${organizationCode}/people-group/${groupId}/projects-locations/`,
`organization/${organizationCode}/people-group/${groupId}/all-locations/`,
config
)
}
Expand Down Expand Up @@ -290,3 +292,31 @@ export function postGroupGallery(
method: 'POST',
})
}

export async function getGroupNews(
organizationCode: string,
groupId: PeopleGroupIdOrSlug,
config = {}
) {
return await useAPI<PaginationResult<NewsModel>>(
`organization/${organizationCode}/people-group/${groupId}/news/`,
{
...config,
method: 'GET',
}
)
}

export async function getGroupEvent(
organizationCode: string,
groupId: PeopleGroupIdOrSlug,
config = {}
) {
return await useAPI<PaginationResult<EventModel>>(
`organization/${organizationCode}/people-group/${groupId}/event/`,
{
...config,
method: 'GET',
}
)
}
58 changes: 55 additions & 3 deletions src/api/v2/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
getGroupSimilar as fetchGetGroupSimilar,
getSubGroup as fetchGetSubGroup,
getGroupGallery as fetchGroupGallery,
getGroupProjectsLocation as fetchGroupProjectsLocation,
getGroupAllLocations as fetchGroupAllLocations,
getGroupNews as fetchGroupNews,
getGroupEvent as fetchGroupEvent,
} from '@/api/groups.service'
import useAsyncAPI from '@/composables/useAsyncAPI'
import useAsyncPaginationAPI from '@/composables/useAsyncPaginationAPI'
Expand Down Expand Up @@ -145,7 +147,7 @@ export const getSubGroup = (
)
}

export const getGroupProjectsLocation = (
export const getGroupAllLocations = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
groupId: RefOrRaw<PeopleGroupIdOrSlug>,
config = {}
Expand All @@ -156,7 +158,7 @@ export const getGroupProjectsLocation = (
return useAsyncAPI(
key,
({ config }) =>
fetchGroupProjectsLocation(unref(organizationCode), unref(groupId), {
fetchGroupAllLocations(unref(organizationCode), unref(groupId), {
...DEFAULT_CONFIG,
...config,
}),
Expand Down Expand Up @@ -189,3 +191,53 @@ export const getGroupGallery = (
}
)
}

export const getGroupNews = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
groupId: RefOrRaw<PeopleGroupIdOrSlug>,
config = {}
) => {
const key = computed(() => `${unref(organizationCode)}::group::${unref(groupId)}::news`)

const { translateNews } = useAutoTranslate()

return useAsyncPaginationAPI(
key,
async ({ config }) => {
return fetchGroupNews(unref(organizationCode), unref(groupId), {
...DEFAULT_CONFIG,
...config,
})
},
{
watch: onlyRefs([organizationCode, groupId]),
translate: translateNews,
...config,
}
)
}

export const getGroupEvent = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
groupId: RefOrRaw<PeopleGroupIdOrSlug>,
config = {}
) => {
const key = computed(() => `${unref(organizationCode)}::group::${unref(groupId)}::event`)

const { translateEvents } = useAutoTranslate()

return useAsyncPaginationAPI(
key,
async ({ config }) => {
return fetchGroupEvent(unref(organizationCode), unref(groupId), {
...DEFAULT_CONFIG,
...config,
})
},
{
watch: onlyRefs([organizationCode, groupId]),
translate: translateEvents,
...config,
}
)
}
9 changes: 8 additions & 1 deletion src/api/v2/location.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ export const getLocations = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
config = {}
) => {
const { translatePeopleGroupLocations, translateProjectLocations } = useAutoTranslate()
const {
translatePeopleGroupLocations,
translateProjectLocations,
translateNewsLocations,
translateEventsLocations,
} = useAutoTranslate()
const key = computed(() => `${unref(organizationCode)}::locations`)

const translateAllModel = (data: ComputedRef<Locations>) => {
return computed(() => {
return {
groups: unref(translatePeopleGroupLocations(data.value?.groups)),
projects: unref(translateProjectLocations(data.value?.projects)),
news: unref(translateNewsLocations(data.value?.news)),
event: unref(translateEventsLocations(data.value?.event)),
}
})
}
Expand Down
12 changes: 12 additions & 0 deletions src/app/router.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,18 @@ const routes = ({
},
],
},
{
path: '/event/:eventId',
name: 'EventPage',
component: () => import('../pages/EventPage/EventPage.vue'),
props: (route) => ({
eventId: route.params.eventId,
}),
meta: {
resetScroll: true,
},
},

{
path: '/create-news',
name: 'CreateNewsPage',
Expand Down
21 changes: 21 additions & 0 deletions src/app/useGroupPagesRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ export default function useGroupPagesRoutes() {
name: 'subGroups',
component: () => import('../pages/GroupPageV2/Tabs/SubGroups/SubGroupsTab.vue'),
},
{
path: 'news',
name: 'groupNews',
component: () => import('../pages/GroupPageV2/Tabs/News/GroupNewsTab.vue'),
},
{
path: 'event',
name: 'groupEvent',
component: () => import('../pages/GroupPageV2/Tabs/Event/GroupEventTab.vue'),
},

// retro compat
{
path: 'Edit',
Expand Down Expand Up @@ -84,6 +95,16 @@ export default function useGroupPagesRoutes() {
name: 'groupGalleryEdit',
component: () => import('../pages/GroupPageV2/Tabs/Gallery/GroupGalleryTab.vue'),
},
{
path: 'news/edit',
name: 'groupNewsEdit',
component: () => import('../pages/GroupPageV2/Tabs/News/GroupNewsTab.vue'),
},
{
path: 'event/edit',
name: 'groupEventEdit',
component: () => import('../pages/GroupPageV2/Tabs/Event/GroupEventTab.vue'),
},
],
props: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
:event="event"
editable
hide-see-more-button
@location="onLocation"
@edit="onEdit"
@delete="onDelete"
/>
</div>
<PaginationButtonsV2 :pagination="pagination" />
<LocationDrawer
:is-opened="stateModals.location"
:locations="selectedEvent?.location ? [selectedEvent.location] : []"
@close="onCancel"
/>

<EditEventDrawer
:is-opened="stateModals.edit"
Expand Down Expand Up @@ -55,6 +61,7 @@ import { getAllEvents } from '@/api/v2/event.service'
import AdminBlock from '@/components/admin/GeneralAdminBlocks/AdminBlock.vue'
import FetchLoader from '@/components/base/FetchLoader.vue'
import PaginationButtonsV2 from '@/components/base/navigation/PaginationButtonsV2.vue'
import LocationDrawer from '@/components/map/LocationDrawer.vue'
import EditEventDrawer from '@/components/event/EditEventDrawer/EditEventDrawer.vue'
import ConfirmModal from '@/components/base/modal/ConfirmModal.vue'
import LpiButton from '@/components/base/button/LpiButton.vue'
Expand All @@ -68,14 +75,15 @@ const { t } = useNuxtI18n()
const selectedEvent = ref(null)
const asyncingDelete = ref(false)
const { stateModals, closeModals, openModals } = useModals({
location: false,
edit: false,
delete: false,
})

const todayAtZero = new Date()
todayAtZero.setHours(0, 0, 0, 0)
const query = {
ordering: 'event_date',
ordering: 'start_date',
from_date: todayAtZero.toISOString(),
}

Expand Down Expand Up @@ -109,6 +117,10 @@ const onEdit = (event) => {
selectedEvent.value = event
openModals('edit')
}
const onLocation = (event) => {
selectedEvent.value = event
openModals('location')
}

const onDeleteEvent = async () => {
asyncingDelete.value = true
Expand All @@ -128,6 +140,6 @@ const onDeleteEvent = async () => {

const onCancel = () => {
selectedEvent.value = null
closeModals('edit', 'delete')
closeModals('edit', 'delete', 'location')
}
</script>
6 changes: 4 additions & 2 deletions src/components/event/EditEventDrawer/EditEventDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ watch(
if (event) {
form.value = {
...event,
event_date: event.event_date ? new Date(event.event_date).toISOString() : null,
start_date: event.start_date ? new Date(event.start_date) : null,
end_date: event.end_date ? new Date(event.end_date) : null,
// build group "object" from array if it is an array
people_groups: event.people_groups.reduce
? event.people_groups.reduce((acc, groupId) => {
Expand Down Expand Up @@ -82,7 +83,8 @@ const saveEvent = async () => {
try {
const formData = {
...form.value,
event_date: form.value.event_date,
start_date: form.value.start_date.toISOString(),
end_date: (form.value.end_date || form.value.start_date).toISOString(),
people_groups: Object.entries(form.value.people_groups)
.filter(([, value]) => value)
.map(([id]) => id),
Expand Down
Loading