Skip to content

Commit

Permalink
remove created value props assignation and pass down directly hardcod…
Browse files Browse the repository at this point in the history
…ed orders to options props
  • Loading branch information
zegonz committed Jul 3, 2019
1 parent a49cd97 commit 6639608
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions src/components/stepforms/WidgetSortColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
id="sortOrderInput"
v-model="sort.order"
name="Order"
:options="sortOrder"
:options="['asc', 'desc']"
placeholder="Order by"
></WidgetAutocomplete>
</fieldset>
Expand All @@ -39,6 +39,10 @@ const defaultValues: SortColumnType = {
export default class WidgetSortColumn extends Vue {
@Prop({
type: Object,
default: () => ({
column: '',
order: 'asc',
}),
})
value!: SortColumnType;
Expand All @@ -47,13 +51,6 @@ export default class WidgetSortColumn extends Vue {
@Mutation setSelectedColumns!: MutationCallbacks['setSelectedColumns'];
sort: SortColumnType = { ...this.value };
sortOrder: SortColumnType['order'][] = ['asc', 'desc'];
created() {
if (_.isEmpty(this.value)) {
this.value = { ...defaultValues };
}
}
@Watch('value', { immediate: true, deep: true })
onSortChanged(newval: SortColumnType, oldval: SortColumnType) {
Expand All @@ -66,7 +63,7 @@ export default class WidgetSortColumn extends Vue {
</script>
<style lang="scss" scoped>
@import '../../styles/_variables';
.widget-aggregation__container {
.widget-sort__container {
@extend %form-widget__container;
margin-bottom: 0;
padding-top: 12px;
Expand All @@ -78,9 +75,6 @@ export default class WidgetSortColumn extends Vue {
flex-direction: row;
margin-bottom: 8px;
}
</style>

<style lang="scss">
.widget-sort__container .widget-autocomplete__label {
margin-bottom: 0px;
width: 40%;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/widget-sort-column.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ describe('Widget sort column', () => {
wrapper.setProps({ value: { column: 'bar', order: 'desc' } });
await localVue.nextTick();
expect(wrapper.emitted().input).to.exist;
expect(wrapper.emitted().input[0]).to.eql([{ column: 'bar', order: 'desc' }]);
expect(wrapper.emitted().input[1]).to.eql([{ column: 'bar', order: 'desc' }]);
});
});

0 comments on commit 6639608

Please sign in to comment.