From c720a8bfb8aaee8fc88a2fda8117c1967f030a37 Mon Sep 17 00:00:00 2001 From: Christine Yu Date: Mon, 2 Feb 2015 15:11:29 -0500 Subject: [PATCH] fix(cart): add all to cart uses my projects filter - add all in summary works again Closes #236 --- app/scripts/cart/cart.directives.ts | 12 +++++++++--- .../cart/templates/add-to-cart-button-all.html | 18 +++++++++++++++++- app/scripts/components/user/user.services.ts | 5 +++-- .../search/templates/search.summary.html | 17 ++--------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/scripts/cart/cart.directives.ts b/app/scripts/cart/cart.directives.ts index da808f3b8..fa7b1422c 100644 --- a/app/scripts/cart/cart.directives.ts +++ b/app/scripts/cart/cart.directives.ts @@ -29,11 +29,16 @@ module ngApp.cart.directives { scope:{ paging: "=", files: "=", - removeAllInSearchResult: "&" + removeAllInSearchResult: "&", + addAllOnly: "@" + }, + compile: function(element, attrs) { + if(!attrs.addAllOnly) + attrs.addAllOnly = false; }, templateUrl: "cart/templates/add-to-cart-button-all.html", controller: function($scope: ng.IScope, CartService: ICartService, LocationService: ILocationService, - FilesService: IFilesService) { + FilesService: IFilesService, UserService: IUserService) { $scope.CartService = CartService; $scope.addToCart = function(files: IFile[]) { @@ -76,7 +81,8 @@ module ngApp.cart.directives { $scope.addAll = function(){ var filters = LocationService.filters(); - var size: number = ($scope.paging.total >= this.CartService.getMaxSize()) ? this.CartService.getMaxSize() : this.paging.total; + filters = UserService.addMyProjectsFilter(filters, "participants.admin.disease_code"); + var size: number = ($scope.paging.total >= CartService.getMaxSize()) ? CartService.getMaxSize() : $scope.paging.total; FilesService.getFiles({ fields: [ "data_access", diff --git a/app/scripts/cart/templates/add-to-cart-button-all.html b/app/scripts/cart/templates/add-to-cart-button-all.html index 6a6854dfd..f2a3f453c 100644 --- a/app/scripts/cart/templates/add-to-cart-button-all.html +++ b/app/scripts/cart/templates/add-to-cart-button-all.html @@ -1,4 +1,4 @@ -
+
@@ -43,3 +43,19 @@
+
+ + + +
diff --git a/app/scripts/components/user/user.services.ts b/app/scripts/components/user/user.services.ts index a4e63a92e..9199cdee2 100644 --- a/app/scripts/components/user/user.services.ts +++ b/app/scripts/components/user/user.services.ts @@ -7,7 +7,7 @@ module ngApp.components.user.services { login(username: string): void; logout(): void; toggleFilter(): void; - addMyProjectsFilter(filters: any, key: string): void; + addMyProjectsFilter(filters: any, key: string): any; isUserProject(file: IFile): boolean; currentUser: IUser; } @@ -46,7 +46,7 @@ module ngApp.components.user.services { return this.currentUser.projects.indexOf(file.archive.disease_code) !== -1; } - addMyProjectsFilter(filters: any, key: string): void { + addMyProjectsFilter(filters: any, key: string): any { if (this.currentUser && this.currentUser.isFiltered && this.currentUser.projects.length) { var userProjects = { @@ -88,6 +88,7 @@ module ngApp.components.user.services { return filters; } + } angular diff --git a/app/scripts/search/templates/search.summary.html b/app/scripts/search/templates/search.summary.html index 902c96a01..d2894cc3c 100644 --- a/app/scripts/search/templates/search.summary.html +++ b/app/scripts/search/templates/search.summary.html @@ -15,19 +15,6 @@

Summary

- - +
- -
\ No newline at end of file +