Guest User

Untitled

a guest
Aug 11th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Loc from '../../../helpers/localization';
  2. import {template} from '../../../helpers/helpers';
  3. import * as ORDER from '../../../helpers/statuses/order';
  4. import CurrencyUpdate from '../../../helpers/emitters/currency-update';
  5. import ProfileService from "../services/profile.service";
  6.  
  7. export default function OrderProfileComponent() {
  8.     return {
  9.         templateUrl: template('profile', 'order-food'),
  10.         controller: DeliveryProfileController
  11.     }
  12. }
  13.  
  14. class DeliveryProfileController {
  15.     private currency: any;
  16.     private subCurrency: { unsubscribe: (() => any) };
  17.     private orderFood: { news: any; confirmeds: any; abandoneds: any; denieds: any; completeds: any; problems: any };
  18.     private lc: any;
  19.  
  20.     constructor (private ProfileService: ProfileService) {
  21.         'ngInject';
  22.        
  23.         this.lc = Loc.get('profile');
  24.         this.currency = null;
  25.         this.subCurrency = CurrencyUpdate.subscribe(currency => {
  26.             this.currency = currency;
  27.         });
  28.  
  29.         this.orderFood = {
  30.             news: [],
  31.             confirmeds: [],
  32.             abandoneds: [],
  33.             denieds: [],
  34.             completeds: [],
  35.             problems: []
  36.         };
  37.     }
  38.  
  39.     $onDestroy() {
  40.         this.subCurrency.unsubscribe();
  41.     }
  42.  
  43.     $onInit () {
  44.         this.ProfileService.getOrderFoods(ORDER.NEW).then(data => {
  45.             this.orderFood.news = data;
  46.         });
  47.         this.ProfileService.getOrderFoods(ORDER.CONFIRMED).then(data => {
  48.             this.orderFood.confirmeds = data;
  49.         });
  50.         this.ProfileService.getOrderFoods(ORDER.ABANDONED).then(data => {
  51.             this.orderFood.abandoneds = data;
  52.         });
  53.         this.ProfileService.getOrderFoods(ORDER.DENIED).then(data => {
  54.             this.orderFood.denieds = data;
  55.         });
  56.         this.ProfileService.getOrderFoods(ORDER.COMPLETED).then(data => {
  57.             this.orderFood.completeds = data;
  58.         });
  59.         this.ProfileService.getOrderFoods(ORDER.PROBLEM).then(data => {
  60.             this.orderFood.problems = data;
  61.         });
  62.     }
  63. }
  64.  
  65.  
  66. // пример вывода новых заказов
  67.  
  68. <div role="tabpanel" class="tab-pane active" id="news">
  69.             <div ng-repeat="order in $ctrl.orderFood.news.data track by $index"
  70.                  class="right-content">
  71.                 <order-food order="order" index="$index" abandon="$ctrl.setOrderStatus(id, status, index, type)"></order-food>
  72.             </div>
  73.             <pg-server ng-if="$ctrl.orderFood.news.data.length > 0" model="$ctrl.orderFood.news"></pg-server>
  74.         </div>
Advertisement
Add Comment
Please, Sign In to add comment