Skip to content

Commit

Permalink
Merge pull request #39 from steinkopffp/master
Browse files Browse the repository at this point in the history
Replace class select handle with multiselect
  • Loading branch information
Mardl authored Nov 8, 2019
2 parents 5628cb4 + f79e0d1 commit 532214d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/ColumnSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function addFields()
// add field
$this->addField(new DataObject([
'key' => 'css_class',
'type' => 'select',
'type' => 'multiselect',
'values' => $this->cssClassColumnModel->toOptionArray(),
'label' => __('CSS Class'),
]));
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/RowSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function addFields()
// add field
$this->addField(new DataObject([
'key' => 'css_class',
'type' => 'select',
'type' => 'multiselect',
'values' => $this->cssClassRowModel->toOptionArray(),
'label' => __('CSS Class'),
]));
Expand Down
4 changes: 2 additions & 2 deletions Block/Adminhtml/SettingsAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ protected function addField($parameter)
$data = array_merge($data, $options);
}

// get data
$data['value'] = $this->getValue($parameter, $fieldName);
// get data and prepare it for multiselect
$data['value'] = explode(' ', $this->getValue($parameter, $fieldName));

// prepare element dropdown values
/** @noinspection PhpUndefinedMethodInspection */
Expand Down
13 changes: 9 additions & 4 deletions view/adminhtml/templates/page_designer/config.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Magenerds\WysiwygWidget\Block\Widget\Editor;
use Magento\Framework\View\Element\Template;
use Magenerds\PageDesigner\Utils\HtmlRenderer;

/**
* Template for the Page Designer configuration
Expand All @@ -30,11 +31,11 @@ use Magento\Framework\View\Element\Template;
*/
window.pageDesignerConfig = {
// widget types with wysiwyg content
wysiwygWidgetTypes: <?php echo json_encode([Editor::class]); ?>,
wysiwygWidgetTypes: <?= json_encode([Editor::class]); ?>,
// settings route url (columns)
columnSettingsUrl: <?php echo json_encode($block->getUrl('adminhtml/pageDesigner/columnSettings')); ?>,
columnSettingsUrl: <?= json_encode($block->getUrl('adminhtml/pageDesigner/columnSettings')); ?>,
// settings route url (rows)
rowSettingsUrl: <?php echo json_encode($block->getUrl('adminhtml/pageDesigner/rowSettings')); ?>,
rowSettingsUrl: <?= json_encode($block->getUrl('adminhtml/pageDesigner/rowSettings')); ?>,
// settings save callback
settingsCallback: null,
/**
Expand All @@ -46,10 +47,14 @@ use Magento\Framework\View\Element\Template;

// define json
var json = {};
var content = '';

// add data to json
jQuery(data).each(function () {
json[this.name] = this.value;
var name = this.name === '<?= HtmlRenderer::JSON_PROPERTY_CSS_CLASS ?>[]' ?
'<?= HtmlRenderer::JSON_PROPERTY_CSS_CLASS ?>' : this.name;
content = (content.length > 0) ? content + ' ' + this.value : this.value;
json[name] = content;
});

// save settings on column
Expand Down

0 comments on commit 532214d

Please sign in to comment.