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

refactor: solved merged conflict

Übergeordnete d95ada46 c950a485
No related branches found
No related tags found
3 Merge Requests!52Update 'next-3.x' with latest changes from 'main',!48Add QUIQQER Tooling,!20fix: create currency - create locale fixed
Pipeline #4695 bestanden mit Phase
in 35 Sekunden
......@@ -27,7 +27,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return new Class({
Extends: QUIControl,
Type : 'package/quiqqer/currency/bin/settings/AllowedCurrencies',
Type: 'package/quiqqer/currency/bin/settings/AllowedCurrencies',
Binds: [
'refresh',
......@@ -78,17 +78,17 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
this.$Elm = new Element('div', {
'class': 'quiqqer-currency-allowed',
html : '<div class="quiqqer-currency-allowed-container"></div>'
html: '<div class="quiqqer-currency-allowed-container"></div>'
}).wraps(this.$Input);
const self = this,
Settings = this.$Elm.getParent('.qui-xml-panel-row-item');
const self = this,
Settings = this.$Elm.getParent('.qui-xml-panel-row-item');
if (Settings) {
Settings.setStyles({
height : 300,
height: 300,
overflow: 'hidden',
width : '100%'
width: '100%'
});
}
......@@ -99,71 +99,71 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
let width = this.$Container.getSize().x;
this.$Grid = new Grid(this.$Container, {
pagination : true,
pagination: true,
multipleSelection: true,
height : 300,
width : width,
columnModel : [
height: 300,
width: width,
columnModel: [
{
header : QUILocale.get(lg, 'grid.setting.currency'),
header: QUILocale.get(lg, 'grid.setting.currency'),
dataIndex: 'code',
dataType : 'string',
width : 60,
editable : true
dataType: 'string',
width: 60,
editable: true
},
{
header : QUILocale.get(lg, 'grid.setting.sign'),
header: QUILocale.get(lg, 'grid.setting.sign'),
dataIndex: 'sign',
dataType : 'string',
width : 60,
editable : true
dataType: 'string',
width: 60,
editable: true
},
{
header : QUILocale.get(lg, 'grid.setting.rate'),
header: QUILocale.get(lg, 'grid.setting.rate'),
dataIndex: 'rate',
dataType : 'string',
width : 100
dataType: 'string',
width: 100
},
{
header : QUILocale.get(lg, 'grid.setting.precision'),
header: QUILocale.get(lg, 'grid.setting.precision'),
dataIndex: 'precision',
dataType : 'string',
width : 100
dataType: 'string',
width: 100
},
{
header : QUILocale.get(lg, 'grid.setting.allowed'),
header: QUILocale.get(lg, 'grid.setting.allowed'),
dataIndex: 'allowed',
dataType : 'QUI',
width : 100
dataType: 'QUI',
width: 100
},
{
header : QUILocale.get(lg, 'grid.setting.update'),
header: QUILocale.get(lg, 'grid.setting.update'),
dataIndex: 'autoupdate',
dataType : 'QUI',
width : 100
dataType: 'QUI',
width: 100
},
{
header : QUILocale.get(lg, 'grid.setting.typeTitle'),
header: QUILocale.get(lg, 'grid.setting.typeTitle'),
dataIndex: 'typeTitle',
dataType : 'string',
width : 100
dataType: 'string',
width: 100
}
],
buttons : [
buttons: [
{
name : 'add',
text : QUILocale.get(lg, 'grid.setting.button.add'),
name: 'add',
text: QUILocale.get(lg, 'grid.setting.button.add'),
textimage: 'fa fa-plus',
events : {
events: {
onClick: this.openCreateDialog
}
},
{
name : 'edit',
text : QUILocale.get(lg, 'grid.setting.button.edit'),
name: 'edit',
text: QUILocale.get(lg, 'grid.setting.button.edit'),
textimage: 'fa fa-edit',
disabled : true,
events : {
disabled: true,
events: {
onClick: function () {
self.openUpdateDialog(self.$Grid.getSelectedData()[0].code);
}
......@@ -173,13 +173,13 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
type: 'separator'
},
{
name : 'delete',
text : QUILocale.get(lg, 'grid.setting.button.delete'),
name: 'delete',
text: QUILocale.get(lg, 'grid.setting.button.delete'),
textimage: 'fa fa-trash',
disabled : true,
events : {
disabled: true,
events: {
onClick: function () {
var currencies = self.$Grid.getSelectedData().map(function (C) {
const currencies = self.$Grid.getSelectedData().map(function (C) {
return C.code;
});
......@@ -194,14 +194,14 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
this.$Grid.addEvents({
onClick: function () {
var selected = self.$Grid.getSelectedIndices(),
buttons = self.$Grid.getButtons();
const selected = self.$Grid.getSelectedIndices(),
buttons = self.$Grid.getButtons();
var Edit = buttons.filter(function (Btn) {
const Edit = buttons.filter(function (Btn) {
return Btn.getAttribute('name') === 'edit';
})[0];
var Delete = buttons.filter(function (Btn) {
const Delete = buttons.filter(function (Btn) {
return Btn.getAttribute('name') === 'delete';
})[0];
......@@ -229,7 +229,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
*/
refresh: function () {
return this.getCurrencies().then(function (list) {
let data = [],
let data = [],
values = this.getAttribute('values');
for (let i in list) {
......@@ -241,43 +241,43 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
}
let perPage = this.$Grid.options.perPage,
page = this.$Grid.options.page,
start = (page - 1) * perPage,
total = data.length;
page = this.$Grid.options.page,
start = (page - 1) * perPage,
total = data.length;
data = data.splice(start, perPage);
data.each(function (entry, i) {
data[i].allowed = new QUISwitch({
status : (typeof values[entry.code] !== 'undefined'),
status: (typeof values[entry.code] !== 'undefined'),
currency: entry.code,
events : {
events: {
onChange: this.$onCurrencyStatusChange
}
});
data[i].autoupdate = new QUISwitch({
status : entry.autoupdate,
status: entry.autoupdate,
currency: entry.code,
events : {
events: {
onChange: this.$changeAutoUpdate
}
});
}.bind(this));
this.$Grid.setData({
data : data,
data: data,
total: total,
page : page
page: page
});
var buttons = this.$Grid.getButtons();
const buttons = this.$Grid.getButtons();
var Edit = buttons.filter(function (Btn) {
const Edit = buttons.filter(function (Btn) {
return Btn.getAttribute('name') === 'edit';
})[0];
var Delete = buttons.filter(function (Btn) {
const Delete = buttons.filter(function (Btn) {
return Btn.getAttribute('name') === 'delete';
})[0];
......@@ -291,11 +291,11 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
* update values to the input field
*/
update: function () {
var allowed = [],
values = this.getAttribute('values');
const allowed = [],
values = this.getAttribute('values');
if (typeOf(values) === 'object') {
for (var i in values) {
for (const i in values) {
if (!values.hasOwnProperty(i)) {
continue;
}
......@@ -317,7 +317,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return new Promise(function (resolve, reject) {
QUIAjax.get('package_quiqqer_currency_ajax_getCurrencies', resolve, {
'package': 'quiqqer/currency',
onError : reject
onError: reject
});
});
},
......@@ -335,9 +335,9 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_currency_ajax_delete', resolve, {
'package' : 'quiqqer/currency',
'package': 'quiqqer/currency',
currencies: JSON.encode(currencies),
onError : reject
onError: reject
});
});
},
......@@ -352,8 +352,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_currency_ajax_create', resolve, {
'package': 'quiqqer/currency',
currency : currency,
onError : reject
currency: currency,
onError: reject
});
});
},
......@@ -364,8 +364,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
* @param {Object} Switch
*/
$onCurrencyStatusChange: function (Switch) {
var currency = Switch.getAttribute('currency');
var values = this.getAttribute('values');
const currency = Switch.getAttribute('currency');
const values = this.getAttribute('values');
if (Switch.getStatus()) {
......@@ -379,8 +379,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
this.setAttribute('values', values);
this.update();
var PanelNode = this.getElm().getParent('.qui-panel'),
Panel = QUI.Controls.getById(PanelNode.get('data-quiid'));
const PanelNode = this.getElm().getParent('.qui-panel'),
Panel = QUI.Controls.getById(PanelNode.get('data-quiid'));
if (!Panel) {
return;
......@@ -399,10 +399,10 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
* @param {Event} event
*/
$switchCurrencyStatus: function (event) {
var Target = event.target;
var SwitchContainer = Target.getParent().getElement('.qui-switch');
const Target = event.target;
const SwitchContainer = Target.getParent().getElement('.qui-switch');
var Switch = QUI.Controls.getById(
const Switch = QUI.Controls.getById(
SwitchContainer.get('data-quiid')
);
......@@ -418,10 +418,10 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
$changeAutoUpdate: function (Switch) {
return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_currency_ajax_setAutoupdate', resolve, {
'package' : 'quiqqer/currency',
currency : Switch.getAttribute('currency'),
'package': 'quiqqer/currency',
currency: Switch.getAttribute('currency'),
autoupdate: Switch.getStatus() ? 1 : 0,
onError : reject
onError: reject
});
});
},
......@@ -435,7 +435,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_currency_ajax_importFromECB', resolve, {
'package': 'quiqqer/currency',
onError : reject
onError: reject
});
});
},
......@@ -452,7 +452,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
openUpdateDialog: function (currency) {
new CurrencyWindow({
currency: currency,
events : {
events: {
onClose: this.refresh
}
}).open();
......@@ -468,8 +468,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
return;
}
var self = this,
text, information;
const self = this;
let text, information;
if (currencies.length === 1) {
text = QUILocale.get(lg, 'window.delete.text', {
......@@ -488,19 +488,19 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
}
new QUIConfirm({
icon : 'fa fa-trash',
texticon : 'fa fa-trash',
title : QUILocale.get(lg, 'window.delete.title'),
text : text,
icon: 'fa fa-trash',
texticon: 'fa fa-trash',
title: QUILocale.get(lg, 'window.delete.title'),
text: text,
information: information,
ok_button : {
text : QUILocale.get('quiqqer/system', 'delete'),
ok_button: {
text: QUILocale.get('quiqqer/system', 'delete'),
textimage: 'icon-ok fa fa-check'
},
maxHeight : 400,
maxWidth : 600,
autoclose : false,
events : {
maxHeight: 400,
maxWidth: 600,
autoclose: false,
events: {
onSubmit: function (Win) {
Win.Loader.show();
self.deleteCurrency(currencies).then(function () {
......@@ -523,16 +523,16 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [
* Opens the create dialog
*/
openCreateDialog: function () {
var self = this;
const self = this;
new QUIPrompt({
icon : 'fa fa-money',
titleicon : 'fa fa-money',
title : QUILocale.get(lg, 'window.create.title'),
icon: 'fa fa-money',
titleicon: 'fa fa-money',
title: QUILocale.get(lg, 'window.create.title'),
information: QUILocale.get(lg, 'window.create.information'),
maxHeight : 300,
maxWidth : 450,
events : {
maxHeight: 300,
maxWidth: 450,
events: {
onSubmit: function (value, Win) {
Win.Loader.show();
......
......@@ -26,7 +26,7 @@ define('package/quiqqer/currency/bin/settings/Currency', [
return new Class({
Extends: QUIControl,
Type : 'package/quiqqer/currency/bin/settings/Currency',
Type: 'package/quiqqer/currency/bin/settings/Currency',
Binds: [
'$onInject'
......@@ -39,15 +39,15 @@ define('package/quiqqer/currency/bin/settings/Currency', [
initialize: function (options) {
this.parent(options);
this.$Form = null;
this.$Code = null;
this.$Rate = null;
this.$Form = null;
this.$Code = null;
this.$Rate = null;
this.$Precision = null;
this.Loader = new QUILoader();
this.$TranslationTitle = null;
this.$TranslationSign = null;
this.$TranslationTitle = null;
this.$TranslationSign = null;
this.$CurrencyTypeSelect = null;
this.$ExtraSettingsContainer = null;
......@@ -65,15 +65,15 @@ define('package/quiqqer/currency/bin/settings/Currency', [
create: function () {
this.$Elm = new Element('div', {
'class': 'quiqqer-currency-setting',
html : Mustache.render(template, {
currencyTitle : QUILocale.get('quiqqer/system', 'title'),
currencyCode : QUILocale.get(lg, 'control.currency.code'),
currencySign : QUILocale.get(lg, 'control.currency.sign'),
currencyExchangeRate : QUILocale.get(lg, 'control.currency.rate'),
html: Mustache.render(template, {
currencyTitle: QUILocale.get('quiqqer/system', 'title'),
currencyCode: QUILocale.get(lg, 'control.currency.code'),
currencySign: QUILocale.get(lg, 'control.currency.sign'),
currencyExchangeRate: QUILocale.get(lg, 'control.currency.rate'),
currencyCodeDescription: QUILocale.get(lg, 'control.currency.code.decription'),
currencyPrecision : QUILocale.get(lg, 'control.currency.precision'),
titleCurrencyType : QUILocale.get(lg, 'control.currency.titleCurrencyType'),
currencyType : QUILocale.get(lg, 'control.currency.currencyType')
currencyPrecision: QUILocale.get(lg, 'control.currency.precision'),
titleCurrencyType: QUILocale.get(lg, 'control.currency.titleCurrencyType'),
currencyType: QUILocale.get(lg, 'control.currency.currencyType')
})
});
......@@ -81,9 +81,9 @@ define('package/quiqqer/currency/bin/settings/Currency', [
this.$Form = this.$Elm.getElement('form');
this.$Code = this.$Form.elements.code;
this.$Rate = this.$Form.elements.rate;
this.$Precision = this.$Form.elements.precision;
this.$Code = this.$Form.elements.code;
this.$Rate = this.$Form.elements.rate;
this.$Precision = this.$Form.elements.precision;
this.$CurrencyTypeSelect = this.$Form.elements.type;
this.$ExtraSettingsContainer = this.$Elm.getElement('.quiqqer-currency-setting-extra');
......@@ -96,18 +96,18 @@ define('package/quiqqer/currency/bin/settings/Currency', [
*/
$onInject: function () {
const TitleContainer = this.getElm().getElement('.currency-title'),
SignContainer = this.getElm().getElement('.currency-sign'),
currency = this.getAttribute('currency');
SignContainer = this.getElm().getElement('.currency-sign'),
currency = this.getAttribute('currency');
this.$TranslationTitle = new Translation({
'group' : 'quiqqer/currency',
'var' : 'currency.' + currency + '.text',
'group': 'quiqqer/currency',
'var': 'currency.' + currency + '.text',
'package': 'quiqqer/currency'
}).inject(TitleContainer);
this.$TranslationSign = new Translation({
'group' : 'quiqqer/currency',
'var' : 'currency.' + currency + '.sign',
'group': 'quiqqer/currency',
'var': 'currency.' + currency + '.sign',
'package': 'quiqqer/currency'
}).inject(SignContainer);
......@@ -118,18 +118,18 @@ define('package/quiqqer/currency/bin/settings/Currency', [
Currencies.getCurrency(this.getAttribute('currency'), true),
Currencies.getCurrencyTypes()
]).then((result) => {
const Currency = result[0];
const Currency = result[0];
const currencyTypes = result[1];
this.$Code.value = Currency.code;
this.$Rate.value = Currency.rate;
this.$Code.value = Currency.code;
this.$Rate.value = Currency.rate;
this.$Precision.value = Currency.precision;
// Load select with currency types
currencyTypes.forEach((CurrencyType) => {
new Element('option', {
value: CurrencyType.type,
html : CurrencyType.typeTitle
html: CurrencyType.typeTitle
}).inject(this.$CurrencyTypeSelect);
});
......@@ -181,12 +181,12 @@ define('package/quiqqer/currency/bin/settings/Currency', [
this.$TranslationSign.save()
]).then(() => {
QUIAjax.post('package_quiqqer_currency_ajax_update', resolve, {
'package' : 'quiqqer/currency',
currency : this.getAttribute('currency'),
code : this.$Code.value,
rate : this.$Rate.value,
precision : this.$Precision.value,
type : this.$CurrencyTypeSelect.value,
'package': 'quiqqer/currency',
currency: this.getAttribute('currency'),
code: this.$Code.value,
rate: this.$Rate.value,
precision: this.$Precision.value,
type: this.$CurrencyTypeSelect.value,
customData: JSON.encode(QUIFormUtils.getDataFromNode(this.$ExtraSettingsContainer))
});
});
......
......@@ -267,7 +267,9 @@ public function autoupdate(): bool
public function convert($amount, $Currency)
{
if (!is_numeric($amount)) {
QUI\System\Log::addError('Only numeric are allowed Currency->convert()');
QUI\System\Log::addError('Only numeric are allowed Currency->convert()', [
'$amount' => $amount
]);
$Exception = new QUI\Exception(
QUI::getLocale()->get('quiqqer/quiqqer', 'exception.error')
......
......@@ -104,21 +104,46 @@ public static function createCurrency(string $currency, $rate = 1, string $type
$textData = QUI\Translator::getVarData($localeGroup, $localeText);
$signData = QUI\Translator::getVarData($localeGroup, $localeSign);
// text
try {
QUI\Translator::add(
'quiqqer/currency',
'currency.' . $currency . '.text',
'quiqqer/currency'
);
} catch (QUI\Exception $e) {
}
if (empty($textData)) {
QUI\Translator::addUserVar(
QUI\Translator::edit(
'quiqqer/currency',
'currency.' . $currency . '.text',
'quiqqer/currency',
$languageData
);
}
// sign
try {
QUI\Translator::add(
'quiqqer/currency',
'currency.' . $currency . '.sign',
'quiqqer/currency'
);
} catch (QUI\Exception $e) {
}
if (empty($signData)) {
QUI\Translator::addUserVar(
QUI\Translator::edit(
'quiqqer/currency',
'currency.' . $currency . '.sign',
$languageData
'quiqqer/currency',
$signData
);
}
QUI\Translator::publish('quiqqer/currency');
}
/**
......@@ -134,6 +159,18 @@ public static function deleteCurrency(string $currency)
QUI::getDataBase()->delete(self::table(), [
'currency' => $currency
]);
QUI\Translator::delete(
'quiqqer/currency',
'currency.' . $currency . '.text'
);
QUI\Translator::delete(
'quiqqer/currency',
'currency.' . $currency . '.sign'
);
QUI\Translator::publish('quiqqer/currency');
}
/**
......@@ -414,7 +451,8 @@ public static function updateCurrency($currency, $data)
{
QUI\Permissions\Permission::checkPermission('currency.edit');
$Currency = self::getCurrency($currency);
// check if currency exists
self::getCurrency($currency);
$dbData = [];
......@@ -431,15 +469,27 @@ public static function updateCurrency($currency, $data)
}
if (isset($data['code'])) {
// set locale
QUI\Translator::addUserVar(
try {
QUI\Translator::add(
'quiqqer/currency',
'currency.' . $data['code'] . '.sign',
'quiqqer/currency'
);
} catch (QUI\Exception $e) {
}
QUI\Translator::edit(
'quiqqer/currency',
'currency.' . $currency . '.sign',
'quiqqer/currency',
'currency.' . $Currency->getCode() . '.sign',
[
'en' => $data['code'],
'de' => $data['code']
]
);
QUI\Translator::publish('quiqqer/currency');
}
if (isset($data['rate'])) {
......
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