Commit 0deba9fe authored by Henning Leutz's avatar Henning Leutz 🥋

Merge branch 'dev'

parents 9f235afa 4e6e7a1d
......@@ -16,11 +16,19 @@ QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_brick_save',
function ($brickId, $data) {
$BrickManager = QUI\Bricks\Manager::init();
$BrickManager->saveBrick($brickId, \json_decode($data, true));
$data = \json_decode($data, true);
$BrickManager->saveBrick($brickId, $data);
$Brick = $BrickManager->getBrickById($brickId);
return $Brick->getAttributes();
return [
'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType(
$Brick->getAttribute('type')
)
];
},
['brickId', 'data'],
'Permission::checkAdminUser'
......
......@@ -26,7 +26,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
'css!package/quiqqer/bricks/bin/BrickEdit.css'
], function (QUI, QUIPanel, QUIConfirm, BrickAreas, QUIAjax, QUILocale,
Projects, QUIFormUtils, ControlUtils, Template, Bricks
Projects, QUIFormUtils, ControlUtils, Template, Bricks
) {
"use strict";
......@@ -65,14 +65,14 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
initialize: function (options) {
this.parent(options);
this.$availableBricks = [];
this.$availableBricks = [];
this.$availableSettings = [];
this.$customfields = [];
this.$loaded = false;
this.$customfields = [];
this.$loaded = false;
this.$Container = null;
this.$Editor = false;
this.$Areas = false;
this.$Editor = false;
this.$Areas = false;
this.addEvents({
onInject : this.$onInject,
......@@ -186,7 +186,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
*/
this.$availableBricks = bricks;
this.$availableSettings = brick.availableSettings;
this.$customfields = brick.customfields;
this.$customfields = brick.customfields;
this.setAttribute('data', brick);
......@@ -258,7 +258,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
data.customfields = self.$customfields;
return Bricks.saveBrick(self.getAttribute('id'), data).then(function () {
return Bricks.saveBrick(self.getAttribute('id'), data).then(function (attributes) {
QUI.getMessageHandler().then(function (MH) {
MH.addSuccess(
QUILocale.get(lg, 'message.brick.save.success')
......@@ -347,10 +347,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
break;
default:
data.attributes = Object.merge(
data.attributes,
QUIFormUtils.getFormData(Form)
);
data.attributes = Object.merge(data.attributes, QUIFormUtils.getFormData(Form));
}
if (Form && Form.getElement('[name="frontendTitle"]')) {
......@@ -382,10 +379,18 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
}
if (unload === 'extra') {
data.settings = Object.merge(
data.settings,
QUIFormUtils.getFormData(Form)
);
var extra = QUIFormUtils.getFormData(Form);
// filter numbers
var isNumeric = function (n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
extra = Object.filter(extra, function (value, key) {
return !isNumeric(key);
});
data.settings = Object.merge(data.settings, extra);
}
if (unload === 'content' && this.$Editor) {
data.attributes.content = this.$Editor.getContent();
......@@ -437,9 +442,9 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
if (attributes.areas) {
areas = attributes.areas
.replace(/^,*/, '')
.replace(/,*$/, '')
.split(',');
.replace(/^,*/, '')
.replace(/,*$/, '')
.split(',');
}
// areas
......@@ -692,8 +697,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
// extra settings
for (i = 0, len = this.$availableSettings.length; i < len; i++) {
setting = this.$availableSettings[i];
extraFieldId = 'extraField_' + id + '_' + i;
setting = this.$availableSettings[i];
extraFieldId = 'extraField_' + id + '_' + i;
dataAttributes = setting['data-attributes'];
text = setting.text;
......
......@@ -92,7 +92,7 @@ class Brick extends QUI\QDOM
}
if (isset($params['id'])) {
$this->id = $params['id'];
$this->id = (int)$params['id'];
}
if (isset($params['uniqueId'])) {
......@@ -440,6 +440,30 @@ class Brick extends QUI\QDOM
}
}
/**
* @param string $name
* @return array|mixed
*/
public function getAttribute($name)
{
if ($name === 'classes') {
return $this->getCSSClasses();
}
return parent::getAttribute($name);
}
/**
* @return array
*/
public function getAttributes()
{
$attributes = parent::getAttributes();
$attributes['classes'] = $this->getCSSClasses();
return $attributes;
}
/**
* This fields can be overwritten by another user
*
......@@ -459,6 +483,10 @@ class Brick extends QUI\QDOM
*/
public function addCSSClass($cssClass)
{
if (\is_array($cssClass)) {
$cssClass = \implode($cssClass, ' ');
}
if (!\is_string($cssClass)) {
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment