Skip to content

Instantly share code, notes, and snippets.

@rossvz
Created October 7, 2016 13:42
Show Gist options
  • Select an option

  • Save rossvz/ebee605035e2dd41fa07f4b5c8f0df73 to your computer and use it in GitHub Desktop.

Select an option

Save rossvz/ebee605035e2dd41fa07f4b5c8f0df73 to your computer and use it in GitHub Desktop.
adding tags and filter based on property
plan.products.forEach(function(prod){
if(prod.properties.topic.value){
prod.tags = [] 
prod.properties.topic.value.forEach(function(topic){
prod.tags.push({
filter: "Topic",
choice: topic,
active: true,
selected: false
})
})
}
})
var allTopics = []
plan.products.forEach(function(product){
product.tags.forEach(function(tag){
if(allTopics.indexOf(tag.choice) < 0){
allTopics.push(tag.choice)
}
})
})
plan.filters.push({
label:"Topic",
choices:[],
choiceCount: allTopics.length,
active:true
})
allTopics.forEach(function(topic){
plan.filters[0].choices.push({
filter: "Topic",
choice: topic,
active: true,
selected: false
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment