Skip to content

Instantly share code, notes, and snippets.

@kylebakerio
Created April 8, 2017 08:36
Show Gist options
  • Save kylebakerio/f6445206a8dc9af62c233691273d8eb9 to your computer and use it in GitHub Desktop.
Save kylebakerio/f6445206a8dc9af62c233691273d8eb9 to your computer and use it in GitHub Desktop.
// if($scope.$storage.currentUser.hiddenGroups || $scope.$storage.currentUser.requiredGroups) { // WE HAVE EITHER REQUIREALL OR BLACK LIST FILTERING ENABLED.
// if($scope.$storage.currentUser.requireGroupsOn) { // WHITE LIST
// // has required groups ON
// if(item.groups) {
// // pin has some groups
// var notInAllRequiredGroups = requiredCount < $scope.$storage.currentUser.requiredGroups.length && $scope.$storage.currentUser.requiredGroups.length > 0
// if(notInAllRequiredGroups) {
// pinShown = false;
// $scope.hiddenPins.push(item)
// conditionCount['("No", 1, "pin has groups + not in all required groups")']++ //
// }
// // add pin
// else {
// $scope.customers.push(item);
// conditionCount['("Yes", 2, "pin has groups + in all required groups")']++ //
// }
// }
// else {
// // pin has no groups property
// var notInAllRequiredGroups = requiredCount < $scope.$storage.currentUser.requiredGroups.length && $scope.$storage.currentUser.requiredGroups.length > 0;
// if(notInAllRequiredGroups) {
// pinShown = false;
// $scope.hiddenPins.push(item)
// conditionCount['("No", 3, "pin has no groups + notInAllRequiredGroups")']++ //
// }
// else {
// $scope.customers.push(item);
// conditionCount['("Yes", 4, "pin has no groups + in all required groups")']++ //
// }
// }
// }
// else {
// // REQUIREALL is OFF
// if(item.hasOwnProperty("groups")) {
// // pin has some groups
// if (itemInAnyShownGroups || $scope.$storage.currentUser.hiddenGroups.length === 0) {
// // add pin / pin is in a shown group ?
// $scope.customers.push(item);
// conditionCount['("Yes", 12, "item is in shown groups, or there are no hidden groups"']++ //
// }
// else if (!itemInAnyShownGroups && itemHasGroups && !itemHasOnlyDeadGroups) {
// pinShown = false;
// $scope.hiddenPins.push(item)
// conditionCount['("No", 5, "all groups of pin are hidden / pin has no shown groups" )']++ //
// }
// else if ((!itemHasGroups || itemHasOnlyDeadGroups) && $scope.$storage.currentUser.showUngroupedPins) {
// $scope.customers.push(item);
// conditionCount['("Yes", 6, "has no groups, but ungrouped pins are shown");']++ //
// }
// else {
// $scope.hiddenPins.push(item)
// conditionCount['("No", 7, "has no groups, and ungrouped pins are hidden");']++ //
// }
// }
// else {
// // [user?] has hidden groups but pin not in group
// console.error("PIN DOESNT HAVE GROUPS AS A DEFINED PROPERTY", item);
// conditionCount['("Yes", 8, "PROBLEM: pin doesnt have groups property");']++ //
// $scope.customers.push(item);
// }
// }
// }
// else { // THERE IS NO BLACK OR REQUIREALL LIST,
// has no hidden groups/required group
// apply filters
if ($scope.filteredGroupsArray.length > 0) {
if ($scope.filterString === "pinsInAny") {
var customersInGroup = $scope.filteredGroupsArray.filter(function(obj) {
return item.groups.indexOf(obj) != -1;
});
if (customersInGroup.length > 0) {
$scope.customers.push(item);
conditionCount['("Yes", 12, "item is in shown groups, or there are no hidden groups"']++
}
else{
conditionCount['("No", 5, "all groups of pin are hidden / pin has no shown groups" )']++
}
}
else if ($scope.filterString === "pinsInAll")
{
var customersInGroup = $scope.filteredGroupsArray.filter(function(obj) {
return item.groups.indexOf(obj) != -1;
});
if (customersInGroup.length === $scope.filteredGroupsArray.length) {
$scope.customers.push(item);
conditionCount['("Yes", 2, "pin has groups + in all required groups")']++
}
else{
conditionCount['("No", 1, "pin has groups + not in all required groups")']++ //
}
}
else if($scope.filterString === "pinsThatMatch"){
var pinsThatMatch = $scope.filteredGroupsArray.filter(function(obj) {
return obj.objectId === item.objectId;
});
if (pinsThatMatch.length > 0) {
$scope.customers.push(item);
// change the wording to accomodate match
conditionCount['("Yes", 2, "pin has groups + in all required groups")']++
}
else{
// change the wording to accomodate match
conditionCount['("No", 7, "has no groups, and ungrouped pins are hidden");']++ //
}
}
else{
$scope.customers.push(item);
conditionCount['("Yes", 12, "item is in shown groups, or there are no hidden groups"']++
}
}
else{
$scope.customers.push(item);
conditionCount['("Yes", 12, "item is in shown groups, or there are no hidden groups"']++
}
//console.error("PROBLEM! WE ARE MISSING A REQUIRED ARRAY! ", $scope.$storage.currentUser.hiddenGroups, $scope.$storage.currentUser.requiredGroups)
//conditionCount['("Yes", 9, "neither whitelist nor blacklist here.")']++ //
//$scope.customers.push(item);
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment