-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix create/edit for ReferenceSourceLibraries,ReferenceAssemblies,Embe…
…ddedResources
- Loading branch information
Showing
13 changed files
with
141 additions
and
16 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
36 changes: 36 additions & 0 deletions
36
Covenant/Components/EmbeddedResources/CreateEmbeddedResource.razor
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,36 @@ | ||
@page "/embeddedresource/create" | ||
@attribute [Authorize(Roles = "User, Administrator")] | ||
@inherits OwningComponentBase<ICovenantService> | ||
|
||
@using Covenant.Core | ||
@using Covenant.Models.Grunts | ||
@inject NavigationManager NavigationManager | ||
|
||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap pb-2 mb-3"> | ||
<h1 class="h2">Create EmbeddedResource</h1> | ||
</div> | ||
|
||
<EmbeddedResourceForm EmbeddedResource="EmbeddedResource" OnSubmit="OnCreate" SubmitIcon="plus" SubmitLabel="Create" /> | ||
|
||
@code { | ||
[Parameter] | ||
public EmbeddedResource EmbeddedResource { get; set; } | ||
|
||
protected override void OnInitialized() | ||
{ | ||
this.EmbeddedResource = this.EmbeddedResource ?? new EmbeddedResource(); | ||
} | ||
|
||
public async Task OnCreate(EmbeddedResource resource) | ||
{ | ||
try | ||
{ | ||
this.EmbeddedResource = await Service.CreateEmbeddedResource(resource); | ||
NavigationManager.NavigateTo("/grunttask"); | ||
} | ||
catch (Exception e) when (e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException) | ||
{ | ||
// return RedirectToAction(nameof(Edit), new { id = libraryModel.Id }); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Covenant/Components/EmbeddedResources/EditEmbeddedResource.razor
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,39 @@ | ||
@page "/embeddedresource/edit/{EmbeddedResourceId:int}" | ||
@attribute [Authorize(Roles = "User, Administrator")] | ||
@inherits OwningComponentBase<ICovenantService> | ||
|
||
@using Covenant.Core | ||
@using Covenant.Models.Grunts | ||
@inject NavigationManager NavigationManager | ||
|
||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap pb-2 mb-3"> | ||
<h1 class="h2">EmbeddedResource: <span class="primary-color">@EmbeddedResource.Name</span></h1> | ||
</div> | ||
|
||
<EmbeddedResourceForm EmbeddedResource="EmbeddedResource" OnSubmit="OnEdit" SubmitIcon="edit" SubmitLabel="Edit" /> | ||
|
||
@code { | ||
[Parameter] | ||
public int EmbeddedResourceId { get; set; } | ||
|
||
[Parameter] | ||
public EmbeddedResource EmbeddedResource { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
this.EmbeddedResource = this.EmbeddedResource ?? await Service.GetEmbeddedResource(this.EmbeddedResourceId); | ||
} | ||
|
||
public async Task OnEdit(EmbeddedResource resource) | ||
{ | ||
try | ||
{ | ||
await Service.EditEmbeddedResource(resource); | ||
NavigationManager.NavigateTo("/grunttask"); | ||
} | ||
catch (Exception e) when (e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException) | ||
{ | ||
// return RedirectToAction(nameof(Edit), new { id = resource.Id }); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Covenant/Components/EmbeddedResources/EmbeddedResourceForm.razor
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,39 @@ | ||
@using Microsoft.JSInterop | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Covenant.Core | ||
@using Covenant.Models.Grunts | ||
@inject IJSRuntime IJSRuntime | ||
|
||
<EditForm Model="EmbeddedResource" OnValidSubmit="(e => this.OnSubmit.InvokeAsync(EmbeddedResource))"> | ||
<div class="form-row"> | ||
<div class="form-group col-md-4"> | ||
<label for="Name">Name</label> | ||
<input id="Name" name="Name" @bind="EmbeddedResource.Name" class="form-control"> | ||
<div class="text-danger"><ValidationMessage For="() => EmbeddedResource.Name" /></div> | ||
</div> | ||
</div> | ||
<div class="form-row"> | ||
<div class="form-group col-md-12"> | ||
<label for="Location">Location</label> | ||
<input id="Location" name="Location" @bind="EmbeddedResource.Location" class="form-control"> | ||
<div class="text-danger"><ValidationMessage For="() => EmbeddedResource.Location" /></div> | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary"> | ||
<span class="fe fe-@SubmitIcon"></span> @SubmitLabel | ||
</button> | ||
</EditForm> | ||
|
||
@code { | ||
[Parameter] | ||
public EmbeddedResource EmbeddedResource { get; set; } | ||
|
||
[Parameter] | ||
public string SubmitIcon { get; set; } | ||
|
||
[Parameter] | ||
public string SubmitLabel { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<EmbeddedResource> OnSubmit { get; set; } | ||
} |
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
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