Skip to content

Conversation

@stephguac
Copy link

@stephguac stephguac commented Aug 22, 2017


function removeSelectedFromList(selected, list, id) {
var filteredList = _.reject(list, function(o) {
for (var i = 0; i < selected.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use _.find() here instead?

GeneralModelService.list(apiPath, params, {preventCancel: true}).then(function(response) {
if (!response) return; //in case http request was cancelled by newer request
scope.list = response;
scope.list = scope.selected.items ? removeSelectedFromList(scope.selected.items, response, scope.options.key) : response;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the branch? Can we just always do:
scope.list = removeSelectedFromlist()?

});

scope.$watch('selected.items', function() { // watch selected.items to ensure previously selected items are accounted for.
if (scope.selected && scope.selected.items && scope.selected.items.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't check length here, otherwise removing the last selected item will not refreshChoices, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants