Class JmixKanban<T>

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.kanbanflowui.kit.component.JmixKanban<T>
Type Parameters:
T - type of items contained
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, HasActions, HasKanbanColumns, Serializable
Direct Known Subclasses:
Kanban

@Tag("smart-kanban") @JsModule("./src/kanban/vendor/modules/smart.kanban.js") @CssImport("./src/kanban/vendor/styles/smart.default.css") @CssImport("./src/kanban/styles/kanban-styles.css") public class JmixKanban<T> extends com.vaadin.flow.component.Component implements HasKanbanColumns, HasActions, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasEnabled
Base component for implementing kanban board.
See Also:
  • Field Details

  • Constructor Details

    • JmixKanban

      public JmixKanban()
  • Method Details

    • initComponent

      protected void initComponent()
    • initComponentProperties

      protected void initComponentProperties()
    • initTaskListeners

      protected void initTaskListeners()
    • initColumnListeners

      protected void initColumnListeners()
    • isColumnReorderingAllowed

      public boolean isColumnReorderingAllowed()
      Returns:
      whether column reordering is allowed
    • setColumnReorderingAllowed

      public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
      Sets whether column reordering is allowed. false by default.
      Parameters:
      columnReorderingAllowed - whether column reordering is allowed
    • isColumnHidingAllowed

      public boolean isColumnHidingAllowed()
      Returns:
      whether column hiding is allowed
    • setColumnHidingAllowed

      public void setColumnHidingAllowed(boolean columnHidingAllowed)
      Sets whether column hiding is allowed. true by default.
      Parameters:
      columnHidingAllowed - whether column hiding is allowed
    • isDragAllowed

      public boolean isDragAllowed()
      Returns:
      whether dragging tasks is allowed
    • setDragAllowed

      public void setDragAllowed(boolean dragAllowed)
      Sets whether dragging tasks is allowed. true by default.
      Parameters:
      dragAllowed - whether dragging tasks is allowed
    • isDropAllowed

      public boolean isDropAllowed()
      Returns:
      whether dropping tasks is allowed
    • setDropAllowed

      public void setDropAllowed(boolean dropAllowed)
      Sets whether dropping tasks is allowed. true by default.
      Parameters:
      dropAllowed - whether dropping tasks is allowed
    • isDropPlaceholderAllowed

      public boolean isDropPlaceholderAllowed()
      Returns:
      whether dropping of tasks placeholder is allowed
    • setDropPlaceholderAllowed

      public void setDropPlaceholderAllowed(boolean dropPlaceholderAllowed)
      Sets whether dropping of tasks placeholder is allowed. false by default. If set to true, then if a task overlaps another task, an empty space appears for it.
      Parameters:
      dropPlaceholderAllowed - whether dripping of tasks placeholder is allowed
    • isApplyColumnColorToTasksEnabled

      public boolean isApplyColumnColorToTasksEnabled()
      Returns:
      whether applying column color to tasks is enabled
    • setApplyColumnColorToTasksEnabled

      public void setApplyColumnColorToTasksEnabled(boolean applyColumnColorToTasksEnabled)
      Sets whether applying column color to tasks is enabled. false by default. When set to true and the KanbanColumn have their KanbanColumn.color property set, the color is also applied to the tasks card.
      Parameters:
      applyColumnColorToTasksEnabled - whether applying column color to tasks is enabled
      See Also:
    • isAutoColumnHeightEnabled

      public boolean isAutoColumnHeightEnabled()
      Returns:
      whether automatically updating of columns height is enabled
    • setAutoColumnHeightEnabled

      public void setAutoColumnHeightEnabled(boolean autoColumnHeightEnabled)
      Sets whether automatically updating of columns height depending on the tasks inside is enabled. false by default. The effect is observed when 'columnColorEntireSurfaceEnabled' property is true.
      Parameters:
      autoColumnHeightEnabled - whether automatically updating of column height depending on the tasks inside is enabled
      See Also:
    • isCollapsible

      public boolean isCollapsible()
      Returns:
      whether collapsing the card content is allowed
    • setCollapsible

      public void setCollapsible(boolean collapsible)
      Sets whether collapsing the card content is allowed. false by default.
      Parameters:
      collapsible - whether collapsing the card content is allowed
    • getColumnsWidth

      public int getColumnsWidth()
      Returns:
      columns width in pixels or 0 if value doesn't set
    • setColumnsWidth

      public void setColumnsWidth(int columnsWidth)
      Sets the same width for all columns. 0 by default.
      Parameters:
      columnsWidth - column width to set in pixels
      See Also:
    • isColumnColorEntireSurfaceEnabled

      public boolean isColumnColorEntireSurfaceEnabled()
      Returns:
      whether to display background in the KanbanColumn.
    • setColumnColorEntireSurfaceEnabled

      public void setColumnColorEntireSurfaceEnabled(boolean columnColorEntireSurfaceEnabled)
      Sets whether to display background in the KanbanColumn. false by default.
      Parameters:
      columnColorEntireSurfaceEnabled - whether to display background in the KanbanColumn
    • isColumnFooterVisible

      public boolean isColumnFooterVisible()
      Returns:
      whether to display a column footer which shows the summary of the column
    • setColumnFooterVisible

      public void setColumnFooterVisible(boolean columnFooterVisible)
      Sets whether to display a column footer which shows the summary of the column. false by default. Works in conjunction with the isColumnSummaryEnabled() property value.
      Parameters:
      columnFooterVisible - whether to display a column footer which shows the summary of the column
    • isColumnActionsEnabled

      public boolean isColumnActionsEnabled()
      Returns:
      whether to display a column actions icon
    • setColumnActionsEnabled

      public void setColumnActionsEnabled(boolean columnActionsEnabled)
      Sets whether to display a column actions icon. false by default.
      Parameters:
      columnActionsEnabled - whether to display a column actions icon
    • isColumnSummaryEnabled

      public boolean isColumnSummaryEnabled()
      Returns:
      whether task count information is displayed in column headers
    • setColumnSummaryEnabled

      public void setColumnSummaryEnabled(boolean columnSummaryEnabled)
      Sets whether task count information is displayed in column headers. false by default.
      Parameters:
      columnSummaryEnabled - whether task count information is displayed in column headers
    • getHierarchyMode

      public JmixKanban.HierarchyMode getHierarchyMode()
      Returns:
      the way column hierarchy is represented
    • setHierarchyMode

      public void setHierarchyMode(JmixKanban.HierarchyMode hierarchyMode)
      Sets the way column hierarchy is represented. JmixKanban.HierarchyMode.COLUMNS by default.
      Parameters:
      hierarchyMode - mode to set
    • getSwimlanesFrom

      public Integer getSwimlanesFrom()
      Returns:
      index of the column at which to start the swimlanes
    • setSwimlanesFrom

      public void setSwimlanesFrom(Integer swimlanesFrom)
      Sets the index of the column at which to start the swimlanes. 0 by default, all swimlanes start from the first column.
      Parameters:
      swimlanesFrom - the index of the column at which to start the swimlanes
    • getSwimlanesTo

      public Integer getSwimlanesTo()
      Returns:
      index of the column at which to end the swimlanes
    • setSwimlanesTo

      public void setSwimlanesTo(Integer swimlanesTo)
      Sets the index of the column at which to end the swimlanes. Equals the number columns by default, all swimlanes end at the last column.
      Parameters:
      swimlanesTo - the index of the column at which to end the swimlanes
    • isTaskDueDateVisible

      public boolean isTaskDueDateVisible()
      Returns:
      whether the task due icon is visible
    • setTaskDueDateVisible

      public void setTaskDueDateVisible(boolean taskDueDateVisible)
      Sets the visibility of the task due icon. false by default.
      Parameters:
      taskDueDateVisible - the visibility of the task due icon
    • isTaskUserAvatarVisible

      public boolean isTaskUserAvatarVisible()
      Returns:
      whether the task user avatar is visible
    • setTaskUserAvatarVisible

      public void setTaskUserAvatarVisible(boolean taskUserAvatarVisible)
      Sets the visibility of the task user avatar. false by default.
      Parameters:
      taskUserAvatarVisible - the visibility of the task user avatar
    • getTaskPosition

      public JmixKanban.TaskPosition getTaskPosition()
      Returns:
      task positioning mode of the Kanban
    • setTaskPosition

      public void setTaskPosition(JmixKanban.TaskPosition taskPosition)
      Sets task positioning mode of the Kanban. JmixKanban.TaskPosition.ALL by default.
      Parameters:
      taskPosition - task positioning mode of the Kanban
    • isTaskPriorityVisible

      public boolean isTaskPriorityVisible()
      Returns:
      whether the task priority icon is visible
    • setTaskPriorityVisible

      public void setTaskPriorityVisible(boolean taskPriorityVisible)
      Sets whether the task priority icon is visible. true by default.
      Parameters:
      taskPriorityVisible - whether the task priority icon is visible
    • isTaskProgressVisible

      public boolean isTaskProgressVisible()
      Returns:
      whether the task progress bar is visible
    • setTaskProgressVisible

      public void setTaskProgressVisible(boolean taskProgressVisible)
      Sets whether the task progress bar is visible. false by default.
      Parameters:
      taskProgressVisible - whether the task progress bar is visible
    • isTaskColorEntireSurfaceEnabled

      public boolean isTaskColorEntireSurfaceEnabled()
      Returns:
      whether the task card background color depends on the task's color property
    • setTaskColorEntireSurfaceEnabled

      public void setTaskColorEntireSurfaceEnabled(boolean taskColorEntireSurfaceEnabled)
      Sets whether the task card background color depends on the task's color property. false by default. By default, the color is renderer within the task's left border.
      Parameters:
      taskColorEntireSurfaceEnabled - whether the task card background color depends on the task's color property
    • isTaskTagsVisible

      public boolean isTaskTagsVisible()
      Returns:
      whether the task tags is visible
    • setTaskTagsVisible

      public void setTaskTagsVisible(boolean taskTagsVisible)
      Sets the visibility of the task tags. true by default.
      Parameters:
      taskTagsVisible - the visibility of the task tags
    • getColumnHeaderRendererFunction

      @Nullable public String getColumnHeaderRendererFunction()
      Returns:
      callback function which can be used for customizing the column header rendering
    • setColumnHeaderRendererFunction

      public void setColumnHeaderRendererFunction(@Nullable String columnHeaderRenderer)
      Sets callback function which can be used for customizing the column header rendering. The Kanban calls it with 3 arguments - column header HTML element, column data and column data field.

      Example:

      
       (header, data, dataField) => {
            let color = '';
            switch (data.label) {
                case 'In Progress': {
                    color = '#0B88DA';
                    break;
                }
                case 'Testing': {
                    color = '#30C1E3';
                    break;
                }
                case 'Done': {
                    color = '#34C8BA';
                    break;
                }
            }
      
            header.style.background = color;
            header.style.color = '#fff';
       }
       
      Parameters:
      columnHeaderRenderer - renderer to set
    • getColumnFooterRendererFunction

      @Nullable public String getColumnFooterRendererFunction()
      Returns:
      callback function which can be used for customizing the column footer rendering
    • setColumnFooterRendererFunction

      public void setColumnFooterRendererFunction(@Nullable String columnFooterRenderer)
      Sets callback function which can be used for customizing the column footer rendering. The Kanban calls it with 3 arguments - column footer HTML element, column data and column data field.

      Example:

      
       (footer, data, dataField) => {
            footer.style.color = data.label === 'In progress' ? '#0B88DA' : '#3634C8';
       }
       
      Parameters:
      columnFooterRenderer - renderer to set
    • getTaskRendererFunction

      @Nullable public String getTaskRendererFunction()
      Returns:
      callback function which can be used for customizing the tasks rendering
    • setTaskRendererFunction

      public void setTaskRendererFunction(@Nullable String taskRenderer)
      Sets callback function which can be used for customizing the tasks rendering. The Kanban calls it with 2 arguments - task HTML element and task data.

      Example:

      
       (task, data) => {
            task.style.color = data.priority === 'Critical' ? '#0B88DA' : '#3634C8';
       }
       
      Parameters:
      taskRenderer - renderer to set
    • getI18n

      public JmixKanban.KanbanI18n getI18n()
      Gets the internationalization object previously set for this component.

      Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using setI18n(KanbanI18n)

      Returns:
      the i18n object, or null, if the i18n properties weren't set
    • setI18n

      public void setI18n(JmixKanban.KanbanI18n i18n)
      Sets the internationalization properties for Kanban component.
      Parameters:
      i18n - the internationalized properties, not null
    • getSwimlanes

      public List<KanbanSwimlane> getSwimlanes()
      Returns:
      an unmodifiable list of KanbanSwimlane
    • getSwimlaneByDataField

      @Nullable public KanbanSwimlane getSwimlaneByDataField(@Nullable String dataField)
      Parameters:
      dataField - the dataField attribute of the swimlane to get
      Returns:
      the swimlane corresponding to the given swimlane dataField, or null if no swimlane has such dataField
      See Also:
    • removeSwimlane

      public void removeSwimlane(KanbanSwimlane swimlane)
      Removes a KanbanSwimlane from the Kanban. Updates the client-side of the Kanban.
      Parameters:
      swimlane - the swimlane to be removed, not null
      Throws:
      IllegalArgumentException - if the passed column is null
    • removeSwimlaneByDataField

      public void removeSwimlaneByDataField(String dataField)
      Removes a KanbanSwimlane with the passed dataField from the Kanban.
      Parameters:
      dataField - the dataField attribute of the swimlane
    • addSwimlane

      public void addSwimlane(KanbanSwimlane swimlane)
      Adds a new swimlane to the Kanban.
      Parameters:
      swimlane - swimlane to add, not null
      Throws:
      IllegalArgumentException - if the passed swimlane is null
    • setSwimlanes

      public void setSwimlanes(List<KanbanSwimlane> swimlanes)
      Sets a list of swimlanes for a Kanban.
      Parameters:
      swimlanes - list of swimlanes to set
      Throws:
      IllegalArgumentException - if the passed list is null
    • expandAllColumns

      public void expandAllColumns()
      Expands all columns of a component.
    • showAllColumns

      public void showAllColumns()
      Shows all columns of a component.
    • getColumns

      public List<KanbanColumn> getColumns()
      Specified by:
      getColumns in interface HasKanbanColumns
      Returns:
      an unmodifiable list of all KanbanColumn, including transitive columns
    • getOwnColumns

      public List<KanbanColumn> getOwnColumns()
      Specified by:
      getOwnColumns in interface HasKanbanColumns
      Returns:
      an unmodifiable list of KanbanColumn that are direct elements of this component
    • getColumnByDataField

      @Nullable public KanbanColumn getColumnByDataField(@Nullable String dataField)
      Specified by:
      getColumnByDataField in interface HasKanbanColumns
      Parameters:
      dataField - the dataField attribute of the column to get
      Returns:
      the column corresponding to the given column dataField, or null if no column has such dataField
      See Also:
    • removeColumn

      public void removeColumn(KanbanColumn column)
      Description copied from interface: HasKanbanColumns
      Removes a KanbanColumn from the component. Updates the client-side of the component.
      Specified by:
      removeColumn in interface HasKanbanColumns
      Parameters:
      column - the column to be removed, not null
    • removeColumnByDataField

      public void removeColumnByDataField(String dataField)
      Description copied from interface: HasKanbanColumns
      Removes a KanbanColumn with the given dataField from the component.
      Specified by:
      removeColumnByDataField in interface HasKanbanColumns
      Parameters:
      dataField - the dataField attribute of the column
    • replaceColumn

      public void replaceColumn(String dataField, KanbanColumn newColumn)
      Description copied from interface: HasKanbanColumns
      Finds a KanbanColumn with the passed dataField and replaces it with the new one.
      Specified by:
      replaceColumn in interface HasKanbanColumns
      Parameters:
      dataField - dataField attribute of the column being replaced
      newColumn - a column for replacement
    • addColumn

      public void addColumn(KanbanColumn column)
      Description copied from interface: HasKanbanColumns
      Adds a new column to the component.
      Specified by:
      addColumn in interface HasKanbanColumns
      Parameters:
      column - column to add, not null
    • setColumns

      public void setColumns(List<KanbanColumn> columns)
      Sets columns properties. Each column's properties are represented by KanbanColumn object.
      Specified by:
      setColumns in interface HasKanbanColumns
      Parameters:
      columns - columns properties to set
    • getItems

      public JmixKanbanItems<T> getItems()
    • getPropertiesMapping

      public JmixKanban.PropertiesMapping getPropertiesMapping()
      Returns:
      object for storing mapping of item attributes to properties of Kanban items
    • setPropertiesMapping

      public void setPropertiesMapping(@Nullable JmixKanban.PropertiesMapping propertiesMapping)
      Sets object for storing mapping of item attributes to properties of Kanban items.
      Parameters:
      propertiesMapping - object for storing mapping
    • addAction

      public void addAction(Action action)
      Specified by:
      addAction in interface HasActions
    • addAction

      public void addAction(Action action, int index)
      Specified by:
      addAction in interface HasActions
    • removeAction

      public void removeAction(Action action)
      Specified by:
      removeAction in interface HasActions
    • getActions

      public Collection<Action> getActions()
      Specified by:
      getActions in interface HasActions
    • getAction

      @Nullable public Action getAction(String id)
      Specified by:
      getAction in interface HasActions
    • addColumnReorderListener

      public com.vaadin.flow.shared.Registration addColumnReorderListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnReorderEvent> listener)
      Add a listener that is called when a column is reordered.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnClickListener

      public com.vaadin.flow.shared.Registration addColumnClickListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnClickEvent> listener)
      Add a listener that is called when a column is clicked.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnDoubleClickListener

      public com.vaadin.flow.shared.Registration addColumnDoubleClickListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnDoubleClickEvent> listener)
      Add a listener that is called when a column is double-clicked.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnShowListener

      public com.vaadin.flow.shared.Registration addColumnShowListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnShowEvent> listener)
      Add a listener that is called when a column is showed.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnHideListener

      public com.vaadin.flow.shared.Registration addColumnHideListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnHideEvent> listener)
      Add a listener that is called when a column is hidden.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnCollapseListener

      public com.vaadin.flow.shared.Registration addColumnCollapseListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnCollapseEvent> listener)
      Add a listener that is called when a column is collapsed.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addColumnExpandListener

      public com.vaadin.flow.shared.Registration addColumnExpandListener(com.vaadin.flow.component.ComponentEventListener<KanbanColumnExpandEvent> listener)
      Add a listener that is called when a column is collapsed.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addDragEndListener

      public com.vaadin.flow.shared.Registration addDragEndListener(com.vaadin.flow.component.ComponentEventListener<KanbanDragEndEvent<T>> listener)
      Add a listener that is called when a task card is dropped.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addDragStartListener

      public com.vaadin.flow.shared.Registration addDragStartListener(com.vaadin.flow.component.ComponentEventListener<KanbanDragStartEvent<T>> listener)
      Add a listener that is called when a task card is dragged.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addTaskClickListener

      public com.vaadin.flow.shared.Registration addTaskClickListener(com.vaadin.flow.component.ComponentEventListener<KanbanTaskClickEvent<T>> listener)
      Add a listener that is called when a task card is clicked.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • addTaskDoubleClickListener

      public com.vaadin.flow.shared.Registration addTaskDoubleClickListener(com.vaadin.flow.component.ComponentEventListener<KanbanTaskDoubleClickEvent<T>> listener)
      Add a listener that is called when a task card is double-clicked.
      Parameters:
      listener - a listener to add
      Returns:
      a handle that can be used for removing the listener
    • getSaveDelegate

      @Nullable public Consumer<T> getSaveDelegate()
      Returns:
      the function which will be used to save data that has been updated on the client-side of the component
    • setSaveDelegate

      public void setSaveDelegate(Consumer<T> saveDelegate)
      Sets the function which will be used to save data that has been updated on the client-side of the component.
      Parameters:
      saveDelegate - function to set
    • refreshColumns

      protected void refreshColumns()
    • refreshSwimlanes

      protected void refreshSwimlanes()
    • appendChildColumns

      protected void appendChildColumns(List<KanbanColumn> columns, KanbanColumn column)
    • onTaskUpdate

      protected void onTaskUpdate(com.vaadin.flow.dom.DomEvent event)
    • updateItemValues

      protected void updateItemValues(T item, elemental.json.JsonObject jsonObject)
    • onColumnShow

      protected void onColumnShow(KanbanColumnShowEvent event)
    • onColumnHide

      protected void onColumnHide(KanbanColumnHideEvent event)
    • onColumnExpand

      protected void onColumnExpand(KanbanColumnExpandEvent event)
    • onColumnCollapse

      protected void onColumnCollapse(KanbanColumnCollapseEvent event)
    • onColumnReorder

      protected void onColumnReorder(KanbanColumnReorderEvent event)
    • onColumnStateChange

      protected void onColumnStateChange(AbstractKanbanColumnEvent event, Consumer<Boolean> method, boolean value)
    • getEnumValue

      @Nullable protected Object getEnumValue(T item, String propertyName, String newValue)
    • runBeforeClientResponse

      protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)
    • isPropertyModifiableBySecurity

      protected boolean isPropertyModifiableBySecurity(String attributeName)
    • createSerializer

      protected JmixKanbanSerializer createSerializer()
    • getActionsSupport

      protected JmixKanbanActionsSupport<? extends JmixKanban<?>> getActionsSupport()
    • createActionsSupport

      protected JmixKanbanActionsSupport<? extends JmixKanban<?>> createActionsSupport()
    • setPropertyInternal

      protected void setPropertyInternal(String propertyName, @Nullable String propertyValue)
    • getPropertySetupExpression

      protected String getPropertySetupExpression(String propertyName, @Nullable String propertyValue)