From b1cd0a879a5a9e03e584b7049a6d8b65930f4a75 Mon Sep 17 00:00:00 2001 From: Riju19 <19.riju@gmail.com> Date: Mon, 11 Mar 2019 12:31:34 +0530 Subject: [PATCH] Show all stories created and allows them to filter according to status This patch shows users all stories created by them in their dashboard regardless of status by default and also gives them the option to filter those stories by status Change-Id: If2edee356afd3436f0ae7c54b486c4e9d9004917 Task: 3091 Signed-off-by: Riju19 <19.riju@gmail.com> --- .../controller/dashboard_controller.js | 44 ++++++++++++++++++- src/app/dashboard/template/dashboard.html | 29 +++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/app/dashboard/controller/dashboard_controller.js b/src/app/dashboard/controller/dashboard_controller.js index f090c846..d69ab061 100644 --- a/src/app/dashboard/controller/dashboard_controller.js +++ b/src/app/dashboard/controller/dashboard_controller.js @@ -69,10 +69,50 @@ angular.module('sb.dashboard').controller('DashboardController', }; $scope.createdStories = Story.browse({ - creator_id: currentUser.id, - status: 'active' + creator_id: currentUser.id }); + + /** + * Filter the stories. + */ + $scope.showActive = true; + $scope.showMerged = true; + $scope.showInvalid = true; + + /** + * Reload the stories in this view based on user selected filters. + */ + $scope.filterStories = function () { + var status = []; + if ($scope.showActive) { + status.push('active'); + } + if ($scope.showMerged) { + status.push('merged'); + } + if ($scope.showInvalid) { + status.push('invalid'); + } + + if (status.length === 0) { + $scope.createdStories = []; + return; + } + + Story.browse({ + sort_field: 'id', + sort_dir: 'desc', + status: status, + creator_id: currentUser.id + }, + function (result) { + $scope.createdStories = result; + } + ); + }; + + function loadEvents() { // Load the user's subscription events. $scope.subscriptionEvents = null; diff --git a/src/app/dashboard/template/dashboard.html b/src/app/dashboard/template/dashboard.html index 06a40c5f..b5f8d6ad 100644 --- a/src/app/dashboard/template/dashboard.html +++ b/src/app/dashboard/template/dashboard.html @@ -93,6 +93,33 @@
+
+ + + + +

Stories created by me

@@ -113,7 +140,7 @@

- There are no active stories created by you. + There are no stories created by you.