Maschinenzuordnung funktionsfähig gemacht
This commit is contained in:
parent
c86262ab02
commit
7fcd0c3247
@ -2,6 +2,8 @@
|
|||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
@using CocktailWeb.Data
|
@using CocktailWeb.Data
|
||||||
@using Microsoft.AspNetCore.Components.Sections
|
@using Microsoft.AspNetCore.Components.Sections
|
||||||
|
@using CocktailWeb.Shared
|
||||||
|
|
||||||
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
||||||
<PageTitle>Maschineneinstellungen</PageTitle>
|
<PageTitle>Maschineneinstellungen</PageTitle>
|
||||||
|
|
||||||
@ -14,7 +16,7 @@
|
|||||||
<div class="row pb-2 gap-2" style="height:45vh">
|
<div class="row pb-2 gap-2" style="height:45vh">
|
||||||
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pourer))
|
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pourer))
|
||||||
{
|
{
|
||||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" href="#" data-bs-toggle="modal" data-bs-target="#examplemodal">
|
<a class="col border border-1 rounded-2 text-decoration-none text-light" @onclick="args => OpenSelectionDialog(args,f)">
|
||||||
@f.Pos - @f.Flasche?.Name
|
@f.Pos - @f.Flasche?.Name
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
@ -24,64 +26,30 @@
|
|||||||
<div class="row gap-2" style="height:25vh">
|
<div class="row gap-2" style="height:25vh">
|
||||||
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pump))
|
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pump))
|
||||||
{
|
{
|
||||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" href="#" data-bs-toggle="modal" data-bs-target="#examplemodal">
|
<a class="col border border-1 rounded-2 text-decoration-none text-light" @onclick="args => OpenSelectionDialog(args,f)">
|
||||||
@f.Pos - @f.Flasche?.Name
|
@f.Pos - @f.Flasche?.Name
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal fade" id="examplemodal" tabindex="-1" aria-hidden="true">
|
<ModalComponent @ref="modal">
|
||||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
|
<Title>Flasche auswählen</Title>
|
||||||
<div class="modal-content">
|
<Body>
|
||||||
<div class="modal-header">
|
<ul class="list-group">
|
||||||
Testdialog
|
<li class="list-group-item list-group-item-action align-middle @(SelectedFlasche == null ? "text-bg-success" : "")" @onclick="args => SelectFlasche(args,null)">
|
||||||
</div>
|
<label class="form-check-label stretched-link">(Leer)</label>
|
||||||
<div class="modal-body">
|
</li>
|
||||||
<ul class="list-group">
|
@foreach (Flasche fl in Flaschen)
|
||||||
@if (Flaschen.Count == 0)
|
{
|
||||||
{
|
<li class="list-group-item list-group-item-action align-middle @(SelectedFlasche == fl ? "text-bg-success" : "")" @onclick="args => SelectFlasche(args,fl)">
|
||||||
<li class="list-group-item list-group-item-action align-middle">
|
<label class="form-check-label stretched-link">@fl.Name</label>
|
||||||
Es wurden noch keine Zutaten angelegt
|
</li>
|
||||||
</li>
|
}
|
||||||
}
|
</ul>
|
||||||
else
|
</Body>
|
||||||
{
|
<Footer>
|
||||||
@foreach (Flasche fl in Flaschen)
|
<button type="button" class="btn btn-secondary" @onclick="CloseDialog">Abbrechen</button>
|
||||||
{
|
<button type="button" class="btn btn-primary" @onclick="SaveSelection">Speichern</button>
|
||||||
<li class="list-group-item list-group-item-action align-middle">
|
</Footer>
|
||||||
<label class="form-check-label stretched-link">@fl.Name</label>
|
</ModalComponent>
|
||||||
</li>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
|
||||||
<button type="button" class="btn btn-primary">Speichern</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private DbDataContext? _DataContext;
|
|
||||||
private List<Filler> Fillers { get; set; } = new();
|
|
||||||
private List<Flasche> Flaschen { get; set; } = new();
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
await ShowFillers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ShowFillers()
|
|
||||||
{
|
|
||||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
|
||||||
if (_DataContext != null)
|
|
||||||
{
|
|
||||||
Fillers = await _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToListAsync();
|
|
||||||
Flaschen = await _DataContext.Flaschen.OrderBy(fl => fl.Name).ToListAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,69 @@
|
|||||||
namespace CocktailWeb.Pages.Settings
|
using CocktailWeb.Data;
|
||||||
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
namespace CocktailWeb.Pages.Settings
|
||||||
{
|
{
|
||||||
partial class Maschine
|
partial class Maschine
|
||||||
{
|
{
|
||||||
|
private DbDataContext? _DataContext;
|
||||||
|
private List<Filler> Fillers { get; set; } = new();
|
||||||
|
private List<Flasche> Flaschen { get; set; } = new();
|
||||||
|
|
||||||
|
private Filler? SelectedFiller { get; set; }
|
||||||
|
|
||||||
|
private Flasche? SelectedFlasche { get; set; }
|
||||||
|
|
||||||
|
private ModalComponent modal = null!;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await ShowFillers();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ShowFillers()
|
||||||
|
{
|
||||||
|
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||||
|
if (_DataContext != null)
|
||||||
|
{
|
||||||
|
Fillers = await _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToListAsync();
|
||||||
|
Flaschen = await _DataContext.Flaschen.OrderBy(fl => fl.Name).ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OpenSelectionDialog(MouseEventArgs e, Filler f)
|
||||||
|
{
|
||||||
|
SelectedFiller = f;
|
||||||
|
SelectedFlasche = f.Flasche;
|
||||||
|
await modal.OpenModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SelectFlasche(MouseEventArgs e, Flasche? fl)
|
||||||
|
{
|
||||||
|
SelectedFlasche = fl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveSelection(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (SelectedFiller != null)
|
||||||
|
{
|
||||||
|
SelectedFiller.Flasche = SelectedFlasche;
|
||||||
|
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||||
|
if (_DataContext != null)
|
||||||
|
{
|
||||||
|
_DataContext.Fillers.Update(SelectedFiller);
|
||||||
|
await _DataContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await CloseDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CloseDialog()
|
||||||
|
{
|
||||||
|
SelectedFiller = null;
|
||||||
|
SelectedFlasche = null;
|
||||||
|
await modal.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user