Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Feature Request: Custom Sorting for Features on Pricing Table #6713


User avatar
0
alexanderpilhar created

6.8.0, Angular, .NET Framework

I think it would be good to have a simple way to define sorting on the public pricing table page.

Right now sorting is done in alphabetic order based on feature names. But this might not always make sense (which is why I have to use a prefix ... and that's not so beautiful ...)

I suggest something like an additional property for FeatureMetadata, e.g.: public int SortIndex { get; set; } Prioritize this property for sorting if set and sort the rest in alphabetic order if not set (or value is 0). And if some values are the same, also use alphabetic order.

What do you think about it?


3 Answer(s)
  • User Avatar
    0
    alexanderpilhar created

    I just found a question by @vladsd asking for something similar: [Extending feature properties #4618](https://support.aspnetzero.com/QA/Questions/4618)

  • User Avatar
    0
    ismcagdas created
    Support Team

    @alexanderpilhar did that work for you ?

  • User Avatar
    0
    alexanderpilhar created

    @ismcagdas yes, that gave me the right hints on what to do!

    In case somebody else wants to implement sorting or ASPNETZERO team decides to implement it:

    1. Add the following property to FeatureMetadata.cs and FlatFeatureSelectDto.cs: public int? SortIndex { get; set; }
    2. Edit CustomDtoMapper.cs:
      1. Add class (see: Before and After Map Action):
      public class MapFeatureSortIndexAction : IMappingAction<Feature, FlatFeatureSelectDto>
      {
          public void Process(Feature source, FlatFeatureSelectDto destination)
          {
              destination.SortIndex = (source[FeatureMetadata.CustomFeatureKey] as FeatureMetadata)?.SortIndex;
          }
      }
      
      1. Change configuration.CreateMap<FlatFeatureSelectDto, Feature>().ReverseMap(); to configuration.CreateMap<FlatFeatureSelectDto, Feature>().ReverseMap().AfterMap<MapFeatureSortIndexAction>();
    3. Edit TenantRegistrationAppService.cs:
    public async Task<EditionsSelectOutput> GetEditionsForSelect()
    {
        ...
        var flatFeatures = ObjectMapper
            .Map<List<FlatFeatureSelectDto>>(features)
            .OrderByDescending(f => f.SortIndex.HasValue)
            .ThenBy(f => f.SortIndex)
            .ThenBy(f => f.DisplayName)
            .ToList();
       ...
    }
    

    Cheers!