From 423d25b84e2f9e08f9ca79aba8e22febe18e5691 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 29 May 2016 23:27:47 +0800 Subject: [PATCH] support select task --- app/index.html | 11 +++++-- app/langs/zh-CN.json | 1 + app/scripts/controllers/list.js | 10 +++---- app/scripts/controllers/main.js | 49 ++++++++++++++++++++++++++++++++ app/scripts/core/lang-default.js | 1 + app/styles/aria-ng.css | 18 ++++++++++++ app/views/list.html | 9 ++++-- app/views/task-detail.html | 3 +- 8 files changed, 90 insertions(+), 12 deletions(-) diff --git a/app/index.html b/app/index.html index 2ff78b2..1acf0a8 100644 --- a/app/index.html +++ b/app/index.html @@ -44,23 +44,28 @@
  • -
  • +
  • -
  • +
  • -
  • +
  • +
  • + + + +
  • diff --git a/app/langs/zh-CN.json b/app/langs/zh-CN.json index 26ec30f..af20ae7 100644 --- a/app/langs/zh-CN.json +++ b/app/langs/zh-CN.json @@ -11,6 +11,7 @@ "Start": "开始下载任务", "Pause": "暂停下载任务", "Delete": "删除下载任务", + "Select All": "全选", "Display Order": "显示顺序", "Search": "搜索", "Default": "默认", diff --git a/app/scripts/controllers/list.js b/app/scripts/controllers/list.js index 87bef05..2a059e8 100644 --- a/app/scripts/controllers/list.js +++ b/app/scripts/controllers/list.js @@ -40,9 +40,9 @@ return invokeMethod({ params: params, callback: function (result) { - if (!utils.extendArray(result, $scope.downloadTasks, 'gid')) { + if (!utils.extendArray(result, $scope.taskContext.list, 'gid')) { if (needRequestWholeInfo) { - $scope.downloadTasks = result; + $scope.taskContext.list = result; needRequestWholeInfo = false; } else { needRequestWholeInfo = true; @@ -51,9 +51,9 @@ needRequestWholeInfo = false; } - if ($scope.downloadTasks && $scope.downloadTasks.length > 0) { - for (var i = 0; i < $scope.downloadTasks.length; i++) { - utils.processDownloadTask($scope.downloadTasks[i]); + if ($scope.taskContext.list && $scope.taskContext.list.length > 0) { + for (var i = 0; i < $scope.taskContext.list.length; i++) { + utils.processDownloadTask($scope.taskContext.list[i]); } } } diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index a9d550f..7ccfe43 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -30,6 +30,55 @@ 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) { var oldType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder()); var newType = utils.parseOrderType(type); diff --git a/app/scripts/core/lang-default.js b/app/scripts/core/lang-default.js index 71cf669..33d8d6b 100644 --- a/app/scripts/core/lang-default.js +++ b/app/scripts/core/lang-default.js @@ -15,6 +15,7 @@ 'Start': 'Start', 'Pause': 'Pause', 'Delete': 'Delete', + 'Select All': 'Select All', 'Display Order': 'Display Order', 'Search': 'Search', 'Default': 'Default', diff --git a/app/styles/aria-ng.css b/app/styles/aria-ng.css index 4c2929a..0e0dbd4 100644 --- a/app/styles/aria-ng.css +++ b/app/styles/aria-ng.css @@ -390,6 +390,24 @@ td { 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 { margin-left: 15px; diff --git a/app/views/list.html b/app/views/list.html index 81e1d37..304afe7 100644 --- a/app/views/list.html +++ b/app/views/list.html @@ -33,9 +33,14 @@