-
Notifications
You must be signed in to change notification settings - Fork 2
First commit - feature 900 Cliente cancelar pedido #251
base: master
Are you sure you want to change the base?
Conversation
@@ -62,5 +64,22 @@ | |||
}, 0); | |||
} | |||
|
|||
function cancelOrder(){ | |||
var submitted=new Date(customerOrderVm.customerOrder.submitted_at); // jshint ignore:line | |||
var now=new Date(); |
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.
nope. utilizamos moment
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.
moment.js
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.
Realizado
.list.list--centered.text-center | ||
button.button.button-outline.button-assertive( | ||
ng-click="customerOrderVm.cancelOrder()" | ||
) {{::("globals.cancel"|translate)}} {{::("order.order"|translate)}} |
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.
un sólo locale; puede ser cancelCustomerOrder
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.
Realizado, un solo mensaje, sin concatenar
if((now-submitted)/60000>5){ | ||
$ionicPopup.alert({ | ||
title: 'Error', | ||
template: '{{::("order.cancel.error"|translate)}}' |
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.
en el error debes mostrar los errores del api
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.
Cambiado por un mensaje "error", en mensaje será cambiado luego depende lo que me devuelva el api
else { | ||
$ionicPopup.alert({ | ||
title: 'Éxito', | ||
template: '{{::("order.cancel.success"|translate)}}' |
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.
y en success haces POST al api
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.
POST realizado en service, la ruta puede ser cambiada, de acuerdo a lo que se proporcione en el api
}); | ||
}); | ||
} | ||
else { |
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.
el botón no debe mostrarse después de los 5 minutos - tal vez podemos dejar esto para luego, primero integremos con el API
.then(function success(response){ | ||
return response.data; | ||
},function error(response){ | ||
return $q.reject(response.errors); |
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.
copia los demás, no hay que hacer esto
@joel-eche una cosa más, me acabo de dar cuenta que vamos a tener que cancelar cada entrega dentro de un pedido |
@macool ... He estado revisando, esta es la parte del api? |
@@ -33,5 +34,17 @@ | |||
); | |||
} | |||
|
|||
function cancelCustomerOrder(customerOrderId){ | |||
return $http({ |
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.
hay un CommonService o algo así que creo que hace esto exactamente
230e06c
to
c595c65
Compare
span | ||
//- some spacing | ||
|
||
.list.list--centered.text-center |
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.
un botón por cada pedido
$ionicLoading.show({ | ||
template: '{{::("globals.updating"|translate)}}' | ||
}); | ||
angular.forEach(customerOrderProviderProfiles,function(provider){ |
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.
se cancela cada proveedor por separado
var customerOrderProviderProfiles=customerOrderVm.customerOrder.provider_profiles; // jshint ignore:line | ||
var cont=0; | ||
$ionicLoading.show({ | ||
template: '{{::("globals.updating"|translate)}}' |
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.
algo como cancelando
function cancelOrder(){ | ||
var customerOrderId=customerOrderVm.customerOrder.id; | ||
var customerOrderProviderProfiles=customerOrderVm.customerOrder.provider_profiles; // jshint ignore:line | ||
var cont=0; |
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.
:wat:
cont++; | ||
if (cont === customerOrderProviderProfiles.length){ | ||
$ionicLoading.hide(); | ||
$ionicPopup.alert({ |
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.
sin popups, deberíamos escribir algo en el documento en lugar de eso
c595c65
to
9cc4a71
Compare
@macool, últimos comentarios revisados |
@@ -5,10 +5,11 @@ | |||
.module('porttare.services') | |||
.factory('CustomerOrdersService', CustomerOrdersService); | |||
|
|||
function CustomerOrdersService($http, ENV, ErrorHandlerService) { | |||
function CustomerOrdersService($http, ENV, $q, ErrorHandlerService) { |
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.
$q?
@@ -92,6 +92,11 @@ ion-view( | |||
price(amount="{{ ::providerProfile.totalCentsOrderProvider }}" | |||
currency="{{customerOrderVm.customerOrder.subtotal_items_currency}}") | |||
|
|||
.list.list--centered.text-center(ng-if="providerProfile.customer_order_delivery.status !== 'canceled'") | |||
button.button.button-outline.button-assertive( | |||
ng-click="customerOrderVm.cancelOrder({{ ::providerProfile.customer_order_delivery.id}},$index)" |
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.
no creo que sea $index, puedes hacerlo bien?
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.
ah, pasas el índice para luego reemplazar en el arreglo? puedes hacer un find luego y no pasamos índices
@@ -33,5 +34,17 @@ | |||
); | |||
} | |||
|
|||
function cancelCustomerOrder(customerOrderId,CustomerOrderDeliveryId){ |
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.
podría ser cancelDelivery o cancelCustomerOrderDelivery
9cc4a71
to
9d23cec
Compare
@macool ... "$q" eliminado, uso de búsqueda para el índice y cambio de nombre al servicio "cancelCustomerOrder" por "cancelCustomerOrderDelivery" |
template: '{{::("order.canceling"|translate)}}' | ||
}); | ||
CustomerOrdersService.cancelCustomerOrderDelivery(customerOrderVm.customerOrder.id,providerCustomerOrderDeliveryId).then(function (resp){ | ||
var index=customerOrderVm.customerOrder.provider_profiles.findIndex(function(element){ // jshint ignore:line |
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.
necesitaremos polyfill para findIndex?
@@ -92,6 +92,11 @@ ion-view( | |||
price(amount="{{ ::providerProfile.totalCentsOrderProvider }}" | |||
currency="{{customerOrderVm.customerOrder.subtotal_items_currency}}") | |||
|
|||
.list.list--centered.text-center(ng-if="providerProfile.customer_order_delivery.status !== 'canceled'") | |||
button.button.button-outline.button-assertive( | |||
ng-click="customerOrderVm.cancelOrder({{ ::providerProfile.customer_order_delivery.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.
necesitamos ell {{}} dentro de ng-click?
}); | ||
customerOrderVm.customerOrder.provider_profiles[index]=resp; // jshint ignore:line | ||
}).finally(function () { | ||
$ionicLoading.hide(); |
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.
nos falta mostrar los errores del api en caso de haber
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.
mejor escribirlos en el documento en lugar de hacer popup
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.
El popup del error sale automáticamente, siempre arroja un 401
No description provided.