Skip to content

Commit

Permalink
Merge pull request #200 from openeuropa/EWPP-2418
Browse files Browse the repository at this point in the history
EWPP-2418: Update webtools media fields description to include WCLOUD wizard.
  • Loading branch information
22Alexandra authored Aug 24, 2022
2 parents 7187a3d + e33d5c7 commit 172ccd9
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_chart
label: 'Webtools chart snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_countdown
label: 'Webtools countdown snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_generic
label: 'Webtools snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_map
label: 'Webtools map snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: oe_media_webtools
entity_type: media
bundle: webtools_social_feed
label: 'Webtools social feed snippet'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.'
description: 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.'
required: true
translatable: false
default_value: { }
Expand Down
31 changes: 31 additions & 0 deletions modules/oe_media_webtools/oe_media_webtools.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,34 @@ function oe_media_webtools_post_update_00004() {
_oe_media_import_config_from_file($name, $storage);
}
}

/**
* Update Webtools media fields description to include the WCLOUD wizard link.
*/
function oe_media_webtools_post_update_00005() {
$original_description = 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/mgmt/wizard/" target="_blank">Webtools wizard</a>.';
$new_description = 'Enter the snippet without the script tag. Snippets can be generated in <a href="https://europa.eu/webtools/tools/#/wizards" target="_blank">Webtools wizard</a> or in the newer <a href="https://europa.eu/webtools/tools/#/wcloud/" target="_blank">WCLOUD wizard</a>.';
$fields = [
'media.webtools_chart.oe_media_webtools',
'media.webtools_countdown.oe_media_webtools',
'media.webtools_generic.oe_media_webtools',
'media.webtools_map.oe_media_webtools',
'media.webtools_social_feed.oe_media_webtools',
];
$modified = [];

foreach ($fields as $field) {
$field_config = FieldConfig::load($field);
// If the description has been customised by users, we don’t change it.
if ($original_description !== $field_config->get('description')) {
$modified[] = $field;
continue;
}
$field_config->setDescription($new_description);
$field_config->save();
}

if (!empty($modified)) {
return sprintf('The field description update for the following fields was skipped as their description was changed: %s.', implode(', ', $modified));
}
}
3 changes: 2 additions & 1 deletion tests/features/webtools-chart.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Webtools chart.
Scenario: Create and reference a Webtools chart.
Given I am logged in as a user with the "create oe_media_demo content,create webtools_chart media" permission
When I visit "the Webtools chart creation page"
And I press "Save"
Then I should see the text "Enter the snippet without the script tag. Snippets can be generated in Webtools wizard or in the newer WCLOUD wizard."
When I press "Save"
Then I should see the following error messages:
| error messages |
| Name field is required |
Expand Down
3 changes: 2 additions & 1 deletion tests/features/webtools-countdown.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Webtools countdown.
Scenario: Create and reference a Webtools countdown.
Given I am logged in as a user with the "create oe_media_demo content, create webtools_countdown media" permission
When I visit "the Webtools countdown creation page"
And I press "Save"
Then I should see the text "Enter the snippet without the script tag. Snippets can be generated in Webtools wizard or in the newer WCLOUD wizard."
When I press "Save"
Then I should see the following error messages:
| error messages |
| Name field is required |
Expand Down
3 changes: 2 additions & 1 deletion tests/features/webtools-generic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Webtools generic.
Scenario: Create and reference a Webtools generic.
Given I am logged in as a user with the "create oe_media_demo content,create webtools_generic media" permission
When I visit "the Webtools generic creation page"
And I press "Save"
Then I should see the text "Enter the snippet without the script tag. Snippets can be generated in Webtools wizard or in the newer WCLOUD wizard."
When I press "Save"
Then I should see the following error messages:
| error messages |
| Name field is required |
Expand Down
3 changes: 2 additions & 1 deletion tests/features/webtools-map.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Webtools map.
Scenario: Create and reference a Webtools map.
Given I am logged in as a user with the "create oe_media_demo content,create webtools_map media" permission
When I visit "the Webtools map creation page"
And I press "Save"
Then I should see the text "Enter the snippet without the script tag. Snippets can be generated in Webtools wizard or in the newer WCLOUD wizard."
When I press "Save"
Then I should see the following error messages:
| error messages |
| Name field is required |
Expand Down
3 changes: 2 additions & 1 deletion tests/features/webtools-social-feeds.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Feature: Webtools social feeds.
Scenario: Create and reference a Webtools social feeds.
Given I am logged in as a user with the "create oe_media_demo content,create webtools_social_feed media" permission
When I visit "the Webtools social feed creation page"
And I press "Save"
Then I should see the text "Enter the snippet without the script tag. Snippets can be generated in Webtools wizard or in the newer WCLOUD wizard."
When I press "Save"
Then I should see the following error messages:
| error messages |
| Name field is required |
Expand Down

0 comments on commit 172ccd9

Please sign in to comment.