avancement connexion d'un événement avec Mapado
This commit is contained in:
parent
880cae624a
commit
1614f8682e
18 changed files with 81 additions and 49 deletions
|
|
@ -88,5 +88,5 @@ tabs:
|
|||
type: number
|
||||
width: 1/4
|
||||
mapadoButton:
|
||||
type: mapado-connect
|
||||
type: mapado-check
|
||||
width: 1/2
|
||||
|
|
|
|||
21
site/plugins/mapado-check/composer.json
Executable file
21
site/plugins/mapado-check/composer.json
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "adrienpayet/mapado-check",
|
||||
"description": "Mapado check",
|
||||
"license": "MIT",
|
||||
"type": "kirby-plugin",
|
||||
"version": "1.0.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Adrien Payet",
|
||||
"email": "contact@adrien-payet.fr"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"getkirby/composer-installer": "^1.1"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"getkirby/composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
4
site/plugins/mapado-check/index.css
Normal file
4
site/plugins/mapado-check/index.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
button[data-v-402405a5] {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
};
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "MapadoConnectField",
|
||||
__name: "MapadoCheckButton",
|
||||
props: {
|
||||
mapadoToken: String
|
||||
},
|
||||
|
|
@ -33,6 +33,17 @@
|
|||
id.value = idInput.value;
|
||||
});
|
||||
}, 100);
|
||||
function formatDateString(inputString) {
|
||||
const splitString = inputString.split(" ");
|
||||
const startDay = splitString[2];
|
||||
const startMonth = splitString[3];
|
||||
const startYear = splitString[4];
|
||||
const endDay = splitString[9];
|
||||
const endMonth = splitString[10];
|
||||
const endYear = splitString[11];
|
||||
const formattedString = `du ${startDay} ${startMonth} ${startYear} au ${endDay} ${endMonth} ${endYear}`;
|
||||
return formattedString;
|
||||
}
|
||||
function connect() {
|
||||
icon.value = "loader";
|
||||
theme.value = "yellow";
|
||||
|
|
@ -44,7 +55,7 @@
|
|||
redirect: "follow"
|
||||
};
|
||||
fetch(
|
||||
"https://ticketing.mapado.net/v1/ticketings/" + id.value + "?fields=title,type,sellingDeviceSchedule,eventDateList{startDate,bookableStock}",
|
||||
"https://ticketing.mapado.net/v1/ticketings/" + id.value + "?fields=title,slug,sellingDeviceSchedule",
|
||||
requestOptions
|
||||
).then((response) => {
|
||||
console.log(response);
|
||||
|
|
@ -62,8 +73,12 @@
|
|||
}).then((result) => {
|
||||
icon.value = "check";
|
||||
theme.value = "green";
|
||||
text.value = "<strong>Événement correspondant sur Mapado : <em>" + result.title + "</em></strong>";
|
||||
const scheduleFirstKey = Object.keys(result.sellingDeviceSchedule)[0];
|
||||
const schedule = formatDateString(
|
||||
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>`;
|
||||
}).catch((error) => {
|
||||
icon.value = "alert";
|
||||
theme.value = "red";
|
||||
|
|
@ -75,7 +90,7 @@
|
|||
}, 2e3);
|
||||
});
|
||||
}
|
||||
return { __sfc: true, id, icon, theme, text, connect };
|
||||
return { __sfc: true, id, icon, theme, text, formatDateString, connect };
|
||||
}
|
||||
};
|
||||
var _sfc_render = function render() {
|
||||
|
|
@ -90,13 +105,13 @@
|
|||
_sfc_staticRenderFns,
|
||||
false,
|
||||
null,
|
||||
"f2640b99"
|
||||
"402405a5"
|
||||
);
|
||||
__component__.options.__file = "/Users/adrienpayet/code/ntb/site/plugins/mapado-connect/src/components/MapadoConnectField.vue";
|
||||
const MapadoConnectField = __component__.exports;
|
||||
window.panel.plugin("getkirby/pluginkit", {
|
||||
__component__.options.__file = "/Users/adrienpayet/code/ntb/site/plugins/mapado-check/src/components/MapadoCheckButton.vue";
|
||||
const MapadoCheckButton = __component__.exports;
|
||||
window.panel.plugin("adrienpayet/mapado-check", {
|
||||
fields: {
|
||||
"mapado-connect": MapadoConnectField
|
||||
"mapado-check": MapadoCheckButton
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
Kirby::plugin('getkirby/mapado-connect', [
|
||||
Kirby::plugin('getkirby/mapado-check', [
|
||||
'fields' => [
|
||||
'mapado-connect' => [
|
||||
'mapado-check' => [
|
||||
"props" => [
|
||||
"mapadoToken" => function() {
|
||||
return $this->model()->site()->mapadoToken()->value();
|
||||
|
|
@ -34,6 +34,22 @@ setTimeout(() => {
|
|||
});
|
||||
}, 100);
|
||||
|
||||
function formatDateString(inputString) {
|
||||
const splitString = inputString.split(" ");
|
||||
|
||||
const startDay = splitString[2];
|
||||
const startMonth = splitString[3];
|
||||
const startYear = splitString[4];
|
||||
|
||||
const endDay = splitString[9];
|
||||
const endMonth = splitString[10];
|
||||
const endYear = splitString[11];
|
||||
|
||||
const formattedString = `du ${startDay} ${startMonth} ${startYear} au ${endDay} ${endMonth} ${endYear}`;
|
||||
|
||||
return formattedString;
|
||||
}
|
||||
|
||||
function connect() {
|
||||
icon.value = "loader";
|
||||
theme.value = "yellow";
|
||||
|
|
@ -49,7 +65,7 @@ function connect() {
|
|||
fetch(
|
||||
"https://ticketing.mapado.net/v1/ticketings/" +
|
||||
id.value +
|
||||
"?fields=title,type,sellingDeviceSchedule,eventDateList{startDate,bookableStock}",
|
||||
"?fields=title,slug,sellingDeviceSchedule",
|
||||
requestOptions
|
||||
)
|
||||
.then((response) => {
|
||||
|
|
@ -69,11 +85,12 @@ function connect() {
|
|||
.then((result) => {
|
||||
icon.value = "check";
|
||||
theme.value = "green";
|
||||
text.value =
|
||||
"<strong>Événement correspondant sur Mapado : <em>" +
|
||||
result.title +
|
||||
"</em></strong>";
|
||||
const scheduleFirstKey = Object.keys(result.sellingDeviceSchedule)[0];
|
||||
const schedule = formatDateString(
|
||||
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>`;
|
||||
})
|
||||
.catch((error) => {
|
||||
icon.value = "alert";
|
||||
7
site/plugins/mapado-check/src/index.js
Executable file
7
site/plugins/mapado-check/src/index.js
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
import MapadoCheckButton from "./components/MapadoCheckButton.vue";
|
||||
|
||||
window.panel.plugin("adrienpayet/mapado-check", {
|
||||
fields: {
|
||||
"mapado-check": MapadoCheckButton,
|
||||
},
|
||||
});
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "getkirby/pluginkit",
|
||||
"description": "Kirby Example Plugin",
|
||||
"license": "MIT",
|
||||
"type": "kirby-plugin",
|
||||
"version": "1.0.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Your Name",
|
||||
"email": "you@example.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"getkirby/composer-installer": "^1.1"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"getkirby/composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
button[data-v-f2640b99] {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import MapadoConnectField from "./components/MapadoConnectField.vue";
|
||||
|
||||
window.panel.plugin("getkirby/pluginkit", {
|
||||
fields: {
|
||||
"mapado-connect": MapadoConnectField,
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue