Auto-complete-interaction

From VPOIDS Documentation

Auto complete interactions should be intuitive and consistent across all features of AFIDS. In additional, there are a number of user failure points which the design of the interaction should be designed to prevent.

We have settled on the following interaction, which is a compromise of simplicity and robustness.

Auto complete is used in two ways. The first is for the picking of a foreign key from a referenced table. In this case, the choice must be made from the list, and the user must select an item, otherwise, the system doesn't know what the choice is. The user cannot be allowed to tab off of the field or move off without selecting an item and expect that their item has been entered. This is a major point of failure. Another failure point is when changing a value in a referenced table. Editing the text of an entry can lead the user to conclude that the change is made, when there may be no matching item.

1. If a referenced value is null (or the record is new), the field is presented as a text field for entering the search term. For example, if the referenced field is an airport, the user would enter the airport name, city, or ident.

a. When the user chooses and item from the list of results, the text box is replaced with the foreign key descriptor (e.g. the airport name or ident) and a clickable link/icon to change or remove if the field is not required. When the item is selected, the value can be saved via ajax or stored in a hidden variable which can then be saved with the form is submitted, depending on which is more appropriate.

2. If the value of the referenced field exists, the foreign key descriptor (e.g. the airport name or ident) is displayed with a clickable link/icon to change or remove if the field is not required.

3. Clicking "change" brings up a text box with auto complete functionality. There must also be a cancel link in the case the user wants to keep the original entry.


<?php if(isset($airport)):?>

  
Identifier:
<?php echo $airport->getIdent()?>
Name:
<?php echo $airport->getName()?>

<?php endif;?> <?php if(!isset($airport)):?>

  <?php if ($can_edit) ?>
     <a href="javascript:change_airport('origin');" class="link-add">specify</a>
  <?php else:?>
     <?php if ($can_edit){ ?>
        <a href="javascript:change_airport('origin');" class="link-add">change</a>
     <?php }   ?>
     <?php if ($can_edit) echo link_to('unlink', '@default?module=airport&action=unlinkAirport&id='.$pilot->getId(), array('class' => 'action-remove', 'confirm' => 'Are you sure you want to remove this airport?'));?>
<?php endif;?>

<?php if($sf_params->get("id") > 0) $leg_id = $sf_params->get("id"); else $leg_id = null;?>