Bastien Dewerse
05/06/2024, 12:47 PMBastien Dewerse
05/06/2024, 12:47 PMBastien Dewerse
05/06/2024, 12:48 PMconst DashboardFiltersWidget: CustomDashboardWidgetComponent = (
  props: React.PropsWithChildren<
    IDashboardWidgetProps & {
      widget?: ExtendedDashboardWidget & {
        filterContextRef?: ObjRef;
      };
    }
  >,
) => {
  const { currentStore } = useUser();
  const changeAttributeFilterSelectionCmd = useDispatchDashboardCommand(
    changeAttributeFilterSelection,
  );
  useEffect(() => {
    console.log(props.widget?.filterContextRef);
    if (currentStore?.name) {
      changeAttributeFilterSelectionCmd(
        "3aa72b67107f46baa03eb260257a7ebb", // How to get it dynamically ?
        {
          uris: ["stores.name"],
          values: [currentStore.name],
        },
        "IN",
      );
    }
  }, [currentStore?.name]);
  return null;
};
class DashboardFiltersPlugin extends DashboardPluginV1 {
  author = "LiveCrew";
  displayName = "Hidden dashboard filters";
  version = "1.0";
  register: DashboardPluginV1["register"] = (ctx, customize) => {
    customize
      .customWidgets()
      .addCustomWidget("DashboardFilters", DashboardFiltersWidget);
    customize.layout().customizeFluidLayout((_, customizer) => {
      customizer.addSection(
        0,
        newDashboardSection(
          undefined,
          newDashboardItem(
            newCustomWidget("DashboardFilters", "DashboardFilters", {
              filterContextRef: ctx.filterContextRef,
            }),
            {
              xl: {
                gridWidth: 12,
                gridHeight: 0.1,
              },
            },
          ),
        ),
      );
    });
  };
}
export const DashboardFilters: IEmbeddedPlugin = {
  factory: () => new DashboardFiltersPlugin(),
  parameters: "filterContextRef",
};Francisco Antunes
05/06/2024, 1:17 PMBastien Dewerse
05/06/2024, 1:20 PMBastien Dewerse
05/06/2024, 1:20 PMFrancisco Antunes
05/06/2024, 1:21 PMBastien Dewerse
05/06/2024, 1:21 PMRadek Novacek
05/06/2024, 1:25 PMRadek Novacek
05/06/2024, 2:00 PMvisibility: hidden on .dash-filters-reset is a super simple way to prevent it from popping up - this comes with the usual disclaimer that the CSS is always subject to change, but I personally can't see a reason for this one to changeBastien Dewerse
05/06/2024, 2:06 PMRadek Novacek
05/06/2024, 2:09 PMRadek Novacek
05/06/2024, 2:38 PMfilterLocalId in the filter context, and elsewhere you get anything in the range of "identifier" to "localIdentifier" at best 😅Bastien Dewerse
05/08/2024, 7:55 AMRadek Novacek
05/20/2024, 9:09 AMBastien Dewerse
05/22/2024, 10:50 AMconst {
  data: { exportResult },
} = await gooddataExport.createPdfExport({
  workspaceId,
  pdfExportRequest: {
    dashboardId,
    fileName: `${dashboardId}-${filterId}.pdf`,
    metadata: {
      filters: [filterId],
    },
  },
});
The metadata part is poorly typed, but I saw in the export response that it exposes used filters in the metadata, so I guess it should be possible to pass a specific filterContext (either with the filterContextId or the actual content)Radek Novacek
06/03/2024, 9:37 AMRadek Novacek
06/07/2024, 1:25 PMEssentially, you need to provide filters fully, not by their IDs. You can take inspiration from here - GitHub ref.
The convert function is an identity, but notice omitting the all-time filter and finally the base types here.I hope these are helpful pointers for your implementation! If not, please let me know and I'll try to get more details 🙂
Radek Novacek
06/14/2024, 9:07 AMBastien Dewerse
06/14/2024, 9:17 AM