Commit fa202c70 authored by Michael Nolan's avatar Michael Nolan

Drupal release version

parent 3cf89679
......@@ -29,36 +29,3 @@ ajax_dashboard_example_profile:
'#attributes':
class:
- sections-wrapper
ajax_dashboard_template_one:
id: ajax_dashboard_template_one
label: 'User Profile'
'#attached':
library:
- 'ajax_dashboard_example/template_one-css'
dashboard:
'#attributes':
class:
- dashboard-wrapper
sections:
example:
plugin: ajax_dashboard_example
constant:
plugin: ajax_dashboard_constant
label: 'User Info'
button:
id: ajax_dashboard_constant_button
label: 'Formal Name'
content: |
<h3>Formal Name</h3>
<p>First Name:</p>
<p>Last Name:</p>
button2:
id: ajax_dashboard_constant_button2
label: 'Contact'
content: |
<h3>Contact Info</h3>
<p>Address:</p>
'#attributes':
class:
- sections-wrapper
......@@ -23,6 +23,8 @@ function ajax_dashboard_example_entity_extra_field_info() {
* Implements hook_ENTITY_TYPE_view().
*/
function ajax_dashboard_example_user_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
$dashboard = \Drupal::formBuilder()->getForm('\Drupal\ajax_dashboard\Form\AJAXDashboard', 'ajax_dashboard_template_one');
$build['ajax_dashboard_example'] = $dashboard;
if ($display->getComponent('ajax_dashboard_example')) {
$dashboard = \Drupal::formBuilder()->getForm('\Drupal\ajax_dashboard\Form\AJAXDashboard', 'ajax_dashboard_template');
$build['ajax_dashboard_example'] = $dashboard;
}
}
<?php
namespace Drupal\ajax_dashboard\Plugin\AJAXDashboardSection;
namespace Drupal\ajax_dashboard_example\Plugin\AJAXDashboardSection;
use Drupal\ajax_dashboard\Plugin\AJAXDashboardSectionBase;
use Drupal\Core\Ajax\AjaxResponse;
......
......@@ -6,7 +6,6 @@ use Drupal\ajax_dashboard\Plugin\AJAXDashboardSectionBase;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Form\FormStateInterface;
use Drupal\js_ajax_test\Ajax\JsAjaxTestCommand;
/**
* Class AJAXDashboardExample
......@@ -20,6 +19,13 @@ use Drupal\js_ajax_test\Ajax\JsAjaxTestCommand;
*/
class AJAXDashboardConstant extends AJAXDashboardSectionBase {
/**
* @param $form
* @param FormStateInterface $form_state
* @param null $request
* @param array $params
* @return array|AjaxResponse|mixed
*/
public static function buildDashboard($form, FormStateInterface $form_state, $request = NULL, $params = []) {
if ($trigger =$form_state->getTriggeringElement()) {
$add = [
......@@ -43,7 +49,13 @@ class AJAXDashboardConstant extends AJAXDashboardSectionBase {
}
/**
* @param $form
* @param FormStateInterface $form_state
* @param array $context
* @param array $params
* @return array|mixed
*/
public static function buildSection($form, FormStateInterface $form_state, array $context = [], array $params = []) {
$section = [
'#type' => 'html_tag',
......@@ -62,22 +74,9 @@ class AJAXDashboardConstant extends AJAXDashboardSectionBase {
],
];
$button2 = [
'#type' => 'button',
'#value' => $params['button']['label'],
'#id' => $params['button']['id'],
'#content_data' => $params['button']['content'],
'#ajax' => [
'callback' => 'Drupal\ajax_dashboard\Plugin\AJAXDashboardSection\AJAXDashboardConstant::buildDashboard',
'event' => 'click',
'wrapper' => 'edit-dashboard',
],
];
return [
'ajax_dashboard_constant_section' => $section,
'ajax_dashboard_constant' => $button,
'ajax_dashboard_constant_button2' => $button2,
'ajax_dashboard_constant' => $button
];
}
......
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