-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It must register `vqb` module and not setup directly the store This fix allow us make the storybook of ListUniqueValues
- Loading branch information
raphael
committed
Apr 20, 2020
1 parent
6b3ddae
commit 2aede0e
Showing
2 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,55 @@ | ||
import { storiesOf } from '@storybook/vue'; | ||
import Vuex from 'vuex'; | ||
import Vue from 'vue'; | ||
|
||
import { ListUniqueValues } from '../dist/storybook/components'; | ||
import { ListUniqueValues, registerModule, VQBnamespace } from '../dist/storybook/components'; | ||
const stories = storiesOf('ListUniqueValues', module); | ||
Vue.use(Vuex) | ||
|
||
stories.add('default', () => ({ | ||
store: new Vuex.Store({}), | ||
created: function() { | ||
registerModule(this.$store, { | ||
dataset: { | ||
headers: [{name: 'col1', isUniqueValuesLoading: false}], | ||
data: [], | ||
} | ||
}); | ||
}, | ||
components: { ListUniqueValues }, | ||
methods: { | ||
loadAllValues(){ | ||
this.$store.commit(VQBnamespace('setUniqueValuesLoading'), { isLoading: true, column: 'col1' }); | ||
// simulate the call to get all unique values of dataset: | ||
setTimeout(() => { | ||
this.options = [ | ||
{value: 'Germany', count: 120}, | ||
{value: 'US', count: 34}, | ||
{value: 'Italy', count: 33}, | ||
{value: 'China', count: 24}, | ||
{value: 'France', count: 12}, | ||
{value: 'Framboise', count: 10}, | ||
{value: 'UK', count: 1}, | ||
]; | ||
this.loaded = false; | ||
this.$store.commit(VQBnamespace('setUniqueValuesLoading'), { isLoading: false, column: 'col1' }); | ||
}, 3000); // the call take 3sec | ||
} | ||
}, | ||
data(){ | ||
return { | ||
options: [ | ||
{value: 'France', count: 12}, | ||
{value: 'UK', count: 1}, | ||
{value: 'Italy', count: 23}, | ||
{value: 'China', count: 14}, | ||
{value: 'France', count: 12}, | ||
{value: 'Framboise', count: 10}, | ||
{value: 'Italy', count: 23}, | ||
{value: 'UK', count: 1}, | ||
], | ||
filter: { column: "col1", operator: "in", value: []}, | ||
loaded: false, | ||
loaded: true, | ||
} | ||
}, | ||
template: `<div><ListUniqueValues :loaded="loaded" :filter="filter" @input="filter = $event" :options="options"/></div>`, | ||
template: `<div style="width: 200px"> | ||
<ListUniqueValues :loaded="loaded" :filter="filter" @input="filter = $event" :options="options" @loadAllValues="loadAllValues"/> | ||
</div>`, | ||
})); |