Skip to content
Code-Schnipsel Gruppen Projekte
Commit de070244 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

refactor: removed unnecessary control files

Übergeordneter 9b206d40
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
/**
* @modue package/quiqqer/order/bin/backend/controls/panels/order/Payments
* @author www.pcsg.de (Henning Leutz)
*
* @event onLoad [self]
*/
define('package/quiqqer/order/bin/backend/controls/panels/order/Payments', [
'qui/QUI',
'qui/controls/Control',
'qui/controls/windows/Confirm',
'controls/grid/Grid',
'package/quiqqer/order/bin/backend/Orders',
'package/quiqqer/payment-transactions/bin/backend/Transactions',
'Locale',
'Ajax'
], function (QUI, QUIControl, QUIConfirm, Grid, Orders, Transactions, QUILocale, QUIAjax) {
"use strict";
var lg = 'quiqqer/order';
return new Class({
Type : 'package/quiqqer/order/bin/backend/controls/panels/order/Payments',
Extends: QUIControl,
Binds: [
'$onInject',
'openAddPaymentDialog'
],
options: {
hash : false,
Panel : false,
disabled: false
},
initialize: function (options) {
this.parent(options);
this.$Grid = null;
this.addEvents({
onInject: this.$onInject
});
},
/**
* Resize the control
*/
resize: function () {
this.parent();
if (!this.$Elm) {
return;
}
this.$Grid.setHeight(this.$Elm.getSize().y);
},
/**
* Refresh the data and the display
*
* @return {Promise}
*/
refresh: function () {
var self = this;
return Transactions.getTransactionsByHash(this.getAttribute('hash')).then(function (result) {
var payments = [];
for (var i = 0, len = result.length; i < len; i++) {
payments.push({
date : result[i].date,
amount : result[i].amount,
payment: result[i].payment,
txid : result[i].txid
});
}
return new Promise(function (resolve) {
QUIAjax.get('package_quiqqer_order_ajax_backend_payments_format', function (data) {
self.$Grid.setData({
data: data
});
self.fireEvent('load', [self]);
resolve();
}, {
'package': 'quiqqer/order',
payments : JSON.encode(payments)
});
});
}).then(function () {
return Orders.get(self.getAttribute('hash'));
}).then(function (result) {
var AddButton = self.$Grid.getButtons().filter(function (Button) {
return Button.getAttribute('name') === 'add';
})[0];
if (result.paid_status !== 1 && !self.getAttribute('disabled')) {
AddButton.enable();
} else {
AddButton.disable();
}
});
},
/**
* Creates the DomNode Element
*
* @return {Element}
*/
create: function () {
var self = this;
this.$Elm = this.parent();
this.$Elm.setStyles({
height: '100%'
});
var Container = new Element('div', {
styles: {
height: '100%'
}
}).inject(this.$Elm);
this.$Grid = new Grid(Container, {
buttons : [{
name : 'add',
text : QUILocale.get(lg, 'panel.btn.paymentBook'),
disabled: true,
events : {
onClick: this.openAddPaymentDialog
}
}],
columnModel: [{
header : QUILocale.get(lg, 'panel.payments.date'),
dataIndex: 'date',
dataType : 'date',
width : 160
}, {
header : QUILocale.get(lg, 'panel.payments.amount'),
dataIndex: 'amount',
dataType : 'string',
className: 'journal-grid-amount',
width : 160
}, {
header : QUILocale.get(lg, 'panel.payments.paymentMethod'),
dataIndex: 'payment',
dataType : 'string',
width : 200
}, {
header : QUILocale.get(lg, 'panel.payments.txid'),
dataIndex: 'txid',
dataType : 'string',
width : 200
}]
});
this.$Grid.addEvents({
onDblClick: function () {
self.$openTransactionId(
self.$Grid.getSelectedData()[0].txid
);
}
});
return this.$Elm;
},
/**
* event: on inject
*/
$onInject: function () {
this.resize();
this.refresh();
},
/**
* Opens the add payment dialog
*/
openAddPaymentDialog: function () {
var self = this;
var Button = this.$Grid.getButtons().filter(function (Button) {
return Button.getAttribute('name') === 'add';
})[0];
Button.setAttribute('textimage', 'fa fa-spinner fa-spin');
require([
'package/quiqqer/order/bin/backend/controls/panels/payments/AddPaymentWindow'
], function (AddPaymentWindow) {
new AddPaymentWindow({
hash : self.getAttribute('hash'),
events: {
onSubmit: function (Win, data) {
Orders.addPaymentToOrder(
self.getAttribute('hash'),
data.amount,
data.payment_method,
data.date
).then(function () {
Button.setAttribute('textimage', 'fa fa-money');
self.refresh();
});
},
onClose: function () {
Button.setAttribute('textimage', 'fa fa-money');
}
}
}).open();
});
},
/**
* opens a transaction window
*
* @param {String} txid - Transaction ID
*/
$openTransactionId: function (txid) {
var self = this;
if (this.getAttribute('Panel')) {
this.getAttribute('Panel').Loader.show();
}
require([
'package/quiqqer/payment-transactions/bin/backend/controls/windows/Transaction'
], function (Window) {
if (self.getAttribute('Panel')) {
self.getAttribute('Panel').Loader.hide();
}
new Window({
txid: txid
}).open();
});
}
});
});
\ No newline at end of file
<form>
<table class="data-table data-table-flexbox">
<tbody>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="{{amountTitle}}">
{{amountTitle}}
</span>
<input class="field-container-field"
type="number"
name="amount"
step="0.01"
min="0"
autofocus
required
/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="{{paymentTitle}}">
{{paymentTitle}}
</span>
<select class="field-container-field" name="payment_method" required>
</select>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="{{dateTitle}}">
{{dateTitle}}
</span>
<input class="field-container-field" type="date" name="date" required/>
</label>
</td>
</tr>
</tbody>
</table>
</form>
/**
* @module package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment
* @author www.pcsg.de (Henning Leutz)
*
* @event onLoad [self]
*/
define('package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment', [
'qui/QUI',
'qui/controls/Control',
'qui/utils/Form',
'Mustache',
'Locale',
'package/quiqqer/payments/bin/backend/Payments',
'package/quiqqer/order/bin/backend/Orders',
'text!package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment.html'
], function (QUI, QUIControl, QUIFormUtils, Mustache, QUILocale, Payments, Orders, template) {
"use strict";
return new Class({
Extends: QUIControl,
Type : 'package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment',
Binds: [
'$onInject'
],
options: {
hash : false,
paymentMethod: false
},
initialize: function (options) {
this.parent(options);
this.$Form = null;
this.addEvents({
onInject: this.$onInject
});
},
/**
* Create the DomNode Element
*
* @return {Element|null}
*/
create: function () {
this.$Elm = new Element('div', {
html: Mustache.render(template, {
amountTitle : QUILocale.get('quiqqer/order', 'dialog.add.payment.amount'),
paymentTitle: QUILocale.get('quiqqer/order', 'dialog.add.payment.paymentMethod'),
dateTitle : QUILocale.get('quiqqer/order', 'dialog.add.payment.date')
})
});
this.$Form = this.$Elm.getElement('form');
this.$Form.addEvent('submit', function (event) {
event.stop();
this.fireEvent('submit');
}.bind(this));
return this.$Elm;
},
/**
* event: on inject
*/
$onInject: function () {
Promise.all([
Payments.getPayments(),
Orders.get(this.getAttribute('hash'))
]).then(function (result) {
var title, payment;
var payments = result[0],
Order = result[1],
current = QUILocale.getCurrent();
var Payments = this.getElm().getElement('[name="payment_method"]');
var DateInput = this.getElm().getElement('[name="date"]');
var Amount = this.getElm().getElement('[name="amount"]');
Amount.value = Order.paidStatus.toPay;
for (var i = 0, len = payments.length; i < len; i++) {
payment = payments[i];
title = payment.title;
if (typeOf(payment.title) === 'object' && current in payment.title) {
title = payment.title[current];
}
if (typeOf(payment.workingTitle) === 'object' &&
current in payment.workingTitle &&
payment.workingTitle[current] !== ''
) {
title = payment.workingTitle[current];
}
new Element('option', {
html : title,
value: parseInt(payment.id)
}).inject(Payments);
}
if (this.getAttribute('paymentMethod')) {
Payments.value = this.getAttribute('paymentMethod');
}
DateInput.valueAsDate = new Date();
this.fireEvent('load', [this]);
}.bind(this)).catch(function (e) {
this.fireEvent('error', [this, e]);
}.bind(this));
},
/**
* Return the form data
*
* @return {Object}
*/
getValue: function () {
return QUIFormUtils.getFormData(this.$Form);
},
/**
* Focus the amount field
*/
focus: function () {
this.getElm().getElement('[name="amount"]').focus();
}
});
});
\ No newline at end of file
/**
* @module package/quiqqer/order/bin/backend/controls/panels/payments/AddPaymentWindow
* @author www.pcsg.de (Henning Leutz)
*/
define('package/quiqqer/order/bin/backend/controls/panels/payments/AddPaymentWindow', [
'qui/QUI',
'qui/controls/windows/Confirm',
'package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment',
'Locale'
], function (QUI, QUIConfirm, AddPayment, QUILocale) {
"use strict";
var lg = 'quiqqer/order';
return new Class({
Extends: QUIConfirm,
Type : 'package/quiqqer/order/bin/backend/controls/panels/payments/AddPayment',
Binds: [
'submit'
],
options: {
hash : false,
paymentMethod: false
},
initialize: function (options) {
this.setAttributes({
icon : 'fa fa-money',
title : QUILocale.get(lg, 'panel.btn.paymentBook'),
maxHeight: 400,
maxWidth : 600
});
this.parent(options);
this.$AddPayment = null;
this.addEvents({
onOpen: this.$onOpen
});
},
/**
* event: on open
*/
$onOpen: function () {
this.Loader.show();
this.getContent().set('html', '');
this.$AddPayment = new AddPayment({
hash : this.getAttribute('hash'),
paymentMethod: this.getAttribute('paymentMethod'),
events : {
onLoad: function () {
this.Loader.hide();
this.$AddPayment.focus();
}.bind(this),
onError: function () {
this.close();
}.bind(this),
onSubmit: this.submit
}
}).inject(this.getContent());
},
/**
* Submit the window
*
* @return {Promise}
*/
submit: function () {
return new Promise(function (resolve) {
var values = this.$AddPayment.getValue();
if (values.amount === '') {
return;
}
if (values.payment_method === '') {
return;
}
this.fireEvent('submit', [this, values]);
resolve(values);
this.close();
}.bind(this));
}
});
});
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren