]> hackdaworld.org Git - outofuni/tavern2.git/commitdiff
disable category create button
authorhackbard <hackbard@hackdaworld.org>
Thu, 6 Oct 2016 22:41:05 +0000 (00:41 +0200)
committerhackbard <hackbard@hackdaworld.org>
Thu, 6 Oct 2016 22:41:05 +0000 (00:41 +0200)
lib/product_category_component.dart
lib/product_category_component.html

index 69633990e7f43e9f510363b8efed4011aa67f4f4..7b48a2aef0a8da676a90f16808295d9ffa9e8d07 100644 (file)
@@ -26,6 +26,7 @@ class ProductCategoryComponent implements OnInit {
        String new_prod_category_id;
        final ProductCategoryService _prodcatSrv;
        final Router _router;
+       var docreate=false;
 
        ProductCategoryComponent(this._prodcatSrv,this._router);
 
@@ -44,6 +45,21 @@ class ProductCategoryComponent implements OnInit {
                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;
+                               }
+                       }
+               }
+       }
+
        choose(ProductCategory pt) {
                selected_prod_category=pt;
                goto_products(pt);
index e255a5417a91298d605a47d51aa76bdf9877a868..6fff73015a57f277a6a5d757ee825ff2226f3b1a 100644 (file)
        <div class="mdl-textfield mdl-js-textfield
                    mdl-textfield--floating-label ain">
                <input class="mdl-textfield__input" type=text id=ptn
-                      [(ngModel)]="new_prod_category_name">
+                      [(ngModel)]="new_prod_category_name"
+                      (keyup)="checkInput()">
                <label class="mdl-textfield__label" for=ptn>Name</label>
        </div>
        <div class="mdl-textfield mdl-js-textfield
                    mdl-textfield--floating-label ain">
                <input class="mdl-textfield__input" type=text id=pti
-                      [(ngModel)]="new_prod_category_id">
+                      [(ngModel)]="new_prod_category_id"
+                      (keyup)="checkInput()">
                <label class="mdl-textfield__label" for=pti>Identifier</label>
        </div>
        <button class="mdl-button mdl-js-button mdl-button--raised abtn"
-               (click)="createProductCategory()">
+               (click)="createProductCategory()"
+               [disabled]="!docreate">
                Create
        </button>
 </div>