support selecting all completed tasks

This commit is contained in:
MaysWind 2019-04-23 00:15:17 +08:00
parent b066fc267e
commit e117d83e93
6 changed files with 74 additions and 0 deletions

View file

@ -24,6 +24,7 @@ Select All=全部选中
Select None=全部不选
Select Invert=反向选择
Select All Failed Task=全选失败任务
Select All Completed Tasks=全选已完成任务
Display Order=显示顺序
Copy Download Url=复制下载链接
Copy Magnet Link=复制磁力链接

View file

@ -24,6 +24,7 @@ Select All=全部選中
Select None=全部不選
Select Invert=反向選擇
Select All Failed Task=全選失敗工作
Select All Completed Tasks=全選已完成工作
Display Order=顯示順序
Copy Download Url=複製下載連結
Copy Magnet Link=複製磁力連結

View file

@ -28,6 +28,7 @@
'Select None': 'Select None',
'Select Invert': 'Select Invert',
'Select All Failed Task': 'Select All Failed Task',
'Select All Completed Tasks': 'Select All Completed Tasks',
'Display Order': 'Display Order',
'Copy Download Url': 'Copy Download Url',
'Copy Magnet Link': 'Copy Magnet Link',

View file

@ -202,6 +202,10 @@
return $rootScope.taskContext.hasRetryableTask();
};
$scope.hasCompletedTask = function () {
return $rootScope.taskContext.hasCompletedTask();
};
$scope.isSelectedTaskRetryable = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
@ -327,6 +331,10 @@
$rootScope.taskContext.selectAllFailed();
};
$scope.selectAllCompletedTasks = function () {
$rootScope.taskContext.selectAllCompleted();
};
$scope.copySelectedOneTaskDownloadLink = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

View file

@ -166,6 +166,21 @@
return false;
},
hasCompletedTask: function () {
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if (task.status === 'complete') {
return true;
}
}
return false;
},
selectAll: function () {
if (!this.list || !this.selected || this.list.length < 1) {
return;
@ -226,6 +241,48 @@
continue;
}
this.selected[task.gid] = !isAllFailedSelected;
}
},
selectAllCompleted: function () {
if (!this.list || !this.selected || this.list.length < 1) {
return;
}
if (!this.enableSelectAll) {
return;
}
var isAllFailedSelected = true;
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if (task.status !== 'complete') {
continue;
}
if (!this.selected[task.gid]) {
isAllFailedSelected = false;
}
}
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if (task.status !== 'complete') {
this.selected[task.gid] = false;
continue;
}
this.selected[task.gid] = !isAllFailedSelected;
}
}

View file

@ -164,6 +164,12 @@
<span translate>Select All Failed Task</span>
</a>
</li>
<li ng-if="hasCompletedTask()">
<a tabindex="-1" class="pointer-cursor" title="{{'Select All Completed Tasks' | translate}}" ng-click="selectAllCompletedTasks()">
<i class="fa fa-fw"></i>
<span translate>Select All Completed Tasks</span>
</a>
</li>
<li>
<a tabindex="-1" class="pointer-cursor" title="{{'Select All' | translate}}" ng-click="selectAllTasks()">
<i class="fa fa-th-large fa-fw"></i>