remove event from associate options

This commit is contained in:
Qiuxia Fan 2022-07-18 09:58:34 +08:00
parent 09ab2e4c99
commit d0616d628f

View File

@ -41,29 +41,17 @@ const widgetIds = ref<string[]>(
associate.map((d: { widgetId: string }) => d.widgetId) associate.map((d: { widgetId: string }) => d.widgetId)
); );
const widgets = computed(() => { const widgets = computed(() => {
// const isRank = ["TopList"].includes(
// dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
// );
const all = getDashboard(dashboardStore.currentDashboard).widgets; const all = getDashboard(dashboardStore.currentDashboard).widgets;
const items = all.filter( const items = all.filter(
(d: { value: string; label: string } & LayoutConfig) => { (d: { value: string; label: string } & LayoutConfig) => {
const isLinear = ["Bar", "Line", "Area"].includes( const isLinear = ["Bar", "Line", "Area"].includes(
(d.graph && d.graph.type) || "" (d.graph && d.graph.type) || ""
); );
if ( if (isLinear && d.id && dashboardStore.selectedGrid.id !== d.id) {
(isLinear || d.type === "Event") &&
d.id &&
dashboardStore.selectedGrid.id !== d.id
) {
d.value = d.id; d.value = d.id;
d.label = (d.widget && d.widget.name) || d.id; d.label = (d.widget && d.widget.name) || d.id;
return d; return d;
} }
// if (isRank && d.type !== "Widget" && d.widget && d.id) {
// d.value = d.id;
// d.label = d.widget.name || d.id;
// return d;
// }
} }
); );
return items; return items;
@ -85,13 +73,11 @@ function updateWidgetConfig(options: Option[]) {
for (const id of widgetIds.value) { for (const id of widgetIds.value) {
if (!newVal.includes(id)) { if (!newVal.includes(id)) {
const w = widgets.find((d: { id: string }) => d.id === id); const w = widgets.find((d: { id: string }) => d.id === id);
if (w.type !== "Event") { const config = {
const config = { ...w,
...w, associate: [],
associate: [], };
}; dashboardStore.setWidget(config);
dashboardStore.setWidget(config);
}
} }
} }
// add association options in target widgets // add association options in target widgets
@ -99,13 +85,11 @@ function updateWidgetConfig(options: Option[]) {
const item = JSON.parse(JSON.stringify(opt)); const item = JSON.parse(JSON.stringify(opt));
item[i] = { widgetId: dashboardStore.selectedGrid.id }; item[i] = { widgetId: dashboardStore.selectedGrid.id };
const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId); const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId);
if (w.type !== "Event") { const config = {
const config = { ...w,
...w, associate: item,
associate: item, };
}; dashboardStore.setWidget(config);
dashboardStore.setWidget(config);
}
} }
widgetIds.value = newVal; widgetIds.value = newVal;
} }