Changing List Displays: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 1: Line 1:
There are many lists in the system and there are many options on how to display them.   
There are many lists in the system and there are many options on how to display them.  Here we look at customizing the display of the Position list.


==Example: Position List==
==Example: Position List==
Line 15: Line 15:
**1:title
**1:title


==Changing the Default Display for Position==


===Creating a module===
==Creating a module==
Suppose that you wanted to customized the position list so that it no longer displays the position code.  We could create a module containing our "position" customizations that would require the "ihris-manage-PersonPosition" module and define a new display as in the following:
Suppose that you wanted to customized the position list so that it no longer displays the position code.  We could create a module containing our "position" customizations that would require the "ihris-manage-PersonPosition" module and define a new display as in the following:
<source lang='xml'>
<source lang='xml'>
Line 84: Line 83:
Note:  we have set the versions based on 4.1 of the software, this may be different for you if you are using version 4.0.
Note:  we have set the versions based on 4.1 of the software, this may be different for you if you are using version 4.0.


===Customized Templates===
==Customized Templates==
There are two files under "templates/en_US" of the "ihris-manage-PersonPosition" module that reference the "code" field which we are not using anymore.  These are "lists_form_postion.html" and "view_position.html."  We will need to create the "templates/en_US" sub-directories of our modules, copy these two files into it and  modify them by removing the reference to the code field.  Here is the result for "list_form_position.html:"
There are two files under "templates/en_US" of the "ihris-manage-PersonPosition" module that reference the "code" field which we are not using anymore.  These are "lists_form_postion.html" and "view_position.html."  We will need to create the "templates/en_US" sub-directories of our modules, copy these two files into it and  modify them by removing the reference to the code field.  Here is the result for "list_form_position.html:"
<source lang='xml'>
<source lang='xml'>

Revision as of 10:50, 15 November 2011

There are many lists in the system and there are many options on how to display them. Here we look at customizing the display of the Position list.

Example: Position List

The default position list display is set in the configuration .xml file for the ihris-manage-PersonPosition module. You can see where this is defined in magic data on lines 795-811. Here we are defining the "default" list display at the magic data node:

/modules/forms/formClasses/iHRIS_Position/meta/list/default

The three important parts here are:

  • The "display_string" which is "%s: %s (%s, %s)". Whenever you see a '%s' you in the display string we expect to substitute a field of the form into the string. For more details, see the explanation of the printf format.
  • The "display_args" which are the fields that are passed to the display string. These are substituted in order into the display string.
    • 0:code
    • 1:title
    • 2:facility
    • 3:department
  • The order in which the list is displayed. We are specifying that we first sort by the position code. Then, if two positions have the same code for some reason (or no code at all), then we sort by the title
    • 0:code
    • 1:title


Creating a module

Suppose that you wanted to customized the position list so that it no longer displays the position code. We could create a module containing our "position" customizations that would require the "ihris-manage-PersonPosition" module and define a new display as in the following: <source lang='xml'> <?xml version="1.0"?> <!DOCTYPE I2CEConfiguration SYSTEM "I2CE_Configuration.dtd"> <I2CEConfiguration name="my-Position">

 <metadata>
   <displayName>My Position</displayName>
   <category>Application Component</category>
   <description>Module for my customized position form </description>
   <creator>Intrahealth Informatics</creator>
   <email>hris@capacityproject.org</email>
   <link>https://launchpad.net/ihris-manage</link>
   <version>4.1.0</version>
   <requirement name="ihris-manage-PersonPosition">
     <atLeast version="4.1" />
     <lessThan version="4.2" />
   </requirement>
   <path name="templates">
     <value>./templates</value>
   </path>
   <priority>380</priority>
 </metadata>
 <configurationGroup name="my-Position" path="/I2CE">
    <configurationGroup name='MyPosition' path="/modules/forms/forms/position">
         <configuration name="class" values="single">
           <value>MyPosition</value>
         </configuration>
    </configurationGroup>
    <configurationGroup name='MyPositionClass' path="/modules/forms/formClasses/MyPosition">
         <configuration name="extends">
           <displayName>The class this form extends</displayName>
             <value>0:title</value>
             <value>1:facility</value>
             <value>2:department</value>
           </configuration>
           <configuration name="sort_fields" type="delimited" values="many">
             <value>0:title</value>
             <value>1:facility</value>
             <value>2:department</value>
           </configuration>
         </configurationGroup>
    </configurationGroup>
 </configurationGroup>

</I2CEConfiguration> </source> Note: we have set the versions based on 4.1 of the software, this may be different for you if you are using version 4.0.

Customized Templates

There are two files under "templates/en_US" of the "ihris-manage-PersonPosition" module that reference the "code" field which we are not using anymore. These are "lists_form_postion.html" and "view_position.html." We will need to create the "templates/en_US" sub-directories of our modules, copy these two files into it and modify them by removing the reference to the code field. Here is the result for "list_form_position.html:" <source lang='xml'> <tbody id="list_fields">

               
               
               
               
               
               
               
               
               
               
               
               
               
               
               

</tbody> </source>