-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
67 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import MegaFilterCard from './components/MegaFilterCard.vue' | ||
import resourceStore from '@/store/resources' | ||
import { registerMixin } from './components/MegaFilter' | ||
|
||
Nova.booting((Vue, store) => { | ||
Nova.booting(app => { | ||
|
||
store.registerModule('mega-filter-store', resourceStore) | ||
const componentFn = app.component | ||
|
||
Vue.component('mega-filter-card', MegaFilterCard) | ||
app.component = function (name, component) { | ||
|
||
if (name === 'FilterMenu') { | ||
registerMixin(component) | ||
} | ||
|
||
return componentFn.call(this, name, component) | ||
|
||
} | ||
|
||
app.component('mega-filter-card', MegaFilterCard) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import reduce from 'lodash/reduce' | ||
|
||
export function filtersAreApplied(store, resourceName, filterFunction) { | ||
|
||
const filters = store.getters[ `${ resourceName }/filters` ].filter(filterFunction) | ||
|
||
return reduce(filters, (result, filter) => { | ||
const originalFilter = store.getters[ `${ resourceName }/getOriginalFilter` ](filter.class) | ||
const originalFilterCloneValue = JSON.stringify(originalFilter.currentValue) | ||
const currentFilterCloneValue = JSON.stringify(filter.currentValue) | ||
return currentFilterCloneValue === originalFilterCloneValue ? result : result + 1 | ||
}, 0) | ||
|
||
} | ||
|
||
export function withoutMegaFilter(filter) { | ||
return filter.megaFilter !== true | ||
} | ||
|
||
export function megaFilterOnly(filter) { | ||
return filter.megaFilter === true | ||
} | ||
|
||
export function registerMixin(component) { | ||
|
||
const filters = component.computed.filters | ||
|
||
component.computed.filters = function () { | ||
return filters.call(this).filter(withoutMegaFilter) | ||
} | ||
|
||
component.computed.activeFilterCount = function () { | ||
return filtersAreApplied(this.$store, this.resourceName, withoutMegaFilter) | ||
} | ||
|
||
component.computed.filtersAreApplied = function () { | ||
return this.activeFilterCount > 0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.