Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

feat(cart-directives): remove frm cart in dropdown #484

Merged
merged 1 commit into from
Jun 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/scripts/cart/cart.directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ module ngApp.cart.directives {
templateUrl: "cart/templates/add-to-cart-button-filtered.html",
controller:function($scope: ng.IScope, CartService: ICartService, LocationService: ILocationService,
FilesService: IFilesService,
ParticipantsService){
ParticipantsService) {
$scope.files = [];
var content = LocationService.filters().content;
$scope.areFiltersApplied = content && _.find(content, (item) => {
Expand Down Expand Up @@ -319,6 +319,7 @@ module ngApp.cart.directives {
}];
});
$scope.files = data.files;
$scope.calculateFileCount();
});
}
};
Expand All @@ -331,6 +332,15 @@ module ngApp.cart.directives {
CartService.addFiles($scope.files);
};

$scope.removeRelatedFiles = function() {
CartService.remove($scope.inBoth);
};

$scope.calculateFileCount = function() {
$scope.inBoth = _.intersection(_.pluck(CartService.getFiles(), "file_id"),
_.pluck($scope.files, "file_id"));
}

$scope.CartService = CartService;
}
}
Expand Down
1 change: 1 addition & 0 deletions app/scripts/cart/cart.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module ngApp.cart.services {
}
});
this.files = this.files.concat(this.lastModifiedFiles);
this.$rootScope.$broadcast("cart-update");
this._sync();
this.notify.config({ duration: 5000 });
this.notify.closeAll();
Expand Down
9 changes: 8 additions & 1 deletion app/scripts/cart/templates/add-to-cart-button-filtered.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="btn-group" data-dropdown dropdown-append-to-body>
<div class="btn-group"
data-dropdown
data-dropdown-append-to-body
data-on-toggle="calculateFileCount()">
<button type="button"
class="btn btn-default dropdown-toggle"
dropdown-toggle
Expand All @@ -15,6 +18,10 @@
<i class="fa fa-shopping-cart fa-stack"></i>
<span data-translate>Add all Case files to the Cart</span> ({{ files.length }})
</a>
<a data-ng-click="removeRelatedFiles()" data-ng-if="inBoth.length">
<i class="fa fa-trash-o fa-stack"></i>
<span data-translate>Remove all Case files from the Cart</span> ({{ inBoth.length }})
</a>
<a data-ng-if="!files.length">
<span class="fa-stack">
<i class="fa fa-shopping-cart fa-stack-1x"></i>
Expand Down