Rellenar el color verde en entradas normales
This commit is contained in:
parent
9db8d93b9b
commit
c6db40c095
@ -31,19 +31,7 @@ const MODULE_NAME = "[event.controller]";
|
||||
|
||||
const controllerOptions = {
|
||||
MODULE_NAME,
|
||||
findOneCallback: (result) => {
|
||||
// Si hay inscripciones normales, ponerles el color por defecto 'verde'.
|
||||
|
||||
result.inscriptions = result.inscriptions.map((inscription) => {
|
||||
const isVirtual = inscription.type === "online" || inscription.type === "online group";
|
||||
if ((inscription.reservationId === null) && (!isVirtual)) {
|
||||
// Inscripción normal
|
||||
inscription.color = 'green';
|
||||
}
|
||||
return inscription;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
findOneCallback: eventInscriptionService._fillInscriptionsColor
|
||||
};
|
||||
|
||||
function generateMemberInscription(user, inscription, reservation) {
|
||||
@ -135,6 +123,8 @@ const extraControllers = {
|
||||
const userId = req.user.id;
|
||||
var result = null;
|
||||
|
||||
|
||||
|
||||
console.log(params, req.user.level);
|
||||
if (eventId) {
|
||||
try {
|
||||
@ -148,6 +138,9 @@ const extraControllers = {
|
||||
} else {
|
||||
try {
|
||||
result = await eventInscriptionService._getInscriptionsUser(userId);
|
||||
result = result.map(row => row.toJSON());
|
||||
// Asigno colores a las entradas normales
|
||||
result = eventInscriptionService._fillInscriptionsColor(result);
|
||||
return handleResultResponse(result, null, params, res, result === null ? httpStatus.NOT_FOUND : httpStatus.OK);
|
||||
} catch (error) {
|
||||
return handleErrorResponse(MODULE_NAME, "getInscriptions", error, res);
|
||||
|
||||
@ -231,11 +231,14 @@ const extraControllers = {
|
||||
|
||||
if (inscription.reservation === null) {
|
||||
console.log('asigno green');
|
||||
inscription.color = 'green';
|
||||
|
||||
/* parche */
|
||||
inscription.reservation = {
|
||||
color: 'green',
|
||||
description: 'Entrada',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
console.log(">>>>>>>voy a dar inscription", inscription);
|
||||
return handleResultResponse(inscription, null, params, res, httpStatus.OK);
|
||||
|
||||
@ -34,6 +34,26 @@ function generateNewCodeTicket() {
|
||||
}
|
||||
|
||||
const extraMethods = {
|
||||
_fillInscriptionColor: (inscription) => {
|
||||
if (inscription && inscription.type) {
|
||||
const isVirtual = inscription.type === "online" || inscription.type === "online group";
|
||||
if ((inscription.reservationId === null) && (!isVirtual)) {
|
||||
// Inscripción normal
|
||||
inscription.color = 'green';
|
||||
}
|
||||
}
|
||||
|
||||
return inscription;
|
||||
},
|
||||
|
||||
_fillInscriptionsColor: (inscriptions) => {
|
||||
if (inscriptions && inscriptions.length) {
|
||||
return inscriptions.map(extraMethods._fillInscriptionColor);
|
||||
} else {
|
||||
return inscriptions;
|
||||
}
|
||||
},
|
||||
|
||||
_getInscriptionById: (id) => {
|
||||
return models.EventInscription.scope(["includeEventAndVenue", "includeReservation", "defaultScope"]).findOne({
|
||||
where: {
|
||||
@ -361,4 +381,7 @@ const extraMethods = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = generateService(models.EventInscription, extraMethods);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user