Feature/setup #54
29
.idea/.idea.HopFrame/.idea/workspace.xml
generated
29
.idea/.idea.HopFrame/.idea/workspace.xml
generated
@@ -9,11 +9,12 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="Added automatic relation mapping">
|
||||
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="Added creation/modification confirmation">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Config/PropertyConfig.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Config/PropertyConfig.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Services/Implementations/ContextExplorer.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Services/Implementations/ContextExplorer.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/Models/Post.cs" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/Models/Post.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/Models/User.cs" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/Models/User.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/Program.cs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -148,7 +149,7 @@
|
||||
<workItem from="1736875984621" duration="8464000" />
|
||||
<workItem from="1736884461354" duration="1075000" />
|
||||
<workItem from="1736962119221" duration="8119000" />
|
||||
<workItem from="1737021098746" duration="19408000" />
|
||||
<workItem from="1737021098746" duration="21001000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Added basic configuration">
|
||||
<option name="closed" value="true" />
|
||||
@@ -214,7 +215,23 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1737037853482</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="9" />
|
||||
<task id="LOCAL-00009" summary="Added property validation">
|
||||
<option name="closed" value="true" />
|
||||
<created>1737040612038</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1737040612038</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00010" summary="Added creation/modification confirmation">
|
||||
<option name="closed" value="true" />
|
||||
<created>1737040946489</created>
|
||||
<option name="number" value="00010" />
|
||||
<option name="presentableId" value="LOCAL-00010" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1737040946489</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="11" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -232,6 +249,8 @@
|
||||
<MESSAGE value="Added reload button and animation" />
|
||||
<MESSAGE value="Added relation picker dialog" />
|
||||
<MESSAGE value="Added automatic relation mapping" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Added automatic relation mapping" />
|
||||
<MESSAGE value="Added property validation" />
|
||||
<MESSAGE value="Added creation/modification confirmation" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Added creation/modification confirmation" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -13,7 +13,6 @@ public class PropertyConfig(PropertyInfo info, TableConfig table) {
|
||||
public PropertyInfo? DisplayedProperty { get; set; }
|
||||
public Func<object, string>? Formatter { get; set; }
|
||||
public Func<string, object>? Parser { get; set; }
|
||||
public Func<object>? Template { get; set; }
|
||||
public Func<object?, Task<IEnumerable<string>>>? Validator { get; set; }
|
||||
public bool Editable { get; set; } = true;
|
||||
public bool Creatable { get; set; } = true;
|
||||
@@ -61,11 +60,6 @@ public class PropertyConfig<TProp>(PropertyConfig config) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PropertyConfig<TProp> ValueTemplate(Func<TProp> template) {
|
||||
InnerConfig.Template = () => template.Invoke()!;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PropertyConfig<TProp> Editable(bool editable) {
|
||||
InnerConfig.Editable = editable;
|
||||
return this;
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
private bool _currentlyEditing;
|
||||
private ITableManager? _manager;
|
||||
private Dictionary<string, List<string>> _validationErrors = new();
|
||||
private readonly Dictionary<string, List<string>> _validationErrors = new();
|
||||
|
||||
protected override void OnInitialized() {
|
||||
_currentlyEditing = Content.CurrentObject is not null;
|
||||
@@ -150,24 +150,14 @@
|
||||
if (Content.CurrentObject is null) return default;
|
||||
var value = config.Info.GetValue(Content.CurrentObject);
|
||||
|
||||
var newlyGenerated = false;
|
||||
if (config.Info.PropertyType.IsDefaultValue(value) && config.Template is not null && !_currentlyEditing) {
|
||||
value = config.Template.Invoke();
|
||||
newlyGenerated = true;
|
||||
}
|
||||
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
if (config.Info.PropertyType == typeof(TValue))
|
||||
return (TValue)value;
|
||||
|
||||
if (typeof(TValue) == typeof(string)) {
|
||||
if (!newlyGenerated)
|
||||
return (TValue)(object)_manager!.DisplayProperty(Content.CurrentObject, config.Info, Content.Config);
|
||||
|
||||
return (TValue)(object)value.ToString()!;
|
||||
}
|
||||
if (typeof(TValue) == typeof(string))
|
||||
return (TValue)(object)_manager!.DisplayProperty(Content.CurrentObject, config.Info, Content.Config);
|
||||
|
||||
return (TValue)Convert.ChangeType(value, typeof(TValue));
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ public class Post {
|
||||
public required string Caption { get; set; }
|
||||
|
||||
public required string Content { get; set; }
|
||||
|
||||
|
||||
[ForeignKey("author")]
|
||||
public User? Author { get; set; }
|
||||
public virtual required User Author { get; set; }
|
||||
|
||||
public bool Published { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
|
||||
public DateOnly Created { get; set; }
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace HopFrame.Testing.Models;
|
||||
|
||||
public class User {
|
||||
[Key]
|
||||
public required Guid Id { get; init; }
|
||||
public required Guid Id { get; init; } = Guid.CreateVersion7();
|
||||
public required string Email { get; init; }
|
||||
public string? Username { get; set; }
|
||||
public string? Password { get; set; }
|
||||
|
||||
@@ -32,8 +32,7 @@ builder.Services.AddHopFrame(options => {
|
||||
.SetDisplayName("Last Name");
|
||||
|
||||
table.Property(u => u.Id)
|
||||
.Sortable(false)
|
||||
.ValueTemplate(Guid.CreateVersion7);
|
||||
.Sortable(false);
|
||||
|
||||
table.SetDisplayName("Benutzer");
|
||||
});
|
||||
@@ -47,8 +46,7 @@ builder.Services.AddHopFrame(options => {
|
||||
.SetDisplayName("ID");
|
||||
|
||||
context.Table<Post>()
|
||||
.Property(p => p.CreatedAt)
|
||||
.ValueTemplate(() => DateTime.UtcNow);
|
||||
.Property(p => p.CreatedAt);
|
||||
|
||||
context.Table<Post>()
|
||||
.Property(p => p.Caption)
|
||||
|
||||
Reference in New Issue
Block a user