-
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.
- simplify the mongo transformation, now the order property is includes in columns - introduce a new object in steps.ts `SortColumnType` - change steps documentation about that - introduce a new widget : `WidgetSortColumn` for widgetList
- Loading branch information
Showing
15 changed files
with
393 additions
and
78 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
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,63 @@ | ||
<template> | ||
<div> | ||
<step-form-title :title="title"></step-form-title> | ||
|
||
<WidgetList | ||
addFieldName="Add Column" | ||
id="sortColumn" | ||
v-model="sortColumns" | ||
:defaultItem="defaultSortColumn" | ||
:widget="widgetSortColumn" | ||
:automatic-new-field="false" | ||
></WidgetList> | ||
|
||
<step-form-buttonbar :errors="errors" :cancel="cancelEdition" :submit="submit"></step-form-buttonbar> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Prop } from 'vue-property-decorator'; | ||
import { SortStep } from '@/lib/steps'; | ||
import BaseStepForm from './StepForm.vue'; | ||
import { StepFormComponent } from '@/components/formlib'; | ||
import WidgetList from './WidgetList.vue'; | ||
import { SortColumnType } from '@/lib/steps'; | ||
import WidgetSortColumn from './WidgetSortColumn.vue'; | ||
@StepFormComponent({ | ||
vqbstep: 'sort', | ||
name: 'sort-step-form', | ||
components: { | ||
WidgetList, | ||
WidgetSortColumn, | ||
}, | ||
}) | ||
export default class SortStepForm extends BaseStepForm<SortStep> { | ||
@Prop({ type: Object, default: () => ({ name: 'sort', columns: [] }) }) | ||
initialStepValue!: SortStep; | ||
readonly title: string = 'Sort'; | ||
widgetSortColumn = WidgetSortColumn; | ||
get defaultSortColumn() { | ||
const column = this.selectedColumns.length === 0 ? '' : this.selectedColumns[0]; | ||
const sortColumn: SortColumnType = { | ||
column, | ||
order: 'asc', | ||
}; | ||
return sortColumn; | ||
} | ||
get sortColumns() { | ||
if (this.editedStep.columns.length) { | ||
return this.editedStep.columns; | ||
} else { | ||
return [this.defaultSortColumn]; | ||
} | ||
} | ||
set sortColumns(newval) { | ||
this.editedStep.columns = [...newval]; | ||
} | ||
} | ||
</script> |
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 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,64 @@ | ||
<template> | ||
<fieldset class="widget-sort__container"> | ||
<WidgetAutocomplete | ||
id="columnInput" | ||
:options="columnNames" | ||
v-model="sort.column" | ||
name="Column" | ||
placeholder="Enter a column" | ||
@input="setSelectedColumns({ column: sort.column })" | ||
></WidgetAutocomplete> | ||
<WidgetAutocomplete | ||
id="sortOrderInput" | ||
v-model="sort.order" | ||
name="Order" | ||
:options="['asc', 'desc']" | ||
placeholder="Order by" | ||
></WidgetAutocomplete> | ||
</fieldset> | ||
</template> | ||
<script lang="ts"> | ||
import _ from 'lodash'; | ||
import { Component, Prop, Vue, Watch } from 'vue-property-decorator'; | ||
import { Getter, Mutation } from 'vuex-class'; | ||
import { MutationCallbacks } from '@/store/mutations'; | ||
import WidgetAutocomplete from './WidgetAutocomplete.vue'; | ||
import { SortColumnType } from '@/lib/steps'; | ||
const defaultValues: SortColumnType = { | ||
column: '', | ||
order: 'asc', | ||
}; | ||
@Component({ | ||
name: 'widget-sort-column', | ||
components: { | ||
WidgetAutocomplete, | ||
}, | ||
}) | ||
export default class WidgetSortColumn extends Vue { | ||
@Prop({ | ||
type: Object, | ||
default: () => ({ | ||
column: '', | ||
order: 'asc', | ||
}), | ||
}) | ||
value!: SortColumnType; | ||
@Getter columnNames!: string[]; | ||
@Mutation setSelectedColumns!: MutationCallbacks['setSelectedColumns']; | ||
sort: SortColumnType = { ...this.value }; | ||
@Watch('value', { immediate: true, deep: true }) | ||
onSortChanged(newval: SortColumnType, oldval: SortColumnType) { | ||
if (!_.isEqual(newval, oldval)) { | ||
this.sort = { ...newval }; | ||
this.$emit('input', this.sort); | ||
} | ||
} | ||
} | ||
</script> | ||
|
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 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,37 @@ | ||
export default { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'Sort column step', | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
enum: ['sort'], | ||
}, | ||
columns: { | ||
type: 'array', | ||
minItems: 1, | ||
title: 'Columns to sort', | ||
description: 'Columns to sort', | ||
attrs: { | ||
placeholder: 'Enter columns', | ||
}, | ||
items: { | ||
type: 'object', | ||
title: 'Column to sort', | ||
description: 'Column to sort', | ||
properties: { | ||
column: { | ||
type: 'string', | ||
minLength: 1, | ||
}, | ||
order: { | ||
type: 'string', | ||
enum: ['asc', 'desc'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
required: ['name', 'columns'], | ||
additionalProperties: false, | ||
}; |
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 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
Oops, something went wrong.