support select task

This commit is contained in:
MaysWind 2016-05-29 23:27:47 +08:00
parent 54f02804d6
commit 423d25b84e
8 changed files with 90 additions and 12 deletions

View file

@ -44,23 +44,28 @@
</a> </a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li class="disabled"> <li ng-class="{'disabled': !isTaskSelected()}">
<a class="toolbar" title="{{'Start' | translate}}"> <a class="toolbar" title="{{'Start' | translate}}">
<i class="fa fa-play"></i> <i class="fa fa-play"></i>
</a> </a>
</li> </li>
<li class="disabled"> <li ng-class="{'disabled': !isTaskSelected()}">
<a class="toolbar" title="{{'Pause' | translate}}"> <a class="toolbar" title="{{'Pause' | translate}}">
<i class="fa fa-pause"></i> <i class="fa fa-pause"></i>
</a> </a>
</li> </li>
<li class="disabled"> <li ng-class="{'disabled': !taskContext.list || taskContext.list.length < 1}">
<a class="toolbar" title="{{'Delete' | translate}}"> <a class="toolbar" title="{{'Delete' | translate}}">
<i class="fa fa-trash-o"></i> <i class="fa fa-trash-o"></i>
<i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i>
</a> </a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li ng-class="{'disabled': !taskContext.list || taskContext.list.length < 1}">
<a class="toolbar" title="{{'Select All' | translate}}" ng-click="selectAllTasks()">
<i class="fa fa-th-large"></i>
</a>
</li>
<li> <li>
<a class="toolbar dropdown-toggle" data-toggle="dropdown" title="{{'Display Order' | translate}}"> <a class="toolbar dropdown-toggle" data-toggle="dropdown" title="{{'Display Order' | translate}}">
<i class="fa fa-sort-alpha-asc"></i> <i class="fa fa-sort-alpha-asc"></i>

View file

@ -11,6 +11,7 @@
"Start": "开始下载任务", "Start": "开始下载任务",
"Pause": "暂停下载任务", "Pause": "暂停下载任务",
"Delete": "删除下载任务", "Delete": "删除下载任务",
"Select All": "全选",
"Display Order": "显示顺序", "Display Order": "显示顺序",
"Search": "搜索", "Search": "搜索",
"Default": "默认", "Default": "默认",

View file

@ -40,9 +40,9 @@
return invokeMethod({ return invokeMethod({
params: params, params: params,
callback: function (result) { callback: function (result) {
if (!utils.extendArray(result, $scope.downloadTasks, 'gid')) { if (!utils.extendArray(result, $scope.taskContext.list, 'gid')) {
if (needRequestWholeInfo) { if (needRequestWholeInfo) {
$scope.downloadTasks = result; $scope.taskContext.list = result;
needRequestWholeInfo = false; needRequestWholeInfo = false;
} else { } else {
needRequestWholeInfo = true; needRequestWholeInfo = true;
@ -51,9 +51,9 @@
needRequestWholeInfo = false; needRequestWholeInfo = false;
} }
if ($scope.downloadTasks && $scope.downloadTasks.length > 0) { if ($scope.taskContext.list && $scope.taskContext.list.length > 0) {
for (var i = 0; i < $scope.downloadTasks.length; i++) { for (var i = 0; i < $scope.taskContext.list.length; i++) {
utils.processDownloadTask($scope.downloadTasks[i]); utils.processDownloadTask($scope.taskContext.list[i]);
} }
} }
} }

View file

@ -30,6 +30,55 @@
text: '' text: ''
}; };
$scope.taskContext = {
list: [],
selected: {}
};
$scope.isTaskSelected = function () {
var allTasks = $scope.taskContext.list;
if (!allTasks || allTasks.length < 1) {
return false;
}
var selectedTasks = $scope.taskContext.selected;
for (var i = 0; i < allTasks.length; i++) {
var task = allTasks[i];
if (selectedTasks[task.gid]) {
return true;
}
}
return false;
};
$scope.selectAllTasks = function () {
var allTasks = $scope.taskContext.list;
if (!allTasks || allTasks.length < 1) {
return;
}
var selectedTasks = $scope.taskContext.selected;
var isAllSelected = true;
for (var i = 0; i < allTasks.length; i++) {
var task = allTasks[i];
if (!selectedTasks[task.gid]) {
isAllSelected = false;
break;
}
}
for (var i = 0; i < allTasks.length; i++) {
var task = allTasks[i];
selectedTasks[task.gid] = !isAllSelected;
}
};
$scope.changeDisplayOrder = function (type, autoSetReverse) { $scope.changeDisplayOrder = function (type, autoSetReverse) {
var oldType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder()); var oldType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder());
var newType = utils.parseOrderType(type); var newType = utils.parseOrderType(type);

View file

@ -15,6 +15,7 @@
'Start': 'Start', 'Start': 'Start',
'Pause': 'Pause', 'Pause': 'Pause',
'Delete': 'Delete', 'Delete': 'Delete',
'Select All': 'Select All',
'Display Order': 'Display Order', 'Display Order': 'Display Order',
'Search': 'Search', 'Search': 'Search',
'Default': 'Default', 'Default': 'Default',

View file

@ -390,6 +390,24 @@ td {
bottom: 2px; bottom: 2px;
} }
/* awesome-bootstrap-checkbox extend */
.checkbox.checkbox-hide {
padding-left: 0;
}
.checkbox.checkbox-hide > input, .checkbox.checkbox-hide > input + label::before, .checkbox.checkbox-hide > input + label::after {
display: none !important;
}
.checkbox.checkbox-hide > label {
padding-left: 0;
}
.skin-aria-ng .checkbox-primary input[type="checkbox"]:checked + label::before, .checkbox-primary input[type="radio"]:checked + label::before {
background-color: #208fe5;
border-color: #208fe5;
}
/* task-table */ /* task-table */
.task-table { .task-table {
margin-left: 15px; margin-left: 15px;

View file

@ -33,9 +33,14 @@
</div> </div>
</div> </div>
<div class="task-table-body"> <div class="task-table-body">
<div class="row" ng-repeat="task in downloadTasks | filter: filterByTaskName | taskOrderBy: getOrderType()" data-gid="{{task.gid}}"> <div class="row" ng-repeat="task in taskContext.list | filter: filterByTaskName | taskOrderBy: getOrderType()" data-gid="{{task.gid}}">
<div class="col-sm-8"> <div class="col-sm-8">
<div class="checkbox checkbox-primary" ng-class="{'checkbox-hide': !taskContext.selected[task.gid]}">
<input id="{{'task_' + task.gid}}" type="checkbox" ng-model="taskContext.selected[task.gid]"/>
<label for="{{'task_' + task.gid}}">
<span class="task-name" ng-bind="task.taskName" title="{{task.taskName}}"></span> <span class="task-name" ng-bind="task.taskName" title="{{task.taskName}}"></span>
</label>
</div>
<div class="task-files"> <div class="task-files">
<span ng-bind="task.totalLength | readableVolumn"></span> <span ng-bind="task.totalLength | readableVolumn"></span>
<a ng-href="#/task/detail/{{task.gid}}"> <a ng-href="#/task/detail/{{task.gid}}">

View file

@ -138,11 +138,10 @@
<div class="task-table-body"> <div class="task-table-body">
<div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()"> <div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()">
<div class="col-sm-8"> <div class="col-sm-8">
<div class="checkbox checkbox-info"> <div class="checkbox checkbox-primary">
<input id="{{'file_' + $index}}" type="checkbox" ng-checked="file.selected == 'true'" disabled="disabled"/> <input id="{{'file_' + $index}}" type="checkbox" ng-checked="file.selected == 'true'" disabled="disabled"/>
<label for="{{'file_' + $index}}" ng-bind="file.fileName"></label> <label for="{{'file_' + $index}}" ng-bind="file.fileName"></label>
</div> </div>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<div class="progress"> <div class="progress">