123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- angular.module('odoo')
- .controller('LeadsController', function (
- $scope,
- $ionicModal,
- $ionicActionSheet,
- $ionicFilterBar,
- $ionicPopup,
- leads
- ) {
- $scope.leads = [];
- $scope.lead = {};
- $scope.search = null;
- $ionicModal.fromTemplateUrl('templates/sales/lead.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.leadModal = modal;
- });
- $scope.$on('$ionicView.enter', function () {
- $scope.fill();
- });
- $scope.$on('$destroy', function() {
- $scope.leadModal.remove();
- });
- $scope.$on('modal.hidden', function() {
- $scope.lead = {};
- });
- $scope.fill = function () {
- leads.read(function (leads) {
- console.log(leads);
- $scope.leads = leads;
- }, function (error) {
- console.log(error);
- });
- }
- $scope.show = function () {
- $scope.leadModal.show();
- }
- $scope.save = function () {
- }
- $scope.delete = function () {
- $ionicPopup.confirm({
- title: 'Confirmar',
- template: 'Estás seguro que quieres eliminar esta iniciativa?'
- }).then(function (confirmation) {
- if(confirmation) {
- console.log(confirmation);
- }
- });
- }
- $scope.toggleSearch = function () {
- $scope.search = $ionicFilterBar.show({
- items: $scope.leads,
- update: function (filtered, text) {
- $scope.leads = filtered;
- }
- });
- }
- $scope.openOptions = function (index) {
- if (index == -1) {
- $scope.lead = {};
- } else {
- $scope.lead = $scope.leads[index];
- }
- $ionicActionSheet.show({
- titleText: 'Acciones',
- buttons: [
- {
- text: '<i class="icon ion-arrow-expand positive"></i> Abrir'
- },
- {
- text: '<i class="icon ion-wand positive"></i> Convertir a oportunidad'
- }
- ],
- destructiveText: '<i class="icon ion-trash-a assertive"></i> Eliminar',
- cancel: function() {
- $scope.lead = {};
- $log.info('ActionSheet canceled');
- },
- buttonClicked: function(index) {
- switch (index) {
- case 0:
- $scope.show();
- break;
- case 1:
- console.log('1');
- break;
- default:
- $scope.show();
- }
- return true;
- },
- destructiveButtonClicked: function() {
- $scope.delete();
- return true;
- }
- });
- }
- });
|