{"version":3,"sources":["webpack:///src/app/admin/public-foods/public-foods-list/public-foods-list.component.ts","webpack:///src/app/admin/public-foods/public-foods-list/public-foods-list.component.html","webpack:///src/app/admin/public-foods/public-foods-routing.module.ts","webpack:///src/app/admin/public-foods/public-foods.component.ts","webpack:///src/app/admin/public-foods/public-foods.module.ts","webpack:///src/app/admin/public-foods/meal-metrics-graph/meal-metrics-graph.module.ts"],"names":["PublicFoodsListComponent","customFoodService","router","route","toasterService","dialogService","MyFoodListLabel","AddLabel","NameLabel","DescriptionLabel","CaloriesLabel","FatsLabel","CarbsLabel","ProteinsLabel","UpdatedDateLabel","SuccessDeleteMyFood","FailDeleteMyFood","BackLabel","unsubscribe$","Subject","MyFoodTableSettings","hideSubHeader","mode","actions","columnTitle","$localize","position","add","edit","editButtonContent","delete","deleteButtonContent","columns","name","title","type","filter","description","totalCalories","fats","carbohydrate","protein","updatedDate","searchTimeout","this","CustomFoodSource","gridDataSource","setFilter","field","search","setSort","direction","open","closeOnEsc","closeOnBackdropClick","context","id","isPublic","onClose","subscribe","goal","refresh","$event","data","Message","result","pipe","takeUntil","handleMyFoodDeleteSuccessResponse","err","handleMyFoodDeleteWrongResponse","query","clearTimeout","setTimeout","self","success","danger","onSearch","AddCustomFood","onEdit","onDelete","routes","path","component","PublicFoodsComponent","children","redirectTo","pathMatch","PublicFoodsRoutingModule","forChild","NB_MODULES","PublicFoodsModule","AuthModule","N","GraphModule","ChartModule"],"mappings":"2nBAmBO,Y,MAAMA,EAoBX,YACUC,EACAC,EACAC,EACAC,EACAC,GAJA,KAAAJ,oBACA,KAAAC,SACA,KAAAC,QACA,KAAAC,iBACA,KAAAC,gBAxBV,KAAAC,gBAAkB,cAClB,KAAAC,SAAW,UAEX,KAAAC,UAAY,OACZ,KAAAC,iBAAmB,cACnB,KAAAC,cAAgB,WAChB,KAAAC,UAAY,OACZ,KAAAC,WAAa,QACb,KAAAC,cAAgB,WAChB,KAAAC,iBAAmB,eAEnB,KAAAC,oBAAsB,mC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AAM,GACNI,WAAY,OACZC,UAAW,QAEb,CACEL,KAAM,OACNC,UAAW,MAeV,Y,MAAMK,G,yDAAAA,I,+EAAAA,IAAwB,UAFxB,GAAE,SAFJ,CAAC,IAAaC,SAASR,IACtB,O,GAGL,G,gBEFP,MAAMS,EAAa,CACjB,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IACA,KAyBK,Y,MAAMC,G,yDAAAA,I,+EAAAA,IAAiB,UAFjB,GAAE,SAnBJ,CACP,IACA,IACA,IACA,EAAAC,WACA,IACA,OACGF,EACH,EACA,Q,GAYG,I,kCCrEP,sFAsBA,MAAMA,EAAa,CACjB,IACA,IACA,IACA,KACA,EAAAG,EACA,KACA,KACA,KACA,KACA,IACA,KACA,IACA,KAQK,Y,MAAMC,G,yDAAAA,I,+EAAAA,IAAW,SAJb,IAAIJ,EAAY,EAAAK,gB,GAIpB","file":"x","sourcesContent":["import { Component, OnInit } from '@angular/core';\r\nimport { Router, ActivatedRoute } from '@angular/router';\r\nimport { takeUntil } from 'rxjs/operators';\r\nimport { Subject } from 'rxjs/Subject';\r\nimport { NbToastrService, NbDialogService } from '@nebular/theme';\r\nimport { DataSource } from 'ng2-smart-table/lib/lib/data-source/data-source';\r\n\r\nimport { CustomFoodData } from '../../../@core/interfaces/common/CalorieFriend/custom-food';\r\nimport { ConfirmMessageDialogComponent } from 'app/@components/confirm-message-dialog/confirm-message-dialog.component';\r\nimport { CustomFoodComponent } from '../custom-food/custom-food.component';\r\n\r\n/**\r\n * Component for listing the Public Food items\r\n */\r\n@Component({\r\n  selector: 'ngx-public-foods-list',\r\n  templateUrl: './public-foods-list.component.html',\r\n  styleUrls: ['./public-foods-list.component.scss'],\r\n})\r\nexport class PublicFoodsListComponent implements OnInit {\r\n  MyFoodListLabel = 'Food Groups';\r\n  AddLabel = 'Add New';\r\n\r\n  NameLabel = 'Name';\r\n  DescriptionLabel = 'Description';\r\n  CaloriesLabel = 'Calories';\r\n  FatsLabel = 'Fats';\r\n  CarbsLabel = 'Carbs';\r\n  ProteinsLabel = 'Proteins';\r\n  UpdatedDateLabel = 'Updated Date';\r\n\r\n  SuccessDeleteMyFood = 'Successfully deleted Custom Food';\r\n  FailDeleteMyFood = 'Problem occurred delelting Custom Food';\r\n  BackLabel = 'Back';\r\n\r\n  CustomFoodSource: DataSource;\r\n  protected readonly unsubscribe$ = new Subject<void>();\r\n\r\n  /** MyFoodList ctor */\r\n  constructor(\r\n    private customFoodService: CustomFoodData,\r\n    private router: Router,\r\n    private route: ActivatedRoute,\r\n    private toasterService: NbToastrService,\r\n    private dialogService: NbDialogService,\r\n  ) {\r\n    this.CustomFoodSource = this.customFoodService.gridDataSource;\r\n    this.CustomFoodSource.setFilter(\r\n      [\r\n        {\r\n          field: 'OnlyPublic',\r\n          search: true,\r\n        },\r\n      ],\r\n      true,\r\n      false,\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Settings of the ng2 smart table of Custom Foods\r\n   */\r\n  MyFoodTableSettings = {\r\n    hideSubHeader: true,\r\n    mode: 'external',\r\n    actions: {\r\n      columnTitle: $localize`:@@Actions:Actions`,\r\n      position: 'right',\r\n      add: false,\r\n    },\r\n\r\n    edit: {\r\n      editButtonContent:\r\n        '<img src=\"assets/icons/added_oultine_modify_pencil.svg\" title=\"' +\r\n        $localize`:@@Edit:Edit` +\r\n        '\" class=\"img-archive\" width=\"24\" height=\"24\">',\r\n    },\r\n    delete: {\r\n      deleteButtonContent:\r\n        '<img src=\"assets/icons/trash-2-outline.svg\" title=\"' +\r\n        $localize`:@@Delete:Delete` +\r\n        '\" class=\"img-archive\" width=\"24\" height=\"24\">',\r\n    },\r\n\r\n    columns: {\r\n      name: { title: $localize`:@@Name:Name`, type: 'string', filter: false },\r\n      description: {\r\n        title: $localize`:@@Description:Description`,\r\n        type: 'string',\r\n        filter: false,\r\n      },\r\n      totalCalories: {\r\n        title: $localize`:@@Calories:Calories`,\r\n        type: 'number',\r\n        filter: false,\r\n      },\r\n      fats: {\r\n        title: $localize`:@@Fats:Fats`,\r\n        type: 'number',\r\n        filter: false,\r\n      },\r\n      carbohydrate: {\r\n        title: $localize`:@@Carbs:Carbs`,\r\n        type: 'number',\r\n        filter: false,\r\n      },\r\n      protein: {\r\n        title: $localize`:@@Protein:Protein`,\r\n        type: 'number',\r\n        filter: false,\r\n      },\r\n      updatedDate: {\r\n        title: $localize`:@@LastUpdate:Last Update`,\r\n        type: 'date',\r\n        filter: false,\r\n      },\r\n    },\r\n  };\r\n\r\n  /**\r\n   * Initializes the component.\r\n   * It sets the default sorting for the table.\r\n   */\r\n  ngOnInit(): void {\r\n    this.CustomFoodSource.setSort([\r\n      { field: 'updatedDate', direction: 'desc' },\r\n    ]);\r\n  }\r\n\r\n  /**\r\n   * It opens the component 'CustomFoodDefComponent' to create a new Custom Food item as the pop up dialog\r\n   */\r\n  AddCustomFood() {\r\n    this.dialogService\r\n      .open(CustomFoodComponent, {\r\n        closeOnEsc: false,\r\n        closeOnBackdropClick: false,\r\n        context: {\r\n          id: null,\r\n          isPublic: true,\r\n        },\r\n      })\r\n      .onClose.subscribe((goal) => {\r\n        this.CustomFoodSource.refresh();\r\n      });\r\n  }\r\n\r\n  /**\r\n   * It opens the component 'CustomFoodDefComponent' to edit an existing Custom Food item as the pop up dialog\r\n   * @param $event Event object\r\n   */\r\n  onEdit($event) {\r\n    this.dialogService\r\n      .open(CustomFoodComponent, {\r\n        closeOnEsc: false,\r\n        closeOnBackdropClick: false,\r\n        context: {\r\n          id: $event.data.id,\r\n          isPublic: true,\r\n        },\r\n      })\r\n      .onClose.subscribe((goal) => {\r\n        this.CustomFoodSource.refresh();\r\n      });\r\n  }\r\n\r\n  /**\r\n   * Event handler of the 'Click' event of the 'Delete' action.\r\n   * It deletes a Custom Food with {id} (given by $event object).\r\n   * @param $event Event object\r\n   */\r\n  onDelete($event) {\r\n    this.dialogService\r\n      .open(ConfirmMessageDialogComponent, {\r\n        closeOnEsc: true,\r\n        closeOnBackdropClick: true,\r\n        context: { Message: 'Are you sure to delete this public food?' },\r\n      })\r\n      .onClose.subscribe((result) => {\r\n        if (result) {\r\n          const observable = this.customFoodService.delete($event.data.id);\r\n\r\n          observable.pipe(takeUntil(this.unsubscribe$)).subscribe(\r\n            () => {\r\n              this.handleMyFoodDeleteSuccessResponse();\r\n            },\r\n            (err) => {\r\n              this.handleMyFoodDeleteWrongResponse();\r\n            },\r\n          );\r\n        }\r\n      });\r\n  }\r\n\r\n  searchTimeout = null;\r\n\r\n  /**\r\n   * Event handler of the auto-complete action.\r\n   * Searches the items within Name or Description fields by the {query} value\r\n   * @param query Query string to search items\r\n   */\r\n  onSearch(query: string = '') {\r\n    if (this.searchTimeout) {\r\n      clearTimeout(this.searchTimeout);\r\n    }\r\n    this.searchTimeout = setTimeout(\r\n      function (self) {\r\n        self.CustomFoodSource.setFilter(\r\n          [\r\n            {\r\n              field: 'OnlyPublic',\r\n              search: true,\r\n            },\r\n            {\r\n              field: 'NameOrDescription',\r\n              search: query,\r\n            },\r\n          ],\r\n          true,\r\n        );\r\n      },\r\n      700,\r\n      this,\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Handler of Success event of Delete action of an existing item\r\n   */\r\n  handleMyFoodDeleteSuccessResponse() {\r\n    this.toasterService.success('', this.SuccessDeleteMyFood);\r\n    // refresh screen\r\n    this.CustomFoodSource.refresh();\r\n  }\r\n\r\n  /**\r\n   * Handler of Fail event of Delete action of an existing item\r\n   */\r\n  handleMyFoodDeleteWrongResponse() {\r\n    this.toasterService.danger('', this.FailDeleteMyFood);\r\n  }\r\n\r\n  Back() {}\r\n}\r\n","<nb-card>\r\n\r\n  <nb-card-header>\r\n    <div i18n=\"@@PublicFoods\" class=\"title\">Food Groups</div>\r\n\r\n    <div class=\"actions\">\r\n      <nb-form-field class=\"search-field\">\r\n        <input nbInput shape=\"semi-round\" fieldSize=\"small\" #search class=\"search\" type=\"text\"\r\n          (input)=\"onSearch(search.value)\" i18n-placeholder=\"@@SearchThreeDots\" placeholder=\"Search...\">\r\n        <nb-icon nbSuffix icon=\"search-outline\" pack=\"eva\"></nb-icon>\r\n      </nb-form-field>\r\n      <button nbButton type=\"submit\" size=\"small\"  class=\"add\" (click)=\"AddCustomFood()\">\r\n        <nb-icon icon=\"plus\"></nb-icon>\r\n      </button>\r\n    </div>\r\n  </nb-card-header>\r\n\r\n  <nb-card-body>\r\n    <ng2-smart-table class=\"order-smart-table\" [settings]=\"MyFoodTableSettings\" [source]=\"CustomFoodSource\"\r\n      (add)=\"AddCustomFood\" (edit)=\"onEdit($event)\" (delete)=\"onDelete($event)\">\r\n    </ng2-smart-table>\r\n  </nb-card-body>\r\n\r\n  <nb-card-footer>\r\n    <table style=\" width: auto; float: right;\">\r\n      <tr>\r\n        <td>\r\n          <button i18n=\"@@AddNew\" nbButton type=\"submit\"  (click)=\"AddCustomFood()\"\r\n            class=\"btn-circle btn-xl btn-main btn-main\">Add New</button>\r\n        </td>\r\n      </tr>\r\n    </table>\r\n  </nb-card-footer>\r\n\r\n</nb-card>\r\n","\r\n\r\nimport { NgModule } from '@angular/core';\r\nimport { Routes, RouterModule } from '@angular/router';\r\nimport { PublicFoodsListComponent } from './public-foods-list/public-foods-list.component';\r\nimport { PublicFoodsComponent } from './public-foods.component';\r\n\r\nconst routes: Routes = [{\r\n  path: '',\r\n  component: PublicFoodsComponent,\r\n  children: [\r\n    {\r\n      path: '',\r\n      redirectTo: 'list',\r\n      pathMatch: 'full',\r\n    },\r\n    {\r\n      path: 'list',\r\n      component: PublicFoodsListComponent,\r\n    },\r\n    // {\r\n    //  path: 'add',\r\n    //  component: SubscriptionComponent,\r\n    //  resolve: { subscriptionData: SubscriptionFormResolver },\r\n    // },\r\n  ],\r\n}];\r\n\r\n@NgModule({\r\n  imports: [RouterModule.forChild(routes)],\r\n  exports: [RouterModule],\r\n  providers: [],\r\n})\r\nexport class PublicFoodsRoutingModule {\r\n\r\n}\r\n","\r\n\r\nimport { Component } from '@angular/core';\r\n\r\n\r\n@Component({\r\n  selector: 'ngx-public-foods',\r\n  template: `\r\n    <router-outlet></router-outlet>\r\n  `,\r\n})\r\nexport class PublicFoodsComponent {\r\n  constructor() { }\r\n}\r\n","import { CommonModule } from '@angular/common';\r\nimport { NgModule } from '@angular/core';\r\nimport { FormsModule } from '@angular/forms';\r\nimport { ReactiveFormsModule } from '@angular/forms';\r\nimport { Ng2SmartTableModule } from 'ng2-smart-table';\r\nimport {\r\n  NbActionsModule,\r\n  NbButtonModule,\r\n  NbCardModule,\r\n  NbInputModule,\r\n  NbTabsetModule,\r\n  NbUserModule,\r\n  NbRadioModule,\r\n  NbSelectModule,\r\n  NbListModule,\r\n  NbIconModule,\r\n  NbSpinnerModule,\r\n  NbDatepickerModule,\r\n  NbFormFieldModule,\r\n  NbDialogModule,\r\n} from '@nebular/theme';\r\n\r\nimport { AuthModule } from '../../@auth/auth.module';\r\nimport { ComponentsModule } from 'app/@components/components.module';\r\n\r\nimport { PublicFoodsRoutingModule } from './public-foods-routing.module';\r\nimport { PublicFoodsComponent } from './public-foods.component';\r\nimport { PublicFoodsListComponent } from './public-foods-list/public-foods-list.component';\r\nimport { CustomFoodComponent, CustomFoodQuickAddComponent } from './custom-food/custom-food.component';\r\nimport { GraphModule } from './meal-metrics-graph/meal-metrics-graph.module';\r\n\r\nconst NB_MODULES = [\r\n  NbActionsModule,\r\n  NbButtonModule,\r\n  NbCardModule,\r\n  NbFormFieldModule,\r\n  NbInputModule,\r\n  NbTabsetModule,\r\n  NbUserModule,\r\n  NbRadioModule,\r\n  NbSelectModule,\r\n  NbListModule,\r\n  NbIconModule,\r\n  NbSpinnerModule,\r\n  NbDatepickerModule,\r\n  NbDialogModule,\r\n];\r\n\r\n@NgModule({\r\n  imports: [\r\n    CommonModule,\r\n    FormsModule,\r\n    ReactiveFormsModule,\r\n    AuthModule,\r\n    ComponentsModule,\r\n    Ng2SmartTableModule,\r\n    ...NB_MODULES,\r\n    PublicFoodsRoutingModule,\r\n    GraphModule,\r\n  ],\r\n  declarations: [\r\n    PublicFoodsComponent,\r\n    PublicFoodsListComponent,\r\n    CustomFoodComponent,\r\n    CustomFoodQuickAddComponent\r\n  ],\r\n  exports: [CustomFoodComponent],\r\n  entryComponents: [],\r\n  providers: [],\r\n})\r\nexport class PublicFoodsModule {}\r\n","import { NgModule } from '@angular/core';\r\nimport { NbEvaIconsModule } from '@nebular/eva-icons';\r\nimport { ChartModule } from 'angular2-chartjs';\r\nimport {\r\n  NbCheckboxModule,\r\n  NbTabsetModule,\r\n  NbToggleModule,\r\n  NbSelectModule,\r\n  NbProgressBarModule,\r\n  NbDialogModule,\r\n  NbPopoverModule,\r\n  NbFormFieldModule,\r\n  NbAutocompleteModule,\r\n  NbIconModule,\r\n  NbAlertModule,\r\n  NbButtonModule,\r\n} from '@nebular/theme';\r\n\r\nimport {\r\n  AdjustMetricsGraphComponent,\r\n  MealMetricsGraphComponent,\r\n} from './meal-metrics-graph.component';\r\n\r\nconst NB_MODULES = [\r\n  NbEvaIconsModule,\r\n  NbButtonModule,\r\n  NbAlertModule,\r\n  NbIconModule,\r\n  NbCheckboxModule,\r\n  NbTabsetModule,\r\n  NbToggleModule,\r\n  NbSelectModule,\r\n  NbProgressBarModule,\r\n  NbDialogModule,\r\n  NbPopoverModule,\r\n  NbFormFieldModule,\r\n  NbAutocompleteModule,\r\n];\r\n\r\n@NgModule({\r\n  imports: [...NB_MODULES, ChartModule],\r\n  declarations: [MealMetricsGraphComponent, AdjustMetricsGraphComponent],\r\n  exports: [MealMetricsGraphComponent, AdjustMetricsGraphComponent],\r\n})\r\nexport class GraphModule {}\r\n"]}