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

refactor: Use user-select-item template #490

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<WarningsAsErrors>
$(WarningsAsErrors);CS8600;CS8601;CS8602;CS8603;CS8604;CS8609;CS8610;CS8614;CS8616;CS8618;CS8619;CS8620;CS8622;CS8625
</WarningsAsErrors>
<MasaFrameworkPackageVersion>1.0.1-preview.10</MasaFrameworkPackageVersion>
<MasaFrameworkPackageVersion>1.0.1-preview.17</MasaFrameworkPackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,6 @@
</MChip>
</SelectionContent>
<ItemContent Context="data">
@if (!string.IsNullOrEmpty(data.Item?.Avatar))
{
<MListItemAvatar>
<img src="@data.Item.Avatar">
</MListItemAvatar>
}
<MListItemContent>
<MListItemTitle>
<span class="subtitle2 emphasis2--text">
@data.Item?.DisplayName
</span>
<MDivider Vertical Class="mx-1" Style="@((!string.IsNullOrEmpty(data.Item?.DisplayName) && !string.IsNullOrEmpty(data.Item.Name))?"height:12px;":"height:0px;")" />
<span class="caption regular2--text">
@data.Item?.Name
</span>
</MListItemTitle>
<MListItemSubtitle>
<span class="body2 regular2--text">
@data.Item?.PhoneNumber
</span>
<MDivider Vertical Class="mx-1" Style="@((!string.IsNullOrEmpty(data.Item?.PhoneNumber) && !string.IsNullOrEmpty(data.Item.Email))?"height:12px;":"height:0px;")" />
<span class="body2 regular2--text">
@data.Item?.Email
</span>
</MListItemSubtitle>
</MListItemContent>
</ItemContent>
</SAutoComplete>
@RenderFragments.UserSelectItem(data.Item.Avatar, data.Item.DisplayName, data.Item.PhoneNumber, data.Item.Account, data.Item.Email)
</ItemContent>
</SAutoComplete>
74 changes: 0 additions & 74 deletions src/Web/Masa.Scheduler.Web.Admin/Global/Config/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,12 @@ public class GlobalConfig
{
#region Field

private bool _isDark;
private string? _pageMode;
private bool _expandOnHover;
private bool _navigationMini;
private string? _favorite;
private CookieStorage? _cookieStorage;
private bool _loading;

#endregion

#region Property

public static string IsDarkCookieKey { get; set; } = "GlobalConfig_IsDark";

public static string PageModeKey { get; set; } = "GlobalConfig_PageMode";

public static string NavigationMiniCookieKey { get; set; } = "GlobalConfig_NavigationMini";

public static string ExpandOnHoverCookieKey { get; set; } = "GlobalConfig_ExpandOnHover";

public static string FavoriteCookieKey { get; set; } = "GlobalConfig_Favorite";

public bool IsDark
{
get => _isDark;
set
{
_isDark = value;
_cookieStorage?.SetItemAsync(IsDarkCookieKey, value);
}
}

public bool NavigationMini
{
get => _navigationMini;
set
{
_navigationMini = value;
_cookieStorage?.SetItemAsync(NavigationMiniCookieKey, value);
}
}

public bool ExpandOnHover
{
get => _expandOnHover;
set
{
_expandOnHover = value;
_cookieStorage?.SetItemAsync(ExpandOnHoverCookieKey, value);
}
}

public string? Favorite
{
get => _favorite;
set
{
_favorite = value;
_cookieStorage?.SetItemAsync(FavoriteCookieKey, value);
}
}

public bool Loading
{
get => _loading;
Expand All @@ -86,12 +30,6 @@ public bool Loading

#endregion

public GlobalConfig(CookieStorage cookieStorage, IHttpContextAccessor httpContextAccessor)
{
_cookieStorage = cookieStorage;
if (httpContextAccessor.HttpContext is not null) Initialization(httpContextAccessor.HttpContext.Request.Cookies);
}

#region event

public delegate void GlobalConfigChanged();
Expand All @@ -101,16 +39,4 @@ public GlobalConfig(CookieStorage cookieStorage, IHttpContextAccessor httpContex
public event LoadingChanged? OnLoadingChanged;

#endregion

#region Method

public void Initialization(IRequestCookieCollection cookies)
{
_isDark = Convert.ToBoolean(cookies[IsDarkCookieKey]);
_pageMode = cookies[PageModeKey];
_navigationMini = Convert.ToBoolean(cookies[NavigationMiniCookieKey]);
_expandOnHover = Convert.ToBoolean(cookies[ExpandOnHoverCookieKey]);
_favorite = cookies[FavoriteCookieKey];
}
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="Masa.BuildingBlocks.Authentication.Identity" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Data.Mapping.Mapster" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.SearchEngine.AutoComplete.ElasticSearch" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.424" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.451" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.15" />
<PackageReference Include="Quartz.AspNetCore" Version="3.6.2" />
<PackageReference Include="Masa.Contrib.StackSdks.Alert" Version="$(MasaFrameworkPackageVersion)" />
Expand Down