Skip to content

Commit

Permalink
Merge pull request #1300 from axonivy-market/bug/IVYPORTAL-18072-SPIK…
Browse files Browse the repository at this point in the history
…E-Evaluate-the-full-screen-issue-with-new-case-and-task-list-12

IVYPORTAL-18072 SPIKE: Evaluate the full screen issue with new case a…
  • Loading branch information
mnhnam-axonivy authored Dec 18, 2024
2 parents 559ae67 + e2ce1b2 commit 96773dc
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 16 deletions.
4 changes: 2 additions & 2 deletions AxonIvyPortal/portal/config/variables/Portal/Dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
],
"layout": {
"w": 12,
"h": 8,
"h": 12,
"x": 0,
"y": 0
},
Expand Down Expand Up @@ -489,7 +489,7 @@
],
"layout": {
"w": 12,
"h": 8,
"h": 12,
"x": 0,
"y": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public void init() {
.findGlobalSettingValue(GlobalVariable.DEFAULT_BEHAVIOUR_WHEN_CLICKING_ON_LINE_IN_TASK_LIST)
.equals(BehaviourWhenClickingOnLineInTaskList.RUN_TASK.name());

// Set responsive option for default task list and case list
if (DashboardUtils.isDefaultCaseListDashboard(selectedDashboard)
|| DashboardUtils.isDefaultTaskListDashboard(selectedDashboard)) {
selectedDashboard.setIsResponsive(true);
}

buildClientStatisticApiUri();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ public class Dashboard extends AbstractConfiguration implements Serializable {
private String displayedPermission;
private Boolean isTopMenu;

@JsonIgnore
private Boolean isResponsive;

public Dashboard() {
// Set default values
isTopMenu = false;
isResponsive = false;
}

public Dashboard(Dashboard dashboard) {
Expand All @@ -54,6 +58,7 @@ public Dashboard(Dashboard dashboard) {
permissionDTOs = dashboard.permissionDTOs;
displayedPermission = dashboard.displayedPermission;
isTopMenu = dashboard.isTopMenu;
isResponsive = dashboard.isResponsive;
}

public String getTitle() {
Expand Down Expand Up @@ -146,6 +151,16 @@ public void setIsTopMenu(Boolean isTopMenu) {
this.isTopMenu = isTopMenu;
}

@JsonIgnore
public Boolean getIsResponsive() {
return isResponsive;
}

@JsonIgnore
public void setIsResponsive(Boolean isResponsive) {
this.isResponsive = isResponsive;
}

@Override
public int hashCode() {
final int prime = 31;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,13 @@ public static void updatePropertiesToNullIfCurrentValueIsDefaultValue(List<Dashb
}
}

public static boolean isDefaultTaskListDashboard(Dashboard dashboard) {
return Optional.ofNullable(dashboard).map(Dashboard::getId)
.orElseGet(() -> "").contentEquals(DEFAULT_TASK_LIST_DASHBOARD);
}

public static boolean isDefaultCaseListDashboard(Dashboard dashboard) {
return Optional.ofNullable(dashboard).map(Dashboard::getId)
.orElseGet(() -> "").contentEquals(DEFAULT_CASE_LIST_DASHBOARD);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class DefaultDashboardUtils {
],
"layout": {
"w": 12,
"h": 8,
"h": 12,
"x": 0,
"y": 0
},
Expand Down Expand Up @@ -168,7 +168,7 @@ public class DefaultDashboardUtils {
],
"layout": {
"w": 12,
"h": 8,
"h": 12,
"x": 0,
"y": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
}

$(document).ready(function () {
loadGrid(#{managedBean.selectedDashboard.isResponsive});
updateDashboardWhenResizeWindow(#{managedBean.selectedDashboard.isResponsive});
setTimeout(() => {
initStatistics();
}, 50);
Expand Down Expand Up @@ -48,7 +50,7 @@

<h:form id="dashboard-remote-command-form" prependId="false">
<h:inputHidden id="dashboard-view-mode" value="#{managedBean.isReadOnlyMode}"/>
<p:remoteCommand name="updateDashboardWidget" update="grid-stack" oncomplete="loadGrid();dashboardToolKit.responsive(); initStatistics('#{managedBean.clientStatisticApiUri}');" />
<p:remoteCommand name="updateDashboardWidget" update="grid-stack" oncomplete="loadGrid(#{managedBean.selectedDashboard.isResponsive});dashboardToolKit.responsive(); initStatistics('#{managedBean.clientStatisticApiUri}');" />
<p:remoteCommand name="loadAllWidgetSavedFilters" actionListener="#{managedBean.loadAllWidgetSavedFilters()}"
global="false" process="@this" immediate="true" partialSubmit="true"
update="delete-saved-filter-form:quick-filter-table"
Expand Down Expand Up @@ -181,7 +183,7 @@
<p:commandButton id="confirm-destruction-dashboard-tasks" value="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/common/destroy')}"
icon="#{visibilityBean.generateButtonIcon('si si-remove')}"
actionListener="#{taskWidgetBean.destroyTask(taskWidgetBean.selectedTaskItemId)}"
oncomplete="PF('destroy-task-dialog').hide();loadGrid(); initStatistics();"
oncomplete="PF('destroy-task-dialog').hide();loadGrid(#{managedBean.selectedDashboard.isResponsive}); initStatistics();"
update="grid-stack dashboard-title-container" />
</ui:define>
</ui:decorate>
Expand All @@ -203,13 +205,13 @@
<p:commandButton id="confirm-escalation-dashboard-tasks" value="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/common/yes')}"
icon="#{visibilityBean.generateButtonIcon('si si-check-1')}"
actionListener="#{taskWidgetBean.expiryTask(taskWidgetBean.selectedTaskItemId)}"
oncomplete="PF('escalation-task-dialog').hide();loadGrid();initStatistics();" update="grid-stack dashboard-title-container" />
oncomplete="PF('escalation-task-dialog').hide();loadGrid(#{managedBean.selectedDashboard.isResponsive});initStatistics();" update="grid-stack dashboard-title-container" />
</ui:define>
</ui:decorate>

<!-- Delegate Task Dialog -->
<ic:ch.ivy.addon.portalkit.component.TaskItemDelegate id="dashboard-tasks-item-delegate"
taskId="#{taskWidgetBean.selectedTaskItemId}" componentToUpdate="grid-stack dashboard-title-container" onCompletedCallback="loadGrid(); initStatistics();"/>
taskId="#{taskWidgetBean.selectedTaskItemId}" componentToUpdate="grid-stack dashboard-title-container" onCompletedCallback="loadGrid(#{managedBean.selectedDashboard.isResponsive}); initStatistics();"/>

<!-- Workflow Event of Task Dialog -->
<ic:ch.ivy.addon.portalkit.component.TaskItemWorkflowEvents id="dashboard-tasks-workflow-event"
Expand All @@ -231,7 +233,7 @@
<p:commandButton id="confirm-destruction-dashboard-cases" value="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/common/destroy')}"
icon="#{visibilityBean.generateButtonIcon('si si-remove')}"
actionListener="#{caseWidgetBean.destroyCase(caseWidgetBean.selectedCase)}"
oncomplete="PF('destroy-case-dialog').hide();loadGrid();initStatistics();"
oncomplete="PF('destroy-case-dialog').hide();loadGrid(#{managedBean.selectedDashboard.isResponsive});initStatistics();"
update="grid-stack dashboard-title-container" />
</ui:define>
</ui:decorate>
Expand Down Expand Up @@ -308,7 +310,7 @@

<h:panelGroup rendered="#{managedBean.isShowShareButtonOnDashboard() and not managedBean.isMainDashboardSelected()}" layout="block" styleClass="u-text-align-center">
<p:link value="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/dashboard/ShareThisDashboard')}"
onclick="PF('share-dashboard-dialog').show(); return false;" />
onclick="PF('share-dashboard-dialog').show(); return false;" styleClass="js-share-dashboard-link" />
</h:panelGroup>
<ic:com.axonivy.portal.component.ShareLinkDialog
id="share-dashboard-component"
Expand Down
62 changes: 57 additions & 5 deletions AxonIvyPortal/portal/webContent/resources/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
var grids;
var originalGridstackHeight = 0;
loadGrid();
// resizeTableBody();
function loadGrid() {

const defaultNumberOfCells = 12;
const defaultCellHeight = 100;
const additionalHeightForResizeHandler = 15;

// Store the initial window height to detect changes
let windowHeight = window.innerHeight;

function loadGrid(isResponsive) {

// Set default height for cells
var gridCellHeight = defaultCellHeight;

if (isResponsive) {
var dashboardModificationPageHeaderHeight = 0;
const announcementHeight = ($('.js-announcement-message').outerHeight(true) || 0);
const shareDashboardLinkHeight = ($('.js-share-dashboard-link').outerHeight(true) || 0);

if ($('.js-dashboard__header').length > 0) {
dashboardModificationPageHeaderHeight = ($('.js-dashboard__header').outerHeight(true) || 0) + additionalHeightForResizeHandler;
}

// calculate available height then divide by default number of cells to get height value for each cell
gridCellHeight = (PortalLayout.getAvailableHeight() - announcementHeight
- shareDashboardLinkHeight - dashboardModificationPageHeaderHeight) / defaultNumberOfCells;

// If the calculated cell height is less than or equals to 0, use the default cell height instead
gridCellHeight = gridCellHeight > 0 ? gridCellHeight : defaultCellHeight;
}

grids = GridStack.initAll({
column: 12,
cellHeight: 100,
column: defaultNumberOfCells,
cellHeight: gridCellHeight,
resizable: {
handles: 'e, se, s, sw, w'
}
Expand Down Expand Up @@ -534,4 +561,29 @@ function udateResizableTablesWhenResizeWidget() {
}
});

}

function updateDashboardWhenResizeWindow(isResponsiveDashboard) {
if (!isResponsiveDashboard) {
return;
}

// resize timeout ID
let resizeTimeout;

window.addEventListener('resize', function () {
clearTimeout(resizeTimeout);

resizeTimeout = setTimeout(function () {

// Check if the window height has changed
if (window.innerHeight !== windowHeight) {

// Call the remote command 'updateDashboardWidget'
updateDashboardWidget();

windowHeight = window.innerHeight;
}
}, 1000); // Delay execution by 1 sec to avoid send multiple requests
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ var PortalLayout = {

getAvailableHeight: function () {
var $layoutMain = $('.js-layout-main');
var layoutMainPadding = parseInt($layoutMain.css('padding-top') || 0) + parseInt($layoutMain.css('padding-bottom') || 0);
const roundedLayoutMainPaddingTop = parseInt(Math.round(parseFloat($layoutMain.css('padding-top') || 0)) || 0);
const roundedLayoutMainPaddingBottom = parseInt(Math.round(parseFloat($layoutMain.css('padding-bottom') || 0)) || 0);
var layoutMainPadding = roundedLayoutMainPaddingTop + roundedLayoutMainPaddingBottom;

return window.innerHeight - layoutMainPadding;
},

Expand Down

0 comments on commit 96773dc

Please sign in to comment.