Advertisement
ahmadtri26

fail

Nov 29th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { FormBuilder, Validators} from '@angular/forms';
  3. import { NavController, NavParams } from 'ionic-angular';
  4. import { MyApp } from '../../app/app.component';
  5.  
  6. import { HttpService } from '../../providers/http-service';
  7. /**
  8. * Generated class for the EditShowcaseSalesPage page.
  9. *
  10. * See https://ionicframework.com/docs/components/#navigation for more info on
  11. * Ionic pages and navigation.
  12. */
  13.  
  14. @Component({
  15. selector: 'page-edit-showcase-sales',
  16. templateUrl: 'edit-showcase-sales.html',
  17. })
  18. export class EditShowcaseSalesPage {
  19. public static TAG = "Edit Showcase";
  20. public data;
  21. public showcaseForm;
  22. public idShowcase;
  23. public isDataLoad: boolean = false;
  24. public dataShowcaseReady: boolean = false;
  25. public dataShowcase;
  26.  
  27. constructor(public navCtrl: NavController, public navParams: NavParams, public http: HttpService, public formBuilder: FormBuilder)
  28. {
  29. try{
  30. this.data = {};
  31. this.showcaseForm = this.formBuilder.group(
  32. {
  33. name : ['', Validators.required]
  34. });
  35. }catch(error){
  36. MyApp.consoleLog("some error happen", error);
  37. }
  38. }
  39.  
  40. ionViewDidLoad(id) {
  41. console.log('ionViewDidLoad EditShowcaseSalesPage');
  42. this.idShowcase = this.navParams.get('id');
  43. MyApp.consoleLog("Data = ", this.idShowcase);
  44. }
  45.  
  46. ionViewDidEnter(){
  47. try{
  48. this.loadShowcase();
  49. //MyApp.consoleLog(EditShowcaseSalesPage.TAG, "load...", this.loadShowcase());
  50. }catch(error){
  51. MyApp.consoleLog("some error happen", error);
  52. }
  53. }
  54.  
  55. editShowcase(){
  56. let link = "http://localhost/phpscring/shop_showcase_sales/edit_showcase";
  57.  
  58. let editShowcase;
  59. editShowcase = {};
  60. editShowcase.id = this.idShowcase;
  61. editShowcase.name = this.showcaseForm.value.name;
  62.  
  63. let postParams = {
  64. "link": link,
  65. "data": editShowcase
  66. }
  67.  
  68. MyApp.consoleLog(EditShowcaseSalesPage.TAG, "postParams ", postParams);
  69.  
  70.  
  71. this.http.postService(postParams).then((data)=>{
  72. this.data.response = data;
  73. MyApp.consoleLog(EditShowcaseSalesPage.TAG, " data response ", data);
  74. MyApp.consoleLog(EditShowcaseSalesPage.TAG, "response", editShowcase);
  75. this.navCtrl.pop()
  76.  
  77. if (this.isDataLoad= true) {
  78. this.dataShowcaseReady = false;
  79. this.loadShowcase(editShowcase);
  80. }
  81. else{
  82. this.isDataLoad = true;
  83. this.dataShowcaseReady = false;
  84. this.loadShowcase(editShowcase);
  85. }
  86. }, error => {
  87. MyApp.consoleError(editShowcase.TAG, error);
  88. });
  89.  
  90. MyApp.consoleLog("ShopShowcase", "Update Showcase");
  91.  
  92. }
  93.  
  94. back(){
  95. this.navCtrl.pop();
  96. }
  97.  
  98. loadShowcase(editShowcase){
  99. this.dataShowcase = [];
  100. if(editShowcase.data.length != 0 ){
  101. for(let i = 0; i < editShowcase.data.length; i++){
  102. this.dataShowcase[i] = {
  103. id: response.data[i].id,
  104. name: response.data[i].name,
  105. }
  106. }
  107. }
  108. MyApp.consoleLog(EditShowcaseSalesPage.TAG, "dataShowcase .......data", this.dataShowcase);
  109. }
  110.  
  111.  
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement