Browse Source

order products under VERY specific criteria

David 9 years atrás
parent
commit
5d3c54e35f
1 changed files with 10 additions and 1 deletions
  1. 10 1
      controllers/editPedidoCtrl.js

+ 10 - 1
controllers/editPedidoCtrl.js

@@ -36,7 +36,16 @@ app.controller('editPedidoCtrl', function ($scope, $http, $routeParams, notify,
 		} else {
 
 			$http.get('back/productos/' + $routeParams.hash).success(function(data) {
-		   		$scope.listaproductos = data; 
+				var first = data.filter(function(el) { return el.id < 9000 });
+				var sec = data.filter(function(el) { return el.id >= 9000 });
+		   		$scope.listaproductos = first.sort(function(a,b) {
+					if (a.id % 1000 === b.id % 1000)
+						return (a.id > b.id ? 1 : -1);
+					if (a.id % 1000 > b.id % 1000)
+						return 1;
+					return -1;
+				}).concat(sec);
+
 			}).error(function(data) {
 
 			});