Commit b135d644 authored by Dries's avatar Dries

- Patch #796658 by yched, andypost: UI for field formatter settings.

parent ecc7ce08
......@@ -16,35 +16,51 @@
*/
?>
<?php if ($rows): ?>
<div id="field-display-overview-wrapper">
<table id="field-display-overview" class="field-display-overview sticky-enabled">
<thead>
<tr>
<th><?php print t('Field'); ?></th>
<th><?php print t('Weight'); ?></th>
<th><?php print t('Label'); ?></th>
<th><?php print t('Format'); ?></th>
<th colspan="3"><?php print t('Format'); ?></th>
</tr>
</thead>
<tbody>
<tr class="region-message region-visible-message <?php print empty($rows['visible']) ? 'region-empty' : 'region-populated'; ?>">
<td colspan="4"><em><?php print t('No field is displayed'); ?></em></td>
<td colspan="5"><em><?php print t('No field is displayed'); ?></em></td>
</tr>
<?php
$count = 0;
foreach ($rows['visible'] as $row): ?>
<tr class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?> <?php print $row->class ?>">
<tr id="<?php print $row->id; ?>" class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?> <?php print $row->class ?>">
<td><span class="<?php print $row->label_class; ?>"><?php print $row->human_name; ?></span></td>
<td><?php print $row->weight . $row->hidden_name; ?></td>
<td><?php if (isset($row->label)) print $row->label; ?></td>
<td><?php print $row->type; ?></td>
<?php if (isset($row->settings_edit_form)) : ?>
<td colspan="3">
<?php print $row->type; ?>
<?php print $row->settings_edit_form; ?>
</td>
<?php else :?>
<td>
<?php print $row->type; ?>
</td>
<td class="field-formatter-summary-cell">
<?php print $row->settings_summary; ?>
</td>
<td>
<?php print $row->settings_edit; ?>
</td>
<?php endif; ?>
</tr>
<?php $count++;
endforeach; ?>
<tr class="region-title region-title-hidden">
<td colspan="4"><?php print t('Hidden'); ?></td>
<td colspan="5"><?php print t('Hidden'); ?></td>
</tr>
<tr class="region-message region-hidden-message <?php print empty($rows['hidden']) ? 'region-empty' : 'region-populated'; ?>">
<td colspan="4"><em><?php print t('No field is hidden'); ?></em></td>
<td colspan="5"><em><?php print t('No field is hidden'); ?></em></td>
</tr>
<?php foreach ($rows['hidden'] as $row): ?>
<tr class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?> <?php print $row->class ?>">
......@@ -52,9 +68,16 @@
<td><?php print $row->weight . $row->hidden_name; ?></td>
<td><?php if (isset($row->label)) print $row->label; ?></td>
<td><?php print $row->type; ?></td>
<td class="field-formatter-summary-cell">
<?php print $row->settings_summary; ?>
</td>
<td>
<?php print $row->settings_edit; ?>
</td>
</tr>
<?php $count++;
endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
This diff is collapsed.
......@@ -131,6 +131,71 @@ function hook_field_widget_settings_form($field, $instance) {
return $form;
}
/**
* Returns form elements for a formatter's settings.
*
* @param $field
* The field structure being configured.
* @param $instance
* The instance structure being configured.
* @param $view_mode
* The view mode being configured.
* @param $form
* The (entire) configuration form array, which will usually have no use here.
* @param $form_state
* The form state of the (entire) configuration form.
*
* @return
* The form elements for the formatter settings.
*/
function hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
$element['trim_length'] = array(
'#title' => t('Length'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $settings['trim_length'],
'#element_validate' => array('_element_validate_integer_positive'),
'#required' => TRUE,
);
}
return $element;
}
/**
* Returns a short summary for the current formatter settings of an instance.
*
* @param $field
* The field structure.
* @param $instance
* The instance structure.
* @param $view_mode
* The view mode for which a settings summary is requested.
*
* @return
* A string containing a short summary of the formatter settings.
*/
function hook_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = '';
if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
$summary = t('Length: @chars chars', array('@chars' => $settings['trim_length']));
}
return $summary;
}
/**
* @} End of "ingroup field_ui_field_type"
*/
......@@ -15,10 +15,37 @@
padding-bottom: .5em;
}
/* Manage display */
/* 'Manage display' overview */
.field-display-overview tr.region-title td {
font-weight: bold;
}
.field-display-overview tr.region-populated {
display: none;
}
.field-display-overview .field-formatter-summary-cell {
line-height: 1em;
}
.field-display-overview .field-formatter-summary {
float: left;
font-size: 0.9em;
}
.field-display-overview td.field-formatter-summary-cell span.warning {
display: block;
float: left;
margin-right: .5em;
}
.field-display-overview .field-formatter-settings-edit-wrapper {
float: right;
}
.field-display-overview .field-formatter-settings-edit {
float: right;
}
.field-display-overview tr.field-formatter-settings-editing td {
vertical-align: top;
}
.field-display-overview tr.field-formatter-settings-editing .field-formatter-type {
display: none;
}
.field-display-overview .field-formatter-settings-edit-form .formatter-name{
font-weight: bold;
}
\ No newline at end of file
......@@ -134,6 +134,8 @@ Drupal.behaviors.fieldManageDisplayDrag = {
var value = 'hidden';
}
$select.val(value);
// Fire AJAX update of formatter settings.
$select.change();
}
$select.removeData('noUpdate');
}
......
......@@ -940,6 +940,28 @@ div.add-or-remove-shortcuts {
border: #ccc 1px solid;
}
/* Field UI */
.field-display-overview input.field-formatter-settings-edit {
margin: 0;
padding: 1px 8px;
}
.field-display-overview tr.field-formatter-settings-changed {
background: #FFFFBB;
}
.field-display-overview tr.drag {
background: #FFEE77;
}
.field-display-overview tr.field-formatter-settings-editing {
background: #D5E9F2;
}
.field-display-overview .field-formatter-settings-edit-form .form-item {
margin: 10px 0;
}
.field-display-overview .field-formatter-settings-edit-form .form-submit {
margin-bottom: 0;
}
/* Recent content block */
#dashboard div#block-node-recent div.content {
padding: 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment