diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 25cebf193..bd894135e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Change Log ========== +v4.12.0 (UNRELEASED) +-------------------- +* :star: Added the multiattachment viewer widget to the codebase in alignment with KE-chain-2 backend. (#1434) +* :+1: dependent versions for development + v4.11.0 (27MAY24) ----------------- * :+1: Added the `ShowScopeMembersOnly` representation on the `UserReferenceProperty`. (#1418) diff --git a/pykechain/enums.py b/pykechain/enums.py index ce19a86cc..5e7c92b78 100644 --- a/pykechain/enums.py +++ b/pykechain/enums.py @@ -227,6 +227,7 @@ class WidgetNames(Enum): :cvar SERVICEWIDGET: serviceWidget :cvar NOTEBOOKWIDGET: notebookWidget :cvar ATTACHMENTVIEWERWIDGET: attachmentViewerWidget + :cvar MULTIATTACHMENTVIEWERWIDGET: multiAttachmentViewerWidget :cvar TASKNAVIGATIONBARWIDGET: taskNavigationBarWidget :cvar JSONWIDGET: jsonWidget @@ -250,6 +251,7 @@ class WidgetNames(Enum): SERVICEWIDGET = "serviceWidget" NOTEBOOKWIDGET = "notebookWidget" ATTACHMENTVIEWERWIDGET = "attachmentViewerWidget" + MULTIATTACHMENTVIEWERWIDGET = "multiAttachmentViewerWidget" TASKNAVIGATIONBARWIDGET = "taskNavigationBarWidget" JSONWIDGET = "jsonWidget" METAPANELWIDGET = "metaPanelWidget" @@ -279,6 +281,7 @@ class WidgetTypes(Enum): :cvar SERVICE: Service widget :cvar NOTEBOOK: Notebook widget :cvar ATTACHMENTVIEWER: Attachmentviewer widget + :cvar MULTIATTACHMENTVIEWER: MultiAttachmentviewer widget :cvar TASKNAVIGATIONBAR: Tasknavigationbar widget :cvar JSON: Json widget :cvar METAPANEL: Metapanel widget @@ -304,6 +307,7 @@ class WidgetTypes(Enum): SERVICE = "SERVICE" NOTEBOOK = "NOTEBOOK" ATTACHMENTVIEWER = "ATTACHMENTVIEWER" + MULTIATTACHMENTVIEWER = "MULTIATTACHMENTVIEWER" TASKNAVIGATIONBAR = "TASKNAVIGATIONBAR" JSON = "JSON" METAPANEL = "METAPANEL" @@ -330,6 +334,7 @@ class WidgetTypes(Enum): WidgetNames.SERVICEWIDGET: WidgetTypes.SERVICE, WidgetNames.NOTEBOOKWIDGET: WidgetTypes.NOTEBOOK, WidgetNames.ATTACHMENTVIEWERWIDGET: WidgetTypes.ATTACHMENTVIEWER, + WidgetNames.MULTIATTACHMENTVIEWERWIDGET: WidgetTypes.MULTIATTACHMENTVIEWER, WidgetNames.TASKNAVIGATIONBARWIDGET: WidgetTypes.TASKNAVIGATIONBAR, WidgetNames.JSONWIDGET: WidgetTypes.JSON, WidgetNames.METAPANELWIDGET: WidgetTypes.METAPANEL, diff --git a/pykechain/models/widgets/widget_models.py b/pykechain/models/widgets/widget_models.py index 96db4a9b8..1a293761e 100644 --- a/pykechain/models/widgets/widget_models.py +++ b/pykechain/models/widgets/widget_models.py @@ -9,6 +9,7 @@ # SERVICE # NOTEBOOK # ATTACHMENTVIEWER +# MULTIATTACHMENTVIEWER # TASKNAVIGATIONBAR # JSON # METAPANEL @@ -62,6 +63,10 @@ class AttachmentviewerWidget(Widget): """Attachmentviewer Widget.""" +class MultiAttachmentviewerWidget(Widget): + """Multi Attachmentviewer Widget.""" + + class TasknavigationbarWidget(Widget): """Tasknavigationbar Widget.""" diff --git a/pykechain/models/widgets/widgets_manager.py b/pykechain/models/widgets/widgets_manager.py index b8c972abd..ec268c342 100644 --- a/pykechain/models/widgets/widgets_manager.py +++ b/pykechain/models/widgets/widgets_manager.py @@ -663,8 +663,17 @@ def add_attachmentviewer_widget( else: kwargs.update({"readable_models": [attachment_model_id]}) + widget_type = WidgetTypes.ATTACHMENTVIEWER + # we also use this function to make the MULTI ATTACHMENT VIEWER widget + # this can be provided in the kwargs as 'widget_type' argument + if ( + "widget_type" in kwargs + and kwargs.get("widget_type") == WidgetTypes.MULTIATTACHMENTVIEWER + ): + widget_type = kwargs.get("widget_type") + widget = self.create_widget( - widget_type=WidgetTypes.ATTACHMENTVIEWER, + widget_type=widget_type, meta=meta, title=title, parent=parent_widget, @@ -673,6 +682,59 @@ def add_attachmentviewer_widget( return widget + def add_multiattachmentviewer_widget( + self, + attachment_property: Union[str, "AttachmentProperty"], + editable: Optional[bool] = False, + title: TITLE_TYPING = False, + parent_widget: Optional[Union[Widget, str]] = None, + alignment: Optional[Alignment] = None, + image_fit: Optional[Union[ImageFitValue, str]] = ImageFitValue.CONTAIN, + show_download_button: Optional[bool] = True, + show_full_screen_button: Optional[bool] = True, + **kwargs, + ) -> Widget: + """ + Add a KE-chain Multi Attachment widget widget manager. + + The widget will be saved to KE-chain. + + :param attachment_property: KE-chain Attachment property to display + :type attachment_property: AttachmentProperty + :param editable: Whether the attachment can be added, edited or deleted (default: False) + :type editable: bool + :param title: A custom title for the script widget + * False (default): Property name + * String value: Custom title + * None: No title + :type title: bool or basestring or None + :param alignment: horizontal alignment of the previewed attachment (Alignment enum class) + :type alignment: Alignment + :param image_fit: (O) enumeration to address the image_fit (defaults to 'contain', otherwise 'cover') + :type image_fit: basestring or None + :param show_download_button: (O) whether a user can download the attached figure (defaults to True) + :type show_download_button: bool + :param show_full_screen_button: (O) whether the figure can be expanded to fit the full screen (defaults to True) + :type show_full_screen_button: bool + :param kwargs: additional keyword arguments to pass + :return: newly created widget + :rtype: Widget + :raises IllegalArgumentError: when incorrect arguments are provided + :raises APIError: When the widget could not be created. + """ + return self.add_attachmentviewer_widget( + attachment_property, + editable, + title, + parent_widget, + alignment, + image_fit, + show_download_button, + show_full_screen_button, + widget_type=WidgetTypes.MULTIATTACHMENTVIEWER, + **kwargs, + ) + def add_tasknavigationbar_widget( self, activities: Union[Iterable[Dict]],