Skip to content

Commit

Permalink
Replaced content schema field selector
Browse files Browse the repository at this point in the history
  • Loading branch information
usercode committed Dec 20, 2022
1 parent f99d5ea commit 946bbbf
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public IEnumerable<Type> GetAllOptionsTypes()

public IEnumerable<Type> GetAllFieldTypes()
{
return _fieldByName.Select(x => x.Value).ToList();
return _fieldByName.Select(x => x.Value).OrderBy(x => x.Name).ToList();
}

public IEnumerable<Type> GetAllQueryTypes()
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/DragonFly.Core/Security/DefaultSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ namespace DragonFly.Security;
public class DefaultSecurity
{
public const string DefaultUsername = "admin";
public const string DefaultPassword = "#Password123";
public const string DefaultEmail = "info@domain.tld";
public const string DefaultPassword = "Password123";
}
2 changes: 1 addition & 1 deletion src/DragonFly.MongoDB/Proxies/ContentItemProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace DragonFly.MongoDB.Proxies;

public class ContentItemProxy
sealed class ContentItemProxy
{
internal static ProxyGenerator Generator = new ProxyGenerator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public static async Task UnpublishAsync<TContentModel>(this IContentStorage stor

action?.Invoke(query);

query.Skip = 0;
query.Top = 1;

QueryResult<ContentItem> result = await storage.QueryAsync(query);
Expand Down
76 changes: 59 additions & 17 deletions src/DragonFly.Razor/Pages/ContentSchemas/ContentFieldsView.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
<BSButton Color="BSColor.Light" class="add-field" OnClick="x => ShowModalDialog = true"><i class="fas fa-plus"></i> Add Field</BSButton>

<ModalWindow Show="ShowModalDialog" Closed="ItemAdded">
<ContentFieldSelector @ref="Selector">

</ContentFieldSelector>
</ModalWindow>
<BSButton Color="BSColor.Light" class="add-field" OnClick="x => OpenModalAsync()"><i class="fas fa-plus"></i> Add Field</BSButton>

<BSOffCanvas @ref="_offCanvas" Placement="Placement.Right">
<Header>Select block</Header>
<Content>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" @bind-value="@Name" />
</div>
</div>

<div class="form-group row">
<label class="col-sm-2 col-form-label">Type</label>
<div class="col-sm-10">
<div class="row">
@foreach (Type p in ContentFieldManager.Default.GetAllFieldTypes())
{
<div class="col-lg-12">
<BSButton OnClick="x => SelectedFieldType = p" Color="p == SelectedFieldType ? BSColor.Danger : BSColor.Light" style="width:100%; cursor:pointer;margin-bottom:1rem;">
<div class="text-start">
@p.Name
</div>
</BSButton>
</div>
}
</div>
</div>
</div>

<div class="mb-3">
<BSButton OnClick="()=> { _offCanvas.ToggleAsync(); AddItem(); }" Color="BSColor.Primary">Create field</BSButton>
</div>
</Content>
</BSOffCanvas>

<BSListGroup>
@foreach (var field in Schema.Fields.OrderBy(x => x.Value.SortKey))
Expand All @@ -14,27 +42,41 @@
</BSListGroup>

@code {
private BSOffCanvas _offCanvas;

[Parameter]
public ISchemaElement Schema { get; set; }

bool IsOpen { get; set; }

public ContentFieldSelector Selector { get; set; }
public string Name { get; set; }

public Type SelectedFieldType { get; set; }

public bool ShowModalDialog { get; set; }
public IEnumerable<Type> FieldTypes { get; private set; }

protected void ItemAdded(object sender, bool result)
protected async Task OpenModalAsync()
{
if (result)
{
var options = ContentFieldManager.Default.CreateOptions(Selector.ContentFieldType);
await _offCanvas.ToggleAsync();

Schema.Fields.Add(Selector.Name, new SchemaField(Selector.ContentFieldType.Name, options));
SelectedFieldType = FieldTypes.FirstOrDefault();
}

ShowModalDialog = false;
protected override void OnInitialized()
{
base.OnInitialized();

FieldTypes = ContentFieldManager.Default.GetAllFieldTypes();
}

protected void AddItem()
{
var options = ContentFieldManager.Default.CreateOptions(SelectedFieldType);

Schema.Fields.Add(Name, new SchemaField(SelectedFieldType.Name, options));

StateHasChanged();

StateHasChanged();
}
}

public void Up(string key)
Expand Down
39 changes: 0 additions & 39 deletions src/DragonFly.Razor/Shared/ContentFieldSelector.razor

This file was deleted.

10 changes: 1 addition & 9 deletions src/Template/templates/DragonFly.Server/DragonFly.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@
<ItemGroup>
<None Include="compilerconfig.json" />
<None Include="libman.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ImageWizard.Client" Version="3.7.4" />
<PackageReference Include="ImageWizard.Core" Version="3.7.4" />
<PackageReference Include="ImageWizard.ImageSharp" Version="3.7.4" />
<PackageReference Include="ImageWizard.OpenGraph" Version="3.7.4" />
<PackageReference Include="ImageWizard.SvgNet" Version="3.7.4" />
</ItemGroup>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DragonFly.API" Version="0.8.3" />
Expand Down

0 comments on commit 946bbbf

Please sign in to comment.