<commit_before>import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CalculatePage } from "../calculate/calculate";
import { HomeModel } from './home.model';
import 'rxjs/Rx';

import { HomeService } from "./home.service";
import { Storage } from '@ionic/storage';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  menu = "drink";
  homemo: HomeModel = new HomeModel();
  prod_drink: any = [];
  prod_dessert: any = [];
  prod_food: any = [];
  private orderDaft: any = [];

  constructor(public navCtrl: NavController,
    public homeservice: HomeService,
    private storage: Storage
  ) {

    this.createDraftOrder();

  }
  gotocalculate() {
    this.navCtrl.push(CalculatePage)
  }
  ionViewDidLoad() {
    this.homeservice
      .getData()
      .then(data => {
        // console.log(data);
        this.homemo.products = data.products;
        this.homemo.orders = data.orders;
        this.prod_drink = this.homemo.products.filter(this.filterProductDrink);
        this.prod_dessert = this.homemo.products.filter(this.filterProductDessert);
        this.prod_food = this.homemo.products.filter(this.filterProductFood);

        // for (let i = 0; i < this.prod_drink.length; i++) {
        //   this.prod_drink[i].customStyle = 'background-image: url("http://www.menshealth.com/sites/menshealth.com/files/coffee-mug.jpg"); background-repeat: no-repeat; background-size: cover; background-position: center center;';
        // }

        console.log(this.prod_drink);
      });
  }

  filterProductDrink(list) {
    // console.log(list);
    return list.category[0].name == 'Drink';
  }
  filterProductDessert(list) {
    return list.category[0].name == 'Dessert';
  }
  filterProductFood(list) {
    return list.category[0].name == 'Food';
  }
  gotoCalculate() {
    if (this.orderDaft.length) {


      // this.storage.setItem('order', )
      this.navCtrl.push(CalculatePage);
    }


  }
  createDraftOrder() {
    this.orderDaft = {
      'item': [
        {
          'product_id': '',
          'amount': 0,
          'qty': 0,
        }
      ],
      'shop_id': '',
      'date': new Date(),
      'emp_id': ''
    };
  }
  addtoOrder(item) {
    console.log(item);
    // this.orderDaft.item.put();
  }
}<commit_msg>mick update<commit_after>import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CalculatePage } from "../calculate/calculate";
import { HomeModel } from './home.model';
import 'rxjs/Rx';

import { HomeService } from "./home.service";
import { Storage } from '@ionic/storage';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  menu = "drink";
  homemo: HomeModel = new HomeModel();
  prod_drink: any = [];
  prod_dessert: any = [];
  prod_food: any = [];
  private orderDaft: any = [];

  constructor(public navCtrl: NavController,
    public homeservice: HomeService,
    private storage: Storage
  ) {

    this.createDraftOrder();

  }
  gotocalculate() {
    this.navCtrl.push(CalculatePage)
  }
  ionViewDidLoad() {
    this.homeservice
      .getData()
      .then(data => {
        // console.log(data);
        this.homemo.products = data.products;
        this.homemo.orders = data.orders;
        this.prod_drink = this.homemo.products.filter(this.filterProductDrink);
        this.prod_dessert = this.homemo.products.filter(this.filterProductDessert);
        this.prod_food = this.homemo.products.filter(this.filterProductFood);

        // for (let i = 0; i < this.prod_drink.length; i++) {
        //   this.prod_drink[i].customStyle = 'background-image: url("http://www.menshealth.com/sites/menshealth.com/files/coffee-mug.jpg"); background-repeat: no-repeat; background-size: cover; background-position: center center;';
        // }

        console.log(this.prod_drink);
      });
  }

  filterProductDrink(list) {
    // console.log(list);
    return list.category[0].name == 'Drink';
  }
  filterProductDessert(list) {
    return list.category[0].name == 'Dessert';
  }
  filterProductFood(list) {
    return list.category[0].name == 'Food';
  }
  gotoCalculate() {
    if (this.orderDaft) {


      // this.storage.setItem('order', )
      this.navCtrl.push(CalculatePage);
    }


  }
  createDraftOrder() {
    this.orderDaft = {
      'item': [
        {
          'name': '',
          'product_id': '',
          'amount': 0,
          'qty': 0,
        }
      ],
      'shop_id': '',
      'date': new Date(),
      'emp_id': ''
    };
  }
  addtoOrder(item) {
    console.log(item);
    if (!this.orderDaft.item) {
      this.orderDaft.item.product_id.put(item._id);
      this.orderDaft.item.qty.put(1);
      this.orderDaft.item.amount.put(item.price);
    } else if (this.orderDaft.item && item._id != this.orderDaft.item._id) {
      this.orderDaft.item.product_id.put(item._id);
      this.orderDaft.item.qty.put(1);
      this.orderDaft.item.amount.put(item.price);
    } else if (this.orderDaft.item && item._id == this.orderDaft.item._id) {

    }

  }
}
{'fraction_non_alphanumeric': 0.1602978640015677, 'fraction_numerical': 0.0027434842249657062, 'mean_word_length': 2.7474302496328926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1167771', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1702, 'n_words': 275}