Skip to content

Commit

Permalink
OP-545: Behat fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Sep 19, 2024
1 parent 1eb8aae commit f1ad2ce
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ $(document).ready(function() {
const textareaId = `${collectionHolder}_${index}_configuration_textarea`;

element.id = textareaId;
CKEDITOR.replace(textareaId, ckeditorConfig);

if (typeof CKEDITOR !== 'undefined') {
CKEDITOR.replace(textareaId, ckeditorConfig);
}
}
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/Resources/assets/admin/js/cms/cms-template.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export class HandleTemplate {
init() {
$(document).ready(() => {
const cmsLoadTemplate = $('[data-bb-cms-load-template]');
const cmsPageTemplate = $('#sylius_cms_page_template');
const cmsBlockTemplate = $('#sylius_cms_block_template');
const cmsLoadTemplate = $('[data-bb-cms-load-content-template]');
const cmsPageTemplate = $('#sylius_cms_page_contentTemplate');
const cmsBlockTemplate = $('#sylius_cms_block_contentTemplate');

let locales = [];
$('.locale-selector option').each(function() {
Expand All @@ -28,7 +28,7 @@ export class HandleTemplate {
return;
}

const endpointUrl = cmsLoadTemplate.data('bb-cms-load-template').replace('REPLACE_ID', templateId);
const endpointUrl = cmsLoadTemplate.data('bb-cms-load-content-template').replace('REPLACE_ID', templateId);
if (!endpointUrl) {
return;
}
Expand All @@ -52,6 +52,7 @@ export class HandleTemplate {
let idx = 0;
$.each(data.content, function (index, element) {
locales.forEach(function (locale) {
console.log(locale);
elements.eq(idx).find('select:first').val(element.type);
elements.eq(idx).find('select:first').change();
elements.eq(idx).find('input[name$="[locale]"]').val(locale);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/assets/admin/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ if (document.querySelector('.collection-type-items')) {
new HandleChooseCollectionType().init();
}

if (document.querySelector('[data-bb-cms-load-template]')) {
if (document.querySelector('[data-bb-cms-load-content-template]')) {
new HandleTemplate().init();
}
2 changes: 1 addition & 1 deletion src/Resources/config/routing/admin/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sylius_cms_admin_template:
vars:
all:
templates:
form: "@SyliusCmsPlugin/Template/Crud/_form.html.twig"
form: "@SyliusCmsPlugin/ContentTemplate/Crud/_form.html.twig"
index:
icon: block layout
type: sylius.resource
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/ContentTemplate/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="ui one column stackable grid">
<div class="column">
{{ form_row(form.contentTemplate) }}
<input type="hidden" data-bb-cms-load-template="{{ ajax_url }}">
<input type="hidden" data-bb-cms-load-content-template="{{ ajax_url }}">
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions tests/Behat/Page/Admin/Block/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ protected function getDefinedElements(): array
'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete',
'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")',
'content_elements_add_button' => '#sylius_cms_block_contentElements a[data-form-collection="add"]',
'template_select_dropdown' => 'h5:contains("Use page template") ~ .column .field > .sylius-autocomplete',
'template_select_dropdown_item' => 'h5:contains("Use page template") ~ .column .field > .sylius-autocomplete > div.menu > div.item:contains("%item%")',
'template_select_dropdown' => 'h5:contains("Content elements template") ~ .column .field > .sylius-autocomplete',
'template_select_dropdown_item' => 'h5:contains("Content elements template") ~ .column .field > .sylius-autocomplete > div.menu > div.item:contains("%item%")',
],
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Behat/Page/Admin/Page/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ protected function getDefinedElements(): array
'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete',
'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")',
'content_elements_add_button' => '#sylius_cms_page_contentElements a[data-form-collection="add"]',
'template_select_dropdown' => 'h5:contains("Use page template") ~ .column .field > .sylius-autocomplete',
'template_select_dropdown_item' => 'h5:contains("Use page template") ~ .column .field > .sylius-autocomplete > div.menu > div.item:contains("%item%")',
'template_select_dropdown' => 'h5:contains("Content elements template") ~ .column .field > .sylius-autocomplete',
'template_select_dropdown_item' => 'h5:contains("Content elements template") ~ .column .field > .sylius-autocomplete > div.menu > div.item:contains("%item%")',
],
);
}
Expand Down

0 comments on commit f1ad2ce

Please sign in to comment.