Added descriptive text to the customer entry page, as well as work to associate labels with the inputs and set their class dynamically, to flag missing required fields.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@753 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -42,11 +42,12 @@ function customerContactDiv($obj, $values = null, $primary = false) {
|
||||
' CLASS="contact-%{id}-source" ' . "\n" .
|
||||
' ID="contact-%{id}-source-'.$stype.'"' . "\n" .
|
||||
' VALUE="'.$stype.'"' . "\n" .
|
||||
//' CHECKED' . "\n" .
|
||||
($stype == 'new' ? ' CHECKED' . "\n" : '') .
|
||||
' />' . "\n" .
|
||||
' <LABEL FOR="contact-%{id}-source-'.$stype.'">'.$sname.'</LABEL>' . "\n" .
|
||||
' ';
|
||||
}
|
||||
$div .= "<P>(Phone numbers / Addresses can be added later)";
|
||||
}
|
||||
$div .= "\n";
|
||||
|
||||
@@ -75,23 +76,35 @@ function customerContactDiv($obj, $values = null, $primary = false) {
|
||||
(
|
||||
'Customer.primary_contact_entry' => array
|
||||
('name' => 'Primary Contact',
|
||||
'label_attributes' => array('class' => null),
|
||||
'no_prefix' => true,
|
||||
'opts' => array
|
||||
('type' => 'radio',
|
||||
'options' => array('%{id}' => false),
|
||||
'value' => ($primary ? '%{id}' : 'bogus-value-to-suppress-hidden-input'),
|
||||
)),
|
||||
),
|
||||
'after' => ("Check this button if this contact will be the primary" .
|
||||
" contact for this customer (there can be only one primary" .
|
||||
" contact"),
|
||||
),
|
||||
|
||||
|
||||
'type' => array
|
||||
('opts' => array
|
||||
('label_attributes' => array('class' => 'required'),
|
||||
'opts' => array
|
||||
('options' => $obj->varstore['contactTypes'],
|
||||
'selected' => (isset($values) ? $values['ContactsCustomer']['type'] : null),
|
||||
)),
|
||||
),
|
||||
'after' => "An actual tenant, or just an alternate contact?"
|
||||
),
|
||||
|
||||
'comment' => array
|
||||
('opts' => array
|
||||
('label_attributes' => array('class' => 'optional empty'),
|
||||
'opts' => array
|
||||
('value' => (isset($values) ? $values['ContactsCustomer']['comment'] : null),
|
||||
)),
|
||||
),
|
||||
'after' => "Optional: Comments on the relationship between this customer and this contact."
|
||||
),
|
||||
|
||||
))) . "\n" .
|
||||
|
||||
@@ -115,22 +128,38 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
||||
if ($stype === 'existing') {
|
||||
$fields = array
|
||||
('id' => array('name' => 'Contact',
|
||||
'opts' => array('options' => $obj->varstore['contacts'])),
|
||||
'label_attributes' => array('class' => 'required empty'),
|
||||
'opts' => array('options' => $obj->varstore['contacts']),
|
||||
'after' => "Select the existing contact."),
|
||||
);
|
||||
}
|
||||
elseif ($stype === 'new') {
|
||||
$fields = array
|
||||
('first_name' => true,
|
||||
'last_name' => true,
|
||||
'middle_name' => true,
|
||||
'display_name' => true,
|
||||
'company_name' => array('name' => 'Company'),
|
||||
'id_federal' => array('name' => 'SSN'),
|
||||
'id_local' => array('name' => 'ID #'),
|
||||
'id_local_state' => array('name' => 'ID State'),
|
||||
('last_name' => array('label_attributes' => array('class' => 'required empty'),
|
||||
//'opts' => array('onchange' => 'alert("changed")'),
|
||||
'after' => "Required."),
|
||||
'first_name' => array('label_attributes' => array('class' => 'recommended empty'),
|
||||
'after' => "Recommended."),
|
||||
'middle_name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => "Optional."),
|
||||
'display_name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => "Optional: Will default to customer name."),
|
||||
'company_name' => array('name' => 'Company',
|
||||
'label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => "Optional: Company name, if corporate contact."),
|
||||
'id_federal' => array('name' => 'SSN',
|
||||
'label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => "Optional: Social Security Number."),
|
||||
'id_local' => array('name' => 'ID #',
|
||||
'label_attributes' => array('class' => 'recommended empty'),
|
||||
'after' => "Recommended: Driver's license, for example."),
|
||||
'id_local_state' => array('name' => 'ID State',
|
||||
'label_attributes' => array('class' => 'recommended empty'),
|
||||
'after' => "Recommended: State which issued the ID"),
|
||||
/* 'id_local_exp' => array('name' => 'ID Expiration', */
|
||||
/* 'opts' => array('empty' => true)), */
|
||||
'comment' => true,
|
||||
'comment' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => "Optional: Comments about this contact."),
|
||||
);
|
||||
}
|
||||
elseif ($stype === 'show') {
|
||||
@@ -151,14 +180,14 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
||||
'<div ' . "\n" .
|
||||
' class="contact-%{id}-div"' . "\n" .
|
||||
' id="contact-%{id}-'.$stype.'-div"' . "\n" .
|
||||
(isset($values) ? '' : ' STYLE="display:none;"' . "\n") .
|
||||
((isset($values) || $stype == 'new') ? '' : ' STYLE="display:none;"' . "\n") .
|
||||
'>' . "\n" .
|
||||
|
||||
$obj->element
|
||||
($element,
|
||||
array('class' => "item contact {$class}",
|
||||
'field_prefix' => 'Contact.%{id}')
|
||||
+ compact('rows', 'fields', 'column_class')) .
|
||||
+ compact('rows', 'fields', 'row_class', 'column_class')) .
|
||||
|
||||
($stype === 'show'
|
||||
? '<input type="hidden" name="data[Contact][%{id}][id]" value="'.$values['id'].'"/>' . "\n"
|
||||
@@ -221,8 +250,28 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
||||
.slideDown();
|
||||
}
|
||||
|
||||
function setEmpty(input_elem) {
|
||||
selector = "label[for=" + $(input_elem).attr("id") + "]";
|
||||
//$("#debug").append($(input_elem).attr("id") + ": " + $(input_elem).val() + "<BR>");
|
||||
if ($(input_elem).val() == '')
|
||||
$(selector).addClass('empty');
|
||||
else
|
||||
$(selector).removeClass('empty');
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
resetForm();
|
||||
|
||||
// In case refresh is hit with populated fields
|
||||
$(":input").each(function(i,elem){ setEmpty(elem); });
|
||||
|
||||
// keyup doesn't catch cut from menu
|
||||
$(":input").live('keyup', function(){
|
||||
setEmpty(this);
|
||||
});
|
||||
$(":input").live('mouseup', function(){
|
||||
setEmpty(this);
|
||||
});
|
||||
});
|
||||
|
||||
--></script>
|
||||
@@ -247,8 +296,12 @@ echo($this->element
|
||||
array('class' => 'item customer detail',
|
||||
'caption' => isset($this->data['Customer']) ? 'Edit Customer' : 'New Customer',
|
||||
'fields' => array
|
||||
('name' => true,
|
||||
'comment' => true,
|
||||
('name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => ("Optional: If this field is left blank, the" .
|
||||
" customer name will be set to the name of" .
|
||||
" the primary contact, below.")),
|
||||
'comment' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => 'Optional: Comments about this customer.'),
|
||||
))) . "\n");
|
||||
|
||||
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
||||
|
||||
@@ -32,8 +32,8 @@ foreach ($fields AS $field => $config) {
|
||||
$include_after = true;
|
||||
}
|
||||
|
||||
|
||||
$column_class = array();
|
||||
if (empty($column_class))
|
||||
$column_class = array();
|
||||
if ($include_before)
|
||||
$column_class[] = 'before';
|
||||
$column_class[] = 'field';
|
||||
@@ -79,7 +79,13 @@ foreach ($fields AS $field => $config) {
|
||||
$cells[] = null;
|
||||
}
|
||||
|
||||
$name = $config['name'];
|
||||
if (empty($config['opts']['label']))
|
||||
$name = $form->label($field, $config['name'],
|
||||
empty($config['label_attributes'])
|
||||
? null : $config['label_attributes']);
|
||||
else
|
||||
$name = $config['name'];
|
||||
|
||||
if (isset($config['with_name_before']))
|
||||
$name = $config['with_name_before'] . $name;
|
||||
elseif (isset($with_name_before))
|
||||
|
||||
@@ -52,8 +52,8 @@ if (isset($rows) && is_array($rows) && count($rows)) {
|
||||
|
||||
foreach ($rows AS $r => &$row) {
|
||||
foreach ($row AS $c => $col) {
|
||||
$cell_class = implode(" ", array_merge(isset( $row_class[$r]) ? $row_class[$r] : array(),
|
||||
isset($column_class[$c]) ? $column_class[$c] : array()));
|
||||
$cell_class = implode(" ", array_merge(empty( $row_class[$r]) ? array() : $row_class[$r],
|
||||
empty($column_class[$c]) ? array() : $column_class[$c]));
|
||||
if ($cell_class)
|
||||
$row[$c] = array($col, array('class' => $cell_class));
|
||||
}
|
||||
@@ -65,11 +65,11 @@ if (isset($rows) && is_array($rows) && count($rows)) {
|
||||
|
||||
// OK, output the table HTML
|
||||
echo('<TABLE' .
|
||||
(isset($id) ? ' ID="'.$id.'"' : '') .
|
||||
(isset($class) ? ' CLASS="'.$class.'"' : '') .
|
||||
(empty($id) ? '' : ' ID="'.$id.'"') .
|
||||
(empty($class) ? '' : ' CLASS="'.$class.'"') .
|
||||
'>' . "\n");
|
||||
|
||||
if (isset($caption))
|
||||
if (!empty($caption))
|
||||
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
||||
|
||||
if (isset($headers) && is_array($headers)) {
|
||||
|
||||
@@ -46,7 +46,7 @@ span.fmt-age.delinquent { color: #f00; }
|
||||
|
||||
table.item th ,
|
||||
table.item td { padding: 0.1em 0.4em 0.1em 0.4em; }
|
||||
table.item td { white-space: nowrap; }
|
||||
table.item td.name { white-space: nowrap; }
|
||||
/* table.item { border-spacing: 0 0; /\*IE*\/border-collapse: collapse; empty-cells: show } */
|
||||
table.item { border-spacing: 0 0; empty-cells: show }
|
||||
table.item { border:1px solid #ccc;
|
||||
@@ -122,6 +122,11 @@ div.detail.supporting { clear : both;
|
||||
.edit table.detail { width : 80%;
|
||||
float : none;
|
||||
}
|
||||
table.item td { vertical-align: top; }
|
||||
.edit .item td.field .required { color: #33f }
|
||||
.edit .item td.field .recommended { color: #35d }
|
||||
.edit .item td.field .recommended.empty { color: #f5d }
|
||||
.edit .item td.field .required.empty { color: #f33 }
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Reference in New Issue
Block a user