Skip to content

Commit 8ca0e95

Browse files
authored
Add descriptions to content-type (#11842)
Fixes #11827
1 parent 45024d0 commit 8ca0e95

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

src/OrchardCore.Modules/OrchardCore.ContentTypes/Editors/ContentTypeSettingsDisplayDriver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public override IDisplayResult Edit(ContentTypeDefinition contentTypeDefinition)
3030
model.Versionable = settings.Versionable;
3131
model.Securable = settings.Securable;
3232
model.Stereotype = settings.Stereotype;
33+
model.Description = settings.Description;
3334
}).Location("Content:5");
3435
}
3536

@@ -44,6 +45,8 @@ public override async Task<IDisplayResult> UpdateAsync(ContentTypeDefinition con
4445
context.Builder.Draftable(model.Draftable);
4546
context.Builder.Versionable(model.Versionable);
4647
context.Builder.Securable(model.Securable);
48+
context.Builder.WithDescription(model.Description);
49+
4750
var stereotype = model.Stereotype?.Trim();
4851
context.Builder.Stereotype(stereotype);
4952

src/OrchardCore.Modules/OrchardCore.ContentTypes/ViewModels/ContentTypeSettingsViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public class ContentTypeSettingsViewModel
88
public bool Versionable { get; set; }
99
public bool Securable { get; set; }
1010
public string Stereotype { get; set; }
11+
public string Description { get; set; }
1112
}
1213
}

src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/ContentTypeSettings.Edit.cshtml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
@model ContentTypeSettingsViewModel
22

3+
<div class="mb-3">
4+
<div class="w-md-75 w-xl-50">
5+
<label asp-for="Description">@T["Description"]</label>
6+
<input asp-for="Description" type="text" class="form-control">
7+
</div>
8+
<span class="hint">@T["(Optional) Description of the content type"]</span>
9+
</div>
10+
311
<div class="mb-3">
412
<div class="form-check">
513
<input type="checkbox" class="form-check-input" asp-for="Creatable">

src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/Shared/DisplayTemplates/EditTypeViewModel.cshtml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@
33
@{
44
var settings = Model.TypeDefinition.GetSettings<ContentTypeSettings>();
55
}
6-
<div class="w-100">
7-
<a asp-route-action="Edit" asp-route-area="OrchardCore.ContentTypes" asp-route-id="@Model.Name">@Model.DisplayName</a>
8-
<div class="float-end">
6+
<div class="d-flex">
7+
<div class="me-auto">
8+
<a asp-route-action="Edit" asp-route-area="OrchardCore.ContentTypes" asp-route-id="@Model.Name">@Model.DisplayName</a>
9+
10+
<span class="badge rounded-pill ta-badge font-weight-normal" data-bs-toggle="tooltip" title="@T["Technical Name"]"><i class="fas fa-file-alt text-danger" aria-hidden="true"></i> @Model.Name</span>
11+
12+
@if (!string.IsNullOrWhiteSpace(settings.Stereotype))
13+
{
14+
<span class="badge rounded-pill ta-badge font-weight-normal" data-bs-toggle="tooltip" title="Stereotype"><i class="fa fa-file text-info" aria-hidden="true"></i> @settings.Stereotype</span>
15+
}
16+
</div>
17+
<div>
918
@if (settings.Creatable)
1019
{
1120
<a id="[email protected]" asp-route-area="OrchardCore.Contents" asp-route-action="Create" asp-route-id="@Model.Name" asp-route-returnUrl="@FullRequestPath" class="btn btn-success btn-sm">@T["Create New {0}", Model.DisplayName]</a>
1221
}
1322
<a role="[email protected]" asp-route-action="List" asp-route-area="OrchardCore.Contents" asp-route-contentTypeId="@Model.Name" class="btn btn-secondary btn-sm">@T["List Items"]</a>
1423
<a role="[email protected]" asp-route-action="Edit" asp-route-area="OrchardCore.ContentTypes" asp-route-id="@Model.Name" class="btn btn-primary btn-sm">@T["Edit"]</a>
1524
</div>
16-
@if (!string.IsNullOrWhiteSpace(settings.Stereotype))
17-
{
18-
<span class="badge rounded-pill ta-badge font-weight-normal" data-bs-toggle="tooltip" title="Stereotype"><i class="fa fa-file text-info" aria-hidden="true"></i> @settings.Stereotype</span>
19-
}
2025
</div>
26+
27+
@if (!string.IsNullOrWhiteSpace(settings.Description))
28+
{
29+
<div class="row">
30+
<div class="col">
31+
<p class="mb-0"><small class="text-muted">@settings.Description</small></p>
32+
</div>
33+
</div>
34+
}

src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Settings/ContentTypeSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ public class ContentTypeSettings
3131
/// Used to determine if this content type supports custom permissions
3232
/// </summary>
3333
public bool Securable { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the description name of this content type.
37+
/// </summary>
38+
public string Description { get; set; }
3439
}
3540
}

src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Settings/ContentTypeSettingsExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,10 @@ public static ContentTypeDefinitionBuilder Stereotype(this ContentTypeDefinition
3333
{
3434
return builder.MergeSettings<ContentTypeSettings>(x => x.Stereotype = stereotype);
3535
}
36+
37+
public static ContentTypeDefinitionBuilder WithDescription(this ContentTypeDefinitionBuilder builder, string description)
38+
{
39+
return builder.MergeSettings<ContentTypeSettings>(x => x.Description = description);
40+
}
3641
}
3742
}

0 commit comments

Comments
 (0)