search stuff
This commit is contained in:
@@ -29,5 +29,14 @@ internal class ZeroIdentityModule : ZeroModule
|
||||
.AddZeroBackofficeCookie<ZeroUser, ZeroUserRole>();
|
||||
|
||||
services.AddAuthorization();
|
||||
|
||||
services.Configure<ZeroSearchOptions>(opts =>
|
||||
{
|
||||
opts.Map<ZeroUser>("fth-user-check").Boost(5).Display((x, res) =>
|
||||
{
|
||||
res.Description = x.Email;
|
||||
res.Url = "/settings/users/edit/" + x.Id;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,22 @@ internal class ZeroLocalizationModule : ZeroModule
|
||||
services.AddScoped<IValidator<Country>, CountryValidator>();
|
||||
services.AddScoped<IValidator<Language>, LanguageValidator>();
|
||||
services.AddScoped<IValidator<Translation>, TranslationValidator>();
|
||||
|
||||
services.Configure<ZeroSearchOptions>(opts =>
|
||||
{
|
||||
opts.Map<Country>("fth-map-pin").Fields().Display((x, res) =>
|
||||
{
|
||||
res.Url = "/settings/countries/edit/" + x.Id;
|
||||
});
|
||||
opts.Map<Language>("fth-globe").Fields().Display((x, res) =>
|
||||
{
|
||||
res.Url = "/settings/languages/edit/" + x.Id;
|
||||
});
|
||||
opts.Map<Translation>("fth-type").Fields("Value").Display((x, res) =>
|
||||
{
|
||||
res.Description = x.Value;
|
||||
res.Url = "/settings/translations/edit/" + x.Id;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,14 @@ internal class ZeroMailModule : ZeroModule
|
||||
{
|
||||
opts.BuildViewPath = mail => $"~/Views/Mails/{mail.Template.Key.Replace('.', '/')}.cshtml";
|
||||
});
|
||||
|
||||
services.Configure<ZeroSearchOptions>(opts =>
|
||||
{
|
||||
opts.Map<MailTemplate>("fth-mail").Fields("Key").Display((x, res) =>
|
||||
{
|
||||
res.Description = x.Key;
|
||||
res.Url = "/settings/mailtemplates/edit/" + x.Id;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,14 @@ public class SearchIndexMap
|
||||
internal string _Icon;
|
||||
protected string _group;
|
||||
protected string[] _fields;
|
||||
protected float _boost = 0;
|
||||
protected Func<ZeroEntity, SearchResult, IZeroOptions, Task> _modify;
|
||||
|
||||
const string mapTemplate = @"map('{collection}', function (x) {
|
||||
return {
|
||||
Id: x.Id,
|
||||
Group: '{group}',
|
||||
Name: x.Name,
|
||||
Name: boost(x.Name, {boost}),
|
||||
IsActive: x.IsActive,
|
||||
Fields: [{fields}]
|
||||
};
|
||||
@@ -33,7 +34,8 @@ public class SearchIndexMap
|
||||
{
|
||||
{ "collection", store.Conventions.GetCollectionName(Type) },
|
||||
{ "group", _group },
|
||||
{ "fields", BuildFieldArray(_fields) }
|
||||
{ "fields", BuildFieldArray(_fields) },
|
||||
{ "boost", _boost.ToString() }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ public class SearchIndexMap
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
return "x." + String.Join(", x.", fields);
|
||||
return String.Join(", ", fields.Select(x => $"x.{x}")); //$"boost(x.{x}, {_boost})"));
|
||||
}
|
||||
|
||||
internal bool CanModify(Type type)
|
||||
@@ -109,4 +111,10 @@ public class SearchIndexMap<T> : SearchIndexMap where T : ZeroEntity
|
||||
_fields = fieldNames;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchIndexMap<T> Boost(float boostValue)
|
||||
{
|
||||
_boost = boostValue;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user