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 @@
</tr>
</tbody>
</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>
\ No newline at end of file
......@@ -19,6 +19,7 @@ function package_quiqqer_bricks_ajax_getBrick($brickId)
return array(
'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType(
$Brick->getAttribute('type')
)
......
......@@ -38,4 +38,9 @@
.brick-edit-extra-header tbody tr td:first-child,
.quiqqer-bricks-brickedit .data-table tbody tr td:first-child {
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', [
this.$availableBricks = [];
this.$availableSettings = [];
this.$customfields = [];
this.$Editor = false;
this.$Areas = false;
......@@ -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({
name : 'settings',
icon : 'icon-magic',
......@@ -146,6 +138,15 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
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', [
*/
this.$availableBricks = bricks;
this.$availableSettings = brick.availableSettings;
this.$customfields = brick.customfields;
this.setAttribute('data', brick);
......@@ -219,6 +221,10 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
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 ()
{
if (typeof callback === 'function') {
......@@ -233,7 +239,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
}.bind(this), {
'package': 'quiqqer/brick',
brickId : this.getAttribute('id'),
data : JSON.encode(this.getAttribute('data').attributes),
data : JSON.encode(data),
onError : reject
});
......@@ -360,7 +366,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
data = this.getAttribute('data');
if (unload == 'information') {
data.attributes = Object.merge(
data.attributes,
QUIFormUtils.getFormData(Form)
......@@ -372,12 +377,35 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
data.attributes.width = Form.elements.width.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 = false;
}
if (unload == 'extra') {
data.settings = QUIFormUtils.getFormData(Form);
data.settings = Object.merge(
data.settings,
QUIFormUtils.getFormData(Form)
);
}
if (unload == 'content') {
......@@ -436,7 +464,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
// areas
var Content = this.getContent(),
areas = [],
attributes = this.getAttribute('data').attributes;
attributes = this.getAttribute('data').attributes,
customfields = this.$customfields;
if (attributes.areas)
{
......@@ -465,6 +494,44 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
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();
}.bind(this), {
......
......@@ -9,6 +9,7 @@
<field type="VARCHAR( 255 ) NOT NULL">title</field>
<field type="TEXT NOT NULL">description</field>
<field type="TEXT">settings</field>
<field type="TEXT">customfields</field>
<field type="VARCHAR( 255 )">type</field>
<field type="TEXT">content</field>
<field type="TEXT">areas</field>
......
......@@ -31,6 +31,13 @@ class Brick extends QUI\QDOM
*/
protected $_settings = array();
/**
* Fields can be overwritten by another user
*
* @var array
*/
protected $_customfields = array();
/**
* Constructor
*
......@@ -93,14 +100,25 @@ public function __construct($params = array())
$settings = json_decode($settings, true);
}
if (!is_array($settings)) {
return;
if (is_array($settings)) {
foreach ($this->_settings as $key => $value) {
if (isset($settings[$key])) {
$this->_settings[$key] = $settings[$key];
}
}
}
}
foreach ($this->_settings as $key => $value) {
if (isset($settings[$key])) {
$this->_settings[$key] = $settings[$key];
}
// customfields
if (isset($params['customfields'])) {
$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)
$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)
return '';
}, $this->getAreasByProject($Project));
if (isset($brickData['areas'])) {
$parts = explode(',', $brickData['areas']);
......@@ -422,22 +421,44 @@ public function saveBrick($brickId, array $brickData)
$areaString = ','.implode(',', $areas).',';
}
$Brick->setAttributes($brickData);
// brick settings
if (isset($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(
'title' => $Brick->getAttribute('title'),
'description' => $Brick->getAttribute('description'),
'content' => $Brick->getAttribute('content'),
'type' => $Brick->getAttribute('type'),
'settings' => json_encode($Brick->getSettings()),
'areas' => $areaString,
'height' => $Brick->getAttribute('height'),
'width' => $Brick->getAttribute('width')
'title' => $Brick->getAttribute('title'),
'description' => $Brick->getAttribute('description'),
'content' => $Brick->getAttribute('content'),
'type' => $Brick->getAttribute('type'),
'settings' => json_encode($Brick->getSettings()),
'customfields' => json_encode($customfields),
'areas' => $areaString,
'height' => $Brick->getAttribute('height'),
'width' => $Brick->getAttribute('width')
), array(
'id' => (int)$brickId
));
......
......@@ -180,6 +180,15 @@
<de><![CDATA[Baustein Breite]]></de>
<en><![CDATA[Brick width]]></en>
</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 name="quiqqer/bricks" datatype="js">
<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