-
Notifications
You must be signed in to change notification settings - Fork 517
Show 'Add New'/'Duplicate' form in a persistent side panel #783
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
Open
sven-n
wants to merge
3
commits into
master
Choose a base branch
from
admin-panel-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,72 @@ | ||
| @* <copyright file="CreationPanel.razor" company="MUnique"> | ||
| Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
| </copyright> *@ | ||
|
|
||
| @using MUnique.OpenMU.Web.AdminPanel.Properties | ||
| @using MUnique.OpenMU.Web.Shared.Components.Form | ||
| @using MUnique.OpenMU.Web.Shared.Services | ||
|
|
||
| @implements IDisposable | ||
| @inject CreationPanelService Panel | ||
| @inject Blazored.Toast.Services.IToastService ToastService | ||
|
|
||
| @if (this.Panel.Current is { } session) | ||
| { | ||
| <div class="creation-panel @(this.Panel.IsCollapsed ? "collapsed" : "expanded")"> | ||
| <button type="button" | ||
| class="collapse-toggle" | ||
| title="@(this.Panel.IsCollapsed ? Resources.ShowEntryForm : Resources.HideEntryForm)" | ||
| @onclick="@this.Panel.ToggleCollapse"> | ||
| <span class="oi @(this.Panel.IsCollapsed ? "oi-chevron-left" : "oi-chevron-right")" aria-hidden="true"></span> | ||
| </button> | ||
| @if (!this.Panel.IsCollapsed) | ||
| { | ||
| <div class="creation-panel-body"> | ||
| <h3>@session.Title</h3> | ||
| <ItemCreationForm Item="@session.Item" | ||
| PersistenceContext="@session.Context" | ||
| Owner="@session.Owner" | ||
| OnValidSubmit="@this.OnSubmitAsync" | ||
| OnCancel="@this.OnCancelAsync" /> | ||
| </div> | ||
| } | ||
| </div> | ||
| } | ||
|
|
||
| @code { | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void OnInitialized() | ||
| { | ||
| base.OnInitialized(); | ||
| this.Panel.StateChanged += this.OnStateChanged; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void Dispose() | ||
| { | ||
| this.Panel.StateChanged -= this.OnStateChanged; | ||
| } | ||
|
|
||
| private void OnStateChanged() | ||
| { | ||
| _ = this.InvokeAsync(this.StateHasChanged); | ||
| } | ||
|
|
||
| private async Task OnSubmitAsync() | ||
| { | ||
| try | ||
| { | ||
| await this.Panel.CompleteAsync(); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| this.ToastService.ShowError($"Could not save the new entry: {ex.Message}"); | ||
| } | ||
| } | ||
|
|
||
| private Task OnCancelAsync() | ||
| { | ||
| return this.Panel.CancelAsync(); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/Web/AdminPanel/Components/Layout/CreationPanel.razor.css
This file contains hidden or 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 @@ | ||
| .creation-panel { | ||
| position: sticky; | ||
| top: 0; | ||
| align-self: flex-start; | ||
| height: 100vh; | ||
| flex-shrink: 0; | ||
| display: flex; | ||
| flex-direction: row; | ||
| background-color: #fff; | ||
| border-left: 1px solid #d6d5d5; | ||
| box-shadow: -2px 0 5px rgba(0, 0, 0, 0.08); | ||
| overflow: hidden; | ||
| z-index: 2; | ||
| } | ||
|
|
||
| .creation-panel.expanded { | ||
| width: clamp(32rem, 42vw, 60rem); | ||
| flex-basis: clamp(32rem, 42vw, 60rem); | ||
| } | ||
|
|
||
| .creation-panel.collapsed { | ||
| width: 1.75rem; | ||
| } | ||
|
|
||
| .collapse-toggle { | ||
| flex-shrink: 0; | ||
| width: 1.75rem; | ||
| padding: 0; | ||
| border: none; | ||
| border-right: 1px solid #d6d5d5; | ||
| background-color: #f7f7f7; | ||
| cursor: pointer; | ||
| color: #333; | ||
| } | ||
|
|
||
| .collapse-toggle:hover { | ||
| background-color: #e9e9e9; | ||
| } | ||
|
|
||
| .creation-panel-body { | ||
| flex: 1; | ||
| min-width: 0; | ||
| overflow-y: auto; | ||
| overflow-x: hidden; | ||
| padding: 1rem 1.25rem; | ||
| } | ||
|
|
||
| .creation-panel-body h3 { | ||
| margin-top: 0; | ||
| margin-bottom: 1rem; | ||
| word-break: break-word; | ||
| } | ||
|
|
||
| /* Let the form controls fill the wider panel so the space is actually used. */ | ||
| .creation-panel-body ::deep input:not([type="checkbox"]):not([type="radio"]), | ||
| .creation-panel-body ::deep select, | ||
| .creation-panel-body ::deep textarea, | ||
| .creation-panel-body ::deep .blazored-typeahead { | ||
| width: 100%; | ||
| box-sizing: border-box; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| </article> | ||
|
|
||
| </main> | ||
| <CreationPanel /> | ||
| </div> | ||
|
|
||
| <div id="blazor-error-ui" data-nosnippet> | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| main { | ||
| flex: 1; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .sidebar { | ||
|
|
||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.