diff --git a/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/AggregationSortByForm.vue b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/AggregationSortByForm.vue
new file mode 100644
index 0000000000..9434b1a9d4
--- /dev/null
+++ b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/AggregationSortByForm.vue
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
index 3567d9f09c..47eb4356b4 100644
--- a/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
+++ b/enterprise/web-frontend/modules/baserow_enterprise/dashboard/components/data_source/GroupedAggregateRowsDataSourceForm.vue
@@ -99,6 +99,13 @@
@value-changed="onGroupByUpdated($event)"
>
+
+
@@ -108,6 +115,7 @@ import form from '@baserow/modules/core/mixins/form'
import { required } from '@vuelidate/validators'
import AggregationSeriesForm from '@baserow_enterprise/dashboard/components/data_source/AggregationSeriesForm'
import AggregationGroupByForm from '@baserow_enterprise/dashboard/components/data_source/AggregationGroupByForm'
+import AggregationSortByForm from '@baserow_enterprise/dashboard/components/data_source/AggregationSortByForm'
const includesIfSet = (array) => (value) => {
if (value === null || value === undefined) {
@@ -118,7 +126,11 @@ const includesIfSet = (array) => (value) => {
export default {
name: 'GroupedAggregateRowsDataSourceForm',
- components: { AggregationSeriesForm, AggregationGroupByForm },
+ components: {
+ AggregationSeriesForm,
+ AggregationGroupByForm,
+ AggregationSortByForm,
+ },
mixins: [form],
props: {
dashboard: {
@@ -149,12 +161,14 @@ export default {
'view_id',
'aggregation_series',
'aggregation_group_bys',
+ 'sortings',
],
values: {
table_id: null,
view_id: null,
aggregation_series: [],
aggregation_group_bys: [],
+ sortings: [],
},
tableLoading: false,
databaseSelectedId: null,
@@ -200,6 +214,19 @@ export default {
tableViewIds() {
return this.tableViews.map((view) => view.id)
},
+ allowedSortFields() {
+ console.log('updating allowed sort fields')
+ const seriesFieldIds = this.values.aggregation_series.map(
+ (item) => item.field_id
+ )
+ const groupByFieldIds = this.values.aggregation_group_bys.map(
+ (item) => item.field_id
+ )
+ const allowedFieldIds = seriesFieldIds.concat(groupByFieldIds)
+ return this.tableFields.filter((item) => {
+ return allowedFieldIds.includes(item.id)
+ })
+ },
},
watch: {
dataSource: {
@@ -291,6 +318,12 @@ export default {
aggregation_group_bys: aggregationGroupBys,
})
},
+ onSortByUpdated(sortBy) {
+ const aggregationSorts = sortBy.field !== null ? [sortBy] : []
+ this.$emit('values-changed', {
+ sortings: aggregationSorts,
+ })
+ },
},
}
diff --git a/enterprise/web-frontend/modules/baserow_enterprise/locales/en.json b/enterprise/web-frontend/modules/baserow_enterprise/locales/en.json
index b65c86e7a3..8705dadab7 100644
--- a/enterprise/web-frontend/modules/baserow_enterprise/locales/en.json
+++ b/enterprise/web-frontend/modules/baserow_enterprise/locales/en.json
@@ -460,5 +460,11 @@
"groupByFieldLabel": "Group by",
"groupByNone": "None",
"groupByRowId": "Row Id"
+ },
+ "aggregationSortByForm": {
+ "sortByFieldLabel": "Sort by",
+ "none": "None",
+ "ascending": "Ascending",
+ "descending": "Descending"
}
}