Changing List Displays: Difference between revisions

From IHRIS Wiki
(Created page with "There are many lists in the system and there are many options on how to display them. ==Example: Position List== ===The Default Display=== The default position list display is...")
 
Line 17: Line 17:


===Changing the Default Display===
===Changing the Default Display===
Suppose that you wanted to customized the position list so that it no longer displays the position code.  We could do so with 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'>
<?xml version="1.0"?>
<!DOCTYPE I2CEConfiguration SYSTEM "I2CE_Configuration.dtd">
<I2CEConfiguration name="my-Position">
  <!-- creating a new module called my-Position.  We will need to require this module in our site module-->
  <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">
      <!-- We will be customizing by extending the existing PersonPosition class which is defined in the ihris-manage-PersonPosition module.  Thus we need  to require it here-->
      <atLeast version="4.1" />
      <lessThan version="4.2" />
    </requirement>
    <path name="templates">
      <!-- Since we are removing the position code, we will want to make customized .html templates which do not reference the "postion+code".  We will store them in the templates subdirectory of this module -->
      <value>./templates</value>
    </path>
    <!-- set the priority of this module higher than the "ihris-manage-PersonPostion" modules (which is 350) so that we load this module's templates over the ihris-manage-PersonPosition templates-->
    <priority>380</priority>
  </metadata>
  <configurationGroup name="my-Position" path="/I2CE">
    <configurationGroup name='MyPosition' path="/modules/forms/forms/position">
          <configuration name="class" values="single">
            <!-- Specifies that the form position will use the customized MyPosition form class -->
            <value>MyPosition</value>
          </configuration>
    </configurationGroup>
    <configurationGroup name='MyPositionClass' path="/modules/forms/formClasses/MyPosition">
          <!-- Definition of the custom MyPosition form class -->
          <configuration name="extends">
            <displayName>The class this form extends</displayName>
            <!-- Specify that we are modifying the iHRIS_Position class
            <value>iHRIS_PersonPosition</value>
          </configuration>
           <configurationGroup name="meta" path="meta/list/default">
           <configurationGroup name="meta" path="meta/list/default">
             <configuration name="display_string">
             <configuration name="display_string">
Line 24: Line 62:
             </configuration>
             </configuration>
             <configuration name="display_args" type="delimited" values="many">
             <configuration name="display_args" type="delimited" values="many">
              <!-- The display of the list will look like:  Title (Facility, Department) -->
               <value>0:title</value>
               <value>0:title</value>
               <value>1:facility</value>
               <value>1:facility</value>
Line 29: Line 68:
             </configuration>
             </configuration>
             <configuration name="sort_fields" type="delimited" values="many">
             <configuration name="sort_fields" type="delimited" values="many">
              <!-- Sort on title, then facility, then department -->
               <value>0:title</value>
               <value>0:title</value>
               <value>0:facility</value>
               <value>1:facility</value>
               <value>1:department</value>
               <value>2:department</value>
             </configuration>
             </configuration>
           </configurationGroup>
           </configurationGroup>
    </configurationGroup>
</source>
</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.

Revision as of 10:42, 15 November 2011

There are many lists in the system and there are many options on how to display them.

Example: Position List

The Default Display

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

Changing the Default Display

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>

</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.