phonecalls.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { Component } from '@angular/core';
  2. import { NavController, NavParams, ActionSheetController, AlertController } from 'ionic-angular';
  3. import { BaseListView } from "../../base/base-list-view";
  4. import { Phonecall } from "../../odoo/models/crm.phonecall";
  5. import { PhonecallPage } from "../phonecall/phonecall"
  6. @Component({
  7. selector: 'page-phonecalls',
  8. templateUrl: 'phonecalls.html'
  9. })
  10. export class PhonecallsPage extends BaseListView<Phonecall> {
  11. constructor(
  12. public navCtrl: NavController,
  13. public navParams: NavParams,
  14. public actionSheetCtrl: ActionSheetController,
  15. public alertCtrl: AlertController
  16. ) {
  17. super(Phonecall);
  18. }
  19. /**
  20. *
  21. */
  22. ionViewDidLoad() {
  23. console.log('ionViewDidLoad PhonecallsPage');
  24. }
  25. /**
  26. *
  27. */
  28. ionViewDidEnter() {
  29. super.unselectItem();
  30. }
  31. /**
  32. *
  33. * @param item
  34. */
  35. openOptions(item: Phonecall): void {
  36. super.setSelectedItem(item);
  37. this.actionSheetCtrl.create({
  38. title: "Opciones",
  39. buttons: [
  40. {
  41. text: "Abrir",
  42. icon: "open",
  43. handler: () => {
  44. this.goToDetails();
  45. }
  46. },
  47. {
  48. text: "Eliminar",
  49. icon: "close",
  50. role: "destructive",
  51. handler: () => {
  52. this.askIfDelete();
  53. }
  54. },
  55. {
  56. text: "Cancelar",
  57. role: "cancel",
  58. handler: () => {
  59. super.unselectItem();
  60. }
  61. },
  62. ]
  63. }).present();
  64. }
  65. /**
  66. *
  67. */
  68. goToDetails(): void {
  69. this.navCtrl.push(PhonecallPage, super.getSelectedItem());
  70. }
  71. /**
  72. *
  73. */
  74. askIfDelete(): void {
  75. this.alertCtrl.create({
  76. title: "Confirmar",
  77. message: "Quieres eliminar esta llamada?",
  78. buttons: [
  79. {
  80. text: "Cancelar"
  81. },
  82. {
  83. text: "Aceptar",
  84. handler: () => {
  85. super.performDelete();
  86. }
  87. }
  88. ]
  89. }).present();
  90. }
  91. }