diff --git a/bin/BrickEdit.js b/bin/BrickEdit.js index 14b4ab633a959261bcbe35f2f66ebec66c3cb75e..e6a52e289787639c9e17fbf819e0460320836dd3 100644 --- a/bin/BrickEdit.js +++ b/bin/BrickEdit.js @@ -298,7 +298,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ var data = this.getAttribute('data'); this.$unload(); - + console.log(data); this.setAttribute('data', data); this.$Active = Button; @@ -354,7 +354,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ var Form = this.getContent().getElement('form'), unload = this.$Active.getAttribute('name'), data = this.getAttribute('data'); - + console.log(unload); if (unload == 'information') { data.attributes = Object.merge( data.attributes, diff --git a/src/QUI/Bricks/Brick.php b/src/QUI/Bricks/Brick.php index a6022fcb9179c046e8e6741ca94d4b051133a548..d15990a552cd6f4275336a30897e88eb2a6ea5b6 100644 --- a/src/QUI/Bricks/Brick.php +++ b/src/QUI/Bricks/Brick.php @@ -69,15 +69,15 @@ public function __construct($params = array()) { // default $default = array( - 'type' => 'content', - 'content' => '', - 'title' => '', + 'type' => 'content', + 'content' => '', + 'title' => '', 'description' => '', - 'project' => '', - 'areas' => '', - 'height' => '', - 'width' => '', - 'classes' => '' + 'project' => '', + 'areas' => '', + 'height' => '', + 'width' => '', + 'classes' => '' ); $this->setAttributes($default); @@ -96,6 +96,16 @@ public function __construct($params = array()) $this->uniqueId = $params['uniqueId']; } + if (isset($params['classes'])) { + $cssClasses = json_decode($params['classes'], true); + + foreach ($cssClasses as $cssClass) { + $this->addCSSClass($cssClass); + } + + unset($params['classes']); + } + // default settings from control $Control = $this->getControl(); $Manager = Manager::init(); @@ -326,6 +336,8 @@ protected function getControl() */ public function getSettings() { + $this->settings['classes'] = $this->getCSSClasses(); + return $this->settings; } @@ -356,6 +368,10 @@ public function setSettings($settings) */ public function getSetting($name) { + if ($name === 'classes') { + return $this->getCSSClasses(); + } + if (isset($this->settings[$name])) { return $this->settings[$name]; } @@ -397,7 +413,19 @@ public function getCustomFields() */ public function addCSSClass($cssClass) { - $this->cssClasses[] = $cssClass; + if (!empty($cssClass)) { + $this->cssClasses[] = $cssClass; + } + } + + /** + * Return all css classes + * + * @return array + */ + public function getCSSClasses() + { + return $this->cssClasses; } /** diff --git a/src/QUI/Bricks/Manager.php b/src/QUI/Bricks/Manager.php index 0f2dcc8c7df4649d4d07270f5347be0bc3e182ce..16722641f404a47967ba4380a9246b1729d24772 100644 --- a/src/QUI/Bricks/Manager.php +++ b/src/QUI/Bricks/Manager.php @@ -615,7 +615,6 @@ public function saveBrick($brickId, array $brickData) } } - // update QUI::getDataBase()->update($this->getTable(), array( 'title' => $Brick->getAttribute('title'), @@ -627,7 +626,7 @@ public function saveBrick($brickId, array $brickData) 'areas' => $areaString, 'height' => $Brick->getAttribute('height'), 'width' => $Brick->getAttribute('width'), - 'classes' => $Brick->getAttribute('classes') + 'classes' => json_encode($Brick->getCSSClasses()) ), array( 'id' => (int)$brickId ));