-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDForm - Added Monaco editor support for string fields.
- Loading branch information
1 parent
362dc97
commit 7170b72
Showing
19 changed files
with
328 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace PanoramicData.Blazor.Demo.Data; | ||
|
||
public class DatabaseQueryModel | ||
{ | ||
[Display(Name = "Email Address")] | ||
public string EmailAddress { get; set; } = string.Empty; | ||
|
||
[Display(Name = "Frequency Period")] | ||
public TimePeriods FrequencyPeriod { get; set; } = TimePeriods.Week; | ||
|
||
[Display(Name = "Frequency Unit")] | ||
[Range(1, 99)] | ||
public ushort FrequencyUnit { get; set; } = 1; | ||
|
||
[Display(Name = "SQL Query")] | ||
[MaxLength(10000)] | ||
public string SqlQuery { get; set; } = string.Empty; | ||
} |
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,63 @@ | ||
@page "/pdform5" | ||
@using PanoramicData.Blazor.Demo.Data | ||
|
||
<h1>PDForm</h1> | ||
|
||
<DemoSourceView SourceFiles="Pages/PDFormPage5.razor, Pages/PDFormPage5.razor.cs, Pages/PDFormPage5.razor.css"> | ||
|
||
<PDToolbar> | ||
<PDToolbarButton Click="OnBeginEditAsync" | ||
CssClass="btn-primary" | ||
IsEnabled="_queryForm?.Mode == FormModes.ReadOnly" | ||
Text="Edit" /> | ||
</PDToolbar> | ||
|
||
<div class="d-flex"> | ||
|
||
<PDForm @ref="_queryForm" | ||
CssClass="w-100" | ||
TItem="DatabaseQueryModel" | ||
Item="_model" | ||
DefaultMode="FormModes.ReadOnly" | ||
DataProvider="_dataProvider"> | ||
|
||
<PDFormHeader TItem="DatabaseQueryModel" | ||
EditTitle="Edit Query" /> | ||
|
||
<PDFormBody TItem="DatabaseQueryModel"> | ||
|
||
<PDField TItem="DatabaseQueryModel" | ||
Field="x => x.EmailAddress" | ||
Group="Email" | ||
Label="Email Address" /> | ||
|
||
<PDField TItem="DatabaseQueryModel" | ||
Field="x => x.FrequencyUnit" | ||
Group="Frequency" /> | ||
|
||
<PDField TItem="DatabaseQueryModel" | ||
Field="x => x.FrequencyPeriod" | ||
Group="Frequency" /> | ||
|
||
<PDField TItem="DatabaseQueryModel" | ||
DisplayOptions="QueryEditorOptions" | ||
Field="x => x.SqlQuery" | ||
ShowCopyButton="_ => true" /> | ||
|
||
</PDFormBody> | ||
|
||
<PDFormFooter TItem="DatabaseQueryModel" | ||
Click="OnFooterClick" | ||
SaveButtonText="Save" | ||
ShowCancelWhenReadOnly="false" | ||
ShowDelete="false" /> | ||
|
||
</PDForm> | ||
|
||
</div> | ||
|
||
</DemoSourceView> | ||
|
||
<style> | ||
</style> |
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,61 @@ | ||
using BlazorMonaco.Editor; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace PanoramicData.Blazor.Demo.Pages; | ||
|
||
public partial class PDFormPage5 | ||
{ | ||
private readonly DelegatedDataProvider<DatabaseQueryModel> _dataProvider = new() | ||
{ | ||
UpdateAsync = (model, delta, cancellationToken) => | ||
{ | ||
return Task.FromResult(new OperationResponse { Success = true }); | ||
|
||
} | ||
}; | ||
|
||
private readonly DatabaseQueryModel _model = new DatabaseQueryModel | ||
{ | ||
SqlQuery = "SELECT * \r\n FROM [Customers]\r\n WHERE [Type] = 123" | ||
}; | ||
|
||
[AllowNull] | ||
private PDForm<DatabaseQueryModel> _queryForm; | ||
private FieldStringOptions QueryEditorOptions | ||
{ | ||
get | ||
{ | ||
return new FieldStringOptions | ||
{ | ||
CssClass = "h-300", | ||
Editor = FieldStringOptions.Editors.Monaco, | ||
MonacoOptions = (_) => new StandaloneEditorConstructionOptions | ||
{ | ||
AutomaticLayout = true, | ||
Language = "sql" | ||
} | ||
}; | ||
} | ||
} | ||
|
||
public PDFormPage5() | ||
{ | ||
} | ||
|
||
private async Task OnBeginEditAsync() | ||
{ | ||
await _queryForm.EditItemAsync(_model, FormModes.Edit); | ||
} | ||
|
||
|
||
private async Task OnFooterClick(string key) | ||
{ | ||
if (_queryForm != null) | ||
{ | ||
if (key == "Save") | ||
{ | ||
} | ||
await _queryForm.EditItemAsync(null, FormModes.ReadOnly).ConfigureAwait(true); | ||
} | ||
} | ||
} |
Empty file.
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
Oops, something went wrong.