Skip to content

Commit

Permalink
Include IProperty with Algolia's index value converter
Browse files Browse the repository at this point in the history
  • Loading branch information
acoumb committed Apr 26, 2024
1 parent 3287f53 commit 65d09ab
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
{
/// <summary>
/// Defines a custom index converter.
Expand All @@ -13,6 +15,6 @@ public interface IAlgoliaIndexValueConverter
/// <summary>
/// Parses the index values.
/// </summary>
object ParseIndexValues(IEnumerable<object> indexValues);
object ParseIndexValues(IProperty property, IEnumerable<object> indexValues);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
{
public class UmbracoBooleanConverter : IAlgoliaIndexValueConverter
{
public string Name => Core.Constants.PropertyEditors.Aliases.Boolean;

public object ParseIndexValues(IEnumerable<object> indexValues)
public object ParseIndexValues(IProperty property, IEnumerable<object> indexValues)
{
if (indexValues != null && indexValues.Any())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
{
public class UmbracoDecimalConverter : IAlgoliaIndexValueConverter
{
public string Name => Core.Constants.PropertyEditors.Aliases.Decimal;

public object ParseIndexValues(IEnumerable<object> indexValues)
public object ParseIndexValues(IProperty property, IEnumerable<object> indexValues)
{
if (indexValues != null && indexValues.Any())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
{
public class UmbracoIntegerConverter : IAlgoliaIndexValueConverter
{
public string Name => Core.Constants.PropertyEditors.Aliases.Integer;

public object ParseIndexValues(IEnumerable<object> indexValues)
public object ParseIndexValues(IProperty property, IEnumerable<object> indexValues)
{
if (indexValues != null && indexValues.Any())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
Expand All @@ -11,7 +12,7 @@ public class UmbracoMediaPickerConverter : IAlgoliaIndexValueConverter

public string Name => Core.Constants.PropertyEditors.Aliases.MediaPicker3;

public object ParseIndexValues(IEnumerable<object> indexValues)
public object ParseIndexValues(IProperty property, IEnumerable<object> indexValues)
{
var list = new List<string>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Text.Json;
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Integrations.Search.Algolia.Converters
{
public class UmbracoTagsConverter : IAlgoliaIndexValueConverter
{
public string Name => Core.Constants.PropertyEditors.Aliases.Tags;

public object ParseIndexValues(IEnumerable<object> indexValues)
public object ParseIndexValues(IProperty property, IEnumerable<object> indexValues)
{
if (indexValues != null && indexValues.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class AlgoliaSearchPropertyIndexValueFactory : IAlgoliaSearchPropertyInde
var converter = _converterCollection.FirstOrDefault(p => p.Name == property.PropertyType.PropertyEditorAlias);
if (converter != null)
{
var result = converter.ParseIndexValues(indexValue.Value);
var result = converter.ParseIndexValues(property, indexValue.Value);
return new KeyValuePair<string, object>(property.Alias, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageIconUrl></PackageIconUrl>
<PackageProjectUrl>https://github.com/umbraco/Umbraco.Cms.Integrations/tree/main/src/Umbraco.Cms.Integrations.Search.Algolia</PackageProjectUrl>
<RepositoryUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</RepositoryUrl>
<Version>2.1.4</Version>
<Version>2.2.0</Version>
<Authors>Umbraco HQ</Authors>
<Company>Umbraco</Company>
<PackageTags>Umbraco;Umbraco-Marketplace</PackageTags>
Expand Down

0 comments on commit 65d09ab

Please sign in to comment.