mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix(plugin-chart-handlebars): order by control not work (#21005)
This commit is contained in:
parent
7c0963f6ae
commit
e70699fb43
@ -16,15 +16,19 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { buildQueryContext, QueryFormData } from '@superset-ui/core';
|
import {
|
||||||
|
buildQueryContext,
|
||||||
|
normalizeOrderBy,
|
||||||
|
QueryFormData,
|
||||||
|
} from '@superset-ui/core';
|
||||||
|
|
||||||
export default function buildQuery(formData: QueryFormData) {
|
export default function buildQuery(formData: QueryFormData) {
|
||||||
const { metric, sort_by_metric, groupby } = formData;
|
const { groupby } = formData;
|
||||||
|
|
||||||
return buildQueryContext(formData, baseQueryObject => [
|
return buildQueryContext(formData, baseQueryObject => [
|
||||||
{
|
{
|
||||||
...baseQueryObject,
|
...baseQueryObject,
|
||||||
...(sort_by_metric && { orderby: [[metric, false]] }),
|
orderby: normalizeOrderBy(baseQueryObject).orderby,
|
||||||
...(groupby && { groupby }),
|
...(groupby && { groupby }),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -59,9 +59,10 @@ const config: ControlPanelConfig = {
|
|||||||
[metricsControlSetItem, allColumnsControlSetItem],
|
[metricsControlSetItem, allColumnsControlSetItem],
|
||||||
[percentMetricsControlSetItem],
|
[percentMetricsControlSetItem],
|
||||||
[timeSeriesLimitMetricControlSetItem, orderByControlSetItem],
|
[timeSeriesLimitMetricControlSetItem, orderByControlSetItem],
|
||||||
|
[orderDescendingControlSetItem],
|
||||||
serverPaginationControlSetRow,
|
serverPaginationControlSetRow,
|
||||||
[rowLimitControlSetItem, serverPageLengthControlSetItem],
|
[rowLimitControlSetItem, serverPageLengthControlSetItem],
|
||||||
[includeTimeControlSetItem, orderDescendingControlSetItem],
|
[includeTimeControlSetItem],
|
||||||
[showTotalsControlSetItem],
|
[showTotalsControlSetItem],
|
||||||
['adhoc_filters'],
|
['adhoc_filters'],
|
||||||
emitFilterControl,
|
emitFilterControl,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
import { ControlSetItem, Dataset } from '@superset-ui/chart-controls';
|
import { ControlSetItem, Dataset } from '@superset-ui/chart-controls';
|
||||||
import { t } from '@superset-ui/core';
|
import { t } from '@superset-ui/core';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
import { isAggMode, isRawMode } from './shared';
|
import { isAggMode, isRawMode } from './shared';
|
||||||
|
|
||||||
export const orderByControlSetItem: ControlSetItem = {
|
export const orderByControlSetItem: ControlSetItem = {
|
||||||
@ -45,7 +46,12 @@ export const orderDescendingControlSetItem: ControlSetItem = {
|
|||||||
label: t('Sort descending'),
|
label: t('Sort descending'),
|
||||||
default: true,
|
default: true,
|
||||||
description: t('Whether to sort descending or ascending'),
|
description: t('Whether to sort descending or ascending'),
|
||||||
visibility: isAggMode,
|
visibility: ({ controls }) =>
|
||||||
|
!!(
|
||||||
|
isAggMode({ controls }) &&
|
||||||
|
controls?.timeseries_limit_metric.value &&
|
||||||
|
!isEmpty(controls?.timeseries_limit_metric.value)
|
||||||
|
),
|
||||||
resetOnHide: false,
|
resetOnHide: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user