JSGlobalUtilityFuncs

From GeoMedia Smart Client
Jump to: navigation, search
GMSC 2013/2014 Javascript API Overview Form Events Types Utility Functions client-side Validation Conditions Interaction with SmartClient Cookbook Cheatsheet
Utility Functions Request and URL Handling Localisation Dialogs & Notification Workflow Utility Functions

Modal Form Functions

IG.openSimpleModalForm (options)

opens a modal form with simplified parameters. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows

  options = {
    controller: 'Form',
    action: 'Index'
    form: '', //name of the form that should be opened as modal form 
    id: '{ROW.ID}' //id of the item that should be opened in the form (interpolated from the server middleware)
    closeAction: '', //close action, either 'reloadPage','reloadField', 'reloadFields' or 'transferFields'
    closeActionParam: '' //the parameter of the close action
}
closeAction closeActionParam Description
reloadPage - reloads the page after the modal form is closed
reloadField 'MAINFORM_FIELD_ID' reloads the field value in the main form after closing the modal form
reloadFields ['FIELD_ID1', 'FIELD_ID2'] reloads the fields in the main form value after closing the modal form
transferFields [{source: 'modalFormFieldId', dest: 'mainFormFieldId'}] transfers the value of the modal form field in source to the main form field given in dest. This happens without contacting the server. Multiple source/dest pairs can be specified.
responseHandling 'FUNCTION_NAME' delegates the handling of the response to a custom javascript function, which receives the parameters (response, modalForm, mainForm). Available since GMSC 2014

Example

This row action opens the modal form 'PRINTMEDIASIZE' with the currently selected ROW.ID

<FormAction 	name="EditFeatureActionParam" 
		image="ig-icon-edit" 
		action="SCRIPT[IG.openSimpleModalForm({
				form:'PRINTMEDIASIZE',
				id:{ROW.ID}, 
				closeAction: 'reloadFields', 
				closeActionParam:['MEDIASIZEGRID']})]" 
		type="row" />

IG.openModalForm (options)

opens a modal form with extended parameters. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows

 var options = {
        nodeid: undefined, //the nodeid of the form
        id: undefined, // the id of the item that should be opened in the modal form
        closeAction: undefined, //a close action, see IG.openSimpleModalForm for parameters
        closeActionParam: undefined, // the close action param, see IG.openSimpleModalForm
        formHeight: undefined, // a value of ('small','medium','large')
        url: '', //relative url as submit target,
        emptyform: undefined, //true or false - whether the modal form should be opened with empty values or not
      }

IG.abortModalForm () / IG.closeModalForm()

closes the modal form without performing any action, intended to be used as an action for a 'CANCEL' button in a modal form. GMSC 2013

IG.removeModalForm(options)

removes the currently opened item and closes the modal form, intended to be used as an action for a 'DELETE' button in a modal form. GMSC 2013

{Object} options options object for the function, the options are the same as for IG.remove (options).

IG.saveModalForm (options)

saves the changes made in the modal form and closes the modal form afterwards. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows

  options = {
      controller: IG.WorkflowContainer.controller || 'Form', //controller of the form (defined automatically by the server middleware)
      action: 'Save', //name of the action
  }

Example

This form.xml excerpt shows a modal form with 3 buttons (Save/Delete/Cancel)

 
<Form name="SessionFilterForm" table="RPI_SESSIONFILTER" idfield="ID">
    <FormTab name="SessionFilterTab">
      <FormGroup name="SessionFilterGroup" label="Definition">
        <FormField name="ID" label="Id:" type="textfield" datatype="guidstring" required="false" maxlength="36" visible="hidden"/>
        <FormField name="NAME" label="Name:" type="textfield" datatype="string" required="true" maxlength="128"/>
        <FormField name="FILTER" label="Filter:" type="textarea" datatype="string" required="true" maxlength="4000" visible="form" />
      </FormGroup>
    </FormTab>
    <!-- Save Button: save changes in the current form item -->
    <FormAction name="SaveCopyright" label="Save" action="SCRIPT[IG.saveModalForm()]" visible="form" submit="true"/> 
    <!-- Delete Button: deletes the current form item-->
    <FormAction name="DeleteCopyright" label="Delete" action="SCRIPT[IG.removeModalForm({confirmMessage:'Do you really want to delete the session filter?', id:{FORM.ID}})]" visible="form[OBJECT[HasValueProvider.GetValue({FORM.ID})]]"/>
    <!-- Cancel Button: aborts the modal form without performing any server side action -->
    <FormAction name="Cancel" label="Cancel" action="SCRIPT[IG.closeModalForm()]" visible="form" />
  </Form>

URL/Request Functions

IG.executeRequest (options)

executes an AJAX request to a server-side controller and reloads the given field(s) once the request has sucessfully completed. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows

  options = {
      controller: 'Workflow', //the name of the controller
      action: 'Index', //name of the action
      postAction: undefined, //name of the postAction, can either be 'reloadFields','reloadPage' or 'reloadField'
      postActionParams: undefined, //parameter of postAction, undefined for 'reloadPage', fieldId for 'reloadField' or array of FieldIds for 'reloadFields'
      reloadFields: [], //shortcut parameter for the most common case, reloadFields - expects an array of to-be-reloaded fields
      validateForm: true, //should the form be validated before the request is sent?
      urlParams: {} // additional url parameters included in the GET-Request
  }


Returns

{jqXHR} url the jQuery XHR object representing the request, can be used to subscribe additional callbacks

Example

performs a request to the controller Feature/SaveLabelFeatureAssignments and reloads the field LABELFEATUREGRID after this request has been completed. The returned {IGUrl} object request is then used to add another action.

var request = IG.executeRequest({controller:'Feature', action:'SaveLabelFeatureAssignments', postAction:'reloadField', postActionParams:'LABELFEATUREGRID'});
request.done(function(){
   alert("Request has been executed and field is reloaded");
});

IG.remove (options)

removed the given form item. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows:

options = {
  controller: IG.WorkflowContainer.controller || 'Form',
  action: "Delete",
  id: IG.WorkflowContainer.routevalues.id || "",
  isReloadPage: false,
  reloadFields: null,
  reloadField: null,
  isReloadList: false,
  confirmMessage: null,
  follownode: null,
  postParams: {}
};

Returns

{jqXHR} url the jQuery XHR object representing the remove request, can be used to subscribe additional callbacks

IG.submit (controller, action)

submits the current form to the given controller/action. GMSC 2013

Returns

{jqXHR} url the jQuery XHR object representing the submit request, can be used to subscribe additional callbacks

IG.trigger (options)

executes the given server-side triggers and performs the selected actions afterwards. GMSC 2013

Parameters

{Object} options options object for the function, the default values are as follows:

var options = {
  triggerNames: [], //Array of the trigger name(s) that should be executed
  postAction: '', //the to-be executed action
  postActionParams: '', // the post-action params
  postForm: true ,// should the form contents be posted?
  reloadFields:[] // fields that should be reloaded after executing the trigger
}

Returns

{jqXHR} url the jQuery XHR object representing the IG.trigger request, can be used to subscribe additional callbacks


Example

this example executes the trigger 'TriggerAssignPluginParam' and reloads the field 'PLUGINPARAMGRID' after completion.

IG.trigger({triggerNames:['TriggerAssignPluginParam'], reloadFields:['PLUGINPARAMGRID']})

Other Form Actions

IG.navigate(nodeId)

navigates the browser to the given node id page. GMSC 2013

IG.redirect (url)

redirects the current browser window to the given url. GMSC 2013

IG.redirectToWorkflowNode (controller, action, nodeid)

redirects the browser to the given workflow node. GMSC 2013

IG.reloadPage()

reloads the current page. GMSC 2013