Merge "Yangman - validate collection name, ..."
authorMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Thu, 11 Aug 2016 22:26:54 +0000 (22:26 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 11 Aug 2016 22:26:54 +0000 (22:26 +0000)
modules/yangman-resources/src/main/resources/yangman/controllers/requests-list.controller.js
modules/yangman-resources/src/main/resources/yangman/models/historylist.model.js
modules/yangman-resources/src/main/resources/yangman/services/requests.services.js
modules/yangman-resources/src/main/resources/yangman/views/leftpanel/save-req-dialog.tpl.html
modules/yangman-resources/src/main/resources/yangman/yangman.less

index 6871ee6fe749a1854f380980218acfccf5ac8d01..69d8a65d98f82257eab227ca26d455faccc5627c 100644 (file)
@@ -66,6 +66,9 @@ define([
          * Clear history requests list and save to storage
          */
         function clearHistoryList(ev) {
+
+            YangmanDesignService.disableMdMenuItem(ev);
+
             var confirm = $mdDialog.confirm()
                 .title($filter('translate')('YANGMAN_DELETE_HISTORY_CONFIRM_TITLE'))
                 .textContent($filter('translate')('YANGMAN_DELETE_HISTORY_CONFIRM_TEXT'))
@@ -78,6 +81,9 @@ define([
                 vm.requestList.clear();
                 vm.requestList.saveToStorage();
                 $scope.rootBroadcast('YANGMAN_REFRESH_HISTORY');
+                YangmanDesignService.enableMdMenuItem(ev);
+            }, function (){
+                YangmanDesignService.enableMdMenuItem(ev);
             });
         }
 
@@ -93,10 +99,15 @@ define([
                 .ok($filter('translate')('YANGMAN_OK'))
                 .cancel($filter('translate')('YANGMAN_CANCEL'));
 
+            YangmanDesignService.disableMdMenuItem(ev);
+
             $mdDialog.show(confirm).then(function (){
                 vm.collectionList.clear();
                 vm.collectionList.saveToStorage();
                 $scope.rootBroadcast('YANGMAN_REFRESH_COLLECTIONS');
+                YangmanDesignService.enableMdMenuItem(ev);
+            }, function () {
+                YangmanDesignService.enableMdMenuItem(ev);
             });
         }
 
index 9566fa9819ab7b36955f83dbc5f05a0ab0bf5c60..3043455545d1f82275d4ba15e13ba65a129d7698 100644 (file)
@@ -76,24 +76,26 @@ define(['app/yangman/models/baselist.model'], function (BaseListModel){
             self.list.forEach(addToListDateGroup);
 
             function addToListDateGroup(elem){
-                var groupName = roundTimestampToDate(elem.timestamp),
-                    dateGroupArr = self.dateGroups.filter(function(group){
-                        return group.name === groupName;
-                    }),
-                    dateGroup = null;
-
-                if (dateGroupArr.length){
-                    dateGroup = dateGroupArr[0];
+                if (elem.timestamp){
+                    var groupName = roundTimestampToDate(elem.timestamp),
+                        dateGroupArr = self.dateGroups.filter(function(group){
+                            return group.name === groupName;
+                        }),
+                        dateGroup = null;
+
+                    if (dateGroupArr.length){
+                        dateGroup = dateGroupArr[0];
+                    }
+                    else {
+                        dateGroup = {
+                            name: groupName,
+                            longName: new Date(groupName).toDateString(),
+                            requests: [],
+                        };
+                        self.dateGroups.push(dateGroup);
+                    }
+                    dateGroup.requests.push(elem);
                 }
-                else {
-                    dateGroup = {
-                        name: groupName,
-                        longName: new Date(groupName).toDateString(),
-                        requests: [],
-                    };
-                    self.dateGroups.push(dateGroup);
-                }
-                dateGroup.requests.push(elem);
             }
         }
 
index 4ea00f705a2a319607507d3f31ce6c984e2c5447..3c694fde295f63dc50aa544ce489d50b8829ffab 100644 (file)
@@ -143,7 +143,7 @@ define([
          * @returns {*}
          */
         function createHistoryRequestFromElement(elem) {
-            if (!elem.hasOwnProperty('timestamp')){
+                if (!elem.hasOwnProperty('timestamp') || elem.timestamp === ''){
                 elem.timestamp = Date.now();
             }
 
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>
index 887981708f921988773751ec56bc7db2b9ef8750..5202a3ec6fc1646965250ec154c1f342eea03a4a 100644 (file)
@@ -145,6 +145,12 @@ button{
     right: 0;
 }
 
+md-dialog{
+    md-autocomplete{
+        height: 50px !important;
+    }
+}
+
 .info-box-container{
     position: relative;
 
@@ -288,6 +294,8 @@ button{
                 }
             }
         }
+
+
     }
     // left panel
     &__left-panel{