Yangman - validate collection name, ...
[dlux.git] / modules / yangman-resources / src / main / resources / yangman / views / leftpanel / save-req-dialog.tpl.html
index 0c04d1f6ecc9d5b0c0fb77b586d8ac715e02caf0..2983e63c4d18a6a1ef95af8606c2853385e83d7f 100644 (file)
@@ -1,5 +1,5 @@
 <md-dialog aria-label="Save to collection"  ng-cloak>
-    <form name="saveReqForm">
+    <form name="dialog.saveReqForm">
         <md-toolbar>
             <div class="md-toolbar-tools">
                 <h2>{{( dialog.duplicate ? 'YANGMAN_REQS_DUPLICATE' : 'YANGMAN_REQS_SAVE_TO_COL')| translate}}</h2>
@@ -8,30 +8,37 @@
         </md-toolbar>
         <md-dialog-content style="width: 400px;">
             <div class="md-dialog-content" layout="column">
-                <md-autocomplete
-                        md-selected-item="dialog.selectedItem"
-                        md-search-text="dialog.collectionName"
-                        md-items="item in dialog.getColAutocomplete()"
-                        md-floating-label="{{'YANGMAN_CREATING_COLLECTION'|translate}}"
-                        md-item-text="item"
-                        md-min-length="0">
-                    <md-item-template>
-                        <span md-highlight-text="dialog.collectionName" md-highlight-flags="^i">{{item}}</span>
-                    </md-item-template>
-                    <md-not-found>
+                <md-input-container>
+                    <md-autocomplete
+                            md-selected-item="dialog.selectedItem"
+                            md-search-text="dialog.collectionName"
+                            md-items="item in dialog.getColAutocomplete()"
+                            md-floating-label="{{'YANGMAN_CREATING_COLLECTION'|translate}}"
+                            md-item-text="item"
+                            md-min-length="0"
+                            ng-required="true">
+                        <md-item-template>
+                            <span md-highlight-text="dialog.collectionName" md-highlight-flags="^i">{{item}}</span>
+                        </md-item-template>
+                        <md-not-found>
                         <span ng-if="dialog.collectionName.length">
                             {{'YANGMAN_COLLECTION_NEW_COL_'| translate}} "{{dialog.collectionName}}" {{'YANGMAN_COLLECTION_WILL_BE_CREATED'| translate}}.
                         </span>
                         <span ng-if="dialog.collectionName.length === 0">
                             {{'YANGMAN_NO_COLLECTIONS'| translate}}
                         </span>
-                    </md-not-found>
-                </md-autocomplete>
-                <div ng-messages="saveReqForm.collectionName.$error" multiple md-auto-hide="false">
-                    <div ng-message="required">
-                        {{'YANGMAN_COLLECTION_NAME_REQUIRED'| translate}}
+                        </md-not-found>
+                    </md-autocomplete>
+                    <input name="collectionName"
+                           ng-model="dialog.collectionName"
+                           ng-required="true" style="display: none;">
+                    <div ng-messages="dialog.saveReqForm.collectionName.$error" multiple md-auto-hide="false">
+                        <div ng-message="required">
+                            {{'YANGMAN_COLLECTION_NAME_REQUIRED'| translate}}
+                        </div>
                     </div>
-                </div>
+                </md-input-container>
+
             </div>
         </md-dialog-content>
         <md-dialog-actions layout="row">
@@ -39,7 +46,7 @@
             <md-button ng-click="dialog.cancel()">
                 {{'YANGMAN_CANCEL'| translate}}
             </md-button>
-            <md-button ng-click="dialog.save()" ng-disabled="dialog.collectionName.length === 0">
+            <md-button ng-click="dialog.save()" ng-disabled="!dialog.saveReqForm.$valid">
                 {{'YANGMAN_SAVE'| translate}}
             </md-button>
         </md-dialog-actions>