Running Dynaforms in full screen

From pmusers
Jump to: navigation, search

This example shows how to run a Dynaform and subsequent steps in the current task in full screen mode, so that users can't interact with the ProcessMaker top menu or the cases sidebar, until they finish the current task.



Process: Run_case_in_full_screen-1.pmx (right click and select Save Link As)
Author: Amos Batto <amos[at]processmaker.com>
Version: 1.0 (2019-05-21)
Tested in: PM 3.3.8 Community in Firefox 60.5


If the users working on a case should not be able to access the top menu or the cases sidebar, then adding the following JavaScript to the Dynaform will display it in full screen mode without a top menu or sidebar:

if (top.location != location) {
  top.location = location;
}

The Dynaform is normally displayed inside an <iframe> at the address:

http://{ip-or-domain}/sys{workspace}/{lang}/{skin}/cases/cases_Step?UID={dynaform-uid}&TYPE=DYNAFORM&POSITION={index}&ACTION=EDIT

For example:

http://example.com/sysworkflow/en/neoclassic/cases/cases_Step?UID=1624765995ce4903b678183049708760&TYPE=DYNAFORM&POSITION=1&ACTION=EDIT


This code will switch the Dynaform out of its <iframe> and display it as the topmost window in the web browser, switching from this window:

NormalViewPM.png

To this one:

DynaformInFullScreen.png


Then, the user can work on the rest of the steps in the current task. The problem is that after completing the task, the case list will be displayed without a top menu or sidebar:

CaseListWithoutMenusOrSidebar.png


To prevent this problem, create the following trigger to set the web browser to the normal view of the Home menu:

$g = new G();
$homeUrl = ($g->is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] .
   '/sys'. @@SYS_SYS .'/'. @@SYS_LANG .'/'. @@SYS_SKIN .'/cases/main';
print "<script>location = '$homeUrl';</script>";
die;

Set this trigger to fire after routing in the same task where the Dynaform is located.

When this trigger is executed, it will cause the web browser to switch to the normal view with the Inbox's case list:

NormalCaseListInsideIframe.png

How to set to full screen from a trigger

The above example will always set the Dynaform to full screen. However, it may be useful to only switch to full screen in certain situations and to make that decision in a trigger fired before the Dynaform. In this example, the Dynaform will only switch to full screen if the current logged-in user is a member of a group named "Full screen users".



Process: Run_case_in_full_screen_if_in_group-1.pmx (right click and select Save Link As)
Author: Amos Batto <amos[at]processmaker.com>
Version: 1.0 (2019-05-22)
Tested in: PM 3.3.8 Community in Firefox 60.5


First, go to Admin > Users > Groups and create a new group named "Full screen users". Add members to the group:

FullScreenCreateGroup.png

Then, create the following trigger, which uses PMFGetGroupUID() and PMFGetGroupUID() to find out if the current logged-in user is a member of the "Full screen users" group:

//if the current logged-in user is in the "Full screen users" group, then set 
//the @@doFullScreen variable to "yes" so that the JavaScript in 
//the Dynaform will switch to full screen
@@doFullScreen = 'no';
$groupId = PMFGetGroupUID('Full screen users');
$aUsers = PMFGetGroupUsers($groupId);

//search for logged-in user in group:
foreach ($aUsers as $aUser) {
   if ($aUser['USR_UID'] == @@USER_LOGGED) {
      @@doFullScreen = 'yes';
      break;
   }
}

Set this trigger to fire before the Dynaform which can switch to full screen.

Then, edit the Dynaform, and add a hidden field which is associated with the "doFullScreen" variable:

FullScreenAddHiddenField.png

Finally, add the following JavaScript to the Dynaform to check if the "doFullScreen" field is set to "yes" before switching the URL to display the Dynaform in the full screen:

if ($("#doFullScreen").getValue() == "yes" && top.location != location) {
  top.location = location;
}

Now, the Dynaform will only switch to full screen if the logged-in user is a member of the "Full screen users" group.