Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate ListPart search into own shape #16749

Merged
merged 16 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("ListPartDetailAdminSearchPanel", (Func<ListPartViewModel, ValueTask>)(async model =>
giannik marked this conversation as resolved.
Show resolved Hide resolved
{
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");
}

}
giannik marked this conversation as resolved.
Show resolved Hide resolved
@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,41 @@
@using System.Globalization
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using OrchardCore.Lists.ViewModels
@using OrchardCore.Localization
@model OrchardCore.Lists.ViewModels.ListPartViewModel
@{
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved
var dropdownClassList = new List<string>()
{
"dropdown-menu"
};

giannik marked this conversation as resolved.
Show resolved Hide resolved
if (CultureInfo.CurrentUICulture.IsRightToLeft())
{
dropdownClassList.Add("dropdown-menu-start");
}
giannik marked this conversation as resolved.
Show resolved Hide resolved
}

<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>
giannik marked this conversation as resolved.
Show resolved Hide resolved
Loading