Commit 999b2e53 authored by merlinofchaos's avatar merlinofchaos

Add better hiliting to the UI; now possible to tell what items are overridden...

Add better hiliting to the UI; now possible to tell what items are overridden as well as what item is currently being edited
parent f4b635b5
......@@ -344,10 +344,23 @@ html.js a.views-button-remove {
padding: 0;
}
div.views-basic-info div.view-changed {
float: right;
div.changed {
background: #ffd;
}
div.views-basic-info div.view-hide {
div.view-changed {
display: none;
float: right;
}
div.changed div.view-changed {
display: block;
}
.hilited {
background: #ffd;
}
.overridden {
font-style: italic;
}
This diff is collapsed.
......@@ -89,13 +89,17 @@ function views_ajax_form($form_id) {
}
// If the form wasn't submitted successfully, render the form.
$output = theme('status_messages');
$output .= drupal_render_form($form_id, $form);
$title = empty($form['#title']) ? '' : $form['#title'];
$url = empty($form['#url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form['#url'];
$js = empty($form['#js']) ? NULL : $form['#js'];
$object = new stdClass();
$object->display = theme('status_messages');
$object->display .= drupal_render_form($form_id, $form);
$object->title = empty($form['#title']) ? '' : $form['#title'];
$object->url = empty($form['#url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form['#url'];
$object->js = empty($form['#js']) ? NULL : $form['#js'];
if (!empty($form['#section'])) {
$object->hilite = '.' . views_ui_item_css($form['#section']);
}
views_ajax_render($output, $title, $url, $js);
views_ajax_render($object);
}
/**
......@@ -133,6 +137,10 @@ function views_render_ajax_form($form_id) {
$output->display .= drupal_render_form($form_id, $form);
$output->title = empty($form['#title']) ? '' : $form['#title'];
$output->url = empty($form['#url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form['#url'];
if ($form['#section']) {
$output->hilite = '.' . views_ui_item_css($form['#section']);
}
return $output;
}
......
......@@ -401,6 +401,16 @@ class views_display_plugin extends views_object {
}
$form['#title'] = check_plain($this->display->display_title) . ': ';
// Set the 'section' to hilite on the form.
// If it's the item we're looking at is pulling from the default display,
// reflect that.
if (!empty($this->display->display_options['defaults'][$form_state['section']])) {
$form['#section'] = 'default-' . $form_state['section'];
}
else {
$form['#section'] = $this->display->id . '-' . $form_state['section'];
}
switch ($form_state['section']) {
case 'display_title':
$form['#title'] .= t('The name of this display');
......@@ -562,6 +572,11 @@ class views_display_plugin extends views_object {
$plugin->options_validate($form[$form_state['section']], $form_state);
}
break;
case 'access':
$access = $form_state['values']['access'];
if ($access['type'] == 'role' && !array_filter($access['role'])) {
form_error($form, t('You must select at least one role if type is "by role"'));
}
}
}
......@@ -577,6 +592,8 @@ class views_display_plugin extends views_object {
break;
case 'title':
case 'access':
$this->set_option($section, $form_state['values'][$section]);
break;
case 'row_plugin':
// This if prevents resetting options to default if they don't change
// the plugin.
......@@ -955,10 +972,15 @@ class views_display_plugin_block extends views_display_plugin {
* but extended block handlers might be able to do interesting
* stuff with it.
*/
function hook_block($op = 'list', $delta = 0, $edit = array()) {
function execute_hook_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$delta = $this->view->name . '-' . $this->display->id;
return array($delta => array('info' => $this->get_option('block_description')));
$desc = $this->get_option('block_description');
if (empty($desc)) {
$desc = $this->view->name;
}
return array($delta => array('info' => $desc));
}
}
......@@ -1162,10 +1184,10 @@ class views_style_plugin_default extends views_style_plugin {
// @todo: This needs to be able to support either a database resource OR
// an array, because our input format doesn't actually have to be from
// a query.
$rows = '';
$rows = array();
while ($row = db_fetch_object($this->view->result)) {
// @todo: Include separator as an option.
$rows .= $this->row_plugin->render($row);
$rows[] = $this->row_plugin->render($row);
}
return theme(array('views_view_unformatted__' . $this->view->name, 'views_view_unformatted'), $this->view, $this->options, $rows);
}
......@@ -1204,10 +1226,9 @@ class views_style_plugin_list extends views_style_plugin {
// @todo: This needs to be able to support either a database resource OR
// an array, because our input format doesn't actually have to be from
// a query.
$rows = '';
$rows = array();
while ($row = db_fetch_object($this->view->result)) {
// @todo: Include separator as an option.
$rows .= $this->row_plugin->render($row);
$rows[] = $this->row_plugin->render($row);
}
return theme(array('views_view_list__' . $this->view->name, 'views_view_list'), $this->view, $this->options, $rows);
}
......
......@@ -145,10 +145,21 @@ class view extends views_db_object {
* @param $display_id
* The id of the display to mark as current.
*/
function set_display($display_id = 'default') {
function set_display($display_id = NULL) {
// If we have not already initialized the display, do so. But be careful.
if (empty($this->current_display)) {
$this->init_display();
// If handlers were not initialized, and no argument was sent, set up
// to the default display.
if (empty($display_id)) {
$display_id = 'default';
}
}
// If no display id sent in and one wasn't chosen above, we're finished.
if (empty($display_id)) {
return TRUE;
}
// Ensure the requested display exists.
......@@ -440,6 +451,24 @@ class view extends views_db_object {
}
}
/**
* Called to get hook_block information from the view and the
* named display handler.
*/
function execute_hook_block($display_id = NULL) {
// Prepare the view with the information we have.
// This was probably already called, but it's good to be safe.
if (!$this->set_display($display_id)) {
return FALSE;
}
// Execute the view
if (isset($this->display_handler)) {
return $this->display_handler->execute_hook_block();
}
}
/**
* Determine if the given user has access to the view. Note that
* this sets the display handler if it hasn't been.
......@@ -958,7 +987,12 @@ class views_db_object {
// Get the existing configuration
$fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
$fields[$id] = $item;
if (isset($item)) {
$fields[$id] = $item;
}
else {
unset($fields[$id]);
}
// Store.
$this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);
......
......@@ -107,7 +107,15 @@ Drupal.Views.Ajax.ajaxResponse = function(data) {
$('#views-tabset').clickTab(instance.$tabs.length);
}
}
if (data.hilite) {
$('.hilited').removeClass('hilited');
$(data.hilite).addClass('hilited');
}
if (data.changed) {
$('div.views-basic-info').addClass('changed');
}
}
Drupal.behaviors.ViewsAjaxLinks = function() {
......
......@@ -166,7 +166,7 @@ function node_views_data() {
'title' => t('Created year + month'),
'help' => t('In the form of YYYYMM'),
'argument' => array(
'handler' => 'views_handler_argument_date_year_month',
'handler' => 'views_handler_argument_node_created_year_month',
'arguments' => array(), // this is required to make sure construct is called.
),
);
......@@ -175,7 +175,7 @@ function node_views_data() {
'title' => t('Created year'),
'help' => t('In the form of YYYY'),
'argument' => array(
'handler' => 'views_handler_argument_date_year',
'handler' => 'views_handler_argument_node_created_year',
'arguments' => array(), // this is required to make sure construct is called.
),
);
......@@ -184,7 +184,7 @@ function node_views_data() {
'title' => t('Created month'),
'help' => t('In the form of MM 01 - 12'),
'argument' => array(
'handler' => 'views_handler_argument_date_month',
'handler' => 'views_handler_argument_node_created_month',
'arguments' => array(), // this is required to make sure construct is called.
),
);
......@@ -356,7 +356,7 @@ class views_handler_argument_node_nid extends views_handler_argument {
/**
* Argument handler for a year (CCYY)
*/
class views_handler_argument_node_date_year extends views_handler_argument_formula {
class views_handler_argument_node_created_year extends views_handler_argument_formula {
/**
* Constructor implementation
*
......@@ -380,7 +380,7 @@ class views_handler_argument_node_date_year extends views_handler_argument_formu
/**
* Argument handler for a year plus month (CCYYMM)
*/
class views_handler_argument_date_year_month extends views_handler_argument_formula {
class views_handler_argument_node_created_year_month extends views_handler_argument_formula {
/**
* Constructor implementation
*/
......@@ -409,7 +409,7 @@ class views_handler_argument_date_year_month extends views_handler_argument_form
/**
* Argument handler for a month (MM)
*/
class views_handler_argument_date_month extends views_handler_argument_formula {
class views_handler_argument_node_created_month extends views_handler_argument_formula {
/**
* Constructor implementation
*/
......
<?php
// $Id$
/**
* @file views-ui-edit-view.tpl.php
* Template for the primary view editing window.
*/
?>
<div class="views-basic-info<?php if (!empty($view->changed)) { print " changed"; }?>">
<?php if (!is_numeric($view->vid)): ?>
<div class="view-changed view-new"><?php print t('New view'); ?></div>
<?php else: ?>
<div class="view-changed"><?php print t('Changed view'); ?></div>
<?php endif; ?>
<?php print t('View %name, displaying items of type <b>@base</b>.',
array('%name' => $view->name, '@base' => $base_table)); ?>
</div>
<?php print $tabs; ?>
<div id="views-ajax-form">
<div id="views-ajax-title">
<?php // This is initially empty ?>
</div>
<div id="views-ajax-pad">
<?php /* This is sent in because it is also sent out through settings and
needs to be consistent. */ ?>
<?php print $message; ?>
</div>
</div>
<?php print $save_button ?>
<?php
// $Id$
/**
* @file views-view-list.tpl.php
* Default simple view template to display a list of rows.
*
* - $options['type'] will either be ul or ol.
* @ingroup views_templates
*/
?>
<div class="item-list">
<<?php print $options['type']; ?>>
<?php foreach ($rows as $row): ?>
<li><?php print $row ?></li>
<?php endforeach; ?>
</<?php print $options['type']; ?>>
</div>
\ No newline at end of file
......@@ -7,4 +7,6 @@
* @ingroup views_templates
*/
?>
<?php print $rows ?>
\ No newline at end of file
<?php foreach ($rows as $row): ?>
<?php print $row ?>
<?php endforeach; ?>
\ No newline at end of file
......@@ -30,7 +30,7 @@
<?php endif; ?>
<?php if ($rows): ?>
<div class="content">
<div class="view-content">
<?php print $rows; ?>
</div>
<?php elseif ($empty): ?>
......
......@@ -141,12 +141,7 @@ function views_block($op = 'list', $delta = 0, $edit = array()) {
list($name, $display_id) = explode('-', $delta);
// Load the view
if ($view = views_get_view($name)) {
if ($op == 'view') {
return $view->execute_display($display_id, $args);
}
else {
return $view->execute_hook_block($display_id, $op, $delta, $edit);
}
return $view->execute_display($display_id);
}
break;
}
......
......@@ -114,21 +114,25 @@ function views_ui_perm() {
}
function views_ui_theme() {
$path = drupal_get_path('module', 'views');
include_once "$path/includes/admin.inc";
return array(
'views_ui_edit_view' => array(
'arguments' => array('form'),
'file' => '/includes/admin.inc',
'arguments' => array('view' => NULL),
'template' => 'views-ui-edit-view',
'path' => "$path/theme",
),
'views_ui_rearrange_form' => array(
'arguments' => array('form'),
'arguments' => array('form' => NULL),
'file' => '/includes/admin.inc',
),
'views_tabset' => array(
'arguments' => array('tabs'),
'arguments' => array('tabs' => NULL),
'file' => '/includes/tabs.inc',
),
'views_tab' => array(
'arguments' => array('body'),
'arguments' => array('body' => NULL),
'file' => '/includes/tabs.inc',
),
);
......
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