Skip to content

Commit

Permalink
Merge pull request #123 from esmero/ISSUE-122
Browse files Browse the repository at this point in the history
ISSUE-122: Europeana Entity Suggest Webform element and Controller + cache
  • Loading branch information
DiegoPino authored Jul 23, 2021
2 parents d3875e2 + 5c3ed43 commit 64a0e1f
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 36 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Webform Strawberry Field
A module that provides Drupal 8 Webform ( == awesome piece of code) integrations for StrawberryField so you can really have control over your Metadata ingests. This is part of the Archipelago Commons Project.
A module that provides Drupal 8/9 Webform ( == awesome piece of code) integrations for StrawberryField so you can really have control over your Metadata ingests. This is part of the Archipelago Commons Project.

# Disclaimer
This is an experimental module, use at your own risk
# Setup

This module provides many LoD Autocomplete suggester Webform Elements, but only *The Europeana Entity Suggester* for now requires you to provide an `APIKEY`.
To be able to use the Europeana Suggester edit your Drupal `settings.php` file (located normally in `web/sites/default/settings.php`) and add the following line:

```PHP
$settings['webform_strawberryfield.europeana_entity_apikey'] = 'thekey';
```

Save and clear caches.

In its current state the Europeana Entity API (Alpha 0.5) uses a static APIKEY (not the same as other APIs) and can be found at https://pro.europeana.eu/page/entity#suggest

If using https://github.com/esmero/archipelago-deployment this is not needed and will be provided by the deployment.

## Help

Expand All @@ -18,6 +30,7 @@ Having issues with this module? Check out the Archipelago Commons google groups

* [Diego Pino](https://github.com/DiegoPino)
* [Giancarlo Birello](https://github.com/giancarlobi)
* [Allison Lund](https://github.com/alliomeria)

## Acknowledgments

Expand Down
6 changes: 6 additions & 0 deletions config/schema/webform_strawberryfield.schema.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
webform_strawberryfield.settings:
type: config_object
mapping:
europeana_entity_apikey:
type: string
label: 'Europeana Entity API Secret key'
field.widget.settings.strawberryfield_webform_inline_widget:
type: config_object
label: 'Webform Inline Widget Schema'
Expand Down
14 changes: 6 additions & 8 deletions js/hidenodeaction-webform_strawberryfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,27 @@
Drupal.behaviors.webformstrawberryHideNodeActions = {
attach: function (context, settings) {
// Only react if the document contains a strawberry webform widget
if ($('.path-node fieldset[data-strawberryfield-selector="strawberry-webform-widget"]').length) {
if ($('.node-form fieldset[data-strawberryfield-selector="strawberry-webform-widget"]').length) {
if ($('.webform-confirmation',context).length) {
// Exclude webform own edit-actions containter
/* And hide, if present the close button but only show save if all are ready.
@TODO we need to figure out what if there are many webforms open at different states in the same
Entity Form.
*/
$('.path-node .node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').show();
$('.path-node .node-form div[data-drupal-selector="edit-footer"]').not('.webform-actions').show();
$('.node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').show();
$('.node-form div[data-drupal-selector="edit-footer"]').not('.webform-actions').show();
$('.webform-confirmation').closest('[data-strawberryfield-selector="strawberry-webform-widget"]').each(function() {
var $id = $(this).attr('id') + '-strawberry-webform-close-modal';
$('#' + $id).toggleClass('js-hide');
})


} else if (
$('div.field--widget-strawberryfield-webform-inline-widget .webform-submission-form').length ||
$('div.field--widget-strawberryfield-webform-widget .webform-submission-form').length
)
{
$('.path-node .node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').hide();
$('.path-node .node-form div[data-drupal-selector="edit-footer"]').not('.webform-actions').hide();
$('.node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').hide();
$('.node-form div[data-drupal-selector="edit-footer"]').not('.webform-actions').hide();
}
var $moderationstate = $('select[data-drupal-selector="edit-moderation-state-0-state"]', context).once('show-hide-actions');
if ($moderationstate.length) {
Expand All @@ -52,8 +51,7 @@
var $nodetitle = $('input[data-drupal-selector="edit-title-0-value"]', context).once('show-hide-actions');
if ($nodetitle.length) {
var $select = $nodetitle.on('input', function () {
$('.path-node .node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').show();

$('.node-form div[data-drupal-selector="edit-actions"]').not('.webform-actions').show();
});
}
}
Expand Down
Loading

0 comments on commit 64a0e1f

Please sign in to comment.