-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
191 additions
and
10 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
18 changes: 18 additions & 0 deletions
18
src/Blazor.FlexGrid/Components/Configuration/DeleteItemOptions.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,18 @@ | ||
namespace Blazor.FlexGrid.Components.Configuration | ||
{ | ||
public class DeleteItemOptions | ||
{ | ||
public const string DialogName = "deleteDialog"; | ||
|
||
public bool UseConfirmationDialog { get; set; } | ||
} | ||
|
||
public class DefaulDeleteItemOptions : DeleteItemOptions | ||
{ | ||
public DefaulDeleteItemOptions() | ||
: base() | ||
{ | ||
UseConfirmationDialog = 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
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
67 changes: 67 additions & 0 deletions
67
src/Blazor.FlexGrid/Components/Renderers/DeleteModalRenderer.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,67 @@ | ||
using Blazor.FlexGrid.Components.Configuration; | ||
using Blazor.FlexGrid.Permission; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using System; | ||
|
||
namespace Blazor.FlexGrid.Components.Renderers | ||
{ | ||
public class DeleteModalRenderer : GridPartRenderer | ||
{ | ||
private readonly FlexGridInterop flexGridInterop; | ||
|
||
public DeleteModalRenderer(FlexGridInterop flexGridInterop) | ||
{ | ||
this.flexGridInterop = flexGridInterop ?? throw new ArgumentNullException(nameof(flexGridInterop)); | ||
} | ||
|
||
public override bool CanRender(GridRendererContext rendererContext) | ||
{ | ||
return true; | ||
} | ||
|
||
protected override void BuildRendererTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext) | ||
{ | ||
rendererContext | ||
.RendererTreeBuilder | ||
.OpenElement(HtmlTagNames.Div, "modal") | ||
.AddAttribute(HtmlAttributes.Id, DeleteItemOptions.DialogName) | ||
.AddAttribute("role", "dialog") | ||
.OpenElement(HtmlTagNames.Div, $"modal-dialog modal-dialog-centered") | ||
.AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalSizeDiv) | ||
.OpenElement(HtmlTagNames.Div, "modal-content") | ||
.OpenElement(HtmlTagNames.Div, "modal-header") | ||
.OpenElement(HtmlTagNames.H4, "modal-title") | ||
.AddContent("Confirm delete") | ||
.CloseElement() | ||
.CloseElement() | ||
.OpenElement(HtmlTagNames.Div, "modal-body") | ||
.AddContent("Are you sure you want to delete item?") | ||
.CloseElement() | ||
.OpenElement(HtmlTagNames.Div, "modal-footer") | ||
.OpenElement(HtmlTagNames.Button, rendererContext.CssClasses.DeleteDialogCssClasses.CancelButton) | ||
.AddAttribute(HtmlAttributes.Type, "button") | ||
.AddAttribute("data-dismiss", "modal") | ||
.AddAttribute(HtmlJSEvents.OnClick, EventCallback.Factory.Create(this, (MouseEventArgs e) => flexGridInterop.HideModal(DeleteItemOptions.DialogName))) | ||
.AddContent("Cancel") | ||
.CloseElement() | ||
.OpenElement(HtmlTagNames.Button, rendererContext.CssClasses.DeleteDialogCssClasses.DeleteButton) | ||
.AddAttribute(HtmlAttributes.Type, "button") | ||
.AddAttribute("data-dismiss", "modal") | ||
.AddAttribute(HtmlJSEvents.OnClick, | ||
EventCallback.Factory.Create(this, (MouseEventArgs e) => | ||
{ | ||
rendererContext.TableDataSet.DeleteItem(rendererContext.FlexGridContext.SelectedItem); | ||
rendererContext.FlexGridContext.RemoveSelection(); | ||
flexGridInterop.HideModal(DeleteItemOptions.DialogName); | ||
rendererContext.RequestRerenderNotification?.Invoke(); | ||
})) | ||
.AddContent("Delete") | ||
.CloseElement() | ||
.CloseElement() | ||
.CloseElement() | ||
.CloseElement() | ||
.CloseElement(); | ||
} | ||
} | ||
} |
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