V8: Support allowed types for MNTP member picker (#6524)

This commit is contained in:
Kenn Jacobsen
2019-10-14 14:34:33 +02:00
committed by Sebastiaan Janssen
parent 0d3e330b12
commit f6d00a177e
6 changed files with 115 additions and 53 deletions

View File

@@ -77,8 +77,7 @@
}
}
// filter items if there is a filter and it's not advanced
// ** ignores advanced filter at the moment
// filter items if there is a filter and it's not advanced (advanced filtering is handled below)
if (scope.entityTypeFilter && scope.entityTypeFilter.filter && !scope.entityTypeFilter.filterAdvanced) {
var a = scope.entityTypeFilter.filter.toLowerCase().replace(/\s/g, '').split(',');
var found = a.indexOf(c.metaData.ContentTypeAlias.toLowerCase()) >= 0;
@@ -88,6 +87,15 @@
}
}
});
// advanced item filtering is handled here
if (scope.entityTypeFilter && scope.entityTypeFilter.filter && scope.entityTypeFilter.filterAdvanced) {
var filtered = angular.isFunction(scope.entityTypeFilter.filter)
? _.filter(miniListView.children, scope.entityTypeFilter.filter)
: _.where(miniListView.children, scope.entityTypeFilter.filter);
_.each(filtered, (node) => node.allowed = false);
}
// update pagination
miniListView.pagination.totalItems = data.totalItems;
miniListView.pagination.totalPages = data.totalPages;

View File

@@ -203,7 +203,9 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
//now we need to filter based on what is stored in the pre-vals, this logic duplicates what is in the treepicker.controller,
// but not much we can do about that since members require special filtering.
var filterItem = currFilter.toLowerCase().split(',');
var found = filterItem.indexOf(i.metaData.contentType.toLowerCase()) >= 0;
// NOTE: when used in a mini list view, the item content type alias is metaData.ContentTypeAlias (in regular views it's metaData.contentType)
var itemContentType = i.metaData.contentType || i.metaData.ContentTypeAlias;
var found = filterItem.indexOf(itemContentType.toLowerCase()) >= 0;
if (!currFilter.startsWith("!") && !found || currFilter.startsWith("!") && found) {
return true;
}