Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// <reference path="./typings/jquery.d.ts" />
  2. /// <reference path="shiftType.ts" />
  3.  
  4. class Schedule {
  5.  
  6.     private shiftTypes:shiftType[] = [];
  7.  
  8.  
  9.     getShiftTypes(showBox:boolean = true) {
  10.         let self = this;
  11.  
  12.         let url = Routing.generate('shift_types', {'_locale': locale});
  13.  
  14.         $.ajax({
  15.             url: url,
  16.             type: "GET",
  17.             success: function (response) {
  18.  
  19.             /*
  20.             * response.json = [{function_id:'12', isActive:true}, {function_id:'88', isActive:true}];
  21.             */
  22.                 for(let st of response.json) {
  23.                     self._addShiftType(st);
  24.                 }
  25.             }
  26.         });
  27.     }
  28.  
  29.     /**
  30.      * Updates day box with function color and tooltip
  31.      * @param $td
  32.      */
  33.     private updateBox() {
  34.  
  35.         console.log ( this.shiftTypes );
  36.         //iterate through all available shiftTypes
  37.         for (let f of this.shiftTypes) {
  38.             /*
  39.             * tutaj mam problem, ponieważ f.functionId zwraca undefined...
  40.             * natomiast f.function_id zwraca dane....
  41.             */
  42.             console.info(f.functionId);
  43.         }
  44.  
  45.     }
  46.  
  47.     private _addShiftType(type: shiftType ) {
  48.  
  49.         this.shiftTypes.push(type);
  50.     }
  51. }
  52.  
  53.  
  54. /// <reference path="./typings/jquery.d.ts" />
  55. /// <reference path="/web/assets/vendors/moment/moment.d.ts" />
  56.  
  57. class shiftType {
  58.  
  59.     private function_id:string;
  60.  
  61.     set functionId(functionId:string) {
  62.         this.function_id = functionId;
  63.     }
  64.  
  65.     get functionId():string {
  66.         return this.function_id;
  67.     }
  68.  
  69.     get shiftStart():moment {
  70.         return moment(this._shiftType.shift_start, 'HH:mm');
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement