1@using Escali.LicenseControl.Client.ViewModels
2@using Escali.LicenseControl.Client.ClientModels
4@inject ModuleViewModel _moduleViewService
6@inject StateService _stateService
8<EditForm Model="Module" OnValidSubmit="AddModule" OnInvalidSubmit="EventCallback.Empty">
9 <StandardModal Header="Ny modul" SubmitButtonName="Opprett modul" @ref="Modal" OnModalClosed="() => Module = new()">
11 <div class="create-modal-container">
12 <ObjectGraphDataAnnotationsValidator />
14 <div class="input-container form-floating mb-3">
15 <InputText @bind-Value="Module.ModuleName" type="text" class="form-control input-text" id="floatingInput" placeholder="Modulnavn" />
16 <label for="floatingInput">Modulnavn</label>
19 <div class="module-level-modal-list">
21 <h6 class="modal-header-second">Modulnivå</h6>
23 @foreach (var ml in Module.ModuleLevels)
25 <InputModuleLevel NewModuleLevel="ml" OnChange="OnModuleLevelChange" ChildConentAtLeft="false">
27 <button @onclick="() => Module.ModuleLevels.Remove(ml)" type="button" class="delete-module-level-button">
28 <img class="" src="Icons/add-icon.svg" alt=""/>
35 <button class="add-module-level-button" type="button" @onclick="() => Module.ModuleLevels.Add(new ModuleLevelClientModel())">
36 <img class="" src="Icons/add-icon-black.svg" alt=""/>
46<button class="btn btn-primary button-with-icon" @onclick="() => Modal.OpenModal()">
48 <img class="button-icon" src="Icons/add-icon.svg" alt=""/>
53 private StandardModal Modal;
55 private ModuleClientModel? Module
60 _module = _mapper.Map<ModuleClientModel>(value);
61 _module.ModuleLevels = _mapper.Map<List<ModuleLevelClientModel>>(value?.ModuleLevels);
65 private EventCallback<ChangeEventArgs> OnModuleLevelChange { get; set; }
67 private async Task AddModule()
69 Module!.ProductSeq = _stateService.SelectedProductSeq.Value;
70 var createdModule = await _moduleViewService.CreateModule(Module);
71 if (createdModule != null)
78 private ModuleClientModel? _module = new();