Escali License control 1
PriceListTableCopy.razor
Gå til dokumentasjonen til denne filen.
1@inject PriceListViewModel _priceListViewService
2@inject ModuleViewModel _moduleViewService
3@inject StateService _stateService
4@inject CurrencyViewModel _currencyViewService
5@implements IDisposable
6
7<PriceListTableButtons />
8
9@if (_priceListViewService.PriceLists != null && _moduleViewService.Modules != null && _stateService.SelectedProductSeq != null)
10{
11
12 <TableNested
13 Items="_priceListViewService.PriceLists.Where(pl => pl.ProductSeq == _stateService.SelectedProductSeq.Value).ToList()"
14 >
15 <TableHeader>
16 <td>Prisliste</td>
17 <td></td>
18 <td></td>
19 </TableHeader>
20
21 <RowTemplate>
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>
27 </td>
28 </RowTemplate>
29
30 <ChildRowTemplate>
31
32 <NestedRows Items="_moduleViewService.Modules.Where(m => m.ProductSeq == _stateService.SelectedProductSeq.Value && m.ProductSeq == context.ProductSeq).ToList()">
33
34 <RowTemplate Context="moduleContext">
35 @if (context != null)
36 {
37 <td>@moduleContext.ModuleName</td>
38 <td></td>
39 <td></td>
40 <td></td>
41 }
42 </RowTemplate>
43
44 <ChildRowTemplate Context="moduleContext">
45 @if (moduleContext.ModuleLevels != null && moduleContext.ModuleLevels.Any() && context.PriceElements != null)
46 {
47 @foreach (var ml in moduleContext.ModuleLevels)
48 {
49 @if (context.PriceElements.Exists(pe => pe.ModuleLevelSeq == ml.ModuleLevelSeq && pe.IsActive == true))
50 {
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>
55 <td></td>
56 <td class="table-col-last"></td>
57 </tr>
58 }
59 }
60 }
61 </ChildRowTemplate>
62
63 </NestedRows>
64
65
66 </ChildRowTemplate>
67
68
69
70 </TableNested>
71
72 <EditPriceListModal />
73
74}
75
76@code {
77
78 private void OpenModal(PriceListClientModel priceList)
79 {
80 _stateService.UpdateEditPriceList(priceList);
81 }
82
83 private (string, Action)[] CreateDropdownOptions(PriceListClientModel context)
84 {
85 return new (string, Action)[] {
86 ("Oppdater prisliste", () => _stateService.EditPriceList.Value = context),
87 };
88 }
89
90 protected override void OnInitialized()
91 {
92 _priceListViewService.DataChanged += StateHasChanged;
93 _moduleViewService.DataChanged += StateHasChanged;
94 _currencyViewService.DataChanged += StateHasChanged;
95
96 _stateService.SelectedProductSeq.ValueChanged += StateHasChanged;
97 _stateService.EditPriceList.ValueChanged += StateHasChanged;
98 }
99
100 void IDisposable.Dispose()
101 {
102 _priceListViewService.DataChanged -= StateHasChanged;
103 _moduleViewService.DataChanged -= StateHasChanged;
104 _currencyViewService.DataChanged -= StateHasChanged;
105
106 _stateService.SelectedProductSeq.ValueChanged -= StateHasChanged;
107 _stateService.EditPriceList.ValueChanged -= StateHasChanged;
108 }
109
110}