@@ -173,11 +173,6 @@
{
this.compact = !this.compact;
localStorage.setItem(compactCacheKey, this.compact.toString());
- },
-
- openSearch()
- {
- //EventHub.$emit('app.search.open');
}
}
});
diff --git a/zero.Backoffice.UI/old_app/app.vue b/zero.Backoffice.UI/old_app/app.vue
index 513dd115..1f92b099 100644
--- a/zero.Backoffice.UI/old_app/app.vue
+++ b/zero.Backoffice.UI/old_app/app.vue
@@ -68,7 +68,7 @@
this.rerender();
});
- EventHub.$on('app.search.open', () =>
+ this.zero.events.on('app.search.open', () =>
{
this.search();
});
diff --git a/zero.Core/Pages/ZeroPageModule.cs b/zero.Core/Pages/ZeroPageModule.cs
index e6b5ef6f..52932a3d 100644
--- a/zero.Core/Pages/ZeroPageModule.cs
+++ b/zero.Core/Pages/ZeroPageModule.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using zero.Search;
namespace zero.Pages;
@@ -32,5 +33,18 @@ internal class ZeroPageModule : ZeroModule
cfg.Add
(Constants.Pages.FolderAlias, "@page.folder.name", "@page.folder.description", "fth-folder");
});
});
+
+ services.Configure(opts =>
+ {
+ opts.Map().Display((x, res, opts) =>
+ {
+ FlavorConfig flavor = opts.For().Get(x.Flavor);
+ if (flavor != null)
+ {
+ res.Icon = flavor.Icon;
+ }
+ res.Url = "/pages/edit/" + x.Id;
+ });
+ });
}
}
\ No newline at end of file
diff --git a/zero.Api/Endpoints/Search/Indexes/zero_Backoffice_Search.cs b/zero.Core/Search/Indexes/zero_Search.cs
similarity index 72%
rename from zero.Api/Endpoints/Search/Indexes/zero_Backoffice_Search.cs
rename to zero.Core/Search/Indexes/zero_Search.cs
index b5bfbe4f..df05089c 100644
--- a/zero.Api/Endpoints/Search/Indexes/zero_Backoffice_Search.cs
+++ b/zero.Core/Search/Indexes/zero_Search.cs
@@ -1,14 +1,14 @@
using Raven.Client.Documents;
-namespace zero.Api.Endpoints.Search;
+namespace zero.Search;
-public class zero_Backoffice_Search : ZeroJavascriptIndex
+public class zero_Search : ZeroJavascriptIndex
{
public override void Setup(IZeroOptions options, IDocumentStore store)
{
// TODO index.Conventions is null, but needed for collection name retrieval
- foreach (var map in options.For())
+ foreach (var map in options.For())
{
Maps.Add(map.BuildInstruction(store));
}
diff --git a/zero.Api/Endpoints/Search/Models/SearchIndexMap.cs b/zero.Core/Search/Models/SearchIndexMap.cs
similarity index 96%
rename from zero.Api/Endpoints/Search/Models/SearchIndexMap.cs
rename to zero.Core/Search/Models/SearchIndexMap.cs
index bc1f9c63..997a401e 100644
--- a/zero.Api/Endpoints/Search/Models/SearchIndexMap.cs
+++ b/zero.Core/Search/Models/SearchIndexMap.cs
@@ -1,6 +1,6 @@
using Raven.Client.Documents;
-namespace zero.Api.Endpoints.Search;
+namespace zero.Search;
public class SearchIndexMap
{
@@ -66,7 +66,7 @@ public class SearchIndexMap : SearchIndexMap where T : ZeroEntity
{
internal SearchIndexMap(string icon = null) : base(typeof(T), icon) { }
- public SearchIndexMap Icon(string icon)
+ public virtual SearchIndexMap Icon(string icon)
{
_Icon = icon;
return this;
diff --git a/zero.Api/Endpoints/Search/Models/SearchResult.cs b/zero.Core/Search/Models/SearchResult.cs
similarity index 93%
rename from zero.Api/Endpoints/Search/Models/SearchResult.cs
rename to zero.Core/Search/Models/SearchResult.cs
index 0536a3c4..7f4cd64f 100644
--- a/zero.Api/Endpoints/Search/Models/SearchResult.cs
+++ b/zero.Core/Search/Models/SearchResult.cs
@@ -1,4 +1,4 @@
-namespace zero.Api.Endpoints.Search;
+namespace zero.Search;
public class SearchResult
{
diff --git a/zero.Api/Endpoints/Search/SearchService.cs b/zero.Core/Search/SearchService.cs
similarity index 92%
rename from zero.Api/Endpoints/Search/SearchService.cs
rename to zero.Core/Search/SearchService.cs
index ab211af3..9dba36b6 100644
--- a/zero.Api/Endpoints/Search/SearchService.cs
+++ b/zero.Core/Search/SearchService.cs
@@ -2,7 +2,7 @@
using Raven.Client.Documents.Queries;
using Raven.Client.Documents.Session;
-namespace zero.Api.Endpoints.Search;
+namespace zero.Search;
public class SearchService : ISearchService
{
@@ -25,7 +25,7 @@ public class SearchService : ISearchService
return "*" + x + "*";
}).ToArray();
- List results = await Store.Session().Query()
+ List results = await Store.Session().Query()
.Statistics(out QueryStatistics stats)
.Search(x => x.Name, searchParts, 2, @operator: SearchOperator.And)
.Search(x => x.Fields, searchParts, 1, Raven.Client.Documents.SearchOptions.Or, @operator: SearchOperator.And)
@@ -35,7 +35,7 @@ public class SearchService : ISearchService
List items = new();
- IEnumerable maps = Options.For();
+ IEnumerable maps = Options.For();
foreach (ZeroEntity result in results)
{
diff --git a/zero.Core/Search/ZeroSearchModule.cs b/zero.Core/Search/ZeroSearchModule.cs
new file mode 100644
index 00000000..c424dca6
--- /dev/null
+++ b/zero.Core/Search/ZeroSearchModule.cs
@@ -0,0 +1,19 @@
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace zero.Search;
+
+internal class ZeroSearchModule : ZeroModule
+{
+ public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
+ {
+ services.AddScoped();
+
+ services.Configure(opts =>
+ {
+ opts.Indexes.Add();
+ });
+
+ services.AddOptions().Bind(configuration.GetSection("Zero:Search"));
+ }
+}
\ No newline at end of file
diff --git a/zero.Api/Endpoints/Search/SearchOptions.cs b/zero.Core/Search/ZeroSearchOptions.cs
similarity index 68%
rename from zero.Api/Endpoints/Search/SearchOptions.cs
rename to zero.Core/Search/ZeroSearchOptions.cs
index 7fb7098e..01a93ae8 100644
--- a/zero.Api/Endpoints/Search/SearchOptions.cs
+++ b/zero.Core/Search/ZeroSearchOptions.cs
@@ -1,6 +1,6 @@
-namespace zero.Api.Endpoints.Search;
+namespace zero.Search;
-public class SearchOptions : List
+public class ZeroSearchOptions : List
{
public bool Enabled { get; set; }
diff --git a/zero.Core/Usings.cs b/zero.Core/Usings.cs
index 9fc55ec8..34318fee 100644
--- a/zero.Core/Usings.cs
+++ b/zero.Core/Usings.cs
@@ -26,4 +26,5 @@ global using zero.Routing;
global using zero.Stores;
global using zero.Spaces;
global using zero.Utils;
-global using zero.Validation;
\ No newline at end of file
+global using zero.Validation;
+global using zero.Search;
\ No newline at end of file
diff --git a/zero.Core/ZeroBuilder.cs b/zero.Core/ZeroBuilder.cs
index 1892ecba..e4e4cc1c 100644
--- a/zero.Core/ZeroBuilder.cs
+++ b/zero.Core/ZeroBuilder.cs
@@ -56,6 +56,7 @@ public class ZeroBuilder
Modules.Add();
Modules.Add();
Modules.Add();
+ Modules.Add();
Modules.ConfigureServices(services, configuration);