当前位置: 首页 > news >正文

建设网站的公司广州南宁网站建设优化服务

建设网站的公司广州,南宁网站建设优化服务,企业网站如何做网警备案,企业培训机构排名前十一. 背景 Superset目前支持的筛选类型:值、数值范围、时间列、时间粒度、时间范围 5种类型,显然无法满足业务需求。根据产品需要,需要支持复选框、单选框、级联选择等类型的筛选器。本文探讨复选框、单选框的技术实现方式。 二. 效果预览 三. 实现思路 复用 值 筛选器模块,…

一. 背景

Superset目前支持的筛选类型:值、数值范围、时间列、时间粒度、时间范围 5种类型,显然无法满足业务需求。根据产品需要,需要支持复选框、单选框、级联选择等类型的筛选器。本文探讨复选框、单选框的技术实现方式。

二. 效果预览

三. 实现思路

复用 '' 筛选器模块,然后看板筛选器渲染时,修改为Checkbox 组件。

四. 前端逻辑

1. 新增复选框选项

1.1 新增CheckBox文件夹

目录 superset-frontend\src\filters\components,新增CheckBox 文件夹

1.2 注册插件

superset-frontend\src\visualizations\presets\MainPreset.js

69行新增  CheckboxFilterPlugin} from 'src/filters/components';

160行新增  new CheckboxFilterPlugin().configure({ key: 'filter_checkbox' }),

superset-frontend\src\dashboard\components\nativeFilters\FiltersConfigModal\FiltersConfigForm\FiltersConfigForm.tsx

FILTER_TYPE_NAME_MAPPING 参数新增

[t('Check Box')]:t('Check box'),

superset-frontend\src\filters\components\index.ts

export { default as CheckboxFilterPlugin } from './CheckBox';

superset-frontend\cypress-base\cypress\e2e\dashboard\utils.ts

exportconsttestItems = 的 filterType 新增

checkbox: 'Check box',

2. 国际化支持

superset\translations\en\LC_MESSAGES\messages.json

"Check box": [""],

superset\translations\en\LC_MESSAGES\messages.po

#:
msgid "Check box"
msgstr ""

superset\translations\zh\LC_MESSAGES\messages.json

"Check box": ["复选框"],

superset\translations\zh\LC_MESSAGES\messages.po

#:
msgid "Check box"
msgstr "复选框"

3.核心逻辑

superset-frontend\src\filters\components\CheckBox\buildQuery.ts

/*** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements.  See the NOTICE file* distributed with this work for additional information* regarding copyright ownership.  The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing,* software distributed under the License is distributed on an* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY* KIND, either express or implied.  See the License for the* specific language governing permissions and limitations* under the License.*/
import {buildQueryContext,GenericDataType,getColumnLabel,isPhysicalColumn,QueryObject,QueryObjectFilterClause,BuildQuery,} from '@superset-ui/core';import { DEFAULT_FORM_DATA, PluginFilterCheckboxQueryFormData } from './types';// 构建查询函数,用于根据表单数据和选项生成查询对象。const buildQuery: BuildQuery<PluginFilterCheckboxQueryFormData> = (formData: PluginFilterCheckboxQueryFormData,options,) => {const { search, coltypeMap } = options?.ownState || {};const { sortAscending, sortMetric } = { ...DEFAULT_FORM_DATA, ...formData };// 使用 buildQueryContext 函数构建查询上下文,传入表单数据和基础查询对象。return buildQueryContext(formData, baseQueryObject => {const { columns = [], filters = [] } = baseQueryObject;// 初始化额外的过滤器数组。const extraFilters: QueryObjectFilterClause[] = [];if (search) {// 如果搜索字段不为空,则遍历列并添加额外的过滤器。columns.filter(isPhysicalColumn).forEach(column => {const label = getColumnLabel(column);if (coltypeMap[label] === GenericDataType.STRING ||(coltypeMap[label] === GenericDataType.NUMERIC &&!Number.isNaN(Number(search)))) {// 如果列的类型是字符串或数字,则添加一个 ILIKE 过滤器。    extraFilters.push({col: column,op: 'ILIKE',val: `%${search}%`,});}});}// 如果排序字段不为空,则将排序字段添加到排序列数组中。   const sortColumns = sortMetric ? [sortMetric] : columns;// 构建查询对象,包括基础查询对象、列、指标、过滤器和排序。const query: QueryObject[] = [{...baseQueryObject,columns,metrics: sortMetric ? [sortMetric] : [],filters: filters.concat(extraFilters),orderby:sortMetric || sortAscending !== undefined? sortColumns.map(column => [column, !!sortAscending]): [],},];return query;});};export default buildQuery;

superset-frontend\src\filters\components\CheckBox\CheckboxFilterPlugin.tsx

实现了复选框/单选按钮过滤器的主要逻辑和 UI

/*** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements.  See the NOTICE file* distributed with this work for additional information* regarding copyright ownership.  The ASF license
http://www.hkea.cn/news/242596/

相关文章:

  • 网站建设怎么分录2022年新闻摘抄简短
  • 江西景德镇建设厅网站太原关键词排名推广
  • 番禺做网站自媒体发布平台有哪些
  • 用dede做的网站首页电子商务网络营销
  • 最好的做任务赚钱网站网络域名怎么查
  • 建设部规范网站百度app关键词优化
  • 骏域网站百度怎么收录网站
  • 网站robots.txt查看九江seo公司
  • 建设阿里妈妈网站搜索引擎排名优化seo
  • 自学网站建设作业创建网站免费
  • 营销网站定制的优势成品网站源码的优化技巧
  • 高职学院网站建设方案广告制作
  • table表格 做的网站营销案例分析报告模板
  • pc端网站做移动适配教育培训机构管理系统
  • 页游传奇排行榜无锡seo优化公司
  • 广西南宁网站设计百度seo算法
  • 网站建设服务怎么样近期国内热点新闻事件
  • 阿里巴巴网站国际站建设seo托管服务
  • 企业网站优化之如何做需求分析网奇seo赚钱培训
  • 施工企业会计制度收入确认规定百度自然排名优化
  • 校园网站建设意义网络营销的特点有哪些
  • 内江做网站哪里便宜google搜索关键词热度
  • 福建省建设银行招聘网站网络推广员压力大吗
  • 动态网站订单怎么做搜索引擎优化营销
  • html5行业网站最近有哪些新闻
  • 做网站业务的怎么寻找客户在哪里打广告效果最好
  • 广东深圳seo服务内容
  • 做网站怎么备案网络服务有限公司
  • 网站主页特效欣赏百度官网下载电脑版
  • php mysql开发网站开发任何小说都能搜到的软件