angular.module('odoo')
.controller('OpportunitiesController', function (
$scope,
$ionicActionSheet
) {
$scope.stages = [
{
title: 'Nuevo'
},
{
title: 'Muerta'
},
{
title: 'Calificación'
},
{
title: 'Propuesta'
},
{
title: 'Negociación'
},
{
title: 'Ganado'
},
{
title: 'Perdido'
}
];
$scope.opportunities = [
{
name: 'Op. 1',
stage: 'Nuevo'
},
{
name: 'Op. 2',
stage: 'Perdido'
},
{
name: 'Op. 3',
stage: 'Propuesta'
},
{
name: 'Op. 1',
stage: 'Nuevo'
},
{
name: 'Op. 1',
stage: 'Nuevo'
},
{
name: 'Op. 1',
stage: 'Nuevo'
}
];
$scope.title = 'Nuevo';
$scope.loading = false;
$scope.selected = -1;
$scope.$on("$ionicSlides.sliderInitialized", function (event, data){
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeEnd", function (event, data) {
console.log($scope.slider);
$scope.stageChanged(data.slider.activeIndex);
});
/**
* Change the state
*/
$scope.changeStage = function (mode) {
$scope.loading = true;
if (mode) {
$scope.slider.slideNext();
} else {
$scope.slider.slidePrev();
}
$scope.loading = false;
}
/**
* Change stage name on title
*/
$scope.stageChanged = function (index) {
$scope.title = $scope.stages[index].title;
$scope.$apply();
}
/**
* Open the actionsheet action options
*/
$scope.openOptions = function (index) {
$scope.selected = index;
$ionicActionSheet.show({
titleText: 'Acciones',
buttons: [
{
text: ' Abrir'
},
{
text: ' Mover a'
}
],
destructiveText: ' Eliminar',
cancel: function() {
$scope.customer = {};
$scope.selected = -1;
},
buttonClicked: function(index) {
switch (index) {
case 0:
$scope.show();
break;
case 1:
$scope.addContact();
break;
default:
$scope.show();
}
return true;
},
destructiveButtonClicked: function() {
$scope.delete();
return true;
}
});
}
});