Skip to content

Commit

Permalink
Merge branch 'field-settings-empty-fix' of https://github.com/davidpu…
Browse files Browse the repository at this point in the history
…plava/OrchardCore into field-settings-empty-fix
  • Loading branch information
MikeAlhayek committed Sep 20, 2024
2 parents d8c5527 + da9fc78 commit 8b79470
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public override IDisplayResult Display(ListPart listPart, BuildPartDisplayContex
InitializeDisplayListPartDisplayShape(listPart, context),
InitializeDisplayListPartDetailAdminShape(listPart, context),
InitializeDisplayListPartNavigationAdminShape(listPart, context, settings),
InitializeDisplayListPartDetailAdminSearchPanelShape(),
InitializeDisplayListPartHeaderAdminShape(listPart, settings),
InitializeDisplayListPartSummaryAdmin(listPart)
);
Expand Down Expand Up @@ -134,6 +135,17 @@ private ShapeResult InitializeDisplayListPartDetailAdminShape(ListPart listPart,
}))
.Location("DetailAdmin", "Content:10");
}
private ShapeResult InitializeDisplayListPartDetailAdminSearchPanelShape()
{
return Initialize<ListPartViewModel>("ListPartDetailAdminSearchPanel", async model =>
{
var listPartFilterViewModel = new ListPartFilterViewModel();
await _updateModelAccessor.ModelUpdater.TryUpdateModelAsync(listPartFilterViewModel, Prefix);
model.ListPartFilterViewModel = listPartFilterViewModel;
}).Location("DetailAdmin", "Content:5");
}

private ShapeResult InitializeDisplayListPartDisplayShape(ListPart listPart, BuildPartDisplayContext context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
@using OrchardCore.Contents
@using OrchardCore.Lists.ViewModels
@using System.Globalization
@using OrchardCore.Localization
@using Microsoft.AspNetCore.Authorization
@model OrchardCore.Lists.ViewModels.ListPartViewModel

@inject OrchardCore.ContentManagement.Display.IContentItemDisplayManager ContentItemDisplayManager
@inject OrchardCore.ContentManagement.IContentManager ContentManager
@inject Microsoft.AspNetCore.Authorization.IAuthorizationService AuthorizationService
@{
var enableOrdering =
Model.EnableOrdering &&
Expand All @@ -19,28 +11,7 @@
{
<script asp-src="~/OrchardCore.Lists/Scripts/ci-list-ordering.min.js" debug-src="~/OrchardCore.Lists/Scripts/ci-list-ordering.js" asp-name="ci-list-ordering" at="Foot" depends-on="Sortable, jQuery"></script>
}

var authorizedContentTypeDefinitions = new List<ContentTypeDefinition>();

foreach (var contentTypeDefinition in Model.ContainedContentTypeDefinitions)
{
if (await AuthorizationService.AuthorizeAsync(
User,
CommonPermissions.EditContent,
await ContentManager.NewAsync(contentTypeDefinition.Name)))
{
authorizedContentTypeDefinitions.Add(contentTypeDefinition);
}
}
var dropdownClassList = new List<string>()
{
"dropdown-menu"
};

if (CultureInfo.CurrentUICulture.IsRightToLeft())
{
dropdownClassList.Add("dropdown-menu-start");
}

}
@if (!Model.ContainedContentTypeDefinitions.Any())
{
Expand All @@ -50,30 +21,6 @@
}
else
{
<form>
<div class="card text-bg-theme mb-3 position-sticky action-bar">
<div class="card-body">
<div class="row gx-3">
<div class="col">
<div class="input-group has-filter">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" id="filter-dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa-solid fa-filter" title="@T["Filters"]" aria-hidden="true"></i>
</button>
<div class="@string.Join(' ', dropdownClassList)" aria-labelledby="filter-dropdown">
@* Latest not surfaced here to be consistent with the main content items list filter. *@
<a class="dropdown-item" href="?Status=Draft">@T["Only draft items"]</a>
<a class="dropdown-item" href="?Status=Published">@T["Only published items"]</a>
<a class="dropdown-item" href="?Status=Owner">@T["Owned by me"]</a>
</div>
<i class="fa-solid fa-search form-control-feedback" aria-hidden="true"></i>
<input name="@nameof(ListPartFilterViewModel.Status)" value="@Model.ListPartFilterViewModel.Status" class="form-control" type="hidden" />
<input name="@nameof(ListPartFilterViewModel.DisplayText)" value="@Model.ListPartFilterViewModel.DisplayText" class="form-control" placeholder="@T["Search"]" type="search" autofocus />
</div>
</div>
</div>
</div>
</div>
</form>

@if (Model.ContentItems.Any())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@using System.Globalization
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using OrchardCore.Lists.ViewModels
@using OrchardCore.Localization

@model OrchardCore.Lists.ViewModels.ListPartViewModel

@{
var dropdownClassList = CultureInfo.CurrentUICulture.IsRightToLeft()
? "dropdown-menu dropdown-menu-start"
: "dropdown-menu";
}

<form>
<div class="card text-bg-theme mb-3 position-sticky action-bar">
<div class="card-body">
<div class="row gx-3">
<div class="col">
<div class="input-group has-filter">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" id="filter-dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa-solid fa-filter" title="@T["Filters"]" aria-hidden="true"></i>
</button>
<div class="@dropdownClassList" aria-labelledby="filter-dropdown">
@* Latest not surfaced here to be consistent with the main content items list filter. *@
<a class="dropdown-item" href="?Status=Draft">@T["Only draft items"]</a>
<a class="dropdown-item" href="?Status=Published">@T["Only published items"]</a>
<a class="dropdown-item" href="?Status=Owner">@T["Owned by me"]</a>
</div>
<i class="fa-solid fa-search form-control-feedback" aria-hidden="true"></i>
<input name="@nameof(ListPartFilterViewModel.Status)" value="@Model.ListPartFilterViewModel.Status" class="form-control" type="hidden" />
<input name="@nameof(ListPartFilterViewModel.DisplayText)" value="@Model.ListPartFilterViewModel.DisplayText" class="form-control" placeholder="@T["Search"]" type="search" autofocus />
</div>
</div>
</div>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
@using OrchardCore.ContentManagement
@using OrchardCore.Contents
@model OrchardCore.Lists.ViewModels.ListPartNavigationAdminViewModel
@inject OrchardCore.ContentManagement.IContentManager ContentManager
@inject Microsoft.AspNetCore.Authorization.IAuthorizationService AuthorizationService

@inject IContentManager ContentManager
@inject IAuthorizationService AuthorizationService
@{
var authorizedContentTypeDefinitions = new List<ContentTypeDefinition>();
foreach (var contentTypeDefinition in Model.ContainedContentTypeDefinitions)
{
if (!await AuthorizationService.AuthorizeAsync(User, CommonPermissions.EditContent, await ContentManager.NewAsync(contentTypeDefinition.Name)))
{
continue;
}

authorizedContentTypeDefinitions.Add(contentTypeDefinition);
}
}
<div class="card text-bg-theme text-right mb-3 second-action-bar">
<div class="card-body">
<div class="d-flex justify-content-end">
Expand All @@ -21,9 +32,9 @@
</a>
}

@if (Model.ContainedContentTypeDefinitions.Length == 1)
@if (authorizedContentTypeDefinitions.Count == 1)
{
var contentTypeDefinition = Model.ContainedContentTypeDefinitions[0];
var contentTypeDefinition = authorizedContentTypeDefinitions.FirstOrDefault();

if (await AuthorizationService.AuthorizeContentTypeAsync(User, CommonPermissions.EditContent, contentTypeDefinition, User.Identity.Name))
{
Expand All @@ -32,13 +43,13 @@
</a>
}
}
else if (Model.ContainedContentTypeDefinitions.Length > 1)
else if (authorizedContentTypeDefinitions.Count > 1)
{
<a class="btn btn-secondary dropdown-toggle" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@T["New"]
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
@foreach (var containedContentTypeDefinition in Model.ContainedContentTypeDefinitions)
@foreach (var containedContentTypeDefinition in authorizedContentTypeDefinitions)
{
if (!await AuthorizationService.AuthorizeContentTypeAsync(User, CommonPermissions.EditContent, containedContentTypeDefinition, User.Identity.Name))
{
Expand Down
1 change: 0 additions & 1 deletion src/OrchardCore.Themes/TheTheme/Views/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@inject IUpdateModelAccessor UpdateModelAccessor
@inject ThemeTogglerService ThemeTogglerService
@{
var adminSettings = Site.As<AdminSettings>();
// Navbar is pre-rendered to allow resource injection.
var navbar = await DisplayAsync(await DisplayManager.BuildDisplayAsync(UpdateModelAccessor.ModelUpdater));
}
Expand Down

0 comments on commit 8b79470

Please sign in to comment.