1@inject PriceListViewModel _priceListViewService
2@inject ModuleViewModel _moduleViewService
3@inject StateService _stateService
4@inject CurrencyViewModel _currencyViewService
7<PriceListTableButtons />
9@if (_priceListViewService.PriceLists != null && _moduleViewService.Modules != null && _stateService.SelectedProductSeq != null)
13 Items="_priceListViewService.PriceLists.Where(pl => pl.ProductSeq == _stateService.SelectedProductSeq.Value).ToList()"
22 <td>@context.PriceListName</td>
23 <td>@(_currencyViewService.Currencies?.Single(c => c.CurrencySeq == context.CurrencySeq).CurrencyName)</td>
24 <td>@context.DateFrom.ToPrettyDate()-@context.DateTo.ToPrettyDate()</td>
25 <td class="table-col-last">
26 <Dropdown Options="CreateDropdownOptions(context)"></Dropdown>
32 <NestedRows Items="_moduleViewService.Modules.Where(m => m.ProductSeq == _stateService.SelectedProductSeq.Value && m.ProductSeq == context.ProductSeq).ToList()">
34 <RowTemplate Context="moduleContext">
37 <td>@moduleContext.ModuleName</td>
44 <ChildRowTemplate Context="moduleContext">
45 @if (moduleContext.ModuleLevels != null && moduleContext.ModuleLevels.Any() && context.PriceElements != null)
47 @foreach (var ml in moduleContext.ModuleLevels)
49 @if (context.PriceElements.Exists(pe => pe.ModuleLevelSeq == ml.ModuleLevelSeq && pe.IsActive == true))
51 <tr class="table-data-third">
52 <td class="table-col-first"></td>
53 <td>@ml.ModuleLevelName</td>
54 <td>@context.PriceElements.SingleOrDefault(pe => pe.ModuleLevelSeq == ml.ModuleLevelSeq)?.Price @(_currencyViewService.Currencies?.Single(c => c.CurrencySeq == context.CurrencySeq).CurrencyName)</td>
56 <td class="table-col-last"></td>
72 <EditPriceListModal />
78 private void OpenModal(PriceListClientModel priceList)
80 _stateService.UpdateEditPriceList(priceList);
83 private (string, Action)[] CreateDropdownOptions(PriceListClientModel context)
85 return new (string, Action)[] {
86 ("Oppdater prisliste", () => _stateService.EditPriceList.Value = context),
90 protected override void OnInitialized()
92 _priceListViewService.DataChanged += StateHasChanged;
93 _moduleViewService.DataChanged += StateHasChanged;
94 _currencyViewService.DataChanged += StateHasChanged;
96 _stateService.SelectedProductSeq.ValueChanged += StateHasChanged;
97 _stateService.EditPriceList.ValueChanged += StateHasChanged;
100 void IDisposable.Dispose()
102 _priceListViewService.DataChanged -= StateHasChanged;
103 _moduleViewService.DataChanged -= StateHasChanged;
104 _currencyViewService.DataChanged -= StateHasChanged;
106 _stateService.SelectedProductSeq.ValueChanged -= StateHasChanged;
107 _stateService.EditPriceList.ValueChanged -= StateHasChanged;