Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove content type sorting constraint #58

Merged
merged 3 commits into from
Dec 21, 2021
Merged

Conversation

pxska
Copy link
Contributor

@pxska pxska commented Dec 20, 2021

  • Remove sorting by content type.
  • Sort assets in manifest.

Closes #56. Closes #57.

- Also if the content type doesn't exist in the given preferred_order
variable, put the layout at the end of the manifest
@pxska pxska requested a review from tanelj December 20, 2021 07:39
@pxska pxska self-assigned this Dec 20, 2021
@tambeta tambeta self-requested a review December 20, 2021 08:18

layouts.sort do |a, b|
preferred_order.index(a.fetch('content_type')) <=> preferred_order.index(b.fetch('content_type'))
(preferred_order.index(a.fetch('content_type')) <=> preferred_order.index(b.fetch('content_type'))) || 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See ei tööta PR kirjelduses välja reklaamitud kujul (eeldan, et pead siin silmas layouts struktuuri lõppu sorteerimist):

Additionally, if the content type doesn't exist in the given preferred_order array, sort the layout to the end of the manifest.json file.

Nt konstrueerides struktuur:

layouts = [
  {                                  
    "content_type" => "product",     
  },                                 
  {                                  
    "content_type" => "page",        
  },                                 
  {                                  
    "content_type" => "blog_article",
  },                                 
  {                                  
    "content_type" => "blog",        
  },                                 
  {                                  
    "content_type" => "ding",
  },                                 
  {                                  
    "content_type" => "dong",        
  },                                 
]                                    

on tulemus:

  "layouts": [
    {
      "content_type": "ding"
    },
    {
      "content_type": "dong"
    },
    {
      "content_type": "page"
    },
    {
      "content_type": "blog"
    },
    {
      "content_type": "blog_article"
    },
    {
      "content_type": "product"
    }
  ]

Peaks olema:

Suggested change
(preferred_order.index(a.fetch('content_type')) <=> preferred_order.index(b.fetch('content_type'))) || 1
type_index = ->(e) { preferred_order.index(e['content_type']) || Float::INFINITY }
layouts.sort { |a, b| type_index[a] <=> type_index[b] }

Ühtlasi peaks see meetod private olema.

@pxska pxska changed the title Add "product" and "category" content types Remove content type sorting constraint Dec 20, 2021
@pxska pxska requested review from tambeta and tanelj December 20, 2021 14:34
lib/voog/dtk/filemanager.rb Outdated Show resolved Hide resolved
@pxska pxska requested a review from tambeta December 21, 2021 06:14
@tanelj tanelj merged commit 2f16c38 into master Dec 21, 2021
@tanelj tanelj deleted the 56_add_new_content_types branch December 21, 2021 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants