Skip to content
Code-Schnipsel Gruppen Projekte
Commit 64a1ff4b erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Flexible Eigenschaften können gesetzt werden und eingestellt werden

Übergeordneter fe18ff20
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -49,4 +49,37 @@ ...@@ -49,4 +49,37 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="data-table brick-table-flexible">
<thead>
<tr>
<th>
{locale group="quiqqer/bricks" var="brick.edit.settings.flexible.header"}
<div class="description">
{locale group="quiqqer/bricks" var="brick.edit.settings.flexible.header.description"}
</div>
</th>
</tr>
</thead>
<tbody>
<tr class="{cycle values="odd,even" reset=true}">
<td>
<label>
<input type="checkbox" name="flexible-height">
<span>{locale group="quiqqer/bricks" var="brick.edit.height"}</span>
</label>
</td>
</tr>
<tr class="{cycle values="odd,even"}">
<td>
<label>
<input type="checkbox" name="flexible-width">
<span>{locale group="quiqqer/bricks" var="brick.edit.width"}</span>
</label>
</td>
</tr>
</tbody>
</table>
</form> </form>
\ No newline at end of file
...@@ -19,6 +19,7 @@ function package_quiqqer_bricks_ajax_getBrick($brickId) ...@@ -19,6 +19,7 @@ function package_quiqqer_bricks_ajax_getBrick($brickId)
return array( return array(
'attributes' => $Brick->getAttributes(), 'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(), 'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType( 'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType(
$Brick->getAttribute('type') $Brick->getAttribute('type')
) )
......
...@@ -38,4 +38,9 @@ ...@@ -38,4 +38,9 @@
.brick-edit-extra-header tbody tr td:first-child, .brick-edit-extra-header tbody tr td:first-child,
.quiqqer-bricks-brickedit .data-table tbody tr td:first-child { .quiqqer-bricks-brickedit .data-table tbody tr td:first-child {
width: 200px; width: 200px;
}
.brick-table-flexible label {
margin-bottom: 0;
width: 100% !important;
} }
\ No newline at end of file
...@@ -68,6 +68,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -68,6 +68,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
this.$availableBricks = []; this.$availableBricks = [];
this.$availableSettings = []; this.$availableSettings = [];
this.$customfields = [];
this.$Editor = false; this.$Editor = false;
this.$Areas = false; this.$Areas = false;
...@@ -120,15 +121,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -120,15 +121,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
} }
}); });
this.addCategory({
name : 'content',
icon : 'icon-file-text-alt',
text : QUILocale.get('quiqqer/system', 'content'),
events : {
onActive : this.$load
}
});
this.addCategory({ this.addCategory({
name : 'settings', name : 'settings',
icon : 'icon-magic', icon : 'icon-magic',
...@@ -146,6 +138,15 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -146,6 +138,15 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
onActive : this.$load onActive : this.$load
} }
}); });
this.addCategory({
name : 'content',
icon : 'icon-file-text-alt',
text : QUILocale.get('quiqqer/system', 'content'),
events : {
onActive : this.$load
}
});
}, },
/** /**
...@@ -167,6 +168,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -167,6 +168,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
*/ */
this.$availableBricks = bricks; this.$availableBricks = bricks;
this.$availableSettings = brick.availableSettings; this.$availableSettings = brick.availableSettings;
this.$customfields = brick.customfields;
this.setAttribute('data', brick); this.setAttribute('data', brick);
...@@ -219,6 +221,10 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -219,6 +221,10 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
return new Promise(function(resolve, reject) return new Promise(function(resolve, reject)
{ {
var data = this.getAttribute('data').attributes;
data.customfields = this.$customfields;
QUIAjax.post('package_quiqqer_bricks_ajax_brick_save', function () QUIAjax.post('package_quiqqer_bricks_ajax_brick_save', function ()
{ {
if (typeof callback === 'function') { if (typeof callback === 'function') {
...@@ -233,7 +239,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -233,7 +239,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
}.bind(this), { }.bind(this), {
'package': 'quiqqer/brick', 'package': 'quiqqer/brick',
brickId : this.getAttribute('id'), brickId : this.getAttribute('id'),
data : JSON.encode(this.getAttribute('data').attributes), data : JSON.encode(data),
onError : reject onError : reject
}); });
...@@ -360,7 +366,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -360,7 +366,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
data = this.getAttribute('data'); data = this.getAttribute('data');
if (unload == 'information') { if (unload == 'information') {
data.attributes = Object.merge( data.attributes = Object.merge(
data.attributes, data.attributes,
QUIFormUtils.getFormData(Form) QUIFormUtils.getFormData(Form)
...@@ -372,12 +377,35 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -372,12 +377,35 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
data.attributes.width = Form.elements.width.value; data.attributes.width = Form.elements.width.value;
data.attributes.height = Form.elements.height.value; data.attributes.height = Form.elements.height.value;
var flexibleList = [],
fieldData = QUIFormUtils.getFormData(Form);
for (var key in fieldData) {
if (!fieldData.hasOwnProperty(key)) {
continue;
}
if (!key.match('flexible')) {
continue;
}
if (fieldData[key]) {
flexibleList.push(key);
}
}
this.$customfields = flexibleList;
this.$Areas.destroy(); this.$Areas.destroy();
this.$Areas = false; this.$Areas = false;
} }
if (unload == 'extra') { if (unload == 'extra') {
data.settings = QUIFormUtils.getFormData(Form); data.settings = Object.merge(
data.settings,
QUIFormUtils.getFormData(Form)
);
} }
if (unload == 'content') { if (unload == 'content') {
...@@ -436,7 +464,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -436,7 +464,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
// areas // areas
var Content = this.getContent(), var Content = this.getContent(),
areas = [], areas = [],
attributes = this.getAttribute('data').attributes; attributes = this.getAttribute('data').attributes,
customfields = this.$customfields;
if (attributes.areas) if (attributes.areas)
{ {
...@@ -465,6 +494,44 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ ...@@ -465,6 +494,44 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
Content.getElement('[name="height"]').value = attributes.height; Content.getElement('[name="height"]').value = attributes.height;
} }
// flexble settings
var i, len, data;
var TBody = Content.getElement('.brick-table-flexible tbody');
for (i = 0, len = this.$availableSettings.length; i < len; i++) {
data = this.$availableSettings[i];
new Element('tr', {
'class' : i % 2 ? 'even' : 'odd',
html : '<td>' +
'<label>'+
'<input type="checkbox" name="flexible-'+ data.name +'" />'+
'<span>'+ QUILocale.get(data.text[0], data.text[1]) +'</span>'+
'</label>'+
'</td>'
}).inject(TBody);
}
if (customfields) {
var name;
var Form = Content.getElement('form');
for (i = 0, len = customfields.length; i < len; i++) {
name = customfields[i];
if (typeof Form.elements[name] !== 'undefined') {
Form.elements[name].checked = true;
}
if (typeof Form.elements['flexible-'+name] !== 'undefined') {
Form.elements['flexible-'+name].checked = true;
}
}
}
resolve(); resolve();
}.bind(this), { }.bind(this), {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<field type="VARCHAR( 255 ) NOT NULL">title</field> <field type="VARCHAR( 255 ) NOT NULL">title</field>
<field type="TEXT NOT NULL">description</field> <field type="TEXT NOT NULL">description</field>
<field type="TEXT">settings</field> <field type="TEXT">settings</field>
<field type="TEXT">customfields</field>
<field type="VARCHAR( 255 )">type</field> <field type="VARCHAR( 255 )">type</field>
<field type="TEXT">content</field> <field type="TEXT">content</field>
<field type="TEXT">areas</field> <field type="TEXT">areas</field>
......
...@@ -31,6 +31,13 @@ class Brick extends QUI\QDOM ...@@ -31,6 +31,13 @@ class Brick extends QUI\QDOM
*/ */
protected $_settings = array(); protected $_settings = array();
/**
* Fields can be overwritten by another user
*
* @var array
*/
protected $_customfields = array();
/** /**
* Constructor * Constructor
* *
...@@ -93,14 +100,25 @@ public function __construct($params = array()) ...@@ -93,14 +100,25 @@ public function __construct($params = array())
$settings = json_decode($settings, true); $settings = json_decode($settings, true);
} }
if (!is_array($settings)) { if (is_array($settings)) {
return; foreach ($this->_settings as $key => $value) {
if (isset($settings[$key])) {
$this->_settings[$key] = $settings[$key];
}
}
} }
}
foreach ($this->_settings as $key => $value) { // customfields
if (isset($settings[$key])) { if (isset($params['customfields'])) {
$this->_settings[$key] = $settings[$key]; $customfields = $params['customfields'];
}
if (is_string($customfields)) {
$customfields = json_decode($customfields, true);
}
if (is_array($customfields)) {
$this->_customfields = $customfields;
} }
} }
} }
...@@ -235,4 +253,14 @@ public function setSetting($name, $value) ...@@ -235,4 +253,14 @@ public function setSetting($name, $value)
$this->_settings[$name] = $value; $this->_settings[$name] = $value;
} }
} }
/**
* This fields can be overwritten by another user
*
* @return array
*/
public function getCustomFields()
{
return $this->_customfields;
}
} }
...@@ -407,7 +407,6 @@ public function saveBrick($brickId, array $brickData) ...@@ -407,7 +407,6 @@ public function saveBrick($brickId, array $brickData)
return ''; return '';
}, $this->getAreasByProject($Project)); }, $this->getAreasByProject($Project));
if (isset($brickData['areas'])) { if (isset($brickData['areas'])) {
$parts = explode(',', $brickData['areas']); $parts = explode(',', $brickData['areas']);
...@@ -422,22 +421,44 @@ public function saveBrick($brickId, array $brickData) ...@@ -422,22 +421,44 @@ public function saveBrick($brickId, array $brickData)
$areaString = ','.implode(',', $areas).','; $areaString = ','.implode(',', $areas).',';
} }
$Brick->setAttributes($brickData); $Brick->setAttributes($brickData);
// brick settings
if (isset($brickData['settings'])) { if (isset($brickData['settings'])) {
$Brick->setSettings($brickData['settings']); $Brick->setSettings($brickData['settings']);
} }
// custom fields
$customfields = array();
if (isset($brickData['customfields'])) {
$availableSettings = $Brick->getSettings();
$availableSettings['width'] = true;
$availableSettings['height'] = true;
foreach ($brickData['customfields'] as $customfield) {
$customfield = str_replace('flexible-', '', $customfield);
if (isset($availableSettings[$customfield])) {
$customfields[] = $customfield;
}
}
}
// update
QUI::getDataBase()->update($this->_getTable(), array( QUI::getDataBase()->update($this->_getTable(), array(
'title' => $Brick->getAttribute('title'), 'title' => $Brick->getAttribute('title'),
'description' => $Brick->getAttribute('description'), 'description' => $Brick->getAttribute('description'),
'content' => $Brick->getAttribute('content'), 'content' => $Brick->getAttribute('content'),
'type' => $Brick->getAttribute('type'), 'type' => $Brick->getAttribute('type'),
'settings' => json_encode($Brick->getSettings()), 'settings' => json_encode($Brick->getSettings()),
'areas' => $areaString, 'customfields' => json_encode($customfields),
'height' => $Brick->getAttribute('height'), 'areas' => $areaString,
'width' => $Brick->getAttribute('width') 'height' => $Brick->getAttribute('height'),
'width' => $Brick->getAttribute('width')
), array( ), array(
'id' => (int)$brickId 'id' => (int)$brickId
)); ));
......
...@@ -180,6 +180,15 @@ ...@@ -180,6 +180,15 @@
<de><![CDATA[Baustein Breite]]></de> <de><![CDATA[Baustein Breite]]></de>
<en><![CDATA[Brick width]]></en> <en><![CDATA[Brick width]]></en>
</locale> </locale>
<locale name="brick.edit.settings.flexible.header">
<de><![CDATA[Flexible Einstellungen]]></de>
<en><![CDATA[Flexible settings]]></en>
</locale>
<locale name="brick.edit.settings.flexible.header.description">
<de><![CDATA[Bestimmen Sie welche Einstellung flexibel von anderen Benutzern verändert werden können.]]></de>
<en><![CDATA[Determine which setting can be flexibly changed by others.]]></en>
</locale>
</groups> </groups>
<groups name="quiqqer/bricks" datatype="js"> <groups name="quiqqer/bricks" datatype="js">
<locale name="brick.type"> <locale name="brick.type">
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren