Updates
This commit is contained in:
@@ -40,3 +40,7 @@ function isDesktopApplication() {
|
||||
function isMacApplication() {
|
||||
return window && window.process && window.process.type && window.process.platform == "darwin";
|
||||
}
|
||||
|
||||
Array.prototype.containsSubset = function(array) {
|
||||
return !array.some(val => this.indexOf(val) === -1);
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class ComponentManager {
|
||||
var requiredPermissions = [
|
||||
{
|
||||
name: "stream-items",
|
||||
content_types: component.content_type
|
||||
content_types: [component.content_type]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -450,9 +450,28 @@ class ComponentManager {
|
||||
|
||||
for(var required of requiredPermissions) {
|
||||
var matching = _.find(requestedPermissions, required);
|
||||
var matching = requestedPermissions.filter((p) => {
|
||||
var matchesContentTypes = true;
|
||||
if(p.content_types) {
|
||||
matchesContentTypes = JSON.stringify(p.content_types.sort()) == JSON.stringify(required.content_types.sort());
|
||||
}
|
||||
return p.name == required.name && matchesContentTypes;
|
||||
})[0];
|
||||
console.log("required", required, "requested", requestedPermissions, "matching", matching);
|
||||
if(!matching) {
|
||||
requestedMatchesRequired = false;
|
||||
break;
|
||||
/* Required permissions can be 1 content type, and requestedPermisisons may send an array of content types.
|
||||
In the case of an array, we can just check to make sure that requiredPermissions content type is found in the array
|
||||
*/
|
||||
matching = requestedPermissions.filter((requested) => {
|
||||
return Array.isArray(requested.content_types) && requested.content_types.containsSubset(required.content_types);
|
||||
});
|
||||
|
||||
console.log("Matching 2nd chance", matching);
|
||||
|
||||
if(!matching) {
|
||||
requestedMatchesRequired = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,6 +481,7 @@ class ComponentManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!component.permissions) {
|
||||
component.permissions = [];
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class PermissionsModal {
|
||||
}
|
||||
|
||||
controller($scope, modelManager) {
|
||||
console.log("permissions", $scope.permissions);
|
||||
$scope.formattedPermissions = $scope.permissions.map(function(permission){
|
||||
if(permission.name === "stream-items") {
|
||||
var title = "Access to ";
|
||||
@@ -51,7 +52,7 @@ class PermissionsModal {
|
||||
} else if(i == types.length - 1) {
|
||||
// last element
|
||||
if(types.length > 2) {
|
||||
typesString += separator + "and " + typesString;
|
||||
typesString += separator + "and " + type;
|
||||
} else if(types.length == 2) {
|
||||
typesString = typesString + " and " + type;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,11 @@ class SingletonManager {
|
||||
var candidateValue = candidate[key];
|
||||
if(typeof predicateValue == 'object') {
|
||||
// Check nested properties
|
||||
if(!candidateValue) {
|
||||
// predicateValue is 'object' but candidateValue is null
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.itemSatisfiesPredicate(candidateValue, predicateValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<script>
|
||||
window._default_sf_server = "<%= ENV['SF_DEFAULT_SERVER'] %>";
|
||||
window._prolink_package_url = "<%= ENV['PROLINK_URL'] %>";
|
||||
window._prolink_package_url = "<%= ENV['PROLINK_PACKAGE_URL'] %>";
|
||||
</script>
|
||||
|
||||
<% if Rails.env.development? %>
|
||||
|
||||
Reference in New Issue
Block a user