diff --git a/src/views/dashboard/configuration/widget/AssociateOptions.vue b/src/views/dashboard/configuration/widget/AssociateOptions.vue
index 7a5685b7..bf846110 100644
--- a/src/views/dashboard/configuration/widget/AssociateOptions.vue
+++ b/src/views/dashboard/configuration/widget/AssociateOptions.vue
@@ -17,7 +17,7 @@ limitations under the License. -->
{{ t("widget") }}
(
+const widgetIds = ref(
associate.map((d: { widgetId: string }) => d.widgetId)
);
const widgets = computed(() => {
@@ -71,11 +71,25 @@ function updateWidgetConfig(options: Option[]) {
const opt = options.map((d: Option) => {
return { widgetId: d.value };
});
+ const newVal = options.map((d: Option) => d.value);
+ // add association options in the source widget
const widget = {
...dashboardStore.selectedGrid,
associate: opt,
};
dashboardStore.selectWidget({ ...widget });
+ // remove unuse association widget option
+ for (const id of widgetIds.value) {
+ if (!newVal.includes(id)) {
+ const w = widgets.find((d: { id: string }) => d.id === id);
+ const config = {
+ ...w,
+ associate: [],
+ };
+ dashboardStore.setWidget(config);
+ }
+ }
+ // add association options in target widgets
for (let i = 0; i < opt.length; i++) {
const item = JSON.parse(JSON.stringify(opt));
item[i] = { widgetId: dashboardStore.selectedGrid.id };
@@ -86,6 +100,7 @@ function updateWidgetConfig(options: Option[]) {
};
dashboardStore.setWidget(config);
}
+ widgetIds.value = newVal;
}