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

fix: #59 - Reihenfolge der Bausteinzonen

Übergeordneter e513bfe4
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -135,7 +135,7 @@ define('package/quiqqer/bricks/bin/Site/Area', [
icon : 'fa fa-caret-left',
events: {
onClick: function (Btn) {
if (Btn.getAttribute('icon') == 'fa fa-caret-left') {
if (Btn.getAttribute('icon') === 'fa fa-caret-left') {
self.openButtons();
return;
}
......@@ -248,9 +248,7 @@ define('package/quiqqer/bricks/bin/Site/Area', [
});
if (promises.length) {
Promise.resolve(promises).then(function () {
self.refresh();
Loader.destroy();
});
......@@ -513,7 +511,7 @@ define('package/quiqqer/bricks/bin/Site/Area', [
clone : function (event) {
var Target = event.target;
if (Target.nodeName != 'LI') {
if (Target.nodeName !== 'LI') {
Target = Target.getParent('li');
}
......
.quiqqer-bricks-site-category {
.quiqqer-bricks-site-category,
.quiqqer-bricks-site-category-image {
float: left;
height: 100%;
position: relative;
width: 100%;
}
.quiqqer-bricks-site-category-areas {
float: left;
width: 60%;
}
.quiqqer-bricks-site-category-image {
float: left;
padding-left: 20px;
width: 40%;
}
.quiqqer-bricks-site-category-image img {
max-width: 100%;
}
\ No newline at end of file
......@@ -44,6 +44,8 @@ define('package/quiqqer/bricks/bin/Site/Category', [
this.Loader = new QUILoader();
this.areas = [];
this.$Areas = null;
this.addEvents({
onInject : this.$onInject,
onDestroy: this.$onDestroy
......@@ -56,11 +58,15 @@ define('package/quiqqer/bricks/bin/Site/Category', [
*/
create: function () {
this.$Elm = new Element('div', {
'class': 'quiqqer-bricks-site-category'
'class': 'quiqqer-bricks-site-category',
'html' : '<div class="quiqqer-bricks-site-category-areas"></div>' +
'<div class="quiqqer-bricks-site-category-image"></div>'
});
this.Loader.inject(this.$Elm);
this.$Areas = this.$Elm.getElement('.quiqqer-bricks-site-category-areas');
this.$Image = this.$Elm.getElement('.quiqqer-bricks-site-category-image');
return this.$Elm;
},
......@@ -69,17 +75,32 @@ define('package/quiqqer/bricks/bin/Site/Category', [
* event : on inject
*/
$onInject: function () {
var self = this;
this.Loader.show();
this.getBrickAreas(function (bricks) {
var self = this,
Site = this.getAttribute('Site'),
Project = Site.getProject(),
layout = Site.getAttribute('layout');
Project.getLayouts().then(function (layouts) {
layout = layouts.find(function (entry) {
return entry.type === layout;
});
if (layout.image && layout.image !== '') {
new Element('img', {
src: layout.image
}).inject(self.$Image);
}
return self.getBrickAreas();
}).then(function (bricks) {
if (!bricks.length) {
self.$Elm.set(
self.$Areas.set(
'html',
QUILocale.get('quiqqer/bricks', 'bricks.message.no.areas.found')
);
return;
}
......@@ -138,24 +159,35 @@ define('package/quiqqer/bricks/bin/Site/Category', [
/**
* Return the available areas for the site
* @param {Function} callback - callback function
*
* @param {Function} [callback] - callback function
* @return {Promise}
*/
getBrickAreas: function (callback) {
var Site = this.getAttribute('Site'),
Project = Site.getProject();
Project.getConfig(function (layout) {
if (Site.getAttribute('layout')) {
layout = Site.getAttribute('layout');
}
return new Promise(function (resolve, reject) {
Project.getConfig(function (layout) {
if (Site.getAttribute('layout')) {
layout = Site.getAttribute('layout');
}
QUIAjax.get('package_quiqqer_bricks_ajax_project_getAreas', callback, {
'package': 'quiqqer/bricks',
project : Project.encode(),
layout : layout
});
QUIAjax.get('package_quiqqer_bricks_ajax_project_getAreas', function (result) {
if (typeof callback === 'function') {
callback(result);
}
resolve(result);
}, {
'package': 'quiqqer/bricks',
project : Project.encode(),
layout : layout,
onError : reject
});
}, 'layout');
}, 'layout');
});
},
/**
......@@ -173,7 +205,7 @@ define('package/quiqqer/bricks/bin/Site/Category', [
Control.setAttribute('Site', Site);
Control.setAttributes(area);
Control.inject(this.$Elm);
Control.inject(this.$Areas);
this.areas.push(Control);
......
......@@ -174,7 +174,7 @@ public function getAreasByProject(Project $Project, $layoutType = false)
// get bricks
foreach ($templates as $template) {
$brickXML = realpath(OPT_DIR . $template . '/bricks.xml');
$brickXML = realpath(OPT_DIR.$template.'/bricks.xml');
if (!$brickXML) {
continue;
......@@ -186,7 +186,7 @@ public function getAreasByProject(Project $Project, $layoutType = false)
);
}
// unque values
// unique values
$cleaned = array();
foreach ($bricks as $val) {
if (!isset($cleaned[$val['name']])) {
......@@ -198,6 +198,13 @@ public function getAreasByProject(Project $Project, $layoutType = false)
// use @ because: https://bugs.php.net/bug.php?id=50688
@usort($bricks, function ($a, $b) {
if (isset($a['priority']) && isset($b['priority'])) {
if ($a['priority'] == $b['priority']) {
return 0;
}
return ($a['priority'] < $b['priority']) ? -1 : 1;
}
$transA = QUI::getLocale()->get(
$a['title']['group'],
......@@ -344,7 +351,7 @@ public function getBrickByUID($uid)
*/
public function getAvailableBrickSettingsByBrickType($brickType)
{
$cache = 'quiqqer/bricks/brickType/' . md5($brickType);
$cache = 'quiqqer/bricks/brickType/'.md5($brickType);
try {
return QUI\Cache\Manager::get($cache);
......@@ -496,7 +503,7 @@ public function getBricksByArea($brickArea, Site $Site)
$result[] = $Clone->check();
} catch (QUI\Exception $Exception) {
QUI\System\Log::addWarning(
$Exception->getMessage() . ' Brick-ID:' . $brickId
$Exception->getMessage().' Brick-ID:'.$brickId
);
}
}
......@@ -578,7 +585,7 @@ public function saveBrick($brickId, array $brickData)
}
if (!empty($areas)) {
$areaString = ',' . implode(',', $areas) . ',';
$areaString = ','.implode(',', $areas).',';
}
$Brick->setAttributes($brickData);
......@@ -679,7 +686,7 @@ protected function getBricksXMLFiles()
// package bricks
foreach ($packages as $package) {
$bricksXML = OPT_DIR . $package['name'] . '/bricks.xml';
$bricksXML = OPT_DIR.$package['name'].'/bricks.xml';
if (file_exists($bricksXML)) {
$result[] = $bricksXML;
......@@ -690,7 +697,7 @@ protected function getBricksXMLFiles()
$projects = $Projects->getProjects();
foreach ($projects as $project) {
$bricksXML = USR_DIR . $project . '/bricks.xml';
$bricksXML = USR_DIR.$project.'/bricks.xml';
if (file_exists($bricksXML)) {
$result[] = $bricksXML;
......
......@@ -148,7 +148,8 @@ public static function parseAreaToArray(\DOMElement $Brick, \DOMXPath $Path)
'name' => $name,
'title' => $title,
'description' => $description,
'inheritance' => $Brick->getAttribute('inheritance')
'inheritance' => $Brick->getAttribute('inheritance'),
'priority' => $Brick->getAttribute('priority')
);
}
......@@ -164,7 +165,7 @@ public static function hasInheritance(Project $Project, $areaName)
$template = $Project->getAttribute('template');
// getAreasByProject
$brickXML = realpath(OPT_DIR . $template . '/bricks.xml');
$brickXML = realpath(OPT_DIR.$template.'/bricks.xml');
$bricks = self::getTemplateAreasFromXML($brickXML);
foreach ($bricks as $brickData) {
......
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