Commit c1a060fa authored by Sol Villar's avatar Sol Villar Committed by topicus

NuCivic/internal#622: Added module for dashboard wizard.

NuCivic/internal#622: Implemented dashboards with Panelizer.

NuCivic/internal#622: Moved layout options to bottom in form.

NuCivic/internal#622: Updated process to change layout.
parent e1c8c884
......@@ -106,6 +106,8 @@ dependencies[] = dkan_dataset_groups
dependencies[] = dkan_sitewide_panels
dependencies[] = dkan_sitewide_search_db
dependencies[] = dkan_featured_groups
dependencies[] = dkan_sitewide_panelizer
dependencies[] = dkan_sitewide_data_dashboard
; DKAN Modules
dependencies[] = dkan_sitewide
......
......@@ -60,6 +60,12 @@ projects[og_moderation][patch][2231737] = https://drupal.org/files/issues/any-us
projects[defaultconfig][version] = 1.0-alpha9
projects[panelizer][version] = 3.1
projects[panelizer][subdir] = contrib
projects[panels][version] = 3.4
projects[panels][subdir] = contrib
projects[views_autocomplete_filters][version] = 1.1
projects[views_autocomplete_filters][patch][2277453] = http://drupal.org/files/issues/ViewsAutocompleteFilters-no_results_on_some_environments-2277453-1.patch
projects[views_autocomplete_filters][patch][2374709] = http://www.drupal.org/files/issues/views_autocomplete_filters-cache-2374709-2.patch
......
<?php
/**
* @file
* dkan_sitewide_data_dashboard.features.inc
*/
/**
* Implements hook_ctools_plugin_api().
*/
function dkan_sitewide_data_dashboard_ctools_plugin_api($module = NULL, $api = NULL) {
if ($module == "panelizer" && $api == "panelizer") {
return array("version" => "1");
}
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => "1");
}
}
/**
* Implements hook_views_api().
*/
function dkan_sitewide_data_dashboard_views_api($module = NULL, $api = NULL) {
return array("api" => "3.0");
}
/**
* Implements hook_node_info().
*/
function dkan_sitewide_data_dashboard_node_info() {
$items = array(
'data_dashboard' => array(
'name' => t('Data Dashboard'),
'base' => 'node_content',
'description' => t('Content type for creation of Data Dashboards.'),
'has_title' => '1',
'title_label' => t('Title'),
'help' => '',
),
);
return $items;
}
name = DKAN Sitewide Data Dashboard
core = 7.x
package = DKAN
version = 7.x-1.0
project = dkan_sitewide_data_dashboard
dependencies[] = ctools
dependencies[] = features
dependencies[] = panelizer
dependencies[] = strongarm
dependencies[] = views
features[ctools][] = panelizer:panelizer:1
features[ctools][] = strongarm:strongarm:1
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[node][] = data_dashboard
features[panelizer_defaults][] = node:data_dashboard:default:default
features[variable][] = menu_options_data_dashboard
features[variable][] = menu_parent_data_dashboard
features[variable][] = node_options_data_dashboard
features[variable][] = node_preview_data_dashboard
features[variable][] = node_submitted_data_dashboard
features[variable][] = panelizer_defaults_node_data_dashboard
features[variable][] = panelizer_node:data_dashboard_allowed_layouts
features[variable][] = panelizer_node:data_dashboard_allowed_layouts_default
features[variable][] = panelizer_node:data_dashboard_allowed_types_default
features[variable][] = panelizer_node:data_dashboard_default
features[views_view][] = data_dashboards
mtime = 1433978961
<?php
/**
* @file
* Code for the DKAN Sitewide Data Dashboard feature.
*/
include_once 'dkan_sitewide_data_dashboard.features.inc';
<?php
/**
* @file
* dkan_sitewide_data_dashboard.panelizer.inc
*/
/**
* Implements hook_panelizer_defaults().
*/
function dkan_sitewide_data_dashboard_panelizer_defaults() {
$export = array();
$panelizer = new stdClass();
$panelizer->disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */
$panelizer->api_version = 1;
$panelizer->name = 'node:data_dashboard:default:default';
$panelizer->title = 'Default';
$panelizer->panelizer_type = 'node';
$panelizer->panelizer_key = 'data_dashboard';
$panelizer->no_blocks = FALSE;
$panelizer->css_id = '';
$panelizer->css = '';
$panelizer->pipeline = 'ipe';
$panelizer->contexts = array();
$panelizer->relationships = array();
$panelizer->access = array();
$panelizer->view_mode = 'default';
$panelizer->css_class = '';
$panelizer->title_element = 'H2';
$panelizer->link_to_entity = FALSE;
$panelizer->extra = array();
$display = new panels_display();
$display->layout = 'radix_boxton';
$display->layout_settings = array();
$display->panel_settings = array(
'style_settings' => array(
'default' => NULL,
'sidebar' => NULL,
'contentheader' => NULL,
'contentcolumn1' => NULL,
'contentcolumn2' => NULL,
),
);
$display->cache = array();
$display->title = '%node:title';
$display->uuid = 'bb105d8e-a7ef-405d-9f67-42ec8c1f968a';
$display->content = array();
$display->panels = array();
$display->hide_title = PANELS_TITLE_NONE;
$display->title_pane = '0';
$panelizer->display = $display;
$export['node:data_dashboard:default:default'] = $panelizer;
return $export;
}
<?php
/**
* @file
* dkan_sitewide_data_dashboard.strongarm.inc
*/
/**
* Implements hook_strongarm().
*/
function dkan_sitewide_data_dashboard_strongarm() {
$export = array();
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'menu_options_data_dashboard';
$strongarm->value = array(
0 => 'main-menu',
);
$export['menu_options_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'menu_parent_data_dashboard';
$strongarm->value = 'main-menu:0';
$export['menu_parent_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'node_options_data_dashboard';
$strongarm->value = array(
0 => 'status',
);
$export['node_options_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'node_preview_data_dashboard';
$strongarm->value = '1';
$export['node_preview_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'node_submitted_data_dashboard';
$strongarm->value = 1;
$export['node_submitted_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'panelizer_defaults_node_data_dashboard';
$strongarm->value = array(
'status' => 1,
'view modes' => array(
'page_manager' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
'default' => array(
'status' => 1,
'default' => 1,
'choice' => 0,
),
'full' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
'teaser' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
'rss' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
'diff_standard' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
'token' => array(
'status' => 0,
'default' => 0,
'choice' => 0,
),
),
);
$export['panelizer_defaults_node_data_dashboard'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'panelizer_node:data_dashboard_allowed_layouts';
$strongarm->value = 'O:22:"panels_allowed_layouts":4:{s:9:"allow_new";b:1;s:11:"module_name";s:29:"panelizer_node:data_dashboard";s:23:"allowed_layout_settings";a:41:{s:8:"flexible";b:0;s:14:"twocol_stacked";b:0;s:13:"twocol_bricks";b:0;s:6:"twocol";b:0;s:25:"threecol_33_34_33_stacked";b:0;s:17:"threecol_33_34_33";b:0;s:25:"threecol_25_50_25_stacked";b:0;s:17:"threecol_25_50_25";b:0;s:6:"onecol";b:0;s:12:"radix_whelan";b:1;s:18:"radix_webb_flipped";b:1;s:10:"radix_webb";b:1;s:20:"radix_taylor_flipped";b:1;s:12:"radix_taylor";b:1;s:18:"radix_sutro_double";b:1;s:11:"radix_sutro";b:1;s:19:"radix_selby_flipped";b:1;s:11:"radix_selby";b:1;s:23:"radix_sanderson_flipped";b:1;s:15:"radix_sanderson";b:1;s:11:"radix_rolph";b:1;s:10:"radix_pond";b:1;s:12:"radix_phelan";b:1;s:21:"radix_moscone_flipped";b:1;s:13:"radix_moscone";b:1;s:14:"radix_mccoppin";b:1;s:21:"radix_hewston_flipped";b:1;s:13:"radix_hewston";b:1;s:12:"radix_harris";b:1;s:11:"radix_geary";b:1;s:18:"radix_burr_flipped";b:1;s:10:"radix_burr";b:1;s:20:"radix_bryant_flipped";b:1;s:12:"radix_bryant";b:1;s:11:"radix_brown";b:1;s:21:"radix_brenham_flipped";b:1;s:13:"radix_brenham";b:1;s:12:"radix_boxton";b:1;s:22:"radix_bartlett_flipped";b:1;s:14:"radix_bartlett";b:1;s:10:"full_width";b:0;}s:10:"form_state";N;}';
$export['panelizer_node:data_dashboard_allowed_layouts'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'panelizer_node:data_dashboard_allowed_layouts_default';
$strongarm->value = 0;
$export['panelizer_node:data_dashboard_allowed_layouts_default'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'panelizer_node:data_dashboard_allowed_types_default';
$strongarm->value = 0;
$export['panelizer_node:data_dashboard_allowed_types_default'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'panelizer_node:data_dashboard_default';
$strongarm->value = array(
'token' => 'token',
'entity_form_field' => 'entity_form_field',
'entity_field' => 'entity_field',
'entity_field_extra' => 'entity_field_extra',
'custom' => 'custom',
'block' => 'block',
'entity_view' => 'entity_view',
'fieldable_panels_pane' => 'fieldable_panels_pane',
'menu_tree' => 'menu_tree',
'views' => 'views',
'views_panes' => 'views_panes',
'other' => 'other',
);
$export['panelizer_node:data_dashboard_default'] = $strongarm;
return $export;
}
name = DKAN Sitewide Panelizer
core = 7.x
package = DKAN
version = 7.x-1.0
project = dkan_sitewide_panelizer
dependencies[] = panelizer
dependencies[] = panels
features[features_api][] = api:2
<?php
/**
* @file
* Drupal needs this blank file.
*/
function dkan_sitewide_panelizer_form_alter(&$form, &$form_state, $form_id) {
if (array_key_exists('node', $form_state)) {
$node = $form_state['node'];
$handler = panelizer_entity_plugin_get_handler('node');
if (!$handler) {
return;
}
// Append layouts form only on node creation and when the content type is panelized.
if ((!isset($node->nid) || isset($node->is_new)) && $handler->is_panelized($node->type . '.default')) {
ctools_include('common', 'panels');
ctools_include('cleanstring');
$default_layout = '';
$default_panel = $handler->get_default_panelizer_object($node->type, 'node:' . $node->type . ':default:default');
if ($default_panel) {
$default_layout = $default_panel->display->layout;
}
// Add layout form.
$form['layout'] = array(
'#prefix' =>
'<div class="panels-choose-layout panels-layouts-checkboxes clearfix">' .
'<label>Select layout</label>' .
'<div class="form-checkboxes clearfix">',
'#suffix' =>
'</div></div>',
'#weight' => $form['additional_settings']['#weight'] - 1,
);
$layouts = panels_common_get_allowed_layouts('panelizer_node' . ':' . $node->type);
foreach ($layouts as $name => $layout) {
// Set first layout as default if empty.
if (empty($default_layout)) {
$default_layout = $name;
}
// Add layout options.
$form['layout'][$name] = array(
'#type' => 'radio',
'#title' => panels_print_layout_icon($name, $layout, check_plain($layout['title'])),
'#parents' => array('layout'),
'#id' => drupal_clean_css_identifier('edit-layout-' . $name),
'#return_value' => check_plain($name),
'#default_value' => in_array($default_layout, array_keys($layouts)) ? $default_layout : NULL,
);
}
// Add custom submit handler.
$form['actions']['submit']['#submit'][] = 'dkan_sitewide_panelizer_node_submit';
}
}
}
function dkan_sitewide_panelizer_node_submit($form, &$form_state) {
if (isset($form_state['node']) && is_object($form_state['node'])) {
$nid = $form_state['node']->nid;
// Load entity.
$entity = entity_load_single('node', $nid);
$current_display = $entity->panelizer['default']->display;
// Update display with the new layout.
$entity->panelizer['default']->display = _change_layout($form_state['values']['layout'], $current_display);
$entity->panelizer['default']->display_is_modified = TRUE;
// Save entity.
entity_save('node', $entity);
// Check: Setting $form_state['reditect'] did not work.
drupal_goto('node/' . $nid, array('query' => array('edit' => 'true')));
}
}
function dkan_sitewide_panelizer_preprocess_page(&$vars)
{
// Get URL parameters
$query_params = drupal_get_query_parameters();
if (isset($query_params['edit']) && $query_params['edit'] == 'true') {
// Get current node.
$node = menu_get_object();
$handler = panelizer_entity_plugin_get_handler('node');
if (!$handler) {
return;
}
if (!empty($node) && $handler->is_panelized($node->type . '.default')) {
// Add JS to open IPE automatically.
drupal_add_js(drupal_get_path('module', 'dkan_sitewide_panelizer') . '/js/dkan_sitewide_panelizer.js');
}
}
}
function _change_layout($new_layout_name, $old_display) {
// Create new display.
$new_display = panels_new_display();
$new_display->layout = $new_layout_name;
$new_display->content = array();
// Get layout regions.
$new_layout = ctools_get_plugins('panels', 'layouts', $new_layout_name);
$new_layout_regions = $new_layout['regions'];
// Set default region.
$keys = array_keys($new_layout_regions);
$default_region = reset($keys);
$new_display->panels[$default_region] = array();
// Get current panes.
$current_panes = $old_display->content;
foreach($current_panes as $pid => $pane) {
$pane->panel = $default_region;
// Add pane on new display.
$new_display->panels[$default_region][] = $pid;
$new_display->content[$pid] = $pane;
}
return $new_display;
}
\ No newline at end of file
jQuery(document).ready(function() {
// Is there a better way to do this?
jQuery('#panels-ipe-customize-page').trigger('click');
});
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