-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into issue/OCORE-136
- Loading branch information
Showing
22 changed files
with
181 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/UserPickerFieldQueryObjectType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using GraphQL; | ||
using GraphQL.DataLoader; | ||
using GraphQL.Types; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Localization; | ||
using OrchardCore.Apis.GraphQL; | ||
using OrchardCore.ContentFields.Fields; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.Users.GraphQL; | ||
using OrchardCore.Users.Indexes; | ||
using OrchardCore.Users.Models; | ||
using YesSql; | ||
using YesSql.Services; | ||
|
||
namespace OrchardCore.ContentFields.GraphQL | ||
{ | ||
public class UserPickerFieldQueryObjectType : ObjectGraphType<UserPickerField> | ||
{ | ||
public UserPickerFieldQueryObjectType(IStringLocalizer<UserPickerFieldQueryObjectType> S) | ||
{ | ||
Name = nameof(UserPickerField); | ||
|
||
Field<ListGraphType<StringGraphType>, IEnumerable<string>>("userIds") | ||
.Description(S["user ids"]) | ||
.PagingArguments() | ||
.Resolve(resolve => | ||
{ | ||
return resolve.Page(resolve.Source.UserIds); | ||
}); | ||
|
||
Field<ListGraphType<UserType>, IEnumerable<User>>("users") | ||
.Description(S["the user items"]) | ||
.PagingArguments() | ||
.ResolveAsync(resolve => | ||
{ | ||
var userLoader = GetOrAddUserProfileByIdDataLoader(resolve); | ||
return userLoader.LoadAsync(resolve.Page(resolve.Source.UserIds)).Then(itemResultSet => | ||
{ | ||
return itemResultSet.SelectMany(users => users); | ||
}); | ||
}); | ||
} | ||
|
||
private static IDataLoader<string, IEnumerable<User>> GetOrAddUserProfileByIdDataLoader<T>(IResolveFieldContext<T> context) | ||
{ | ||
var dataLoaderContextAccessor = context.RequestServices.GetRequiredService<IDataLoaderContextAccessor>(); | ||
|
||
return dataLoaderContextAccessor.Context.GetOrAddCollectionBatchLoader("GetOrAddUserByIds", async (IEnumerable<string> userIds) => | ||
{ | ||
if (userIds == null || !userIds.Any()) | ||
{ | ||
return default; | ||
} | ||
var session = context.RequestServices.GetService<ISession>(); | ||
var users = await session.Query<User, UserIndex>(user => user.UserId.IsIn(userIds)).ListAsync(); | ||
return users.ToLookup(user => user.UserId); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/OrchardCore.Modules/OrchardCore.Users/Views/ForgotPasswordFormIdentifier.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@model ForgotPasswordViewModel | ||
|
||
<div class="mb-3"> | ||
<label asp-for="Identifier" class="form-label">@T["Username or email address"]</label> | ||
<input asp-for="Identifier" class="form-control" /> | ||
<label asp-for="UsernameOrEmail" class="form-label">@T["Username or email address"]</label> | ||
<input asp-for="UsernameOrEmail" class="form-control" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.