Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 0faa2f48 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: #11

Übergeordneter 1ac897e0
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -20,6 +20,10 @@ function parseChildren(&$data)
}
foreach ($data['children'] as $key => $entry) {
if (!class_exists($entry['type'])) {
continue;
}
/* @var $Item \QUI\Menu\Independent\Items\AbstractMenuItem */
$Item = new $entry['type']($entry);
$icon = QUI\Menu\Independent\Items\Site::itemIcon(); // default
......
<form>
<table class="data-table data-table-flexbox site-data">
<tbody>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Titel
</span>
<input class="field-container-field"
type="text"
name="title"
data-qui="controls/lang/InputMultiLang"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Name
</span>
<input class="field-container-field"
type="text"
name="name"
data-qui="controls/lang/InputMultiLang"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Icon
</span>
<input class="field-container-field"
type="text"
name="icon"
data-qui="controls/projects/project/media/Input"
data-qui-options-cssclasses="1"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Anker
</span>
<input class="field-container-field" type="text" name="url"/>
</label>
</td>
</tr>
</table>
</form>
......@@ -5,9 +5,12 @@
define('package/quiqqer/menu/bin/Controls/Independent/Items/Anchor', [
'qui/QUI',
'qui/controls/Control'
'qui/controls/Control',
'Mustache',
], function (QUI, QUIControl) {
'text!package/quiqqer/menu/bin/Controls/Independent/Items/Anchor.html'
], function (QUI, QUIControl, Mustache, template) {
"use strict";
return new Class({
......@@ -28,8 +31,65 @@ define('package/quiqqer/menu/bin/Controls/Independent/Items/Anchor', [
},
$onInject: function () {
this.getElm().addClass();
this.getElm().set('data-qui', this.getType());
this.getElm().set('html', Mustache.render(template, {}));
let title = this.getAttribute('title');
let icon = this.getAttribute('icon');
let data = this.getAttribute('data');
try {
title = JSON.decode(title);
} catch (e) {
}
try {
data = JSON.decode(data);
} catch (e) {
}
if (!data) {
data = {};
}
if (typeof data.url === 'undefined') {
data.url = '';
}
if (typeof data.name === 'undefined') {
data.name = '';
}
this.getElm().getElement('[name="icon"]').set('value', icon);
this.getElm().getElement('[name="url"]').set('value', data.url);
QUI.parse(this.getElm()).then(() => {
this.$Title = QUI.Controls.getById(
this.getElm().getElement('[name="title"]').get('data-quiid')
);
this.$Name = QUI.Controls.getById(
this.getElm().getElement('[name="name"]').get('data-quiid')
);
this.$Title.setData(title);
this.$Name.setData(data.name);
this.fireEvent('load');
});
},
save: function () {
const Form = this.getElm().getElement('form');
return {
title: this.$Title.getValue(),
icon : Form.elements.icon.value,
data : {
url : Form.elements.url.value,
name: this.$Name.getValue()
}
};
}
});
});
\ No newline at end of file
/**
* @module package/quiqqer/menu/bin/Controls/Independent/Items/Custom
* @author www.pcsg.de
*
* @todo click speichern -> js + textarea
*/
define('package/quiqqer/menu/bin/Controls/Independent/Items/Custom', [
......
<form>
<table class="data-table data-table-flexbox site-data">
<tbody>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Titel
</span>
<input class="field-container-field"
type="text"
name="title"
data-qui="controls/lang/InputMultiLang"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Name
</span>
<input class="field-container-field"
type="text"
name="name"
data-qui="controls/lang/InputMultiLang"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
Icon
</span>
<input class="field-container-field"
type="text"
name="icon"
data-qui="controls/projects/project/media/Input"
data-qui-options-cssclasses="1"
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
URL
</span>
<input class="field-container-field" type="text" name="url"/>
</label>
</td>
</tr>
</table>
</form>
......@@ -5,9 +5,12 @@
define('package/quiqqer/menu/bin/Controls/Independent/Items/Url', [
'qui/QUI',
'qui/controls/Control'
'qui/controls/Control',
'Mustache',
], function (QUI, QUIControl) {
'text!package/quiqqer/menu/bin/Controls/Independent/Items/Url.html'
], function (QUI, QUIControl, Mustache, template) {
"use strict";
return new Class({
......@@ -28,9 +31,65 @@ define('package/quiqqer/menu/bin/Controls/Independent/Items/Url', [
},
$onInject: function () {
this.getElm().addClass();
this.getElm().set('data-qui', this.getType());
}
this.getElm().set('html', Mustache.render(template, {}));
let title = this.getAttribute('title');
let icon = this.getAttribute('icon');
let data = this.getAttribute('data');
try {
title = JSON.decode(title);
} catch (e) {
}
try {
data = JSON.decode(data);
} catch (e) {
}
if (!data) {
data = {};
}
if (typeof data.url === 'undefined') {
data.url = '';
}
if (typeof data.name === 'undefined') {
data.name = '';
}
this.getElm().getElement('[name="icon"]').set('value', icon);
this.getElm().getElement('[name="url"]').set('value', data.url);
QUI.parse(this.getElm()).then(() => {
this.$Title = QUI.Controls.getById(
this.getElm().getElement('[name="title"]').get('data-quiid')
);
this.$Name = QUI.Controls.getById(
this.getElm().getElement('[name="name"]').get('data-quiid')
);
this.$Title.setData(title);
this.$Name.setData(data.name);
this.fireEvent('load');
});
},
save: function () {
const Form = this.getElm().getElement('form');
return {
title: this.$Title.getValue(),
icon : Form.elements.icon.value,
data : {
url : Form.elements.url.value,
name: this.$Name.getValue()
}
};
}
});
});
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<database>
<global>
<table name="menus">
<field type="BIGINT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY">id</field>
<field type="TEXT DEFAULT NULL">title</field>
<field type="TEXT DEFAULT NULL">workingTitle</field>
<field type="TEXT NULL">data</field>
</table>
</global>
</database>
......@@ -4,8 +4,50 @@
use QUI;
use function is_array;
/**
* menu item to an anchor
*/
class Anchor extends AbstractMenuItem
{
//region frontend item methods
/**
* @return string
*/
public function getUrl(): string
{
$data = $this->getCustomData();
if (is_array($data) && isset($data['url'])) {
return $data['url'];
}
return '';
}
/**
* @return string
*/
public function getName(): string
{
$data = $this->getCustomData();
if (is_array($data) && isset($data['name'])) {
return $data['name'];
}
return '';
}
//endregion
//region type stuff
/**
* @return string
*/
public static function itemTitle(): string
{
return QUI::getLocale()->get('quiqqer/menu', 'item.anchor.title');
......@@ -19,8 +61,13 @@ public static function itemIcon(): string
return 'fa fa-anchor';
}
/**
* @return string
*/
public static function itemJsControl(): string
{
return 'package/quiqqer/menu/bin/Controls/Independent/Items/Anchor';
}
//endregion
}
......@@ -7,7 +7,7 @@
use function is_array;
/**
*
* menu item which gets its data from a site
*/
class Site extends AbstractMenuItem
{
......
......@@ -4,8 +4,14 @@
use QUI;
/**
* menu item to an external url
*/
class Url extends AbstractMenuItem
{
/**
* @return string
*/
public static function itemTitle(): string
{
return QUI::getLocale()->get('quiqqer/menu', 'item.url.title');
......@@ -19,6 +25,9 @@ public static function itemIcon(): string
return 'fa fa-globe';
}
/**
* @return string
*/
public static function itemJsControl(): string
{
return 'package/quiqqer/menu/bin/Controls/Independent/Items/Url';
......
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