X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=lib%2Fproduct_category_component.dart;h=70b1a93996594f6c3d3b017c185ab7fead68bbd1;hb=74001e08303ce797811fc91816a67c2006fe0a25;hp=7b48a2aef0a8da676a90f16808295d9ffa9e8d07;hpb=3307c69f4b16867ba7522626b6b0acf2d6d9a478;p=outofuni%2Ftavern2.git diff --git a/lib/product_category_component.dart b/lib/product_category_component.dart index 7b48a2a..70b1a93 100644 --- a/lib/product_category_component.dart +++ b/lib/product_category_component.dart @@ -22,42 +22,24 @@ import 'package:angular2_rbi/directives.dart'; class ProductCategoryComponent implements OnInit { List product_categories; ProductCategory selected_prod_category; - String new_prod_category_name; - String new_prod_category_id; + String new_prod_category_name=''; final ProductCategoryService _prodcatSrv; final Router _router; - var docreate=false; ProductCategoryComponent(this._prodcatSrv,this._router); - Future getProductCategories() async { - product_categories = await _prodcatSrv.getAll(); - } - Future createProductCategory() async { - await _prodcatSrv.createProdCategory( - new_prod_category_name, - new_prod_category_id + String id = await _prodcatSrv.createProdCategory( + new_prod_category_name ); + product_categories.add(new ProductCategory( + id,new_prod_category_name,'product_cetegory' + )); + new_prod_category_name=''; } - void ngOnInit() { - getProductCategories(); - } - - void checkInput() { - if(new_prod_category_name=='' || new_prod_category_id=='') { - docreate=false; - } - else { - docreate=true; - for(var cat in product_categories) { - if(cat.id==new_prod_category_id) { - docreate=false; - break; - } - } - } + Future ngOnInit() async { + product_categories = await _prodcatSrv.getAll(); } choose(ProductCategory pt) {