vue-instantsearch
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -0,1 +1,35 @@ | ||
<a name="0.6.0"></a> | ||
# [0.6.0](https://github.com/algolia/vue-instantsearch/compare/v0.5.0...v0.6.0) (2017-08-08) | ||
### Bug Fixes | ||
* **refinement-list:** remove duplicated class ([728314c](https://github.com/algolia/vue-instantsearch/commit/728314c)) | ||
* **sort-by-selector:** make SSR ready ([e50c38a](https://github.com/algolia/vue-instantsearch/commit/e50c38a)) | ||
* **store:** avoid mutating query parameters ([cb8cfb7](https://github.com/algolia/vue-instantsearch/commit/cb8cfb7)) | ||
* make all components SSR ready ([4db0720](https://github.com/algolia/vue-instantsearch/commit/4db0720)) | ||
### Features | ||
* **index:** add a prop to enable/disable cache ([268c0b6](https://github.com/algolia/vue-instantsearch/commit/268c0b6)) | ||
* **index:** add a prop to toggle auto search on load ([3c85017](https://github.com/algolia/vue-instantsearch/commit/3c85017)) | ||
* **store:** add methods to interact with cache ([98406fb](https://github.com/algolia/vue-instantsearch/commit/98406fb)) | ||
* **store:** do not automatically refresh when using start() ([cda198c](https://github.com/algolia/vue-instantsearch/commit/cda198c)) | ||
* **store:** do not register facet if already existing ([6370bd1](https://github.com/algolia/vue-instantsearch/commit/6370bd1)) | ||
### Performance Improvements | ||
* use unique keys in all v-for loops ([fdbf56a](https://github.com/algolia/vue-instantsearch/commit/fdbf56a)) | ||
### BREAKING CHANGES | ||
* **store:** using `store.start()` will no longer trigger an Algolia call. | ||
if you were using `store.stop()`/`store.start()` you should now | ||
also call `store.refresh()` if you want your store to stay in sync with Algolia. | ||
<a name="0.5.0"></a> | ||
@@ -2,0 +36,0 @@ # [0.5.0](https://github.com/algolia/vue-instantsearch/compare/v0.4.0...v0.5.0) (2017-08-05) |
@@ -11,3 +11,3 @@ 'use strict'; | ||
var version = "0.5.0"; | ||
var version = "0.6.0"; | ||
@@ -193,2 +193,4 @@ var serialize = function(helper) { | ||
this._cacheEnabled = true; | ||
this.algoliaHelper = helper; | ||
@@ -272,6 +274,2 @@ }; | ||
} | ||
if (this._stoppedCounter === 0) { | ||
this.refresh(); | ||
} | ||
}; | ||
@@ -344,3 +342,5 @@ | ||
assertValidFacetType(type); | ||
if (this.hasFacet(attribute, type)) { | ||
return; | ||
} | ||
@@ -371,2 +371,3 @@ this.stop(); | ||
this.start(); | ||
this.refresh(); | ||
}; | ||
@@ -390,2 +391,19 @@ | ||
Store.prototype.hasFacet = function hasFacet (attribute, type) { | ||
if ( type === void 0 ) type = FACET_AND; | ||
assertValidFacetType(type); | ||
switch (type) { | ||
case FACET_AND: | ||
return this._helper.state.isConjunctiveFacet(attribute); | ||
case FACET_OR: | ||
return this._helper.state.isDisjunctiveFacet(attribute); | ||
case FACET_TREE: | ||
return this._helper.state.isHierarchicalFacet(attribute); | ||
default: | ||
throw new TypeError((type + " could not be handled.")); | ||
} | ||
}; | ||
Store.prototype.addFacetRefinement = function addFacetRefinement (attribute, value) { | ||
@@ -462,18 +480,18 @@ if (this._helper.state.isConjunctiveFacet(attribute)) { | ||
/* eslint-disable no-param-reassign */ | ||
// Todo: this should be rewritten to be non-mutating method | ||
var params = Object.assign({}, parameters); | ||
this.stop(); | ||
for (var parameter in parameters) { | ||
if (parameters[parameter] === null) { | ||
parameters[parameter] = undefined; | ||
for (var parameter in params) { | ||
if (params[parameter] === null) { | ||
params[parameter] = undefined; | ||
} | ||
this$1._helper.setQueryParameter(parameter, parameters[parameter]); | ||
this$1._helper.setQueryParameter(parameter, params[parameter]); | ||
} | ||
// Make sure page starts at 1. | ||
if ('page' in parameters) { | ||
this.page = parameters.page; | ||
delete parameters.page; | ||
if ('page' in params) { | ||
this.page = params.page; | ||
delete params.page; | ||
} | ||
this.start(); | ||
this.refresh(); | ||
}; | ||
@@ -509,7 +527,24 @@ | ||
// Todo: find a better name for this function. | ||
Store.prototype.refresh = function refresh () { | ||
if (this._stoppedCounter !== 0) { | ||
return; | ||
} | ||
if (this._cacheEnabled === false) { | ||
this.clearCache(); | ||
} | ||
this._helper.search(); | ||
}; | ||
Store.prototype.enableCache = function enableCache () { | ||
this._cacheEnabled = true; | ||
}; | ||
Store.prototype.disableCache = function disableCache () { | ||
this._cacheEnabled = false; | ||
}; | ||
Store.prototype.clearCache = function clearCache () { | ||
this.algoliaClient.clearCache(); | ||
}; | ||
Store.prototype.waitUntilInSync = function waitUntilInSync () { | ||
@@ -550,5 +585,3 @@ var this$1 = this; | ||
var onHelperChange = function() { | ||
if (this._stoppedCounter === 0) { | ||
this.refresh(); | ||
} | ||
this.refresh(); | ||
}; | ||
@@ -655,3 +688,2 @@ | ||
default: function default$2$$1() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -667,3 +699,2 @@ return this._searchStore.algoliaApiKey; | ||
default: function default$3() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -679,3 +710,2 @@ return this._searchStore.algoliaAppId; | ||
default: function default$4() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -695,2 +725,10 @@ return this._searchStore.indexName; | ||
}, | ||
cache: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
autoSearch: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
@@ -710,3 +748,2 @@ data: function data() { | ||
this._localSearchStore = this.searchStore; | ||
// Todo: check if is started and stop it. | ||
} | ||
@@ -726,2 +763,8 @@ | ||
if (this.cache) { | ||
this._localSearchStore.enableCache(); | ||
} else { | ||
this._localSearchStore.disableCache(); | ||
} | ||
return { | ||
@@ -733,2 +776,5 @@ _searchStore: this._localSearchStore, | ||
this._localSearchStore.start(); | ||
if (this.autoSearch) { | ||
this._localSearchStore.refresh(); | ||
} | ||
}, | ||
@@ -833,2 +879,3 @@ watch: { | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}); | ||
@@ -840,3 +887,3 @@ }, | ||
var Results = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.results),function(result,key){return _vm._t("default",[_vm._v("Result 'objectID': "+_vm._s(result.objectID))],{result:result})}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var Results = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.results),function(result){return _vm._t("default",[_vm._v("Result 'objectID': "+_vm._s(result.objectID))],{result:result})}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -857,3 +904,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.updateResultsPerPage(); | ||
@@ -933,3 +980,3 @@ }, | ||
var Pagination = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.totalResults > 0),expression:"totalResults > 0"}],class:_vm.bem()},[_c('li',{class:[_vm.bem('item', 'first'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToFirstPage($event);}}},[_vm._t("first",[_vm._v("<<")])],2)]),_c('li',{class:[_vm.bem('item', 'previous'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPreviousPage($event);}}},[_vm._t("previous",[_vm._v("<")])],2)]),_vm._l((_vm.pages),function(item,key){return _c('li',{key:key,class:[_vm.bem('item'), _vm.page === item ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPage(item);}}},[_vm._t("default",[_vm._v(_vm._s(item))],{value:item,active:item === _vm.page})],2)])}),_c('li',{class:[_vm.bem('item', 'next'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToNextPage($event);}}},[_vm._t("next",[_vm._v(">")])],2)]),_c('li',{class:[_vm.bem('item', 'last'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToLastPage($event);}}},[_vm._t("last",[_vm._v(">>")])],2)])],2)},staticRenderFns: [], | ||
var Pagination = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.totalResults > 0),expression:"totalResults > 0"}],class:_vm.bem()},[_c('li',{class:[_vm.bem('item', 'first'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToFirstPage($event);}}},[_vm._t("first",[_vm._v("<<")])],2)]),_c('li',{class:[_vm.bem('item', 'previous'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPreviousPage($event);}}},[_vm._t("previous",[_vm._v("<")])],2)]),_vm._l((_vm.pages),function(item){return _c('li',{key:item,class:[_vm.bem('item'), _vm.page === item ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPage(item);}}},[_vm._t("default",[_vm._v(_vm._s(item))],{value:item,active:item === _vm.page})],2)])}),_c('li',{class:[_vm.bem('item', 'next'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToNextPage($event);}}},[_vm._t("next",[_vm._v(">")])],2)]),_c('li',{class:[_vm.bem('item', 'last'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToLastPage($event);}}},[_vm._t("last",[_vm._v(">>")])],2)])],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1017,3 +1064,3 @@ props: { | ||
var ResultsPerPageSelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.resultsPerPage),expression:"resultsPerPage"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.resultsPerPage=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.options),function(option,key){return [_c('option',{key:key,domProps:{"value":option}},[_vm._t("default",[_vm._v(_vm._s(option))],{option:option})],2)]})],2)},staticRenderFns: [], | ||
var ResultsPerPageSelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.resultsPerPage),expression:"resultsPerPage"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.resultsPerPage=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.options),function(option){return [_c('option',{key:option,domProps:{"value":option}},[_vm._t("default",[_vm._v(_vm._s(option))],{option:option})],2)]})],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1043,3 +1090,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
if (this.options.indexOf(this.searchStore.resultsPerPage) === -1) { | ||
@@ -1081,3 +1128,3 @@ this.searchStore.resultsPerPage = this.options[0]; | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet( | ||
@@ -1221,3 +1268,3 @@ { | ||
var SortBySelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.indexName),expression:"indexName"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.indexName=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.indices),function(index){return _vm._t("default",[_c('option',{domProps:{"value":index.name}},[_vm._v(_vm._s(index.label))])],{indexName:index.name,label:index.label})})],2)},staticRenderFns: [], | ||
var SortBySelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.indexName),expression:"indexName"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.indexName=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.indices),function(index){return _vm._t("default",[_c('option',{key:index.name,domProps:{"value":index.name}},[_vm._v(_vm._s(index.label))])],{indexName:index.name,label:index.label})})],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1245,3 +1292,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
var this$1 = this; | ||
@@ -1305,2 +1352,3 @@ | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1347,3 +1395,3 @@ }, | ||
var Rating = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),(_vm.currentValue)?_c('a',{class:_vm.bem('clear'),attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.clear($event);}}},[_vm._t("clear",[_vm._v("Clear")])],2):_vm._e(),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.toggleRefinement(facet);}}},[_vm._t("default",[_vm._l((_vm.max),function(n,key){return [(n <= facet.value)?_c('span',{key:key,class:_vm.bem('star')},[_vm._v("β ")]):_c('span',{key:key,class:_vm.bem('star', 'empty')},[_vm._v("β")])]}),_vm._v("Β & up "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{value:facet.value,min:_vm.min,max:_vm.max,count:facet.count})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var Rating = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),(_vm.currentValue)?_c('a',{class:_vm.bem('clear'),attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.clear($event);}}},[_vm._t("clear",[_vm._v("Clear")])],2):_vm._e(),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.toggleRefinement(facet);}}},[_vm._t("default",[_vm._l((_vm.max),function(n){return [(n <= facet.value)?_c('span',{key:n,class:_vm.bem('star')},[_vm._v("β ")]):_c('span',{key:n,class:_vm.bem('star', 'empty')},[_vm._v("β")])]}),_vm._v("Β & up "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{value:facet.value,min:_vm.min,max:_vm.max,count:facet.count})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1369,3 +1417,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet(this.attributeName, FACET_OR); | ||
@@ -1468,2 +1516,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
return undefined; | ||
@@ -1494,3 +1543,3 @@ }, | ||
var RefinementList = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('label',{class:_vm.bem('label')},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(facet.isRefined),expression:"facet.isRefined"}],class:_vm.bem('checkbox'),attrs:{"type":"checkbox"},domProps:{"value":facet.name,"checked":Array.isArray(facet.isRefined)?_vm._i(facet.isRefined,facet.name)>-1:(facet.isRefined)},on:{"change":function($event){_vm.toggleRefinement(facet);},"__c":function($event){var $$a=facet.isRefined,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=facet.name,$$i=_vm._i($$a,$$v);if($$c){$$i<0&&(facet.isRefined=$$a.concat($$v));}else{$$i>-1&&(facet.isRefined=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{facet.isRefined=$$c;}}}}),_vm._t("default",[_c('span',{class:_vm.bem('value')},[_vm._v(_vm._s(facet.name))]),_vm._v(" "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{count:facet.count,active:facet.isRefined,value:facet.name})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var RefinementList = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.facetValues),function(facet){return _c('div',{key:facet.name,class:facet.isRefined ? _vm.bem('item', 'active') : _vm.bem('item')},[_c('label',{class:_vm.bem('label')},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(facet.isRefined),expression:"facet.isRefined"}],class:_vm.bem('checkbox'),attrs:{"type":"checkbox"},domProps:{"value":facet.name,"checked":Array.isArray(facet.isRefined)?_vm._i(facet.isRefined,facet.name)>-1:(facet.isRefined)},on:{"change":function($event){_vm.toggleRefinement(facet);},"__c":function($event){var $$a=facet.isRefined,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=facet.name,$$i=_vm._i($$a,$$v);if($$c){$$i<0&&(facet.isRefined=$$a.concat($$v));}else{$$i>-1&&(facet.isRefined=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{facet.isRefined=$$c;}}}}),_vm._t("default",[_c('span',{class:_vm.bem('value')},[_vm._v(_vm._s(facet.name))]),_vm._v(" "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{count:facet.count,active:facet.isRefined,value:facet.name})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1526,3 +1575,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet(this.attributeName, this.operator); | ||
@@ -1629,2 +1678,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1662,2 +1712,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1664,0 +1715,0 @@ }, |
@@ -5,3 +5,3 @@ import algolia from 'algoliasearch/lite'; | ||
var version = "0.5.0"; | ||
var version = "0.6.0"; | ||
@@ -187,2 +187,4 @@ var serialize = function(helper) { | ||
this._cacheEnabled = true; | ||
this.algoliaHelper = helper; | ||
@@ -266,6 +268,2 @@ }; | ||
} | ||
if (this._stoppedCounter === 0) { | ||
this.refresh(); | ||
} | ||
}; | ||
@@ -338,3 +336,5 @@ | ||
assertValidFacetType(type); | ||
if (this.hasFacet(attribute, type)) { | ||
return; | ||
} | ||
@@ -365,2 +365,3 @@ this.stop(); | ||
this.start(); | ||
this.refresh(); | ||
}; | ||
@@ -384,2 +385,19 @@ | ||
Store.prototype.hasFacet = function hasFacet (attribute, type) { | ||
if ( type === void 0 ) type = FACET_AND; | ||
assertValidFacetType(type); | ||
switch (type) { | ||
case FACET_AND: | ||
return this._helper.state.isConjunctiveFacet(attribute); | ||
case FACET_OR: | ||
return this._helper.state.isDisjunctiveFacet(attribute); | ||
case FACET_TREE: | ||
return this._helper.state.isHierarchicalFacet(attribute); | ||
default: | ||
throw new TypeError((type + " could not be handled.")); | ||
} | ||
}; | ||
Store.prototype.addFacetRefinement = function addFacetRefinement (attribute, value) { | ||
@@ -456,18 +474,18 @@ if (this._helper.state.isConjunctiveFacet(attribute)) { | ||
/* eslint-disable no-param-reassign */ | ||
// Todo: this should be rewritten to be non-mutating method | ||
var params = Object.assign({}, parameters); | ||
this.stop(); | ||
for (var parameter in parameters) { | ||
if (parameters[parameter] === null) { | ||
parameters[parameter] = undefined; | ||
for (var parameter in params) { | ||
if (params[parameter] === null) { | ||
params[parameter] = undefined; | ||
} | ||
this$1._helper.setQueryParameter(parameter, parameters[parameter]); | ||
this$1._helper.setQueryParameter(parameter, params[parameter]); | ||
} | ||
// Make sure page starts at 1. | ||
if ('page' in parameters) { | ||
this.page = parameters.page; | ||
delete parameters.page; | ||
if ('page' in params) { | ||
this.page = params.page; | ||
delete params.page; | ||
} | ||
this.start(); | ||
this.refresh(); | ||
}; | ||
@@ -503,7 +521,24 @@ | ||
// Todo: find a better name for this function. | ||
Store.prototype.refresh = function refresh () { | ||
if (this._stoppedCounter !== 0) { | ||
return; | ||
} | ||
if (this._cacheEnabled === false) { | ||
this.clearCache(); | ||
} | ||
this._helper.search(); | ||
}; | ||
Store.prototype.enableCache = function enableCache () { | ||
this._cacheEnabled = true; | ||
}; | ||
Store.prototype.disableCache = function disableCache () { | ||
this._cacheEnabled = false; | ||
}; | ||
Store.prototype.clearCache = function clearCache () { | ||
this.algoliaClient.clearCache(); | ||
}; | ||
Store.prototype.waitUntilInSync = function waitUntilInSync () { | ||
@@ -544,5 +579,3 @@ var this$1 = this; | ||
var onHelperChange = function() { | ||
if (this._stoppedCounter === 0) { | ||
this.refresh(); | ||
} | ||
this.refresh(); | ||
}; | ||
@@ -649,3 +682,2 @@ | ||
default: function default$2$$1() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -661,3 +693,2 @@ return this._searchStore.algoliaApiKey; | ||
default: function default$3() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -673,3 +704,2 @@ return this._searchStore.algoliaAppId; | ||
default: function default$4() { | ||
// Todo: add validator callback in case no search store is injected | ||
if (this._searchStore) { | ||
@@ -689,2 +719,10 @@ return this._searchStore.indexName; | ||
}, | ||
cache: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
autoSearch: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
@@ -704,3 +742,2 @@ data: function data() { | ||
this._localSearchStore = this.searchStore; | ||
// Todo: check if is started and stop it. | ||
} | ||
@@ -720,2 +757,8 @@ | ||
if (this.cache) { | ||
this._localSearchStore.enableCache(); | ||
} else { | ||
this._localSearchStore.disableCache(); | ||
} | ||
return { | ||
@@ -727,2 +770,5 @@ _searchStore: this._localSearchStore, | ||
this._localSearchStore.start(); | ||
if (this.autoSearch) { | ||
this._localSearchStore.refresh(); | ||
} | ||
}, | ||
@@ -827,2 +873,3 @@ watch: { | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}); | ||
@@ -834,3 +881,3 @@ }, | ||
var Results = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.results),function(result,key){return _vm._t("default",[_vm._v("Result 'objectID': "+_vm._s(result.objectID))],{result:result})}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var Results = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.results),function(result){return _vm._t("default",[_vm._v("Result 'objectID': "+_vm._s(result.objectID))],{result:result})}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -851,3 +898,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.updateResultsPerPage(); | ||
@@ -927,3 +974,3 @@ }, | ||
var Pagination = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.totalResults > 0),expression:"totalResults > 0"}],class:_vm.bem()},[_c('li',{class:[_vm.bem('item', 'first'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToFirstPage($event);}}},[_vm._t("first",[_vm._v("<<")])],2)]),_c('li',{class:[_vm.bem('item', 'previous'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPreviousPage($event);}}},[_vm._t("previous",[_vm._v("<")])],2)]),_vm._l((_vm.pages),function(item,key){return _c('li',{key:key,class:[_vm.bem('item'), _vm.page === item ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPage(item);}}},[_vm._t("default",[_vm._v(_vm._s(item))],{value:item,active:item === _vm.page})],2)])}),_c('li',{class:[_vm.bem('item', 'next'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToNextPage($event);}}},[_vm._t("next",[_vm._v(">")])],2)]),_c('li',{class:[_vm.bem('item', 'last'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToLastPage($event);}}},[_vm._t("last",[_vm._v(">>")])],2)])],2)},staticRenderFns: [], | ||
var Pagination = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.totalResults > 0),expression:"totalResults > 0"}],class:_vm.bem()},[_c('li',{class:[_vm.bem('item', 'first'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToFirstPage($event);}}},[_vm._t("first",[_vm._v("<<")])],2)]),_c('li',{class:[_vm.bem('item', 'previous'), _vm.page === 1 ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPreviousPage($event);}}},[_vm._t("previous",[_vm._v("<")])],2)]),_vm._l((_vm.pages),function(item){return _c('li',{key:item,class:[_vm.bem('item'), _vm.page === item ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToPage(item);}}},[_vm._t("default",[_vm._v(_vm._s(item))],{value:item,active:item === _vm.page})],2)])}),_c('li',{class:[_vm.bem('item', 'next'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToNextPage($event);}}},[_vm._t("next",[_vm._v(">")])],2)]),_c('li',{class:[_vm.bem('item', 'last'), _vm.page >= _vm.totalPages ? _vm.bem('item', 'disabled') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.goToLastPage($event);}}},[_vm._t("last",[_vm._v(">>")])],2)])],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1011,3 +1058,3 @@ props: { | ||
var ResultsPerPageSelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.resultsPerPage),expression:"resultsPerPage"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.resultsPerPage=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.options),function(option,key){return [_c('option',{key:key,domProps:{"value":option}},[_vm._t("default",[_vm._v(_vm._s(option))],{option:option})],2)]})],2)},staticRenderFns: [], | ||
var ResultsPerPageSelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.resultsPerPage),expression:"resultsPerPage"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.resultsPerPage=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.options),function(option){return [_c('option',{key:option,domProps:{"value":option}},[_vm._t("default",[_vm._v(_vm._s(option))],{option:option})],2)]})],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1037,3 +1084,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
if (this.options.indexOf(this.searchStore.resultsPerPage) === -1) { | ||
@@ -1075,3 +1122,3 @@ this.searchStore.resultsPerPage = this.options[0]; | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet( | ||
@@ -1215,3 +1262,3 @@ { | ||
var SortBySelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.indexName),expression:"indexName"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.indexName=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.indices),function(index){return _vm._t("default",[_c('option',{domProps:{"value":index.name}},[_vm._v(_vm._s(index.label))])],{indexName:index.name,label:index.label})})],2)},staticRenderFns: [], | ||
var SortBySelector = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.indexName),expression:"indexName"}],class:_vm.bem(),on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.indexName=$event.target.multiple ? $$selectedVal : $$selectedVal[0];}}},[_vm._l((_vm.indices),function(index){return _vm._t("default",[_c('option',{key:index.name,domProps:{"value":index.name}},[_vm._v(_vm._s(index.label))])],{indexName:index.name,label:index.label})})],2)},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1239,3 +1286,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
var this$1 = this; | ||
@@ -1299,2 +1346,3 @@ | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1341,3 +1389,3 @@ }, | ||
var Rating = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),(_vm.currentValue)?_c('a',{class:_vm.bem('clear'),attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.clear($event);}}},[_vm._t("clear",[_vm._v("Clear")])],2):_vm._e(),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.toggleRefinement(facet);}}},[_vm._t("default",[_vm._l((_vm.max),function(n,key){return [(n <= facet.value)?_c('span',{key:key,class:_vm.bem('star')},[_vm._v("β ")]):_c('span',{key:key,class:_vm.bem('star', 'empty')},[_vm._v("β")])]}),_vm._v("Β & up "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{value:facet.value,min:_vm.min,max:_vm.max,count:facet.count})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var Rating = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),(_vm.currentValue)?_c('a',{class:_vm.bem('clear'),attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.clear($event);}}},[_vm._t("clear",[_vm._v("Clear")])],2):_vm._e(),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('a',{attrs:{"href":"#"},on:{"click":function($event){$event.preventDefault();_vm.toggleRefinement(facet);}}},[_vm._t("default",[_vm._l((_vm.max),function(n){return [(n <= facet.value)?_c('span',{key:n,class:_vm.bem('star')},[_vm._v("β ")]):_c('span',{key:n,class:_vm.bem('star', 'empty')},[_vm._v("β")])]}),_vm._v("Β & up "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{value:facet.value,min:_vm.min,max:_vm.max,count:facet.count})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1363,3 +1411,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet(this.attributeName, FACET_OR); | ||
@@ -1462,2 +1510,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
return undefined; | ||
@@ -1488,3 +1537,3 @@ }, | ||
var RefinementList = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.facetValues),function(facet,key){return _c('div',{key:key,class:[_vm.bem('item'), facet.isRefined ? _vm.bem('item', 'active') : '']},[_c('label',{class:_vm.bem('label')},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(facet.isRefined),expression:"facet.isRefined"}],class:_vm.bem('checkbox'),attrs:{"type":"checkbox"},domProps:{"value":facet.name,"checked":Array.isArray(facet.isRefined)?_vm._i(facet.isRefined,facet.name)>-1:(facet.isRefined)},on:{"change":function($event){_vm.toggleRefinement(facet);},"__c":function($event){var $$a=facet.isRefined,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=facet.name,$$i=_vm._i($$a,$$v);if($$c){$$i<0&&(facet.isRefined=$$a.concat($$v));}else{$$i>-1&&(facet.isRefined=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{facet.isRefined=$$c;}}}}),_vm._t("default",[_c('span',{class:_vm.bem('value')},[_vm._v(_vm._s(facet.name))]),_vm._v(" "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{count:facet.count,active:facet.isRefined,value:facet.name})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
var RefinementList = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.show)?_c('div',{class:_vm.bem()},[_vm._t("header"),_vm._l((_vm.facetValues),function(facet){return _c('div',{key:facet.name,class:facet.isRefined ? _vm.bem('item', 'active') : _vm.bem('item')},[_c('label',{class:_vm.bem('label')},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(facet.isRefined),expression:"facet.isRefined"}],class:_vm.bem('checkbox'),attrs:{"type":"checkbox"},domProps:{"value":facet.name,"checked":Array.isArray(facet.isRefined)?_vm._i(facet.isRefined,facet.name)>-1:(facet.isRefined)},on:{"change":function($event){_vm.toggleRefinement(facet);},"__c":function($event){var $$a=facet.isRefined,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=facet.name,$$i=_vm._i($$a,$$v);if($$c){$$i<0&&(facet.isRefined=$$a.concat($$v));}else{$$i>-1&&(facet.isRefined=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{facet.isRefined=$$c;}}}}),_vm._t("default",[_c('span',{class:_vm.bem('value')},[_vm._v(_vm._s(facet.name))]),_vm._v(" "),_c('span',{class:_vm.bem('count')},[_vm._v(_vm._s(facet.count))])],{count:facet.count,active:facet.isRefined,value:facet.name})],2)])}),_vm._t("footer")],2):_vm._e()},staticRenderFns: [], | ||
mixins: [algoliaComponent], | ||
@@ -1520,3 +1569,3 @@ props: { | ||
}, | ||
mounted: function mounted() { | ||
created: function created() { | ||
this.searchStore.addFacet(this.attributeName, this.operator); | ||
@@ -1623,2 +1672,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1656,2 +1706,3 @@ }, | ||
this.searchStore.start(); | ||
this.searchStore.refresh(); | ||
}, | ||
@@ -1658,0 +1709,0 @@ }, |
@@ -19,3 +19,3 @@ { | ||
"license": "MIT", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"files": [ | ||
@@ -30,3 +30,2 @@ "dist" | ||
"build:cjs": "rollup -c ./build/rollup.cjs.config.js", | ||
"build:cjs:watch": "yarn run build:cjs -- -w", | ||
"build:es": "rollup -c ./build/rollup.es.config.js", | ||
@@ -38,4 +37,3 @@ "build:umd": "rollup -c ./build/rollup.umd.config.js", | ||
"docs:deploy": "cd docs && yarn && yarn deploy", | ||
"watch": "concurrently --raw --kill-others \"yarn run test:watch\" \"yarn run build:cjs:watch\"", | ||
"test": "yarn run build:cjs && yarn run lint && jest --verbose --coverage", | ||
"test": "yarn run lint && jest --verbose --coverage", | ||
"test:update": "jest --verbose --updateSnapshot", | ||
@@ -71,2 +69,3 @@ "test:watch": "jest --verbose --watchAll --notify", | ||
"jest-serializer-html": "^4.0.0", | ||
"jest-vue-preprocessor": "^1.1.0", | ||
"prettier": "^1.4.4", | ||
@@ -86,9 +85,14 @@ "rollup": "^0.41.5", | ||
"jest": { | ||
"collectCoverageFrom": [ | ||
"dist/vue-instantsearch.common.js" | ||
"moduleFileExtensions": [ | ||
"js", | ||
"vue" | ||
], | ||
"snapshotSerializers": [ | ||
"jest-serializer-html" | ||
] | ||
], | ||
"transform": { | ||
"^.+\\.js$": "<rootDir>/node_modules/babel-jest", | ||
".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor" | ||
} | ||
} | ||
} |
@@ -8,3 +8,4 @@ [![Vue InstantSearch logo][logo]][website] | ||
| [React InstantSearch][react-instantsearch-github] | ||
| [InstantSearch Android][instantsearch-android-github]. | ||
| [InstantSearch Android][instantsearch-android-github] | ||
| [InstantSearch iOS][instantsearch-ios-github]. | ||
@@ -47,1 +48,2 @@ ## Vue InstantSearch | ||
[instantsearch-android-github]: https://github.com/algolia/instantsearch-android | ||
[instantsearch-ios-github]: https://github.com/algolia/instantsearch-ios |
Sorry, the diff of this file is too big to display
321669
3911
48
27