-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WatchList - Add table "WatchCinemaTable". * (Solution)WatchList.MudBlazor - Add Implementation button "Add" watch item. * WatchList.MudBlazor - Fixed Linter. * Solution - Fixed bug. Change IMessageBox (void -> Task). Refactoring. * WatchList.MudBlazor - Clear non used code. * WatchList.MudBlazor - Refactoring and chenge interface app. * WatchList.MudBlazor - Fixed bug/linter and unused code. * WatchList.MudBlazor - Fix file encoding. * WatchList.MudBlazor - Add "FilterModel" and used it in the project. * WatchList.MudBlazor - Add "SorterField" and use it in project. * WatchList.MudBlazor - Change icons button.
- Loading branch information
1 parent
a650d2f
commit 87f9f8c
Showing
44 changed files
with
897 additions
and
114 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@using WatchList.Core.Model.ItemCinema.Components | ||
|
||
<MudContainer> | ||
|
||
<MudForm @bind-Errors="@_errors" Model="@_watchItemModel"> | ||
|
||
<MudTextField T="string" Label="Title" | ||
InputType="InputType.Text" | ||
Required="true" | ||
@bind-Value=@_watchItemModel.Title | ||
Validation="@(new Func<string, IEnumerable<string>>(ValidFormatText))" /> | ||
|
||
<MudSelect T="TypeCinema" Label="Type" @bind-Value="_watchItemModel.Type" AdornmentIcon="@Icons.Material.Filled.ShortText"> | ||
@foreach (var item in TypeCinema.List.Where(x => x != TypeCinema.AllType).ToList()) | ||
{ | ||
<MudSelectItem T="TypeCinema" Value="@item" /> | ||
} | ||
</MudSelect> | ||
|
||
<MudSelect T="StatusCinema" Label="Status" @bind-Value="_watchItemModel.Status" AdornmentIcon="@Icons.Material.Filled.ShortText"> | ||
@foreach (var item in StatusCinema.List.Where(x => x != StatusCinema.AllStatus).ToList()) | ||
{ | ||
<MudSelectItem T="StatusCinema" Value="@item" /> | ||
} | ||
</MudSelect> | ||
|
||
|
||
<MudNumericField @bind-Value="_watchItemModel.Sequel" Label="@_watchItemModel.Type.TypeSequel" Variant="Variant.Text" Min="1"/> | ||
|
||
@if (_watchItemModel.Status != StatusCinema.Planned) | ||
{ | ||
<MudNumericField @bind-Value="_watchItemModel.Grade" | ||
Label="Grade" | ||
Variant="Variant.Text" | ||
Min="1" Max="10"/> | ||
} | ||
@if (_watchItemModel.Status == StatusCinema.Viewed) | ||
{ | ||
<MudDatePicker @bind-Date=@_watchItemModel.Date | ||
Label="Date" | ||
MaxDate="DateTime.Now" | ||
Required="true"/> | ||
} | ||
|
||
</MudForm> | ||
|
||
<MudSpacer /> | ||
|
||
<MudToolBar DisableGutters="true" Class="relative d-flex justify-end gap-1"> | ||
|
||
@if (_isAddItem) | ||
{ | ||
<MudTooltip Text="Save" Placement="Placement.Bottom"> | ||
<MudButton Style="max-width: 100px; max-height : 40px;" Size="Size.Medium" Color="Color.Primary" Variant="Variant.Outlined" OnClick="Add">Save</MudButton> | ||
</MudTooltip> | ||
<MudTooltip Text="Clear" Placement="Placement.Bottom"> | ||
<MudButton Style="max-width: 100px; max-height : 40px;" Size="Size.Medium" Color="Color.Primary" Variant="Variant.Outlined" OnClick="ClearData">Clear</MudButton> | ||
</MudTooltip> | ||
} | ||
else | ||
{ | ||
<MudTooltip Text="Save" Placement="Placement.Bottom"> | ||
<MudButton Style="max-width: 100px; max-height : 40px;" Size="Size.Medium" Color="Color.Primary" Variant="Variant.Outlined" OnClick="Updata">Save</MudButton> | ||
</MudTooltip> | ||
<MudTooltip Text="Replace" Placement="Placement.Bottom"> | ||
<MudButton Class="ml-1" Style="max-width: 100px; max-height : 40px;" Size="Size.Medium" Color="Color.Primary" Variant="Variant.Outlined" OnClick="RecoverPastData">Recover</MudButton> | ||
</MudTooltip> | ||
} | ||
|
||
<MudTooltip Text="Close" Placement="Placement.Bottom"> | ||
<MudButton Style="max-width: 100px; max-height : 40px;" Size="Size.Medium" Color="Color.Primary" Variant="Variant.Outlined" OnClick="Close">Close</MudButton> | ||
</MudTooltip> | ||
|
||
</MudToolBar> | ||
|
||
</MudContainer> | ||
|
||
|
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,138 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using MudBlazor; | ||
using WatchList.Core.Model.ItemCinema; | ||
using WatchList.Core.Model.ItemCinema.Components; | ||
using WatchList.Core.Service; | ||
using WatchList.Core.Service.Component; | ||
using WatchList.MudBlazors.Extension; | ||
using WatchList.MudBlazors.Model; | ||
|
||
namespace WatchList.MudBlazors.Dialog | ||
{ | ||
public partial class WatchItemDialog | ||
{ | ||
[CascadingParameter] MudDialogInstance MudDialog { get; set; } = null!; | ||
[Inject] private WatchItemService WatchItemService { get; set; } = null!; | ||
[Inject] IMessageBox MessageBoxDialog { get; set; } = null!; | ||
|
||
private WatchItemModel _watchItemModel { get; set; } = new WatchItemModel(); | ||
private string[] _errors = { }; | ||
private bool _isAddItem = true; | ||
|
||
private WatchItem? _oldWatchItem; | ||
|
||
[Parameter] public Guid? Id { get; set; } = null; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
if (Id == null) | ||
{ | ||
_isAddItem = true; | ||
return; | ||
} | ||
|
||
_isAddItem = false; | ||
_oldWatchItem = WatchItemService.GetItemById((Guid)Id); | ||
_watchItemModel = _oldWatchItem.GetItemModel(); | ||
} | ||
|
||
private void Close() => MudDialog.Cancel(); | ||
|
||
private async Task Add() | ||
{ | ||
if (_errors.Length != 0) | ||
{ | ||
return; | ||
} | ||
|
||
if (!ValidateFields(out var message)) | ||
{ | ||
await MessageBoxDialog.ShowWarning(message); | ||
return; | ||
} | ||
|
||
var item = _watchItemModel.ToWatchItem(); | ||
await WatchItemService.AddAsync(item); | ||
|
||
MudDialog.Close(); | ||
} | ||
|
||
private void ClearData() => _watchItemModel.ClearData(); | ||
|
||
private async Task Updata() | ||
{ | ||
if (_errors.Length != 0) | ||
{ | ||
return; | ||
} | ||
|
||
if (!ValidateFields(out var message)) | ||
{ | ||
await MessageBoxDialog.ShowWarning(message); | ||
return; | ||
} | ||
|
||
var item = _watchItemModel.ToWatchItem(); | ||
if (!_oldWatchItem.Equals(item)) | ||
{ | ||
await WatchItemService.UpdateAsync(_oldWatchItem, item); | ||
} | ||
|
||
MudDialog.Close(); | ||
} | ||
|
||
private void RecoverPastData() => _watchItemModel = _oldWatchItem.GetItemModel(); | ||
|
||
private IEnumerable<string> ValidFormatText(string str) | ||
{ | ||
if (string.IsNullOrWhiteSpace(str)) | ||
{ | ||
yield return "Field is required."; | ||
} | ||
} | ||
|
||
private bool ValidateFields(out string message) | ||
{ | ||
message = string.Empty; | ||
|
||
if (_watchItemModel.Title == null || _watchItemModel.Title == string.Empty) | ||
{ | ||
message = "Title is required."; | ||
return false; | ||
} | ||
|
||
if (_watchItemModel.Type == null) | ||
{ | ||
message = "Type cinema not selected."; | ||
return false; | ||
} | ||
|
||
if (_watchItemModel.Status == null) | ||
{ | ||
message = "Status not selected."; | ||
return false; | ||
} | ||
|
||
if ((_watchItemModel.Grade == null || _watchItemModel.Grade <= 0) | ||
&& _watchItemModel.Status != StatusCinema.Planned) | ||
{ | ||
message = "Grade cinema above in zero."; | ||
return false; | ||
} | ||
|
||
if (_watchItemModel.Sequel == 0) | ||
{ | ||
message = $"Enter number {_watchItemModel.Title}"; | ||
return false; | ||
} | ||
|
||
if (_watchItemModel.Date == null && _watchItemModel.Status == StatusCinema.Viewed) | ||
{ | ||
message = "Ener the viewing date."; | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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,37 @@ | ||
using MudBlazor; | ||
using WatchList.MudBlazors.Message; | ||
|
||
namespace WatchList.MudBlazors.Extension | ||
{ | ||
public static class DialogServiceShow | ||
{ | ||
public static async Task<bool> DialogYesNoShow(this IDialogService dialogService, string title, string content) | ||
{ | ||
var parameters = new DialogParameters<DialogYesNo> { { x => x.Content, content } }; | ||
return await DialogShowAsync(parameters, dialogService, title, content); | ||
} | ||
|
||
public static async Task<bool> DialogOkCloseShowAsync(this IDialogService dialogService, string title, string content) | ||
{ | ||
var parameters = new DialogParameters<DialogYesNo> | ||
{ | ||
{x => x.Content, content }, | ||
{x => x.SelectButtonDialog, new Dictionary<bool, string> | ||
{ | ||
{true, "Ok"}, | ||
{false, "Close"}, | ||
} | ||
} | ||
}; | ||
return await DialogShowAsync(parameters, dialogService, title, content); | ||
} | ||
|
||
private static async Task<bool> DialogShowAsync(DialogParameters<DialogYesNo> dialogParameters, IDialogService dialogService, string title, string content) | ||
{ | ||
var options = new DialogOptions { CloseOnEscapeKey = true }; | ||
var dialog = await dialogService.ShowAsync<DialogYesNo>(title, dialogParameters, options); | ||
var result = await dialog.Result; | ||
return result == null || !result.Cancelled; | ||
} | ||
} | ||
} |
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,11 @@ | ||
using WatchList.Core.Model.ItemCinema; | ||
using WatchList.MudBlazors.Model; | ||
|
||
namespace WatchList.MudBlazors.Extension | ||
{ | ||
public static class GetModelItemExtension | ||
{ | ||
public static WatchItemModel GetItemModel(this WatchItem item) | ||
=> new WatchItemModel(item.Title, item.Sequel, item.Date, item.Grade, item.Status, item.Type, item.Id); | ||
} | ||
} |
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,21 @@ | ||
<MudDialog DefaultFocus="DefaultFocus.LastChild"> | ||
<DialogContent> | ||
@Content | ||
</DialogContent> | ||
<DialogActions> | ||
<MudButton Variant="Variant.Filled" Class="ml-2" OnClick="Submit">@SelectButtonDialog[true]</MudButton> | ||
<MudButton Variant="Variant.Filled" OnClick="Cancel">@SelectButtonDialog[false]</MudButton> | ||
</DialogActions> | ||
</MudDialog> | ||
|
||
@code { | ||
[CascadingParameter] MudDialogInstance MudDialog { get; set; } = null!; | ||
|
||
[Parameter] public string Content { get; set; } = string.Empty; | ||
|
||
[Parameter] public Dictionary<bool, string> SelectButtonDialog { get; set; } = new Dictionary<bool, string> { { true, "Yes" }, { false, "No" } }; | ||
|
||
void Submit() => MudDialog.Close(DialogResult.Ok(true)); | ||
|
||
void Cancel() => MudDialog.Cancel(); | ||
} |
Oops, something went wrong.