-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature :: Sort step form #228
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
981f9af
init form
zegonz aaa039a
add sort step to action menu, add form and change mongo transformation
zegonz 4c4a40b
cleaning sort step form and add test edited step if columns don't exist
zegonz c7dc072
fix style widget sort column css classname
zegonz b953163
add tests sort step form
zegonz 20f6f78
add test for widgetSortColumn
zegonz ac783b8
change schema json into ts file
zegonz 8e23951
Cleaning tests
zegonz 58c57fa
remove useless style css declaration and rename title
zegonz 66a4a3f
remove created value props assignation and pass down directly hardcod…
zegonz 268fc8a
dynamic component widgetSortColumn for widgetList improvement
zegonz f2c0553
fix bug widgetList with defaultValue when opened
zegonz 41875dd
Harmonization generic style css widget aggregate and widget sort into…
zegonz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,4 +155,4 @@ export default class WidgetList extends Vue { | |
top: calc(50% - 16px); | ||
cursor: pointer; | ||
} | ||
</style> | ||
</style> |
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,82 @@ | ||
<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> | ||
<style lang="scss" scoped> | ||
@import '../../styles/_variables'; | ||
.widget-sort__container { | ||
@extend %form-widget__container; | ||
margin-bottom: 0; | ||
padding-top: 12px; | ||
padding-bottom: 4px; | ||
} | ||
|
||
.widget-autocomplete__container { | ||
zegonz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
align-items: center; | ||
flex-direction: row; | ||
margin-bottom: 8px; | ||
} | ||
.widget-sort__container .widget-autocomplete__label { | ||
margin-bottom: 0px; | ||
width: 40%; | ||
} | ||
</style> |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note for later: I wonder if we could not register the widget globally and then use
widget="widget-sort-column"
in the template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue for this => #240