Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new category modal #265

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.8.9</AssemblyVersion>
<Version>2024.03.20.0114</Version>
<Version>2024.03.20.2043</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
4 changes: 3 additions & 1 deletion BLAZAMGui/UI/AppModal.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ protected override void OnInitialized()
if (Options == null)
Options = new();
}

/// <summary>
/// Re-renders the modal with the latest property values
/// </summary>
public void RefreshView()
{
InvokeAsync(StateHasChanged);
Expand Down
2 changes: 2 additions & 0 deletions BLAZAMGui/UI/Inputs/MudSelectList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
Class=@Class
OnClearButtonClick=@OnClearButtonClick
Adornment=@Adornment
AdornmentIcon=@AdornmentIcon
OnAdornmentClick="@OnAdornmentClick"
AutoFocus=@AutoFocus
Disabled=@Disabled
Clearable=@Clearable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@inherits AppModalContent
<MudForm>
<MudTextField T="string" @bind-Value=newCategory Validation="!newCategory.IsNullOrEmpty()"/>
</MudForm>
@code {
string newCategory;

[Parameter]
public IEnumerable<string> Categories { get; set; }

[Parameter]
public EventCallback<string> CategoryAdded{ get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
Modal.OnYes = Submit;
Modal.YesText = AppLocalization["Add"];
Modal.RefreshView();
}
private async void Submit()
{
if (Categories.Contains(newCategory))
{
SnackBarService.Warning(AppLocalization["A category with that name already exists."]);
}
CategoryAdded.InvokeAsync(newCategory);

Close();
}
}
211 changes: 108 additions & 103 deletions BLAZAMGui/UI/Settings/Templates/EditDirectoryTemplate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,84 @@
<CascadingValue Value="DirectoryTemplate">
<MudStack>
<MudText Class="mt-5" Typo="Typo.h6">@AppLocalization["Current Template:"] @originalTemplate.Name</MudText>
<MudSelectList T="DirectoryTemplate"
AnchorOrigin="Origin.BottomCenter"
TransformOrigin="Origin.TopCenter"
FullWidth=true
HelperText="@(dropdownTemplates.IsNullOrEmpty()?"There are no other templates":null)"
Disabled=@(dropdownTemplates.IsNullOrEmpty())
Clearable=true
OnClearButtonClick="@(async()=>{
<MudSelectList T="DirectoryTemplate"
AnchorOrigin="Origin.BottomCenter"
TransformOrigin="Origin.TopCenter"
FullWidth=true
HelperText="@(dropdownTemplates.IsNullOrEmpty()?"There are no other templates":null)"
Disabled=@(dropdownTemplates.IsNullOrEmpty())
Clearable=true
OnClearButtonClick="@(async()=>{
await ParentTemplateChanged(null);
})"
Label="Parent Template"
Values="@dropdownTemplates.OrderBy(t=>t.Name)"
Value="@DirectoryTemplate.ParentTemplate"
ValueChanged="@ParentTemplateChanged" />


<MudTextField Label="@AppLocalization["Template Name"]"
@bind-Value=DirectoryTemplate.Name />


<MudSelectList T="string"
AnchorOrigin="Origin.BottomCenter"
TransformOrigin="Origin.TopCenter"
Clearable=true
Adornment="Adornment.End"
AdornmentIcon="@Icons.Material.Filled.Add"
AdornmentColor="@Color.Success"
OnAdornmentClick="@(()=>{ })"
Values="categories.OrderBy(t=>t)"
ValueChanged="@((value)=>{DirectoryTemplate.Category=value;})"
@bind-Text=DirectoryTemplate.Category
Label="@AppLocalization["Template Category"]" />

<MudSwitch Label="@AppLocalization["Visible"]"
Color="@(DirectoryTemplate.Visible==true?Color.Success:Color.Warning)"
@bind-Value=@DirectoryTemplate.Visible />
<MudExpansionPanel Text="Variables">
Label="Parent Template"
Values="@dropdownTemplates.OrderBy(t=>t.Name)"
Value="@DirectoryTemplate.ParentTemplate"
ValueChanged="@ParentTemplateChanged" />


<MudTextField Label="@AppLocalization["Template Name"]"
@bind-Value=DirectoryTemplate.Name />


<MudSelectList T="string"
AnchorOrigin="Origin.BottomCenter"
TransformOrigin="Origin.TopCenter"
Clearable=true
Adornment="Adornment.End"
AdornmentIcon="@Icons.Material.Filled.Add"
AdornmentColor="@Color.Success"
OnAdornmentClick="@(()=>{categoryModal.Show();})"
Values="categories.OrderBy(t=>t)"
ValueChanged="@((value)=>{DirectoryTemplate.Category=value;})"
@bind-Text=DirectoryTemplate.Category
Label="@AppLocalization["Template Category"]" />
<AppModal @ref=categoryModal Title=@AppLocalization["Add Category"]>
<AddTemplateCategoryModalContent Categories="@categories"
CategoryAdded="@(async(newCategory)=>{DirectoryTemplate.Category=newCategory; categories.Add(newCategory); await InvokeAsync(StateHasChanged);})" />
</AppModal>
<MudSwitch Label="@AppLocalization["Visible"]"
Color="@(DirectoryTemplate.Visible==true?Color.Success:Color.Warning)"
@bind-Value=@DirectoryTemplate.Visible />
<MudExpansionPanel Text="Variables">

<MudStack Row=true>
<code>{fn}</code>:First Name<br />
</MudStack>
<MudStack Row=true>
<MudStack Row=true>
<code>{fn}</code>:First Name<br />
</MudStack>
<MudStack Row=true>

<code>{fi}</code>:First Initial<br />
</MudStack>
<MudStack Row=true>
<code>{mn}</code>:Middle Name<br />
</MudStack>
<MudStack Row=true>
<code>{mi}</code>:Middle Initial<br />
</MudStack>
<MudStack Row=true>
<code>{ln}</code>:Last Name<br />
</MudStack>
<MudStack Row=true>
<code>{li}</code>:Last Initial<br />
</MudStack>
<MudStack Row=true>
<code>{username}</code>:Username<br />
</MudStack>
<MudStack Row=true>
<code>{AlphaNum[u/l]}</code>:Random letter or number (optional force uppercase/lowercase)<br />
</MudStack>
<MudStack Row=true>
<code>{Alpha[u/l]}</code>:Random letter (optional force uppercase/lowercase)<br />
</MudStack>
<MudStack Row=true>
<code>{Num}</code>:Random number<br />
<code>{fi}</code>:First Initial<br />
</MudStack>
<MudStack Row=true>
<code>{mn}</code>:Middle Name<br />
</MudStack>
<MudStack Row=true>
<code>{mi}</code>:Middle Initial<br />
</MudStack>
<MudStack Row=true>
<code>{ln}</code>:Last Name<br />
</MudStack>
<MudStack Row=true>
<code>{li}</code>:Last Initial<br />
</MudStack>
<MudStack Row=true>
<code>{username}</code>:Username<br />
</MudStack>
<MudStack Row=true>
<code>{AlphaNum[u/l]}</code>:Random letter or number (optional force uppercase/lowercase)<br />
</MudStack>
<MudStack Row=true>
<code>{Alpha[u/l]}</code>:Random letter (optional force uppercase/lowercase)<br />
</MudStack>
<MudStack Row=true>
<code>{Num}</code>:Random number<br />

</MudStack>
</MudExpansionPanel>
<Section Title=@AppLocalization["Account and Name"]>
</MudStack>
</MudExpansionPanel>
<Section Title=@AppLocalization["Account and Name"]>

<MudStack>
@{
<MudStack>
@{
var usernameFromTemplate = GetParentOfValue(DirectoryTemplate.EffectiveUsernameFormula, template => template.UsernameFormula);
var displayNameFromTemplateName = GetParentOfValue(DirectoryTemplate.EffectiveDisplayNameFormula, template => template.DisplayNameFormula);
var passwordFromTemplateName = GetParentOfValue(DirectoryTemplate.EffectivePasswordFormula, template => template.PasswordFormula); ;
Expand Down Expand Up @@ -173,7 +176,7 @@ await ParentTemplateChanged(null);
}
})>
<MudText Color="Color.Tertiary">@field.DisplayName</MudText>
</MudButton>
</MudButton>

}

Expand Down Expand Up @@ -206,38 +209,38 @@ await ParentTemplateChanged(null);
<TemplateOverride SourceTemplate="@fromTemplateName">
<MudText>@cellContext.Item.FieldDisplayName</MudText>

</TemplateOverride>


</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="Value">
<CellTemplate Context="cellContext">
<MudTextField T=string Value=cellContext.Item.Value
ValueChanged=@((newValue)=>{ValueChanged(newValue,cellContext.Item);}) />

</CellTemplate>
</TemplateColumn>
<TemplateColumn Title=@AppLocalization["Editable"]>
<CellTemplate Context="cellContext">
<MudCheckBox T=bool
Value=cellContext.Item.Editable
ValueChanged="@((newValue)=>{EditableChanged(newValue,cellContext.Item);})" />

</CellTemplate>
</TemplateColumn>
<TemplateColumn Title=@AppLocalization["Required"]>
<CellTemplate Context="cellContext">
<MudCheckBox T=bool
Value=cellContext.Item.Required
ValueChanged="@((newValue)=>{RequiredChanged(newValue,cellContext.Item);})"
Disabled=@(!cellContext.Item.Editable) />

</CellTemplate>
</TemplateColumn>
<TemplateColumn>
<CellTemplate Context="cellContext">
@if (DirectoryTemplate.IsValueOverriden(cellContext.Item))
</TemplateOverride>


</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="Value">
<CellTemplate Context="cellContext">
<MudTextField T=string Value=cellContext.Item.Value
ValueChanged=@((newValue)=>{ValueChanged(newValue,cellContext.Item);}) />

</CellTemplate>
</TemplateColumn>
<TemplateColumn Title=@AppLocalization["Editable"]>
<CellTemplate Context="cellContext">
<MudCheckBox T=bool
Value=cellContext.Item.Editable
ValueChanged="@((newValue)=>{EditableChanged(newValue,cellContext.Item);})" />

</CellTemplate>
</TemplateColumn>
<TemplateColumn Title=@AppLocalization["Required"]>
<CellTemplate Context="cellContext">
<MudCheckBox T=bool
Value=cellContext.Item.Required
ValueChanged="@((newValue)=>{RequiredChanged(newValue,cellContext.Item);})"
Disabled=@(!cellContext.Item.Editable) />

</CellTemplate>
</TemplateColumn>
<TemplateColumn>
<CellTemplate Context="cellContext">
@if (DirectoryTemplate.IsValueOverriden(cellContext.Item))
{
<RevertTemplateValueButton OnClick=@(async()=>{await RemoveField(cellContext.Item);}) />
}
Expand Down Expand Up @@ -327,7 +330,7 @@ await ParentTemplateChanged(null);
<MudButton Disabled=SaveDisabled
Color="Color.Success"
ButtonType="ButtonType.Submit">@buttonText</MudButton>
@if (DirectoryTemplate.Id == 0)
@if (DirectoryTemplate.Id == 0)
{
<MudButton Color="Color.Warning"
OnClick="@CancelNewTemplate">Cancel</MudButton>
Expand All @@ -345,6 +348,8 @@ await ParentTemplateChanged(null);
public SetHeader? Header { get; set; }
protected DirectoryTemplate originalTemplate;


AppModal? categoryModal;
protected string groupText;
protected bool fieldDrawerOpen;
protected List<IActiveDirectoryField> fields = new();
Expand Down
Loading