mapado route -> 'mapado-api'
This commit is contained in:
parent
37a84058d1
commit
dde1813f78
12 changed files with 127 additions and 42 deletions
|
|
@ -21,8 +21,8 @@ tabs:
|
|||
mapadoKeyInfos:
|
||||
label: Événement connecté à Mapado
|
||||
type: info
|
||||
text: Les données de dates et de durée sont récupérées de [Mapado](https://desk.mapado.com/).
|
||||
width: 2/4
|
||||
text: Les données de dates et de durée sont récupérées de Mapado ([gestion Mapado](https://desk.mapado.com/)).
|
||||
width: 2/3
|
||||
when:
|
||||
isMapadoEvent: true
|
||||
endDate:
|
||||
|
|
@ -65,6 +65,9 @@ tabs:
|
|||
label: Galerie
|
||||
type: files
|
||||
layout: cards
|
||||
image:
|
||||
cover: true
|
||||
ratio: 4/3
|
||||
- width: 1/2
|
||||
fields:
|
||||
authors:
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ tabs:
|
|||
label: Calendrier
|
||||
icon: calendar
|
||||
sections:
|
||||
events:
|
||||
label: Événements
|
||||
seasons:
|
||||
label: Saisons
|
||||
type: pages
|
||||
template: event
|
||||
layout: cards
|
||||
template: season
|
||||
info: "{{ page.children.count }} événements"
|
||||
18
site/blueprints/pages/season.yml
Normal file
18
site/blueprints/pages/season.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
title: Saison
|
||||
image: false
|
||||
|
||||
tabs:
|
||||
contentTab:
|
||||
label: Calendrier
|
||||
icon: calendar
|
||||
sections:
|
||||
seasons:
|
||||
label: Événéments
|
||||
type: pages
|
||||
template: event
|
||||
layout: cards
|
||||
size: large
|
||||
image:
|
||||
cover: true
|
||||
ratio: 4/3
|
||||
search: true
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
return [
|
||||
'debug' => true,
|
||||
'routes' => [
|
||||
require_once(__DIR__ . '/routes/mapado.php')
|
||||
require_once(__DIR__ . '/routes/mapado-api.php'),
|
||||
require_once(__DIR__ . '/routes/month-dates.php')
|
||||
]
|
||||
];
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
return [
|
||||
'pattern' => '/mapado.json',
|
||||
'pattern' => '/mapado-api.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents("php://input");
|
||||
25
site/config/routes/month-dates.php
Normal file
25
site/config/routes/month-dates.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
return [
|
||||
'pattern' => '/month-dates.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$jsonRequest = file_get_contents("php://input");
|
||||
$request = json_decode($jsonRequest, true);
|
||||
|
||||
$dates = $request['dates'];
|
||||
$year = explode('-', $request['month'])[0];
|
||||
$correspondingSeasons = page('programme')->children()->filter(
|
||||
fn ($season) => str_contains($season->title()->value(), $year)
|
||||
);
|
||||
|
||||
$eventsFromSameMonth = $correspondingSeasons->children()->filter(
|
||||
fn ($event) => $event->isNotEmpty() && $event->startDate()->toDate('Y-m') == $request['month']
|
||||
);
|
||||
|
||||
foreach ($eventsFromSameMonth as $event) {
|
||||
$day = $event->startDate()->toDate('d');
|
||||
}
|
||||
|
||||
return json_encode($eventsFromSameMonth);
|
||||
}
|
||||
];
|
||||
|
|
@ -30,4 +30,8 @@ function buildParamsString($requestParams) {
|
|||
$queryString[] = urlencode($param['name']) . '=' . urlencode($param['value']);
|
||||
}
|
||||
return implode('&', $queryString);
|
||||
}
|
||||
|
||||
function getEventsByMonth($month) {
|
||||
$events = page('programme')->children();
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
redirect: "follow"
|
||||
};
|
||||
fetch(
|
||||
"https://ticketing.mapado.net/v1/ticketings/" + id.value + "?fields=title,slug,sellingDeviceSchedule",
|
||||
"https://ticketing.mapado.net/v1/ticketings/" + id.value + "?fields=id,title,slug,sellingDeviceSchedule",
|
||||
requestOptions
|
||||
).then((response) => {
|
||||
console.log(response);
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
result.sellingDeviceSchedule[scheduleFirstKey].fr.toLowerCase()
|
||||
);
|
||||
console.log(result);
|
||||
text.value = `<strong>Événement correspondant sur Mapado : <em>${result.title}</em>, ${schedule}.</strong> <a href="https://desk.mapado.com/activity/${result.slug}/events" target="_blank">Gérer sur Mapado.</a>`;
|
||||
text.value = `<strong>Événement correspondant sur Mapado : <em>${result.title}</em>, ${schedule}</strong> (<a href="https://desk.mapado.com/mass-action/ticketing/${id.value}" target="_blank">gérer sur Mapado.</a>).`;
|
||||
}).catch((error) => {
|
||||
icon.value = "alert";
|
||||
theme.value = "red";
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ function connect() {
|
|||
fetch(
|
||||
"https://ticketing.mapado.net/v1/ticketings/" +
|
||||
id.value +
|
||||
"?fields=title,slug,sellingDeviceSchedule",
|
||||
"?fields=id,title,slug,sellingDeviceSchedule",
|
||||
requestOptions
|
||||
)
|
||||
.then((response) => {
|
||||
|
|
@ -91,7 +91,7 @@ function connect() {
|
|||
result.sellingDeviceSchedule[scheduleFirstKey].fr.toLowerCase()
|
||||
);
|
||||
console.log(result);
|
||||
text.value = `<strong>Événement correspondant sur Mapado : <em>${result.title}</em>, ${schedule}.</strong> <a href="https://desk.mapado.com/activity/${result.slug}/events" target="_blank">Gérer sur Mapado.</a>`;
|
||||
text.value = `<strong>Événement correspondant sur Mapado : <em>${result.title}</em>, ${schedule}</strong> (<a href="https://desk.mapado.com/mass-action/ticketing/${id.value}" target="_blank">gérer sur Mapado.</a>).`;
|
||||
})
|
||||
.catch((error) => {
|
||||
icon.value = "alert";
|
||||
|
|
|
|||
|
|
@ -18,10 +18,15 @@
|
|||
this.dates = getDatesInMonth(this.monthNumb);
|
||||
|
||||
const mapadoDates = await getMapadoDates(this.monthNumb)
|
||||
|
||||
mapadoDates.forEach(mapadoDate => {
|
||||
const day = parseInt(mapadoDate.day)
|
||||
this.dates[day].push(mapadoDate)
|
||||
})
|
||||
|
||||
const kirbyDates = await getKirbyDates(this.monthNumb, this.dates)
|
||||
|
||||
console.log('kirby dates', kirbyDates)
|
||||
|
||||
console.log('dates', this.dates)
|
||||
document.body.classList.toggle('progress')
|
||||
|
|
@ -36,7 +41,7 @@
|
|||
x-init="updateDates()"
|
||||
>
|
||||
<div class="calendar-strip__selector">
|
||||
<button class="prev-month" @click="monthNumb--; updateDates()" :disabled="monthNumb === -4 ? true : false">←</button>
|
||||
<button class="prev-month" @click="monthNumb--; updateDates()">←</button>
|
||||
<span x-text="monthName"></span>
|
||||
<button class="next-month" @click="monthNumb++; updateDates()">→</button>
|
||||
</div>
|
||||
|
|
|
|||
0
site/templates/season.php
Normal file
0
site/templates/season.php
Normal file
Loading…
Add table
Add a link
Reference in a new issue