Commit 2d058e43 by 陈慧

fix search app bug

parent 49b27bd0
...@@ -14,14 +14,14 @@ directive_module.directive('apollonav', ...@@ -14,14 +14,14 @@ directive_module.directive('apollonav',
}); });
scope.sourceApps = []; scope.sourceApps = [];
scope.copyedApps = []; scope.copiedApps = [];
AppService.find_apps().then(function (result) { AppService.find_apps().then(function (result) {
result.forEach(function (app) { result.forEach(function (app) {
app.selected = false; app.selected = false;
scope.sourceApps.push(app); scope.sourceApps.push(app);
}); });
scope.copyedApps = angular.copy(scope.sourceApps); scope.copiedApps = angular.copy(scope.sourceApps);
}, function (result) { }, function (result) {
toastr.error(AppUtil.errorMsg(result), "load apps error"); toastr.error(AppUtil.errorMsg(result), "load apps error");
}); });
...@@ -36,12 +36,12 @@ directive_module.directive('apollonav', ...@@ -36,12 +36,12 @@ directive_module.directive('apollonav',
}; };
scope.changeSearchKey = function () { scope.changeSearchKey = function () {
scope.copyedApps = []; scope.copiedApps = [];
var searchKey = scope.searchKey.toLocaleLowerCase(); var searchKey = scope.searchKey.toLocaleLowerCase();
scope.sourceApps.forEach(function (app) { scope.sourceApps.forEach(function (app) {
if (app.name.toLocaleLowerCase().indexOf(searchKey) > -1 if (app.name.toLocaleLowerCase().indexOf(searchKey) > -1
|| app.appId.toLocaleLowerCase().indexOf(searchKey) > -1) { || app.appId.toLocaleLowerCase().indexOf(searchKey) > -1) {
scope.copyedApps.push(app); scope.copiedApps.push(app);
} }
}); });
scope.shouldShowAppList = true; scope.shouldShowAppList = true;
...@@ -63,18 +63,18 @@ directive_module.directive('apollonav', ...@@ -63,18 +63,18 @@ directive_module.directive('apollonav',
element.bind("keydown keypress", function (event) { element.bind("keydown keypress", function (event) {
if (event.keyCode == 40) { if (event.keyCode == 40) {
if (selectedAppIdx < scope.copyedApps.length - 1) { if (selectedAppIdx < scope.copiedApps.length - 1) {
clearAppsSelectedStatus(); clearAppsSelectedStatus();
scope.copyedApps[++selectedAppIdx].selected = true; scope.copiedApps[++selectedAppIdx].selected = true;
} }
} else if (event.keyCode == 38) { } else if (event.keyCode == 38) {
if (selectedAppIdx >= 1) { if (selectedAppIdx >= 1) {
clearAppsSelectedStatus(); clearAppsSelectedStatus();
scope.copyedApps[--selectedAppIdx].selected = true; scope.copiedApps[--selectedAppIdx].selected = true;
} }
} else if (event.keyCode == 13) { } else if (event.keyCode == 13) {
if (scope.shouldShowAppList && selectedAppIdx > -1) { if (scope.shouldShowAppList && selectedAppIdx > -1) {
select(scope.copyedApps[selectedAppIdx]); select(scope.copiedApps[selectedAppIdx]);
event.preventDefault(); event.preventDefault();
} else { } else {
scope.jumpToConfigPage(); scope.jumpToConfigPage();
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
ng-model="searchKey" ng-change="changeSearchKey()" ng-focus="changeSearchKey()"> ng-model="searchKey" ng-change="changeSearchKey()" ng-focus="changeSearchKey()">
<div class="row app-list" ng-show="shouldShowAppList"> <div class="row app-list" ng-show="shouldShowAppList">
<div ng-repeat="app in copyedApps" class="app-item" ng-class="{'app-selected':app.selected}" <div ng-repeat="app in copiedApps" class="app-item" ng-class="{'app-selected':app.selected}"
ng-click="selectApp(app)">{{app.appId}} / {{app.name}} ng-click="selectApp(app)">{{app.appId}} / {{app.name}}
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment