Presentation of reference attributes

We will have a separate look at the presentation options for reference attributes (see also presentation options for references).

Most of the time instances of the objects referred to through reference attributes are displayed on a form as a table, where every instance is represented as a row in this table. Every row shows certain attributes of the referred object. For example, loans on the member form are shown as a table. For each loan this table shows when the loan was made and its due date. AwareIM automatically generates such a table and shows the default number of instances of the referred object (you can navigate to other instances as well). AwareIM picks the attributes of the referred object that it shows in this table at random.

Most of the time we want to customize the default appearance of the reference table and specify the attributes that will be shown. We will start by customizing the appearance of the Loans attribute of the Member object. When loans of a member are displayed we want to show the following details for each loan: loan status, item title and due date. We have Status and DueDate attributes in the Loan object, but the title of the item that has been borrowed is only available through the referred item: Loan.Item.Title. At this stage AwareIM cannot show such attributes in a reference table – it can only show attributes that are defined in the referred object itself. Fortunately, there is another option – we can define the attribute of the Shortcut type in the Loan object (called, for example, ItemTitle) that will point to the Title attribute of the referred Item object. To do this open the Loan object for editing and define the new attribute called ItemTitle. Its type should be Shortcut and the shortcut path should be Item.Title (the attribute will point to the Title attribute through the reference attribute of the Loan object Item).

Now we can change the presentation of the Loans attribute in the Member object to show Status, ItemTitle and DueDate attributes. To do this open the Member object for editing and select the Loans attribute. Click on the Presentation tab on the list of properties for the attribute. Then click on the Widget settings property. The dialog will be displayed. Tick the above attributes from the list of Attributes to Display. Then click OK on the dialog. We will also sort loans in the reference table by status and due date, so we click on the Record sorting/filtering property and set the corresponding sorting criteria in the Record Sorting table. We will now click on the OK button to save the sorting dialog and then click on the Save button to save the changes to the Member object.

Similar changes should be made not only to the Loans attribute, but to all other references of the Member object and all references of other objects as well. You can check presentation of all references in the sample configuration located in the samples directory of your AwareIM installation.

One of the references will be displayed a little differently so we will mention it here. We are talking about the reference attribute Type in the Item object. This attribute refers to the ItemType object. Unlike many other reference attributes this attribute is editable. This means that the user will be able to change it by selecting a different instance of the ItemType object from the list of all existing item types. When a reference attribute is represented as a reference table, if you want to add an instance to a table or select a different instance you need to click on a button that brings you to a separate screen that lists all existing instances. In this particular case, though, there are usually a very few instances of the ItemType object in the system so we want to show them all on the form itself (for example, as a drop down list, so the user will be able to select the item type from the drop down without having to go to a separate screen).

To specify that the Type attribute of the Item object should be represented as a drop down list we open the Item object for editing, select the Type attribute on the Attributes tab and click on the Presentation tab on the list of attribute properties. Then we select the “Combo-box” option in the drop-down representing the Widget property (rather than the usual “Grid” option.)

Another improvement that we will make to the presentation of loans on the form of the Member object is highlighting overdue loans. In the table of loans for a member entries representing overdue loans will be displayed in red, whereas all other loans will be displayed in the default color. To achieve this we will select the Loans attribute of the Member object, click on the “Presentation” tab and then click on the Item display rules property. This will show the Item Rules dialog that allows us to specify the conditions under which a particular entry will be highlighted.

An entry representing a loan should be highlighted if the loan is current and its due date is in the past:

Loan.Status = 'Current' AND Loan.DueDate < CURRENT_DATE 

We need to enter these conditions into the table displayed by the dialog. Each condition is specified in the Condition column. Enter the above condition directly into the Condition column.

Now we need to define the properties of the entry in the table of loans that will be displayed when the above conditions are met. Click on the Set Style button. In the dialog that appears select Use this color radio button for the foreground color and pick the red color. Also select the Use this font style radio button and select “Bold” as font style. Click on the OK button to save the property and then click on the Save button to save changes to the object.