Add posibillty to use composition on memberstype (#14060)
This commit is contained in:
committed by
GitHub
parent
f7bdba6279
commit
9f028e0bd5
@@ -6,17 +6,5 @@ namespace Umbraco.Cms.Core;
|
||||
public static class ConventionsHelper
|
||||
{
|
||||
public static Dictionary<string, PropertyType> GetStandardPropertyTypeStubs(IShortStringHelper shortStringHelper) =>
|
||||
new()
|
||||
{
|
||||
{
|
||||
Constants.Conventions.Member.Comments,
|
||||
new PropertyType(
|
||||
shortStringHelper,
|
||||
Constants.PropertyEditors.Aliases.TextArea,
|
||||
ValueStorageType.Ntext,
|
||||
true,
|
||||
Constants.Conventions.Member.Comments)
|
||||
{ Name = Constants.Conventions.Member.CommentsLabel }
|
||||
},
|
||||
};
|
||||
new();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ public class MemberTypeController : ContentTypeControllerBase<IMemberType>
|
||||
localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
|
||||
}
|
||||
|
||||
public int GetCount() => _memberTypeService.Count();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the member type a given id
|
||||
/// </summary>
|
||||
@@ -172,6 +174,21 @@ public class MemberTypeController : ContentTypeControllerBase<IMemberType>
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns where a particular composition has been used
|
||||
/// This has been wrapped in a dto instead of simple parameters to support having multiple parameters in post request
|
||||
/// body
|
||||
/// </summary>
|
||||
/// <param name="contentTypeId"></param>
|
||||
/// <returns></returns>
|
||||
public IActionResult GetWhereCompositionIsUsedInMemberTypes(int contentTypeId)
|
||||
{
|
||||
var result =
|
||||
PerformGetWhereCompositionIsUsedInContentTypes(contentTypeId, UmbracoObjectTypes.MemberType).Value?
|
||||
.Select(x => new { contentType = x });
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
public MemberTypeDisplay? GetEmpty()
|
||||
{
|
||||
var ct = new MemberType(_shortStringHelper, -1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function GroupsBuilderDirective(contentTypeHelper, contentTypeResource, mediaTypeResource,
|
||||
function GroupsBuilderDirective(contentTypeHelper, contentTypeResource, mediaTypeResource, memberTypeResource,
|
||||
$filter, iconHelper, $q, $timeout, notificationsService,
|
||||
localizationService, editorService, eventsService, overlayService) {
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
scope.sortableRequestedTabTimeout = $timeout(() => {
|
||||
scope.openTabAlias = scope.sortableRequestedTabAlias;
|
||||
scope.sortableRequestedTabTimeout = null;
|
||||
/* hack to update sortable positions when switching from one tab to another.
|
||||
/* hack to update sortable positions when switching from one tab to another.
|
||||
without this sorting direct properties doesn't work correctly */
|
||||
scope.$apply();
|
||||
$('.umb-group-builder__ungrouped-properties .umb-group-builder__properties').sortable('refresh');
|
||||
@@ -238,7 +238,7 @@
|
||||
if (items && items.length <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// update the moved item sort order to fit into where it is dragged
|
||||
const movedItem = items[movedIndex];
|
||||
|
||||
@@ -250,8 +250,8 @@
|
||||
movedItem.sortOrder = prevItem.sortOrder + 1;
|
||||
}
|
||||
|
||||
/* After the above two items next to each other might have the same sort order
|
||||
to prevent this we run through the rest of the
|
||||
/* After the above two items next to each other might have the same sort order
|
||||
to prevent this we run through the rest of the
|
||||
items and update the sort order if they are next to each other.
|
||||
This will make it possible to make gaps without the number being updated */
|
||||
for (let i = movedIndex; i < items.length; i++) {
|
||||
@@ -289,7 +289,12 @@
|
||||
});
|
||||
|
||||
//use a different resource lookup depending on the content type type
|
||||
var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
|
||||
var resourceLookup = mediaTypeResource.getAvailableCompositeContentTypes;
|
||||
if (scope.contentType === "documentType") {
|
||||
resourceLookup = contentTypeResource.getAvailableCompositeContentTypes;
|
||||
} else if (scope.contentType === "memberType") {
|
||||
resourceLookup = memberTypeResource.getAvailableCompositeContentTypes;
|
||||
}
|
||||
|
||||
return resourceLookup(scope.model.id, selectedContentTypeAliases, propAliasesExisting).then(filteredAvailableCompositeTypes => {
|
||||
scope.compositionsDialogModel.availableCompositeContentTypes.forEach(current => {
|
||||
@@ -406,7 +411,12 @@
|
||||
//merge composition with content type
|
||||
|
||||
//use a different resource lookup depending on the content type type
|
||||
var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getById : mediaTypeResource.getById;
|
||||
var resourceLookup = mediaTypeResource.getById;
|
||||
if (scope.contentType === "documentType") {
|
||||
resourceLookup = contentTypeResource.getById;
|
||||
} else if (scope.contentType === "memberType") {
|
||||
resourceLookup = memberTypeResource.getById;
|
||||
}
|
||||
|
||||
resourceLookup(selectedContentType.id).then(composition => {
|
||||
//based on the above filtering we shouldn't be able to select an invalid one, but let's be safe and
|
||||
@@ -449,10 +459,19 @@
|
||||
}
|
||||
};
|
||||
|
||||
//select which resource methods to use, eg document Type or Media Type versions
|
||||
var availableContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
|
||||
var whereUsedContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getWhereCompositionIsUsedInContentTypes : mediaTypeResource.getWhereCompositionIsUsedInContentTypes;
|
||||
var countContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getCount : mediaTypeResource.getCount;
|
||||
var availableContentTypeResource = mediaTypeResource.getAvailableCompositeContentTypes;
|
||||
var whereUsedContentTypeResource = mediaTypeResource.getWhereCompositionIsUsedInContentTypes;
|
||||
var countContentTypeResource = mediaTypeResource.getCount;
|
||||
|
||||
if (scope.contentType === "documentType") {
|
||||
availableContentTypeResource = contentTypeResource.getAvailableCompositeContentTypes;
|
||||
whereUsedContentTypeResource = contentTypeResource.getWhereCompositionIsUsedInContentTypes;
|
||||
countContentTypeResource = contentTypeResource.getCount;
|
||||
} else if (scope.contentType === "memberType") {
|
||||
availableContentTypeResource = memberTypeResource.getAvailableCompositeContentTypes;
|
||||
whereUsedContentTypeResource = memberTypeResource.getWhereCompositionIsUsedInContentTypes;
|
||||
countContentTypeResource = memberTypeResource.getCount;
|
||||
}
|
||||
|
||||
//get the currently assigned property type aliases - ensure we pass these to the server side filer
|
||||
var propAliasesExisting = _.filter(_.flatten(_.map(scope.model.groups, g => {
|
||||
@@ -548,7 +567,7 @@
|
||||
|
||||
const localizeMany = localizationService.localizeMany(['general_delete', 'contentTypeEditor_confirmDeleteTabNotice']);
|
||||
const localize = localizationService.localize('contentTypeEditor_confirmDeleteTabMessage', [tabName]);
|
||||
|
||||
|
||||
$q.all([localizeMany, localize]).then(values => {
|
||||
const translations = values[0];
|
||||
const message = values[1];
|
||||
@@ -752,7 +771,7 @@
|
||||
|
||||
const localizeMany = localizationService.localizeMany(['general_delete', 'contentTypeEditor_confirmDeleteGroupNotice']);
|
||||
const localize = localizationService.localize('contentTypeEditor_confirmDeleteGroupMessage', [groupName]);
|
||||
|
||||
|
||||
$q.all([localizeMany, localize]).then(values => {
|
||||
const translations = values[0];
|
||||
const message = values[1];
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
function memberTypeResource($q, $http, umbRequestHelper, umbDataFormatter, localizationService) {
|
||||
|
||||
return {
|
||||
|
||||
getCount: function () {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"memberTypeApiBaseUrl",
|
||||
"GetCount")),
|
||||
'Failed to retrieve count');
|
||||
},
|
||||
getAvailableCompositeContentTypes: function (contentTypeId, filterContentTypes, filterPropertyTypes) {
|
||||
if (!filterContentTypes) {
|
||||
filterContentTypes = [];
|
||||
@@ -39,7 +46,17 @@ function memberTypeResource($q, $http, umbRequestHelper, umbDataFormatter, local
|
||||
query)),
|
||||
'Failed to retrieve data for content type id ' + contentTypeId);
|
||||
},
|
||||
getWhereCompositionIsUsedInContentTypes: function (contentTypeId) {
|
||||
var query = "contentTypeId=" + contentTypeId;
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"memberTypeApiBaseUrl",
|
||||
"GetWhereCompositionIsUsedInMemberTypes",
|
||||
query)),
|
||||
"Failed to retrieve data for content type id " + contentTypeId);
|
||||
},
|
||||
//return all member types
|
||||
getTypes: function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<umb-groups-builder
|
||||
model="model"
|
||||
compositions="false"
|
||||
content-type="memberType">
|
||||
</umb-groups-builder>
|
||||
|
||||
Reference in New Issue
Block a user