Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asva-vue-filters

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asva-vue-filters - npm Package Compare versions

Comparing version 0.3.3 to 1.0.0

48

mixins/child.js
import _ from 'lodash'
import Vue from 'vue'
export default{
data: function () {
data () {
return {

@@ -10,3 +11,5 @@ defaultValue: ''

props: {
value: {default: ''},
value: {
default: '',
},
name: {

@@ -16,9 +19,10 @@ type: String,

},
bus: {type: Vue},
id: {
default: function () {
default () {
var component_name = _.kebabCase(this.constructor.name);
if (component_name.substring(0, 3) === 'vm-')
component_name = component_name.substring(3)
return component_name + '-' + this._uid

@@ -32,16 +36,14 @@ },

},
created: function () {
ready () {
let self = this
this.bus.$on('set-filters', function (filters) {
console.log(filters)
self.setFilters(filters)
})
this.defaultValue = this.value
},
events: {
/*
* Key event is if 'set-filter'.
* Example is depicted in method setFilter.
* */
},
methods: {
showParentTheChange: function () {
this.$dispatch('filter-changed', this.getFilterObject())
},
getFilterObject: function () {
getFilterObject () {
var filter = {}

@@ -55,4 +57,4 @@ filter[this.name] = this.value

*/
setFilter (filter) {
if (!(this.name in filter)) {
setFilters (filters) {
if (!(this.name in filters)) {
this.value = this.defaultValue

@@ -62,6 +64,12 @@ return

this.value = filter[this.name]
this.showParentTheChange()
this.value = filters[this.name]
this.changed()
},
changed (){
this.bus.$emit('change', this.getFilterObject())
},
disabled (){
this.bus.$emit('disable', this.name)
}
}
}
import _ from 'lodash'
import Vue from 'vue'
import storage from './../libs/LocalStorage'

@@ -14,2 +15,3 @@

toUpdate: false,
bus: new Vue,
},

@@ -19,12 +21,2 @@ }

events: {
'filter-changed': function (filters) {
_.each(filters, function (value, key) {
this.$options.filters.data[key] = value
this.registerUpdate()
}.bind(this))
},
'filter-disabled': function (key) {
delete this.$options.filters.data[key]
this.registerUpdate()
},
// 'filters-formed' is triggered when filters are ready to be sent.

@@ -36,3 +28,3 @@ },

*/
ready: function () {
ready () {
// Override prototype property.

@@ -42,12 +34,25 @@ // Should be done for each component instance.

if (this.$options.filters.storageName === null) {
return
// Register listeners
let self = this
this.filters.bus.$on('change', function (filters) {
_.each(filters, function (value, key) {
self.$options.filters.data[key] = value
self.registerUpdate()
})
})
this.filters.bus.$on('disable', function (key) {
delete self.$options.filters.data[key]
self.registerUpdate()
})
// Inform children if we have filters to share.
if (this.$options.filters.storageName !== null) {
let savedFilters = storage.getValue(storageName)
this.filters.bus.$emit('set-filters', savedFilters)
this.registerUpdate()
}
this.$broadcast('set-filter', this.loadFilters())
return this.registerUpdate()
},
methods: {
setFilters: function () {
this.$broadcast('set-filter', this.$options.filters.data)
this.$broadcast('set-filters', this.$options.filters.data)
},

@@ -74,16 +79,19 @@ resetFilters: function () {

var filters = _.clone(this.$options.filters.data)
this.$emit('filters-formed', filters)
this.filtersFormed(filters)
}.bind(this), this.$options.filters.timeout)
},
loadFilters: function () {
return storage.getValue(this.$options.filters.storageName)
filtersFormed (){
console.warn('Override the "filtersFormed" method to get updates on filters change. Component name is: ' + this.constructor.name)
},
saveFilters: function () {
loadFilters () {
return
},
saveFilters () {
storage.setValue(this.$options.filters.storageName, this.$options.filters.data)
},
loadState: function (state) {
loadState (state) {
this.$options.filters.data = {}
this.$broadcast('set-filter', state)
this.filters.bus.$emit('set-filters', state)
},
},
}
{
"name": "asva-vue-filters",
"version": "0.3.3",
"version": "1.0.0",
"description": "Decoupled filter block for vue.js. Mixins and example components",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc