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
|
||||
* under the License.
|
||||
*/
|
||||
import { buildQueryContext, QueryFormData } from '@superset-ui/core';
|
||||
import {
|
||||
buildQueryContext,
|
||||
normalizeOrderBy,
|
||||
QueryFormData,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const { metric, sort_by_metric, groupby } = formData;
|
||||
const { groupby } = formData;
|
||||
|
||||
return buildQueryContext(formData, baseQueryObject => [
|
||||
{
|
||||
...baseQueryObject,
|
||||
...(sort_by_metric && { orderby: [[metric, false]] }),
|
||||
orderby: normalizeOrderBy(baseQueryObject).orderby,
|
||||
...(groupby && { groupby }),
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,10 @@ const config: ControlPanelConfig = {
|
|||
[metricsControlSetItem, allColumnsControlSetItem],
|
||||
[percentMetricsControlSetItem],
|
||||
[timeSeriesLimitMetricControlSetItem, orderByControlSetItem],
|
||||
[orderDescendingControlSetItem],
|
||||
serverPaginationControlSetRow,
|
||||
[rowLimitControlSetItem, serverPageLengthControlSetItem],
|
||||
[includeTimeControlSetItem, orderDescendingControlSetItem],
|
||||
[includeTimeControlSetItem],
|
||||
[showTotalsControlSetItem],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
import { ControlSetItem, Dataset } from '@superset-ui/chart-controls';
|
||||
import { t } from '@superset-ui/core';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isAggMode, isRawMode } from './shared';
|
||||
|
||||
export const orderByControlSetItem: ControlSetItem = {
|
||||
|
|
@ -45,7 +46,12 @@ export const orderDescendingControlSetItem: ControlSetItem = {
|
|||
label: t('Sort descending'),
|
||||
default: true,
|
||||
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,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue