-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
posSalvar(data); | ||
return self.reserva.salvar().then(data => { | ||
AgendamentoService.salvarReserva(self.reserva); | ||
posSalvar(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toaster para notificar sucesso
@@ -39,38 +41,57 @@ let sequenceReserva = 1; | |||
corTexto}); | |||
} | |||
|
|||
function obterPropriedades(instancia, props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc
if (indiceReserva !== -1) { | ||
// atualizar | ||
mock.splice(indiceReserva, 1, new Reserva(reserva)); | ||
reservas.splice(indiceReserva, 1, new Reserva(reserva)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testa se isso anida funciona
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realmente precisa, documentei como funciona.
*/ | ||
function getIndiceReserva(lista, reserva) { | ||
function getIndiceReserva(lista, id) { | ||
for (let i = 0; i < lista.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}); | ||
|
||
return promiseEventosFuturos.then(reservasRes => { | ||
let reservasDia = reservasRes.filter(r => r.dia === data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
@@ -110,79 +80,26 @@ | |||
* @return {Promise} Promessa contendo a reserva. | |||
*/ | |||
this.getReserva = id => { | |||
let indiceReserva = getIndiceReserva(mock, {id}); | |||
return $q.when(mock[indiceReserva]); | |||
let indiceReserva = getIndiceReserva(reservas, id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
let indiceReserva = getIndiceReserva(mock, {id}); | ||
return $q.when(mock[indiceReserva]); | ||
let indiceReserva = getIndiceReserva(reservas, id); | ||
return $q.when(reservas[indiceReserva]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisa de promise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisa da promise? ficou em aberto do último review
if (r._id.toString() === reserva._id) { | ||
continue; | ||
} | ||
if (r.fim > inicio && r.inicio < inicio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extrair condição para função
const caso2 = inicio < r.fim && fim > r.fim; | ||
const caso3 = inicio >= r.inicio && fim <= r.fim; | ||
const caso4 = inicio <= r.inicio && fim >= r.fim; | ||
if (caso1 || caso2 || caso3 || caso4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dá uma olhada nesses casos que eu tinha montado, creio que dá pra cobrir todos apenas com 3 condições. Seria bacana extrair para um método: causaChoqueDeHorario(reserva), por exemplo
let indiceReserva = getIndiceReserva(mock, {id}); | ||
return $q.when(mock[indiceReserva]); | ||
let indiceReserva = getIndiceReserva(reservas, id); | ||
return $q.when(reservas[indiceReserva]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisa da promise? ficou em aberto do último review
No description provided.