diff --git a/panels_ipe/js/panels_ipe.js b/panels_ipe/js/panels_ipe.js new file mode 100644 index 0000000..0137dfb --- /dev/null +++ b/panels_ipe/js/panels_ipe.js @@ -0,0 +1,30 @@ +/** + * @file + * Attaches behavior for the Panels IPE module. + * + */ + +(function ($, _, Backbone, Drupal, drupalSettings, JSON, storage) { + + 'use strict'; + + /** + * + * @type {Drupal~behavior} + */ + Drupal.behaviors.panels_ipe = { + attach: function (context) { + console.log('attached panels ipe'); + }, + detach: function (context, settings, trigger) { + console.log('detached panels ipe'); + } + }; + + /** + * + * @namespace + */ + Drupal.panels_ipe = {}; + +})(jQuery, _, Backbone, Drupal, drupalSettings, window.JSON, window.sessionStorage); diff --git a/panels_ipe/panels_ipe.libraries.yml b/panels_ipe/panels_ipe.libraries.yml new file mode 100644 index 0000000..9ff1294 --- /dev/null +++ b/panels_ipe/panels_ipe.libraries.yml @@ -0,0 +1,19 @@ +panels_ipe: + version: VERSION + js: + # Core. + js/panels_ipe.js: {} + dependencies: + - core/jquery + - core/jquery.once + - core/underscore + - core/backbone + - core/jquery.form + - core/jquery.ui.position + - core/drupal + - core/drupal.displace + - core/drupal.form + - core/drupal.ajax + - core/drupal.debounce + - core/drupalSettings + - core/drupal.dialog diff --git a/panels_ipe/panels_ipe.module b/panels_ipe/panels_ipe.module index 0f358e4..18d7d94 100644 --- a/panels_ipe/panels_ipe.module +++ b/panels_ipe/panels_ipe.module @@ -17,17 +17,10 @@ function panels_ipe_help($route_name, RouteMatchInterface $route_match) { $output = ''; $output .= '
' . t('Panels In-place editor.') . '
'; + // @todo: Add useful help text for Panels In-place editor. return $output; default: } } -/** - * Implements hook_theme(). - */ -function panels_ipe_theme() { - $theme = []; - - return $theme; -} diff --git a/panels_ipe/panels_ipe.permissions.yml b/panels_ipe/panels_ipe.permissions.yml new file mode 100644 index 0000000..6350b38 --- /dev/null +++ b/panels_ipe/panels_ipe.permissions.yml @@ -0,0 +1,2 @@ +access panels in-place editing: + title: 'Access panels in-place editing' \ No newline at end of file diff --git a/panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php b/panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php index 22469b1..dab2643 100644 --- a/panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php +++ b/panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php @@ -63,13 +63,18 @@ class InPlaceEditorDisplayBuilder extends StandardDisplayBuilder { */ protected function buildRegions(array $regions, array $contexts) { $build = []; + + // Attach the Panels In-place editor library based on permissions. + if ($this->account->hasPermission('access panels in-place editing')) { + $build['#attached']['library'][] = 'panels_ipe/panels_ipe'; + } + foreach ($regions as $region => $blocks) { if (!$blocks) { continue; } - $region_name = Html::getClass("block-region-$region"); - $build[$region]['#prefix'] = '