apostrophe-snippets
Advanced tools
Comparing version 0.0.32 to 0.0.33
34
index.js
@@ -1021,4 +1021,10 @@ var async = require('async'); | ||
if (typeof(fetch.tags) === 'object') { | ||
if (fetch.tags.only) { | ||
criteria.tags = fetch.tags.only; | ||
if (fetch.tags.only || fetch.tags.never) { | ||
criteria.tags = {}; | ||
if (fetch.tags.only) { | ||
criteria.tags.$in = fetch.tags.only; | ||
} | ||
if (fetch.tags.except) { | ||
criteria.tags.$nin = fetch.tags.except; | ||
} | ||
} | ||
@@ -1031,3 +1037,7 @@ } | ||
// Always restore any criteria we modified | ||
criteria.tags = saveTagCriteria; | ||
if (saveTagCriteria !== undefined) { | ||
criteria.tags = saveTagCriteria; | ||
} else { | ||
delete criteria.tags; | ||
} | ||
results.tags = tags; | ||
@@ -1217,6 +1227,13 @@ if (fetch.tags.always) { | ||
}; | ||
if (req.page.typeSettings && req.page.typeSettings.tags && req.page.typeSettings.tags.length) { | ||
criteria.tags = { $in: req.page.typeSettings.tags }; | ||
// This restriction also applies when fetching distinct tags | ||
options.fetch.tags = { only: req.page.typeSettings.tags }; | ||
if (req.page.typeSettings) { | ||
if (req.page.typeSettings.tags && req.page.typeSettings.tags.length) { | ||
options.tags = req.page.typeSettings.tags; | ||
// This restriction also applies when fetching distinct tags | ||
options.fetch.tags.only = req.page.typeSettings.tags; | ||
} | ||
if (req.page.typeSettings.notTags && req.page.typeSettings.notTags.length) { | ||
options.notTags = req.page.typeSettings.notTags; | ||
// This restriction also applies when fetching distinct tags | ||
options.fetch.tags.except = req.page.typeSettings.notTags; | ||
} | ||
} | ||
@@ -1228,3 +1245,3 @@ if (req.query.tag) { | ||
if (tag.length) { | ||
criteria.tags = { $in: [ tag ] }; | ||
options.tags = [ tag ]; | ||
// Always return the active tag as one of the filter choices even if | ||
@@ -1357,2 +1374,3 @@ // there are no results in this situation. Otherwise the user may not be | ||
ok.tags = self._apos.sanitizeTags(data.tags); | ||
ok.notTags = self._apos.sanitizeTags(data.notTags); | ||
return callback(null, ok); | ||
@@ -1359,0 +1377,0 @@ } |
{ | ||
"name": "apostrophe-snippets", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "Reusable content snippets for the Apostrophe content management system. The blog and events modules are built on this foundation, which is also useful in and of itself.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,7 +48,11 @@ // NOTES FOR REUSE: | ||
serialize: function($el, $details) { | ||
var data = { tags: apos.tagsToArray($details.find('[name="typeSettings[tags]"]').val()) }; | ||
var data = { | ||
tags: apos.tagsToArray($details.findByName("typeSettings[tags]").val()), | ||
notTags: apos.tagsToArray($details.findByName("typeSettings[notTags]").val()) | ||
}; | ||
return data; | ||
}, | ||
unserialize: function(data, $el, $details) { | ||
$details.find('[name="typeSettings[tags]"]').val(apos.tagsToString(data.tags)); | ||
$details.findByName("typeSettings[tags]").val(apos.tagsToString(data.tags)); | ||
$details.findByName("typeSettings[notTags]").val(apos.tagsToString(data.notTags)); | ||
} | ||
@@ -55,0 +59,0 @@ }; |
Sorry, the diff of this file is not supported yet
137169
1944
13