Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HRIN-767: Added GIS map token #376

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-376](https://github.com/itk-dev/hoeringsportal/pull/376)
Added GIS map token

## [3.5.3] - 2023-11-08

* [PR-370](https://github.com/itk-dev/hoeringsportal/pull/370)
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"drupal/redirect": "^1.6",
"drupal/search_autocomplete": "^2.0",
"drupal/system_status": "^2.8",
"drupal/token_filter": "^2.1",
"drupal/toolbar_visibility": "dev-3127402-drupal-9-readiness",
"drupal/twig_tweak": "^2.1",
"drupal/view_custom_table": "^2.0",
Expand Down Expand Up @@ -175,7 +176,8 @@
"drupal/core-project-message": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"oomphinc/composer-installers-extender": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"chx/drupal-issue-fork": true
}
},
"scripts": {
Expand Down
71 changes: 70 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module:
telephone: 0
text: 0
token: 0
token_filter: 0
toolbar: 0
toolbar_visibility: 0
twig_tweak: 0
Expand Down
59 changes: 59 additions & 0 deletions config/sync/editor.editor.hearing_description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
uuid: d4a16c11-faf2-4617-bd62-c28ad4eb5f31
langcode: da
status: true
dependencies:
config:
- filter.format.hearing_description
module:
- ckeditor5
format: hearing_description
editor: ckeditor5
settings:
toolbar:
items:
- bold
- italic
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- '|'
- sourceEditing
- '|'
- heading
- tokenBrowser
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
ckeditor5_list:
reversed: false
startIndex: true
ckeditor5_sourceEditing:
allowed_tags:
- '<cite>'
- '<a hreflang target>'
- '<blockquote cite>'
- '<ul type>'
- '<ol type>'
- '<h2 id>'
- '<h3 id>'
- '<h4 id>'
editor_advanced_link_link:
enabled_attributes:
- target
token_filter_token_browser:
token_types: { }
image_upload:
status: false
scheme: public
directory: inline-images
max_size: ''
max_dimensions:
width: null
height: null
7 changes: 5 additions & 2 deletions config/sync/field.field.node.hearing.field_description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ status: true
dependencies:
config:
- field.storage.node.field_description
- filter.format.hearing_description
- node.type.hearing
module:
- allowed_formats
- text
third_party_settings:
allowed_formats:
allowed_formats:
- filtered_html
- hearing_description
id: node.hearing.field_description
field_name: field_description
entity_type: node
Expand All @@ -22,5 +23,7 @@ required: true
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
settings:
allowed_formats:
- hearing_description
field_type: text_long
45 changes: 45 additions & 0 deletions config/sync/filter.format.hearing_description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
uuid: 15881684-2eac-4426-bae4-7e44d395c82a
langcode: da
status: true
dependencies:
module:
- token_filter
name: 'Hearing description'
format: hearing_description
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not worth a change, but generally i'm not sure our filters should be attached to specific fields or entities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [gis:minimap:?] token makes sense only in the hearing description field, and therefore a new text format with the token filter has been added.

weight: 0
filters:
filter_autop:
id: filter_autop
provider: filter
status: true
weight: 9
settings: { }
filter_htmlcorrector:
id: filter_htmlcorrector
provider: filter
status: true
weight: -50
settings: { }
filter_url:
id: filter_url
provider: filter
status: false
weight: -50
settings:
filter_url_length: 72
filter_html:
id: filter_html
provider: filter
status: true
weight: 0
settings:
allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <cite> <a hreflang target href> <blockquote cite> <ul type> <ol type start> <strong> <em> <li>'
filter_html_help: true
filter_html_nofollow: false
token_filter:
id: token_filter
provider: token_filter
status: true
weight: 15
settings:
replace_empty: '1'
2 changes: 2 additions & 0 deletions config/sync/user.role.authenticated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- filter.format.citizen_proposal_content
- filter.format.filtered_html
- filter.format.hearing_description
module:
- filter
- media
Expand All @@ -21,4 +22,5 @@ permissions:
- 'search content'
- 'use text format citizen_proposal_content'
- 'use text format filtered_html'
- 'use text format hearing_description'
- 'view media'
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
$geojsonUrl = 'http://geojson.io/';
$geojsonUrlWithMap = $geojsonUrl . '#map=13/56.1464/10.1739';
// @see https://github.com/mapbox/geojson.io/blob/gh-pages/API.md#datadataapplicationjson
$geojsonUrlWithData = $geojsonUrl . '#data=data:application/json,' . urlencode(json_encode(json_decode($item->geojson)) ?? '');
$geojsonUrlWithData = $geojsonUrl . '#data=data:application/json,' . urlencode(json_encode(json_decode($item->geojson ?? 'null')) ?? '');
$element['geojson'] = [
'#type' => 'textarea',
'#title' => t('GeoJSON'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.hoeringsportal-hearing-gis-minimap {
/* We use a `span` element to render the map (it's most times inside a `p` element). */
display: block;
height: 500px;
}

.hoeringsportal-hearing-gis-minimap.invalid-token {
color: #f00;
background: #ff0;
height: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @file
* Code related to installing and updating this module.
*/

/**
* Update text format on hearing description.
*/
function hoeringsportal_hearing_update_9001() {
$storage = \Drupal::entityTypeManager()
->getStorage('node');
$ids = $storage->getQuery()
->condition('type', 'hearing')
->accessCheck(FALSE)
->execute();
$hearings = $storage->loadMultiple($ids);

$field_name = 'field_description';
$text_format = 'hearing_description';
foreach ($hearings as $hearing) {
if ($value = ($hearing->get($field_name)->getValue()[0] ?? NULL)) {
$value['format'] = $text_format;
$hearing->set($field_name, $value);

$hearing->save();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ hearing-form:
version: VERSION
js:
assets/js/form.js: {}

gis-minimap:
version: VERSION
css:
theme:
assets/css/gis-minimap.css: {}
js:
https://webkort.aarhuskommune.dk/clientapi/minimap2/mmloader.js: { type: external, minified: true }
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\hoeringsportal_hearing\TokenHelper;

/**
* Implements hook_help().
Expand Down Expand Up @@ -82,6 +84,23 @@ function hoeringsportal_hearing_node_view(array &$build, EntityInterface $entity
$new_title = $title . $state;
$build['title'][0]['#context']['value'] = $new_title;
}

}
}

/**
* Implements hook_token_info().
*
* @see \Drupal\hoeringsportal_hearing\TokenHelper::tokenInfo()
*/
function hoeringsportal_hearing_token_info() {
return \Drupal::service(TokenHelper::class)->tokenInfo();
}

/**
* Implements hook_tokens().
*
* @see \Drupal\hoeringsportal_hearing\TokenHelper::tokens()
*/
function hoeringsportal_hearing_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
return \Drupal::service(TokenHelper::class)->tokens($type, $tokens, $data, $options, $bubbleable_metadata);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ services:
class: Drupal\hoeringsportal_hearing\EventSubscriber\EventSubscriber
tags:
- {name: event_subscriber}

Drupal\hoeringsportal_hearing\TokenHelper:
Loading