Skip to content
This repository has been archived by the owner on Dec 6, 2017. It is now read-only.

First commit - feature 900 Cliente cancelar pedido #251

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

joel-eche
Copy link

No description provided.

@@ -62,5 +64,22 @@
}, 0);
}

function cancelOrder(){
var submitted=new Date(customerOrderVm.customerOrder.submitted_at); // jshint ignore:line
var now=new Date();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. utilizamos moment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment.js

Copy link
Author

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)}}
Copy link
Member

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

Copy link
Author

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)}}'
Copy link
Member

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

Copy link
Author

@joel-eche joel-eche Feb 11, 2017

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)}}'
Copy link
Member

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

Copy link
Author

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 {
Copy link
Member

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);
Copy link
Member

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

@macool
Copy link
Member

macool commented Feb 13, 2017

@joel-eche una cosa más, me acabo de dar cuenta que vamos a tener que cancelar cada entrega dentro de un pedido

@macool
Copy link
Member

macool commented Feb 13, 2017

@joel-eche
Copy link
Author

@macool ... He estado revisando, esta es la parte del api?
/customer/orders/:order_id/deliveries/:id/cancel

@@ -33,5 +34,17 @@
);
}

function cancelCustomerOrder(customerOrderId){
return $http({
Copy link
Member

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

@joel-eche joel-eche force-pushed the feature900-cliente-cancelarpedido branch from 230e06c to c595c65 Compare February 16, 2017 16:27
span
//- some spacing

.list.list--centered.text-center
Copy link
Member

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){
Copy link
Member

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)}}'
Copy link
Member

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;
Copy link
Member

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({
Copy link
Member

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

@joel-eche joel-eche force-pushed the feature900-cliente-cancelarpedido branch from c595c65 to 9cc4a71 Compare February 19, 2017 05:34
@joel-eche
Copy link
Author

@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) {
Copy link
Member

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)"
Copy link
Member

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?

Copy link
Member

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){
Copy link
Member

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

@joel-eche joel-eche force-pushed the feature900-cliente-cancelarpedido branch from 9cc4a71 to 9d23cec Compare February 19, 2017 19:12
@joel-eche
Copy link
Author

@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
Copy link
Member

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}})"
Copy link
Member

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();
Copy link
Member

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

Copy link
Member

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

Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants