Skip to content

Commit

Permalink
Fix setup of store in Storybook
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .storybook/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ import FilterEditor from '../src/components/FilterEditor.vue';
import ListUniqueValues from '../src/components/ListUniqueValues.vue';

export { FilterEditor, ConditionsEditor, DataViewer, RenameStepForm, Pipeline, ResizablePanels, Step, ListUniqueValues };
export { setupStore } from '../src/store';
export { setupStore, registerModule, VQBnamespace } from '../src/store';
45 changes: 39 additions & 6 deletions stories/list-unique-values.js
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>`,
}));

0 comments on commit 2aede0e

Please sign in to comment.