Escali License control 1
EditPriceListModal.razor
Gå til dokumentasjonen til denne filen.
1@inject StateService _stateService
2@inject CurrencyViewModel _currencyViewService
3@inject PriceListViewModel _priceListViewSerivce
4@implements IDisposable
5
6@if (_stateService.EditPriceList.Value != null)
7{
8
9 <EditForm Model="_stateService.EditPriceList" OnValidSubmit="Submit" OnInvalidSubmit="EventCallback.Empty" >
10
11 <StandardModal Header="Endre prisliste" SubmitButtonName="Oppdater prisliste" @ref="Modal" ShowModal="true" OnModalClosed="ResetPriceList">
12
13 <div class="create-modal-container">
14 <ObjectGraphDataAnnotationsValidator />
15
16 <div class="input-split">
17
18 <FloatingInput Name="Navn">
19 <InputText @bind-Value="_stateService.EditPriceList.Value.PriceListName" type="text" class="form-control input-text input-split-left" id="floatingInput" placeholder=" " autocomplete="off"/>
20 </FloatingInput>
21
22 @* @if (_currencyViewService.Currencies != null && _stateService.EditPriceList.Value.Currency != null) *@
23 @* { *@
24 @* <FloatingInput Name="Valuta"> *@
25 @* <InputText @bind-Value="_stateService.EditPriceList.Value.Currency.CurrencyName" type="text" class="form-control input-text hide-picker input-split-right" id="floatingInput" placeholder=" " list="valutaList" autocomplete="off"/> *@
26 @* </FloatingInput> *@
27 @* <datalist id="valutaList"> *@
28 @* @foreach (var c in _currencyViewService.Currencies.DistinctBy(c => c.CurrencyName).ToList()) *@
29 @* { *@
30 @* <option value="@c.CurrencyName">@c.CurrencyName</option> *@
31 @* } *@
32 @* </datalist> *@
33 @* } *@
34
35 </div>
36
37 <div class="input-split">
38 <div class="input-container form-floating mb-3">
39 <InputDate @bind-Value="_stateService.EditPriceList.Value.DateFrom" class="form-control input-text input-split-left" id="floatingInput" autocomplete="off" max="@_stateService.EditPriceList.Value.DateTo"/>
40 <label for="floatingInput">Startdato</label>
41 </div>
42
43 <div class="input-container form-floating mb-3">
44 <InputDate @bind-Value="_stateService.EditPriceList.Value.DateTo" class="form-control input-text input-split-right" id="floatingInput" autocomplete="off"/>
45 <label for="floatingInput">Sluttdato</label>
46 </div>
47 </div>
48
49 </div>
50
51 </StandardModal>
52
53 </EditForm>
54
55
56}
57
58@code {
59
60 private StandardModal Modal { get; set; }
61
62 private void Submit()
63 {
64
65 var updatedPriceList = _priceListViewSerivce.UpdatePricelist(_stateService.EditPriceList.Value!);
66 if (updatedPriceList != null)
67 {
68 ResetPriceList();
69 }
70 }
71
72 private void ResetPriceList()
73 {
74 _stateService.UpdateEditPriceList(null);
75 }
76
77 protected override void OnInitialized()
78 {
79 _stateService.EditPriceList.ValueChanged += StateHasChanged;
80 }
81
82 void IDisposable.Dispose()
83 {
84 _stateService.EditPriceList.ValueChanged -= StateHasChanged;
85 }
86
87}