diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..9ab59b180fb670006ac910a2bc4524a1376dcea0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ + +# Ignore developer files when exporting +.gitattributes export-ignore +.gitignore export-ignore +.gitlab-ci.yml export-ignore +.phive export-ignore +captainhook.json export-ignore +phpcs.xml.dist export-ignore +phpstan-baseline.neon export-ignore +phpstan.dist.neon export-ignore +phpunit.dist.xml export-ignore +tests export-ignore + +# Explicitly set file type and line endings for PHP files, improves git diff output +*.php text eol=lf diff=php \ No newline at end of file diff --git a/.gitignore b/.gitignore index f4da20891502a3992abf2981d8f6c46e33868ab6..e25391c1f85364060ac958b37e8e35c6c51beafe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ tools/ phpstan.neon .phpunit.result.cache -phpunit.xml \ No newline at end of file +phpunit.xml +tools/ + +phpstan.neon + +.phpunit.result.cache + +phpunit.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index db836dd9e00fce8b7d4d91ecb67d0269dae33d83..b5a64b401e554341447c74d7cf93a89ac95a3fdb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,17 @@ include: - - project: 'quiqqer/stabilization/semantic-release' - file: '/ci-templates/.gitlab-ci.yml' \ No newline at end of file + - component: dev.quiqqer.com/quiqqer/stabilization/ci-cd-components/quiqqer-package-bundle/quiqqer-package-bundle@main + +# Remove the entire phpunit-php8.1 block, to allow PHPUnit to run on PHP 8.1 in your pipeline +phpunit-php8.1: + rules: + - when: never + +# Remove the entire phpunit-php8.2 block, to allow PHPUnit to run on PHP 8.2 in your pipeline +phpunit-php8.2: + rules: + - when: never + +# Remove the entire phpunit-php8.3 block, to allow PHPUnit to run on PHP 8.3 in your pipeline +phpunit-php8.3: + rules: + - when: never \ No newline at end of file diff --git a/.phive/phars.xml b/.phive/phars.xml index a1315a09b4adad780a9c5e52f74835c708c5c7d5..5bfa092bfad10dad9d23240281a5a2041acb815b 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,4 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <phive xmlns="https://phar.io/phive"> - <phar name="phpstan" version="^1.10.67" installed="1.10.67" location="./tools/phpstan" copy="false"/> + <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> + <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> + <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> + <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> + <phar name="captainhook" version="^5.23.3" installed="5.23.3" location="./tools/captainhook" copy="false"/> </phive> diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..4a69a59b440e5beec561eca1e341509bd5a18688 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +This package follows the [QUIQQER contribution guidelines](https://dev.quiqqer.com/quiqqer/stabilization/documentation/-/wikis/home). \ No newline at end of file diff --git a/bin/backend/Shipping.js b/bin/backend/Shipping.js index 1492e94d8a7bdb346100bda0dee9625f4721b9df..1c0bd3418e1a56b9cfc8588f5e2ae75329c666fc 100644 --- a/bin/backend/Shipping.js +++ b/bin/backend/Shipping.js @@ -3,8 +3,8 @@ */ define('package/quiqqer/shipping/bin/backend/Shipping', [ 'package/quiqqer/shipping/bin/backend/classes/Handler' -], function (Shipping) { - "use strict"; +], function(Shipping) { + 'use strict'; return new Shipping(); }); \ No newline at end of file diff --git a/bin/backend/ShippingRules.js b/bin/backend/ShippingRules.js index 43e6f6e1e66f410ea984aa47cd0c6ba87a418e49..1ee25ba034b7f037c6daee3955c6879325085b4a 100644 --- a/bin/backend/ShippingRules.js +++ b/bin/backend/ShippingRules.js @@ -3,8 +3,8 @@ */ define('package/quiqqer/shipping/bin/backend/ShippingRules', [ 'package/quiqqer/shipping/bin/backend/classes/ShippingRules' -], function (ShippingRules) { - "use strict"; +], function(ShippingRules) { + 'use strict'; return new ShippingRules(); }); \ No newline at end of file diff --git a/bin/backend/ShippingStatus.js b/bin/backend/ShippingStatus.js index c1de3dbcbfc50cc65d3d287c67a9a9d4a878bafa..a2171d78808909196b61b4a9e417d1d22a008520 100644 --- a/bin/backend/ShippingStatus.js +++ b/bin/backend/ShippingStatus.js @@ -7,7 +7,7 @@ */ define('package/quiqqer/shipping/bin/backend/ShippingStatus', [ 'package/quiqqer/shipping/bin/backend/classes/ShippingStatus' -], function (ShippingStatus) { - "use strict"; +], function(ShippingStatus) { + 'use strict'; return new ShippingStatus(); }); diff --git a/bin/backend/classes/Handler.js b/bin/backend/classes/Handler.js index e28b463a296b033726d878d9aed803c16caaa9e9..37d9d2142383f29d3ed5d7b8def26f2188fbb158 100644 --- a/bin/backend/classes/Handler.js +++ b/bin/backend/classes/Handler.js @@ -14,15 +14,15 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ 'qui/classes/DOM', 'Ajax' -], function (QUI, QUIDOM, QUIAjax) { - "use strict"; +], function(QUI, QUIDOM, QUIAjax) { + 'use strict'; return new Class({ Extends: QUIDOM, - Type : 'package/quiqqer/shipping/bin/Manager', + Type: 'package/quiqqer/shipping/bin/Manager', - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$shippings = null; @@ -33,20 +33,20 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * * @return {Promise} */ - getShippingList: function () { + getShippingList: function() { if (this.$shippings) { return window.Promise.resolve(this.$shippings); } var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.get('package_quiqqer_shipping_ajax_backend_getShippingList', function (result) { + return new Promise(function(resolve, reject) { + QUIAjax.get('package_quiqqer_shipping_ajax_backend_getShippingList', function(result) { self.$shippings = result; resolve(self.$shippings); }, { 'package': 'quiqqer/shipping', - onError : reject + onError: reject }); }); }, @@ -57,11 +57,11 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {String|Number} shippingId * @return {Promise} */ - getShippingEntry: function (shippingId) { - return new Promise(function (resolve, reject) { + getShippingEntry: function(shippingId) { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_getShippingEntry', resolve, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingId: shippingId }); }); @@ -72,11 +72,11 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * * @return {Promise} */ - getShippingTypes: function () { - return new Promise(function (resolve, reject) { + getShippingTypes: function() { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_getShippingTypes', resolve, { 'package': 'quiqqer/shipping', - onError : reject + onError: reject }); }); }, @@ -87,24 +87,24 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {String} shippingType - Hash of the shipping type * @return {Promise} */ - createShipping: function (shippingType) { + createShipping: function(shippingType) { var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_create', function (shippingId) { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_create', function(shippingId) { self.$shippings = null; require([ 'package/quiqqer/translator/bin/Translator' - ], function (Translator) { - Translator.refreshLocale().then(function () { + ], function(Translator) { + Translator.refreshLocale().then(function() { self.fireEvent('shippingCreate', [self, shippingId]); resolve(shippingId); }); }); }, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingType: shippingType }); }); @@ -117,26 +117,26 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {Object} data - Data of the shipping * @return {Promise} */ - updateShipping: function (shippingId, data) { + updateShipping: function(shippingId, data) { var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_update', function (result) { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_update', function(result) { self.$shippings = null; require([ 'package/quiqqer/translator/bin/Translator' - ], function (Translator) { - Translator.refreshLocale().then(function () { + ], function(Translator) { + Translator.refreshLocale().then(function() { self.fireEvent('shippingUpdate', [self, shippingId, result]); resolve(result); }); }); }, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingId: shippingId, - data : window.JSON.encode(data) + data: window.JSON.encode(data) }); }); }, @@ -146,18 +146,18 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {String|Number} shippingId * @return {Promise} */ - deleteShipping: function (shippingId) { + deleteShipping: function(shippingId) { var self = this; - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { self.$shippings = null; - QUIAjax.post('package_quiqqer_shipping_ajax_backend_delete', function () { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_delete', function() { self.fireEvent('shippingDelete', [self, shippingId]); resolve(); }, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingId: shippingId }); }); @@ -169,18 +169,18 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {String|Number} shippingId * @return {Promise} */ - activateShipping: function (shippingId) { + activateShipping: function(shippingId) { var self = this; - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { self.$shippings = null; - QUIAjax.post('package_quiqqer_shipping_ajax_backend_activate', function (result) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_activate', function(result) { self.fireEvent('shippingActivate', [self, shippingId, result]); resolve(result); }, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingId: shippingId }); }); @@ -192,18 +192,18 @@ define('package/quiqqer/shipping/bin/backend/classes/Handler', [ * @param {String|Number} shippingId * @return {Promise} */ - deactivateShipping: function (shippingId) { + deactivateShipping: function(shippingId) { var self = this; - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { self.$shippings = null; - QUIAjax.post('package_quiqqer_shipping_ajax_backend_deactivate', function (result) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_deactivate', function(result) { self.fireEvent('shippingDeactivate', [self, shippingId, result]); resolve(result); }, { - 'package' : 'quiqqer/shipping', - onError : reject, + 'package': 'quiqqer/shipping', + onError: reject, shippingId: shippingId }); }); diff --git a/bin/backend/classes/ShippingRules.js b/bin/backend/classes/ShippingRules.js index bf45e0294c6c87301eef0d7f7ecbf20211fdc80a..84fd910cae4e01a61aeaf14651b1381519ffce8c 100644 --- a/bin/backend/classes/ShippingRules.js +++ b/bin/backend/classes/ShippingRules.js @@ -12,24 +12,24 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ 'qui/classes/DOM', 'Ajax' -], function (QUI, QUIDOM, QUIAjax) { - "use strict"; +], function(QUI, QUIDOM, QUIAjax) { + 'use strict'; return new Class({ Extends: QUIDOM, - Type : 'package/quiqqer/shipping/bin/backend/classes/ShippingRules', + Type: 'package/quiqqer/shipping/bin/backend/classes/ShippingRules', /** * Return * @return {Promise|*} */ - getList: function (options) { - return new Promise(function (resolve, reject) { + getList: function(options) { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_rules_getList', resolve, { 'package': 'quiqqer/shipping', - options : JSON.encode(options), - onError : reject + options: JSON.encode(options), + onError: reject }); }); }, @@ -40,17 +40,17 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * @param rules * @return {Promise} */ - create: function (rules) { + create: function(rules) { var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_create', function (ruleId) { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_create', function(ruleId) { resolve(ruleId); self.fireEvent('create', [self, ruleId]); }, { 'package': 'quiqqer/shipping', - rules : JSON.encode(rules), - onError : reject + rules: JSON.encode(rules), + onError: reject }); }); }, @@ -62,18 +62,18 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * @param {Object} data * @return {Promise} */ - update: function (ruleId, data) { + update: function(ruleId, data) { var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_update', function () { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_update', function() { resolve(); self.fireEvent('update', [self, ruleId]); }, { 'package': 'quiqqer/shipping', - ruleId : ruleId, - data : JSON.encode(data), - onError : reject + ruleId: ruleId, + data: JSON.encode(data), + onError: reject }); }); }, @@ -84,17 +84,17 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * @param {Number|Array} ruleIds * @return {Promise} */ - delete: function (ruleIds) { + delete: function(ruleIds) { var self = this; - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_delete', function () { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_rules_delete', function() { resolve(); self.fireEvent('delete', [self, ruleIds]); }, { 'package': 'quiqqer/shipping', - ruleIds : JSON.encode(ruleIds), - onError : reject + ruleIds: JSON.encode(ruleIds), + onError: reject }); }); }, @@ -105,12 +105,12 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * @param ruleIds * @return {Promise} */ - getRules: function (ruleIds) { - return new Promise(function (resolve, reject) { + getRules: function(ruleIds) { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_rules_getRules', resolve, { 'package': 'quiqqer/shipping', - ruleIds : JSON.encode(ruleIds), - onError : reject + ruleIds: JSON.encode(ruleIds), + onError: reject }); }); }, @@ -121,8 +121,8 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * @param {Integer} ruleId * @return {Promise} */ - getRule: function (ruleId) { - return this.getRules([ruleId]).then(function (result) { + getRule: function(ruleId) { + return this.getRules([ruleId]).then(function(result) { return result[0]; }); }, @@ -131,8 +131,8 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingRules', [ * * @return {Promise} */ - getShippingRuleUnitFields: function () { - return new Promise(function (resolve) { + getShippingRuleUnitFields: function() { + return new Promise(function(resolve) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFieldSetting', resolve, { 'package': 'quiqqer/shipping' }); diff --git a/bin/backend/classes/ShippingStatus.js b/bin/backend/classes/ShippingStatus.js index 7c2bb944990327c440319dbadf44ff28a2a4faa4..516cae661072e4f865f8911ed042fe2b2ceacbf6 100644 --- a/bin/backend/classes/ShippingStatus.js +++ b/bin/backend/classes/ShippingStatus.js @@ -8,15 +8,15 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ 'qui/classes/DOM', 'Ajax' -], function (QUI, QUIDOM, QUIAjax) { - "use strict"; +], function(QUI, QUIDOM, QUIAjax) { + 'use strict'; return new Class({ Extends: QUIDOM, - Type : 'package/quiqqer/shipping/bin/backend/classes/ShippingStatus', + Type: 'package/quiqqer/shipping/bin/backend/classes/ShippingStatus', - initialize: function (options) { + initialize: function(options) { this.parent(options); }, @@ -25,11 +25,11 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * * @return {Promise} */ - getList: function () { - return new Promise(function (resolve, reject) { + getList: function() { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_shippingStatus_list', resolve, { 'package': 'quiqqer/shipping', - onError : reject + onError: reject }); }); }, @@ -39,11 +39,11 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * * @return {Promise} */ - getNextId: function () { - return new Promise(function (resolve, reject) { + getNextId: function() { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_shippingStatus_getNextId', resolve, { 'package': 'quiqqer/shipping', - onError : reject + onError: reject }); }); }, @@ -57,23 +57,23 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * @param {Boolean} notification * @return {Promise} */ - createShippingStatus: function (id, color, title, notification) { - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_create', function (result) { + createShippingStatus: function(id, color, title, notification) { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_create', function(result) { require([ 'package/quiqqer/translator/bin/Translator' - ], function (Translator) { - Translator.refreshLocale().then(function () { + ], function(Translator) { + Translator.refreshLocale().then(function() { resolve(result); }); }); }, { - 'package' : 'quiqqer/shipping', - id : id, - color : color, - title : JSON.encode(title), + 'package': 'quiqqer/shipping', + id: id, + color: color, + title: JSON.encode(title), notification: notification ? 1 : 0, - onError : reject + onError: reject }); }); }, @@ -84,20 +84,20 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * @param {String|Number} id - Processing Status ID * @return {Promise} */ - deleteShippingStatus: function (id) { - return new Promise(function (resolve, reject) { - QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_delete', function () { + deleteShippingStatus: function(id) { + return new Promise(function(resolve, reject) { + QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_delete', function() { require([ 'package/quiqqer/translator/bin/Translator' - ], function (Translator) { - Translator.refreshLocale().then(function () { + ], function(Translator) { + Translator.refreshLocale().then(function() { resolve(); }); }); }, { 'package': 'quiqqer/shipping', - id : id, - onError : reject + id: id, + onError: reject }); }); }, @@ -108,12 +108,12 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * @param {String|Number} id - Processing Status ID * @return {Promise} */ - getShippingStatus: function (id) { - return new Promise(function (resolve, reject) { + getShippingStatus: function(id) { + return new Promise(function(resolve, reject) { QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_get', resolve, { 'package': 'quiqqer/shipping', - id : id, - onError : reject + id: id, + onError: reject }); }); }, @@ -127,14 +127,14 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * @param {Boolean} notification * @return {Promise} */ - updateShippingStatus: function (id, color, title, notification) { - return new Promise(function (resolve, reject) { + updateShippingStatus: function(id, color, title, notification) { + return new Promise(function(resolve, reject) { QUIAjax.post('package_quiqqer_shipping_ajax_backend_shippingStatus_update', resolve, { - 'package' : 'quiqqer/shipping', - id : id, - color : color, - title : JSON.encode(title), - onError : reject, + 'package': 'quiqqer/shipping', + id: id, + color: color, + title: JSON.encode(title), + onError: reject, notification: notification ? 1 : 0 }); }); @@ -147,13 +147,13 @@ define('package/quiqqer/shipping/bin/backend/classes/ShippingStatus', [ * @param {Number} orderId - shipping ID * @return {Promise} */ - getNotificationText: function (shippingId, orderId) { - return new Promise(function (resolve, reject) { + getNotificationText: function(shippingId, orderId) { + return new Promise(function(resolve, reject) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_shippingStatus_getNotificationText', resolve, { - 'package' : 'quiqqer/shipping', + 'package': 'quiqqer/shipping', shippingId: shippingId, - orderId : orderId, - onError : reject + orderId: orderId, + onError: reject }); }); } diff --git a/bin/backend/controls/Shipping.js b/bin/backend/controls/Shipping.js index 71c9c22650b94b12d2f6ced1adce7144af13bccf..86a1384216d93260a818d8701a51ecd5c5ddb385 100644 --- a/bin/backend/controls/Shipping.js +++ b/bin/backend/controls/Shipping.js @@ -16,8 +16,8 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ 'Mustache', 'Locale' -], function (QUI, QUIPanel, QUIConfirm, QUIButton, Shipping, Grid, Mustache, QUILocale) { - "use strict"; +], function(QUI, QUIPanel, QUIConfirm, QUIButton, Shipping, Grid, Mustache, QUILocale) { + 'use strict'; const lg = 'quiqqer/shipping'; const current = QUILocale.getCurrent(); @@ -25,7 +25,7 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ return new Class({ Extends: QUIPanel, - Type : 'package/quiqqer/shipping/bin/backend/controls/Shipping', + Type: 'package/quiqqer/shipping/bin/backend/controls/Shipping', Binds: [ 'refresh', @@ -40,36 +40,36 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ '$refreshButtonStatus' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$Grid = null; this.setAttributes({ - icon : 'fa fa-truck', + icon: 'fa fa-truck', title: QUILocale.get(lg, 'menu.erp.shipping.title') }); this.addEvents({ - onCreate : this.$onCreate, - onInject : this.$onInject, - onResize : this.$onResize, + onCreate: this.$onCreate, + onInject: this.$onInject, + onResize: this.$onResize, onDestroy: this.$onDestroy }); Shipping.addEvents({ onShippingDeactivate: this.$onShippingChange, - onShippingActivate : this.$onShippingChange, - onShippingDelete : this.$onShippingChange, - onShippingCreate : this.$onShippingChange, - onShippingUpdate : this.$onShippingChange + onShippingActivate: this.$onShippingChange, + onShippingDelete: this.$onShippingChange, + onShippingCreate: this.$onShippingChange, + onShippingUpdate: this.$onShippingChange }); }, /** * Refresh the value and the display */ - refresh: function () { + refresh: function() { if (!this.$Elm) { return; } @@ -78,20 +78,20 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ const self = this; - this.$Grid.getButtons().filter(function (Btn) { + this.$Grid.getButtons().filter(function(Btn) { return Btn.getAttribute('name') === 'edit'; })[0].disable(); - this.$Grid.getButtons().filter(function (Btn) { + this.$Grid.getButtons().filter(function(Btn) { return Btn.getAttribute('name') === 'delete'; })[0].disable(); - Shipping.getShippingList().then(function (result) { - const toggle = function (Btn) { - let data = Btn.getAttribute('data'), + Shipping.getShippingList().then(function(result) { + const toggle = function(Btn) { + let data = Btn.getAttribute('data'), shippingId = data.id, - status = parseInt(data.active); + status = parseInt(data.active); Btn.setAttribute('icon', 'fa fa-spinner fa-spin'); @@ -106,11 +106,11 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ for (let i = 0, len = result.length; i < len; i++) { if (parseInt(result[i].active)) { result[i].status = { - icon : 'fa fa-check', + icon: 'fa fa-check', styles: { lineHeight: 20, - padding : 0, - width : 20 + padding: 0, + width: 20 }, events: { onClick: toggle @@ -118,11 +118,11 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ }; } else { result[i].status = { - icon : 'fa fa-remove', + icon: 'fa fa-remove', styles: { lineHeight: 20, - padding : 0, - width : 20 + padding: 0, + width: 20 }, events: { onClick: toggle @@ -140,7 +140,7 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ result[i].workingTitle = result[i].workingTitle[current]; } - if ("shippingType" in result[i] && result[i].shippingType) { + if ('shippingType' in result[i] && result[i].shippingType) { result[i].shippingType_display = result[i].shippingType.title; } } @@ -156,21 +156,21 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ /** * event: on create */ - $onCreate: function () { + $onCreate: function() { const Container = new Element('div', { styles: { minHeight: 300, - width : '100%' + width: '100%' } }).inject(this.getContent()); this.$Grid = new Grid(Container, { - buttons : [ + buttons: [ { - name : 'add', - text : QUILocale.get('quiqqer/core', 'add'), + name: 'add', + text: QUILocale.get('quiqqer/core', 'add'), textimage: 'fa fa-plus', - events : { + events: { onClick: this.$openCreateDialog } }, @@ -178,67 +178,67 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ type: 'separator' }, { - name : 'edit', - text : QUILocale.get('quiqqer/core', 'edit'), + name: 'edit', + text: QUILocale.get('quiqqer/core', 'edit'), textimage: 'fa fa-edit', - disabled : true, - events : { + disabled: true, + events: { onClick: this.$onEditClick } }, { - name : 'delete', - text : QUILocale.get('quiqqer/system', 'delete'), + name: 'delete', + text: QUILocale.get('quiqqer/system', 'delete'), textimage: 'fa fa-trash', - disabled : true, - events : { + disabled: true, + events: { onClick: this.$openDeleteDialog } } ], columnModel: [ { - header : QUILocale.get('quiqqer/system', 'priority'), + header: QUILocale.get('quiqqer/system', 'priority'), dataIndex: 'priority', - dataType : 'number', - width : 50 + dataType: 'number', + width: 50 }, { - header : QUILocale.get('quiqqer/system', 'status'), + header: QUILocale.get('quiqqer/system', 'status'), dataIndex: 'status', - dataType : 'button', - width : 60 + dataType: 'button', + width: 60 }, { - header : QUILocale.get('quiqqer/system', 'title'), + header: QUILocale.get('quiqqer/system', 'title'), dataIndex: 'title', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 }, { - header : QUILocale.get('quiqqer/system', 'workingtitle'), + header: QUILocale.get('quiqqer/system', 'workingtitle'), dataIndex: 'workingTitle', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 }, { - header : QUILocale.get('quiqqer/system', 'id'), + header: QUILocale.get('quiqqer/system', 'id'), dataIndex: 'id', - dataType : 'number', - width : 30 + dataType: 'number', + width: 30 }, { - header : QUILocale.get(lg, 'shipping.type'), + header: QUILocale.get(lg, 'shipping.type'), dataIndex: 'shippingType_display', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 } ] }); this.$Grid.addEvents({ - onRefresh : this.refresh, - onClick : this.$refreshButtonStatus, + onRefresh: this.refresh, + onClick: this.$refreshButtonStatus, onDblClick: this.$onEditClick }); }, @@ -246,27 +246,27 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ /** * event : on inject */ - $onInject: function () { + $onInject: function() { this.refresh(); }, /** * event: on destroy */ - $onDestroy: function () { + $onDestroy: function() { Shipping.removeEvents({ onShippingDeactivate: this.$onShippingChange, - onShippingActivate : this.$onShippingChange, - onShippingDelete : this.$onShippingChange, - onShippingCreate : this.$onShippingChange, - onShippingUpdate : this.$onShippingChange + onShippingActivate: this.$onShippingChange, + onShippingDelete: this.$onShippingChange, + onShippingCreate: this.$onShippingChange, + onShippingUpdate: this.$onShippingChange }); }, /** * event : on resize */ - $onResize: function () { + $onResize: function() { if (!this.$Grid) { return; } @@ -286,18 +286,18 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ * event : on shipping change * if a shipping changed */ - $onShippingChange: function () { + $onShippingChange: function() { this.refresh(); }, /** * open the edit dialog */ - openShipping: function (shippingId) { + openShipping: function(shippingId) { require([ 'package/quiqqer/shipping/bin/backend/controls/ShippingEntry', 'utils/Panels' - ], function (ShippingEntry, Utils) { + ], function(ShippingEntry, Utils) { Utils.openPanelInTasks( new ShippingEntry({ shippingId: shippingId @@ -309,7 +309,7 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ /** * event: on edit */ - $onEditClick: function () { + $onEditClick: function() { const data = this.$Grid.getSelectedData(); if (data.length) { @@ -320,45 +320,45 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ /** * open the add dialog */ - $openCreateDialog: function () { + $openCreateDialog: function() { const self = this; new QUIConfirm({ - icon : 'fa fa-plus', - texticon : 'fa fa-plus', - title : QUILocale.get(lg, 'window.create.title'), - text : QUILocale.get(lg, 'window.create.title'), + icon: 'fa fa-plus', + texticon: 'fa fa-plus', + title: QUILocale.get(lg, 'window.create.title'), + text: QUILocale.get(lg, 'window.create.title'), information: QUILocale.get(lg, 'window.create.information'), - autoclose : false, - maxHeight : 400, - maxWidth : 600, - events : { - onOpen : function (Win) { + autoclose: false, + maxHeight: 400, + maxWidth: 600, + events: { + onOpen: function(Win) { const Content = Win.getContent(), - Body = Content.getElement('.textbody'); + Body = Content.getElement('.textbody'); Win.Loader.show(); const Container = new Element('div', { - html : QUILocale.get(lg, 'window.create.shippingType'), + html: QUILocale.get(lg, 'window.create.shippingType'), styles: { - clear : 'both', - 'float' : 'left', - marginTop : 20, + clear: 'both', + 'float': 'left', + marginTop: 20, paddingLeft: 80, - width : '100%' + width: '100%' } }).inject(Body, 'after'); const Select = new Element('select', { styles: { marginTop: 10, - maxWidth : '100%', - width : 300 + maxWidth: '100%', + width: 300 } }).inject(Container); - Shipping.getShippingTypes().then(function (result) { + Shipping.getShippingTypes().then(function(result) { for (let i in result) { if (!result.hasOwnProperty(i)) { continue; @@ -366,25 +366,25 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ new Element('option', { value: result[i].type, - html : result[i].title + html: result[i].title }).inject(Select); } Win.Loader.hide(); - }).catch(function () { + }).catch(function() { Win.Loader.hide(); }); }, - onSubmit: function (Win) { + onSubmit: function(Win) { Win.Loader.show(); const Select = Win.getContent().getElement('select'); - Shipping.createShipping(Select.value).then(function (newId) { + Shipping.createShipping(Select.value).then(function(newId) { Win.close(); self.refresh(); self.openShipping(newId); - }).catch(function () { + }).catch(function() { Win.Loader.hide(); }); } @@ -395,7 +395,7 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ /** * open the add dialog */ - $openDeleteDialog: function () { + $openDeleteDialog: function() { const selected = this.$Grid.getSelectedData(); if (!selected.length) { @@ -403,7 +403,7 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ } const self = this; - let shipping = selected[0].title, + let shipping = selected[0].title, shippingId = selected[0].id; if (shipping === '') { @@ -411,27 +411,27 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ } new QUIConfirm({ - texticon : 'fa fa-trash', - icon : 'fa fa-trash', - title : QUILocale.get(lg, 'window.delete.title'), + texticon: 'fa fa-trash', + icon: 'fa fa-trash', + title: QUILocale.get(lg, 'window.delete.title'), information: QUILocale.get(lg, 'window.delete.information', { shipping: shipping }), - text : QUILocale.get(lg, 'window.delete.text', { + text: QUILocale.get(lg, 'window.delete.text', { shipping: shipping }), - autoclose : false, - maxHeight : 400, - maxWidth : 600, - ok_button : { - text : QUILocale.get('quiqqer/system', 'delete'), + autoclose: false, + maxHeight: 400, + maxWidth: 600, + ok_button: { + text: QUILocale.get('quiqqer/system', 'delete'), textimage: 'fa fa-trash' }, - events : { - onSubmit: function (Win) { + events: { + onSubmit: function(Win) { Win.Loader.show(); - Shipping.deleteShipping(shippingId).then(function () { + Shipping.deleteShipping(shippingId).then(function() { Win.close(); self.refresh(); }); @@ -444,15 +444,15 @@ define('package/quiqqer/shipping/bin/backend/controls/Shipping', [ * refresh the button disable enable status * looks at the grid */ - $refreshButtonStatus: function () { + $refreshButtonStatus: function() { const selected = this.$Grid.getSelectedIndices(), - buttons = this.$Grid.getButtons(); + buttons = this.$Grid.getButtons(); - const Edit = buttons.filter(function (Btn) { + const Edit = buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'edit'; })[0]; - const Delete = buttons.filter(function (Btn) { + const Delete = buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'delete'; })[0]; diff --git a/bin/backend/controls/ShippingEntry.List.js b/bin/backend/controls/ShippingEntry.List.js index 029270b7779cfb97fb57a6985ce148368d1b5a1f..4cd3cdda11a46be7dc998b1041ad752237b5a699 100644 --- a/bin/backend/controls/ShippingEntry.List.js +++ b/bin/backend/controls/ShippingEntry.List.js @@ -13,15 +13,15 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ 'controls/grid/Grid', 'Locale' -], function (QUI, QUIControl, Grid, QUILocale) { - "use strict"; +], function(QUI, QUIControl, Grid, QUILocale) { + 'use strict'; const lg = 'quiqqer/shipping'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', Binds: [ '$onInject', @@ -31,13 +31,13 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ options: { shippingId: false, - name : 'shipping-rules' + name: 'shipping-rules' }, - initialize: function (options) { + initialize: function(options) { this.parent(options); - this.$Grid = null; + this.$Grid = null; this.$Input = null; this.addEvents({ @@ -49,7 +49,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ * * @return {HTMLDivElement} */ - create: function () { + create: function() { this.$Elm = this.parent(); this.$Elm.addClass('quiqqer-shipping-rules'); @@ -65,12 +65,12 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ /** * refresh the input value */ - refreshInput: function () { + refreshInput: function() { if (!this.$Grid) { return; } - let value = this.$Grid.getData().map(function (entry) { + let value = this.$Grid.getData().map(function(entry) { return parseInt(entry.id); }); @@ -84,7 +84,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ * * @return {Promise} */ - refresh: function () { + refresh: function() { this.fireEvent('refreshBegin', [this]); return new Promise((resolve) => { @@ -93,7 +93,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ 'package/quiqqer/shipping/bin/backend/ShippingRules', 'package/quiqqer/shipping/bin/backend/utils/ShippingUtils' ], (Shipping, ShippingRules, Utils) => { - let shippingRules = this.$Grid.getData().map(function (entry) { + let shippingRules = this.$Grid.getData().map(function(entry) { return entry.id; }); @@ -115,74 +115,81 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ /** * event: on inject */ - $onInject: function () { + $onInject: function() { const Container = new Element('div').inject(this.getElm()); - const width = Container.getSize().x - 5; + const width = Container.getSize().x - 5; this.$Grid = new Grid(Container, { - height : 300, - width : width, - pagination : false, - buttons : [{ - name : 'add', - text : QUILocale.get('quiqqer/core', 'add'), - textimage: 'fa fa-plus', - events : { - onClick: this.$openAddDialog + height: 300, + width: width, + pagination: false, + buttons: [ + { + name: 'add', + text: QUILocale.get('quiqqer/core', 'add'), + textimage: 'fa fa-plus', + events: { + onClick: this.$openAddDialog + } + }, { + name: 'remove', + text: QUILocale.get('quiqqer/system', 'remove'), + textimage: 'fa fa-trash', + disabled: true, + events: { + onClick: this.$openRemoveDialog + } } - }, { - name : 'remove', - text : QUILocale.get('quiqqer/system', 'remove'), - textimage: 'fa fa-trash', - disabled : true, - events : { - onClick: this.$openRemoveDialog + ], + columnModel: [ + { + header: QUILocale.get('quiqqer/system', 'id'), + dataIndex: 'id', + dataType: 'number', + width: 50 + }, { + header: QUILocale.get('quiqqer/system', 'priority'), + dataIndex: 'priority', + dataType: 'number', + width: 50 + }, { + header: QUILocale.get('quiqqer/system', 'status'), + dataIndex: 'statusNode', + dataType: 'node', + width: 60, + className: 'grid-align-center' + }, { + header: QUILocale.get('quiqqer/system', 'title'), + dataIndex: 'title', + dataType: 'string', + width: 200 } - }], - columnModel: [{ - header : QUILocale.get('quiqqer/system', 'id'), - dataIndex: 'id', - dataType : 'number', - width : 50 - }, { - header : QUILocale.get('quiqqer/system', 'priority'), - dataIndex: 'priority', - dataType : 'number', - width : 50 - }, { - header : QUILocale.get('quiqqer/system', 'status'), - dataIndex: 'statusNode', - dataType : 'node', - width : 60, - className: 'grid-align-center' - }, { - header : QUILocale.get('quiqqer/system', 'title'), - dataIndex: 'title', - dataType : 'string', - width : 200 - }] + ] }); this.$Grid.setWidth(width); this.$Grid.addEvents({ onClick: () => { - this.$Grid.getButtons().filter(function (Btn) { + this.$Grid.getButtons().filter(function(Btn) { return Btn.getAttribute('name') === 'remove'; })[0].enable(); }, onDblClick: () => { - require(['package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow'], (RuleWindow) => { - new RuleWindow({ - ruleId: this.$Grid.getSelectedData()[0].id, - events: { - onUpdateEnd: () => { - this.refreshInput(); - this.refresh(); + require( + ['package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow'], + (RuleWindow) => { + new RuleWindow({ + ruleId: this.$Grid.getSelectedData()[0].id, + events: { + onUpdateEnd: () => { + this.refreshInput(); + this.refresh(); + } } - } - }).open(); - }); + }).open(); + } + ); } }); @@ -200,7 +207,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ shippingRules = []; } - let data = shippingRules.map(function (entry) { + let data = shippingRules.map(function(entry) { return { id: entry }; @@ -222,14 +229,14 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ * * @param {Array} shippingRules - list of ids */ - addShippingRules: function (shippingRules) { + addShippingRules: function(shippingRules) { return new Promise((resolve) => { require(['package/quiqqer/shipping/bin/backend/ShippingRules'], (ShippingRules) => { ShippingRules.getRules(shippingRules).then((rules) => { - const current = QUILocale.getCurrent(), - currentData = this.$Grid.getData(); + const current = QUILocale.getCurrent(), + currentData = this.$Grid.getData(); - const isInCurrentData = function (id) { + const isInCurrentData = function(id) { id = parseInt(id); for (let i = 0, len = currentData.length; i < len; i++) { @@ -241,7 +248,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ return false; }; - rules.forEach(function (v, k) { + rules.forEach(function(v, k) { let title = ''; if (typeof v.title[current] !== 'undefined') { @@ -276,10 +283,10 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ * * @param {Array} shippingRuleIds - ids of the shipping rules */ - removeShippingRules: function (shippingRuleIds) { + removeShippingRules: function(shippingRuleIds) { let data = this.$Grid.getData(); - data = data.filter(function (entry) { + data = data.filter(function(entry) { return shippingRuleIds.indexOf(entry.id) === -1; }); @@ -293,7 +300,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ /** * open rule window to add a rule to the shipping rules */ - $openAddDialog: function () { + $openAddDialog: function() { require([ 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleListWindow' ], (ShippingRuleListWindow) => { @@ -311,18 +318,18 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ * Open the remove dialog * - The user has the possibility to remove a shipping rule from the shipping entry */ - $openRemoveDialog: function () { + $openRemoveDialog: function() { const selected = this.$Grid.getSelectedData(); if (!selected.length) { return; } - const shippingIds = selected.map(function (entry) { + const shippingIds = selected.map(function(entry) { return entry.id; }); - let idHtml = selected.map(function (entry) { + let idHtml = selected.map(function(entry) { return '<li>#' + entry.id + ' ' + entry.title + '</li>'; }); @@ -330,16 +337,16 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry.List', [ require(['qui/controls/windows/Confirm'], (QUIConfirm) => { new QUIConfirm({ - icon : 'fa fa-trash', - texticon : 'fa fa-trash', - title : QUILocale.get(lg, 'window.shipping.entry.remove.rule.title'), - text : QUILocale.get(lg, 'window.shipping.entry.remove.rule.text'), + icon: 'fa fa-trash', + texticon: 'fa fa-trash', + title: QUILocale.get(lg, 'window.shipping.entry.remove.rule.title'), + text: QUILocale.get(lg, 'window.shipping.entry.remove.rule.text'), information: QUILocale.get(lg, 'window.shipping.entry.remove.rule.information', { ids: idHtml }), - maxHeight : 300, - maxWidth : 600, - events : { + maxHeight: 300, + maxWidth: 600, + events: { onSubmit: () => { this.removeShippingRules(shippingIds); } diff --git a/bin/backend/controls/ShippingEntry.js b/bin/backend/controls/ShippingEntry.js index 63479ac7302c2a10737a61e3b274f93f5ffb49fd..f8a0429395a5c1b911c85d54e88e1ce1fa164ea9 100644 --- a/bin/backend/controls/ShippingEntry.js +++ b/bin/backend/controls/ShippingEntry.js @@ -19,16 +19,17 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ 'text!package/quiqqer/shipping/bin/backend/controls/ShippingEntry.html' -], function (QUI, QUIPanel, QUIConfirm, Shipping, ShippingRulesGrid, - Translator, TranslatUpdater, FormUtils, Mustache, QUILocale, template) { - "use strict"; +], function(QUI, QUIPanel, QUIConfirm, Shipping, ShippingRulesGrid, + Translator, TranslatUpdater, FormUtils, Mustache, QUILocale, template +) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIPanel, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingEntry', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingEntry', Binds: [ 'showInformation', @@ -48,23 +49,23 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ shippingId: false }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ - '#id': "shippingId" in options ? options.shippingId : false + '#id': 'shippingId' in options ? options.shippingId : false }); - this.$Container = null; - this.$IconField = null; - this.$DataTitle = null; + this.$Container = null; + this.$IconField = null; + this.$DataTitle = null; this.$DataWorkingTitle = null; - this.$DataDescription = null; + this.$DataDescription = null; this.addEvents({ - onCreate : this.$onCreate, - onInject : this.$onInject, + onCreate: this.$onCreate, + onInject: this.$onInject, onRefresh: this.$onRefresh, onDestroy: this.$onDestroy }); @@ -73,13 +74,13 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * event: on create */ - $onCreate: function () { + $onCreate: function() { this.addButton({ - name : 'save', - title : QUILocale.get('quiqqer/core', 'save'), - text : QUILocale.get('quiqqer/core', 'save'), + name: 'save', + title: QUILocale.get('quiqqer/core', 'save'), + text: QUILocale.get('quiqqer/core', 'save'), textimage: 'fa fa-save', - events : { + events: { onClick: this.save } }); @@ -89,20 +90,20 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ }); this.addButton({ - name : 'status', - text : QUILocale.get('quiqqer/core', 'deactivate'), - title : QUILocale.get('quiqqer/core', 'deactivate'), + name: 'status', + text: QUILocale.get('quiqqer/core', 'deactivate'), + title: QUILocale.get('quiqqer/core', 'deactivate'), textimage: 'fa fa-remove', - disabled : true, - events : { + disabled: true, + events: { onClick: this.toggleStatus } }); this.addButton({ - name : 'delete', - title : QUILocale.get('quiqqer/system', 'delete'), - icon : 'fa fa-trash', + name: 'delete', + title: QUILocale.get('quiqqer/system', 'delete'), + icon: 'fa fa-trash', events: { onClick: this.openDeleteDialog }, @@ -113,18 +114,18 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ this.addCategory({ - name : 'information', - text : QUILocale.get('quiqqer/system', 'information'), - icon : 'fa fa-file-o', + name: 'information', + text: QUILocale.get('quiqqer/system', 'information'), + icon: 'fa fa-file-o', events: { onClick: this.showInformation } }); this.addCategory({ - name : 'description', - text : QUILocale.get('quiqqer/system', 'description'), - icon : 'fa fa-file-text-o', + name: 'description', + text: QUILocale.get('quiqqer/system', 'description'), + icon: 'fa fa-file-text-o', events: { onClick: this.showDescription } @@ -132,16 +133,16 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ this.$Container = new Element('div', { styles: { - height : '100%', + height: '100%', overflow: 'auto', - padding : 10, + padding: 10, position: 'relative', - width : '100%' + width: '100%' } }).inject(this.getContent()); this.getContent().setStyles({ - padding : 0, + padding: 0, position: 'relative' }); }, @@ -149,19 +150,19 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * event : on inject */ - $onInject: function () { + $onInject: function() { var self = this; this.Loader.show(); Shipping.addEvents({ onShippingDeactivate: this.$onShippingChange, - onShippingActivate : this.$onShippingChange, - onShippingDelete : this.$onShippingDelete, - onShippingUpdate : this.$onShippingChange + onShippingActivate: this.$onShippingChange, + onShippingDelete: this.$onShippingDelete, + onShippingUpdate: this.$onShippingChange }); - this.reload().then(function () { + this.reload().then(function() { self.getCategory('information').click(); }); }, @@ -169,10 +170,10 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * event: on refresh */ - $onRefresh: function () { + $onRefresh: function() { var data = this.getAttribute('data'); - if (!data || !("active" in data)) { + if (!data || !('active' in data)) { return; } @@ -195,12 +196,12 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * event: on destroy */ - $onDestroy: function () { + $onDestroy: function() { Shipping.removeEvents({ onShippingDeactivate: this.$onShippingChange, - onShippingActivate : this.$onShippingChange, - onShippingDelete : this.$onShippingDelete, - onShippingUpdate : this.$onShippingChange + onShippingActivate: this.$onShippingChange, + onShippingDelete: this.$onShippingDelete, + onShippingUpdate: this.$onShippingChange }); }, @@ -211,7 +212,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * @param {Number} shippingId * @param {Object} data */ - $onShippingChange: function (Shipping, shippingId, data) { + $onShippingChange: function(Shipping, shippingId, data) { if (shippingId !== this.getAttribute('shippingId')) { return; } @@ -226,7 +227,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * @param {Object} Shipping * @param {Number} shippingId */ - $onShippingDelete: function (Shipping, shippingId) { + $onShippingDelete: function(Shipping, shippingId) { if (shippingId === this.getAttribute('shippingId')) { this.destroy(); } @@ -235,11 +236,11 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Reload the shipping data */ - reload: function () { - var self = this, + reload: function() { + var self = this, shippingId = this.getAttribute('shippingId'); - return Shipping.getShippingEntry(shippingId).then(function (result) { + return Shipping.getShippingEntry(shippingId).then(function(result) { var current = QUILocale.getCurrent(); self.setAttribute('title', result.title[current]); @@ -251,7 +252,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ self.setAttribute('data', result); self.refresh(); - }).catch(function (err) { + }).catch(function(err) { console.error(err); self.destroy(); }); @@ -262,25 +263,25 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * * @return {Promise} */ - save: function () { - var self = this, + save: function() { + var self = this, shippingId = this.getAttribute('shippingId'); this.Loader.show(); this.$unloadContainerData(); this.$__storageData = {}; - this.$__running = false; + this.$__running = false; var data = this.getAttribute('data'); - return new Promise(function (resolve, reject) { - Shipping.updateShipping(shippingId, data).then(function () { + return new Promise(function(resolve, reject) { + Shipping.updateShipping(shippingId, data).then(function() { return self.reload(); - }).then(function () { + }).then(function() { resolve(); self.Loader.hide(); - }).catch(function (exc) { + }).catch(function(exc) { self.Loader.hide(); reject(exc); }); @@ -290,13 +291,13 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Activate the shipping */ - activate: function () { - var self = this, + activate: function() { + var self = this, shippingId = this.getAttribute('shippingId'); self.Loader.show(); - Shipping.activateShipping(shippingId).then(function (data) { + Shipping.activateShipping(shippingId).then(function(data) { self.setAttribute('data', data); self.refresh(); self.Loader.hide(); @@ -306,11 +307,11 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Deactivate the shipping */ - deactivate: function () { - var self = this, + deactivate: function() { + var self = this, shippingId = this.getAttribute('shippingId'); - Shipping.deactivateShipping(shippingId).then(function (data) { + Shipping.deactivateShipping(shippingId).then(function(data) { self.setAttribute('data', data); self.refresh(); self.Loader.hide(); @@ -320,10 +321,10 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Toggle the active status of the shipping */ - toggleStatus: function () { + toggleStatus: function() { var data = this.getAttribute('data'); - if (!("active" in data)) { + if (!('active' in data)) { return; } @@ -337,39 +338,39 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Show the information */ - showInformation: function () { + showInformation: function() { var self = this, data = self.getAttribute('data'); - this.$hideContainer().then(function (Container) { + this.$hideContainer().then(function(Container) { Container.set({ html: Mustache.render(template, { - header : QUILocale.get(lg, 'shipping.edit.template.title'), - id : QUILocale.get(lg, 'shipping.edit.template.id'), - type : QUILocale.get(lg, 'shipping.edit.template.type'), - title : QUILocale.get(lg, 'shipping.edit.template.title'), - workingTitle : QUILocale.get('quiqqer/system', 'workingtitle'), - usageHeader : QUILocale.get(lg, 'shipping.edit.template.usage'), - usageFrom : QUILocale.get(lg, 'shipping.edit.template.usage.from'), - usageTo : QUILocale.get(lg, 'shipping.edit.template.usage.to'), - usageAmountOf : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'), - usageAmountTo : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'), - usageValueOf : QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'), - usageValueTo : QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'), - usageAssignment : QUILocale.get(lg, 'shipping.edit.template.assignment'), + header: QUILocale.get(lg, 'shipping.edit.template.title'), + id: QUILocale.get(lg, 'shipping.edit.template.id'), + type: QUILocale.get(lg, 'shipping.edit.template.type'), + title: QUILocale.get(lg, 'shipping.edit.template.title'), + workingTitle: QUILocale.get('quiqqer/system', 'workingtitle'), + usageHeader: QUILocale.get(lg, 'shipping.edit.template.usage'), + usageFrom: QUILocale.get(lg, 'shipping.edit.template.usage.from'), + usageTo: QUILocale.get(lg, 'shipping.edit.template.usage.to'), + usageAmountOf: QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'), + usageAmountTo: QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'), + usageValueOf: QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'), + usageValueTo: QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'), + usageAssignment: QUILocale.get(lg, 'shipping.edit.template.assignment'), usageAssignmentAreas: QUILocale.get(lg, 'shipping.edit.template.areas'), - calculationPriority : QUILocale.get(lg, 'shipping.edit.template.calculationPriority'), - customIcon : QUILocale.get(lg, 'shipping.edit.template.customIcon'), - customIconDesc : QUILocale.get(lg, 'shipping.edit.template.customIcon.description'), + calculationPriority: QUILocale.get(lg, 'shipping.edit.template.calculationPriority'), + customIcon: QUILocale.get(lg, 'shipping.edit.template.customIcon'), + customIconDesc: QUILocale.get(lg, 'shipping.edit.template.customIcon.description'), shippingRulesHeader: QUILocale.get(lg, 'shipping.edit.template.shippingRules.description'), - usageAssignmentProduct : QUILocale.get(lg, 'shipping.edit.template.assignment.product'), + usageAssignmentProduct: QUILocale.get(lg, 'shipping.edit.template.assignment.product'), usageAssignmentCategory: QUILocale.get(lg, 'shipping.edit.template.assignment.category'), - usageAssignmentUser : QUILocale.get(lg, 'shipping.edit.template.assignment.user'), + usageAssignmentUser: QUILocale.get(lg, 'shipping.edit.template.assignment.user'), paymentHeader: QUILocale.get(lg, 'shipping.edit.template.assignment.payment.header'), - paymentUsage : QUILocale.get(lg, 'shipping.edit.template.assignment.payment.usage') + paymentUsage: QUILocale.get(lg, 'shipping.edit.template.assignment.payment.usage') }) }); @@ -377,13 +378,13 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ new ShippingRulesGrid({ shippingId: self.getAttribute('shippingId'), - name : 'shipping_rules', - events : { - onRefreshBegin: function () { + name: 'shipping_rules', + events: { + onRefreshBegin: function() { self.Loader.show(); }, - onRefreshEnd: function () { + onRefreshEnd: function() { self.Loader.hide(); } } @@ -402,11 +403,12 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ self.$getTranslationData('title'), self.$getTranslationData('workingTitle') ]); - }).then(function (translationData) { - return new Promise(function (resolve, reject) { - require(['controls/lang/InputMultiLang'], function (InputMultiLang) { - self.$DataTitle = new InputMultiLang().replaces(self.$Container.getElement('.shipping-title')); - self.$DataWorkingTitle = new InputMultiLang().replaces(self.$Container.getElement('.shipping-workingTitle')); + }).then(function(translationData) { + return new Promise(function(resolve, reject) { + require(['controls/lang/InputMultiLang'], function(InputMultiLang) { + self.$DataTitle = new InputMultiLang().replaces(self.$Container.getElement('.shipping-title')); + self.$DataWorkingTitle = new InputMultiLang().replaces(self.$Container.getElement( + '.shipping-workingTitle')); self.$DataTitle.setData(translationData[0]); self.$DataWorkingTitle.setData(translationData[1]); @@ -414,15 +416,15 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ resolve(); }, reject); }); - }).then(function () { + }).then(function() { return self.$showContainer(); - }).then(function () { + }).then(function() { self.$IconField = QUI.Controls.getById( self.$Container.getElement('[name="icon"]').get('data-quiid') ); self.$IconField.setValue(data.icon_path); - }).catch(function (err) { + }).catch(function(err) { console.error(err); }); }, @@ -430,24 +432,24 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * SHow the description */ - showDescription: function () { + showDescription: function() { var self = this; Promise.all([ this.$hideContainer(), this.$getTranslationData('description') - ]).then(function (result) { - var Container = result[0], + ]).then(function(result) { + var Container = result[0], description = result[1]; - return new Promise(function (resolve) { - require(['controls/lang/ContentMultiLang'], function (ContentMultiLang) { + return new Promise(function(resolve) { + require(['controls/lang/ContentMultiLang'], function(ContentMultiLang) { self.$DataDescription = new ContentMultiLang({ styles: { height: '100%' }, events: { - onLoad: function () { + onLoad: function() { self.$DataDescription.setData(description); resolve(); } @@ -455,7 +457,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ }).inject(Container); }); }); - }).then(function () { + }).then(function() { return self.$showContainer(); }); }, @@ -463,32 +465,32 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * Opens the delete dialog */ - openDeleteDialog: function () { - var self = this, + openDeleteDialog: function() { + var self = this, shippingId = this.getAttribute('shippingId'); new QUIConfirm({ - texticon : 'fa fa-trash', - icon : 'fa fa-trash', - title : QUILocale.get(lg, 'window.delete.title'), + texticon: 'fa fa-trash', + icon: 'fa fa-trash', + title: QUILocale.get(lg, 'window.delete.title'), information: QUILocale.get(lg, 'window.delete.information', { shipping: this.getAttribute('title') }), - text : QUILocale.get(lg, 'window.delete.text', { + text: QUILocale.get(lg, 'window.delete.text', { shipping: this.getAttribute('title') }), - autoclose : false, - maxHeight : 400, - maxWidth : 600, - ok_button : { - text : QUILocale.get('quiqqer/system', 'delete'), + autoclose: false, + maxHeight: 400, + maxWidth: 600, + ok_button: { + text: QUILocale.get('quiqqer/system', 'delete'), textimage: 'fa fa-trash' }, - events : { - onSubmit: function (Win) { + events: { + onSubmit: function(Win) { Win.Loader.show(); - Shipping.deleteShipping(shippingId).then(function () { + Shipping.deleteShipping(shippingId).then(function() { Win.close(); self.destroy(); }); @@ -504,17 +506,17 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * * @return {Promise} */ - $showContainer: function () { + $showContainer: function() { var self = this; - return new Promise(function (resolve) { - QUI.parse(self.$Container).then(function () { + return new Promise(function(resolve) { + QUI.parse(self.$Container).then(function() { moofx(self.$Container).animate({ opacity: 1, - top : 0 + top: 0 }, { duration: 250, - callback: function () { + callback: function() { self.Loader.hide(); resolve(self.$Container); } @@ -528,18 +530,18 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * * @return {Promise} */ - $hideContainer: function () { + $hideContainer: function() { var self = this; this.Loader.show(); - return new Promise(function (resolve) { + return new Promise(function(resolve) { moofx(self.$Container).animate({ opacity: 0, - top : -20 + top: -20 }, { duration: 250, - callback: function () { + callback: function() { self.$unloadContainer(); self.$Container.set('html', ''); resolve(self.$Container); @@ -551,7 +553,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ /** * unload the data from the current category */ - $unloadContainer: function () { + $unloadContainer: function() { this.$unloadContainerData(); if (this.$DataDescription) { @@ -579,7 +581,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * Unload the current container data and set the data to the shipping object * The data is not saved */ - $unloadContainerData: function () { + $unloadContainerData: function() { var Form = this.$Container.getElement('form'); if (this.$DataDescription) { @@ -617,8 +619,8 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * @param {String} name * @param {String} value */ - $setData: function (name, value) { - var data = this.getAttribute('data'); + $setData: function(name, value) { + var data = this.getAttribute('data'); data[name] = value; this.setAttribute('data', data); @@ -629,7 +631,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * * @param {String} name */ - $getData: function (name) { + $getData: function(name) { var data = this.getAttribute('data'); if (name in data) { @@ -645,27 +647,27 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ * @param name * @return {Promise} */ - $getTranslationData: function (name) { + $getTranslationData: function(name) { var shippingId = this.getAttribute('shippingId'); - var title = 'shipping.' + shippingId + '.title'; - var description = 'shipping.' + shippingId + '.description'; + var title = 'shipping.' + shippingId + '.title'; + var description = 'shipping.' + shippingId + '.description'; var workingTitle = 'shipping.' + shippingId + '.workingTitle'; if (typeof this.$__running === 'undefined') { this.$__storageData = {}; - this.$__running = false; + this.$__running = false; } - var getData = function () { - return new Promise(function (resolve, reject) { - if ("title" in this.$__storageData) { + var getData = function() { + return new Promise(function(resolve, reject) { + if ('title' in this.$__storageData) { resolve(); return; } if (this.$__running) { - (function () { + (function() { getData().then(resolve, reject); }).delay(100); return; @@ -678,11 +680,11 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ Translator.get(lg, description, lg), Translator.get(lg, workingTitle, lg), Translator.getAvailableLanguages() - ]).then(function (promiseResult) { - this.$__storageData.title = promiseResult[0]; - this.$__storageData.description = promiseResult[1]; + ]).then(function(promiseResult) { + this.$__storageData.title = promiseResult[0]; + this.$__storageData.description = promiseResult[1]; this.$__storageData.workingTitle = promiseResult[2]; - this.$__storageData.languages = promiseResult[3]; + this.$__storageData.languages = promiseResult[3]; this.$__running = false; resolve(); @@ -691,17 +693,17 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingEntry', [ }.bind(this); - return getData().then(function () { + return getData().then(function() { var data = this.$__storageData; var result = {}; - var value = data[name]; + var value = data[name]; if (this.$getData(name)) { value = this.$getData(name); } - data.languages.each(function (language) { + data.languages.each(function(language) { var val = value[language]; if (value[language + '_edit'] !== '' && value[language + '_edit']) { diff --git a/bin/backend/controls/ShippingRules.js b/bin/backend/controls/ShippingRules.js index cf981222e82eeab6a59dd58eef9dd96a97ff55cb..8293a7f87fcb96bff3c8a6d9f9d8762f8db2fbf6 100644 --- a/bin/backend/controls/ShippingRules.js +++ b/bin/backend/controls/ShippingRules.js @@ -11,26 +11,26 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingRules', [ 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleList', 'Locale' -], function (QUI, QUIPanel, ShippingRuleList, QUILocale) { - "use strict"; +], function(QUI, QUIPanel, ShippingRuleList, QUILocale) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIPanel, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingRules', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingRules', Binds: [ '$onCreate', '$onInject' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ - icon : 'fa fa-truck', + icon: 'fa fa-truck', title: QUILocale.get(lg, 'menu.erp.shipping.rules.title') }); @@ -39,23 +39,23 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingRules', [ this.addEvents({ onCreate: this.$onCreate, onInject: this.$onInject, - onShow : this.$onInject + onShow: this.$onInject }); }, /** * event: on create */ - $onCreate: function () { + $onCreate: function() { var self = this; this.$List = new ShippingRuleList({ events: { - onRefreshBegin: function () { + onRefreshBegin: function() { self.Loader.show(); }, - onRefreshEnd: function () { + onRefreshEnd: function() { self.Loader.hide(); } } @@ -65,8 +65,8 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingRules', [ /** * event: on resize */ - $onInject: function () { - (function () { + $onInject: function() { + (function() { this.$List.resize(); }).delay(200, this); } diff --git a/bin/backend/controls/ShippingSelect.js b/bin/backend/controls/ShippingSelect.js index 272bdba934d4c806d48005dc4ff14d0c8a1239cb..2958d4c2e74d1c8a20aa38957c7178468ab7235e 100644 --- a/bin/backend/controls/ShippingSelect.js +++ b/bin/backend/controls/ShippingSelect.js @@ -11,20 +11,20 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingSelect', [ 'css!package/quiqqer/shipping/bin/backend/controls/ShippingSelect.css' -], function (QUI, QUIElementSelect, Handler, QUILocale) { - "use strict"; +], function(QUI, QUIElementSelect, Handler, QUILocale) { + 'use strict'; return new Class({ Extends: QUIElementSelect, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingSelect', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingSelect', Binds: [ '$onCreate', '$onSearchButtonClick' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttribute('icon', 'fa fa-truck'); @@ -38,14 +38,14 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingSelect', [ this.addEvents({ onSearchButtonClick: this.$onSearchButtonClick, - onCreate : this.$onCreate + onCreate: this.$onCreate }); }, /** * Event: onCreate */ - $onCreate: function () { + $onCreate: function() { this.getElm().getParent().addClass('quiqqer-shipping-select'); }, @@ -55,16 +55,16 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingSelect', [ * @param {Object} self - select object * @param {Object} Btn - button object */ - $onSearchButtonClick: function (self, Btn) { + $onSearchButtonClick: function(self, Btn) { Btn.setAttribute('icon', 'fa fa-spinner fa-spin'); require(['package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window'], (Window) => { new Window({ autoclose: true, - multiple : this.getAttribute('multiple'), - events : { + multiple: this.getAttribute('multiple'), + events: { onSubmit: (Win, data) => { - data = data.map(function (Entry) { + data = data.map(function(Entry) { return parseInt(Entry.id); }); diff --git a/bin/backend/controls/ShippingSelectItem.js b/bin/backend/controls/ShippingSelectItem.js index 61d14c6f635806b7aebb3642ede532198c32fcce..e260461e47d3b9041c5b6f80d55f05478bdb1f26 100644 --- a/bin/backend/controls/ShippingSelectItem.js +++ b/bin/backend/controls/ShippingSelectItem.js @@ -8,19 +8,19 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingSelectItem', [ 'qui/controls/elements/SelectItem', 'package/quiqqer/shipping/bin/backend/Shipping' -], function (QUI, QUIElementSelectItem, Handler) { - "use strict"; +], function(QUI, QUIElementSelectItem, Handler) { + 'use strict'; return new Class({ Extends: QUIElementSelectItem, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingSelectItem', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingSelectItem', Binds: [ 'refresh' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttribute('icon', 'fa fa-truck'); @@ -31,10 +31,10 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingSelectItem', [ * * @returns {Promise} */ - refresh: function () { + refresh: function() { var self = this; - return Handler.getShippingEntry(this.getAttribute('id')).then(function (Shipping) { + return Handler.getShippingEntry(this.getAttribute('id')).then(function(Shipping) { self.$Text.set({ html: Shipping.currentTitle }); diff --git a/bin/backend/controls/ShippingWindow.js b/bin/backend/controls/ShippingWindow.js index 9212e226e89dcdcfedf7ae70895099e84623436a..319cc5e6e10d35265ee994f067456cd0bca79b6a 100644 --- a/bin/backend/controls/ShippingWindow.js +++ b/bin/backend/controls/ShippingWindow.js @@ -10,8 +10,8 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ 'controls/grid/Grid', 'Locale' -], function (QUI, QUIConfirm, Shipping, Grid, QUILocale) { - "use strict"; +], function(QUI, QUIConfirm, Shipping, Grid, QUILocale) { + 'use strict'; const lg = 'quiqqer/shipping'; const current = QUILocale.getCurrent(); @@ -19,7 +19,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ return new Class({ Extends: QUIConfirm, - Type : 'package/quiqqer/shipping/bin/backend/controls/ShippingWindow', + Type: 'package/quiqqer/shipping/bin/backend/controls/ShippingWindow', Binds: [ '$onOpen', @@ -31,14 +31,14 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ Order: null }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ - title : QUILocale.get(lg, 'shipping.window.title'), - icon : 'fa fa-truck', + title: QUILocale.get(lg, 'shipping.window.title'), + icon: 'fa fa-truck', maxHeight: 560, - maxWidth : 500, + maxWidth: 500 }); this.$Grid = null; @@ -48,7 +48,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ }); }, - refresh: function () { + refresh: function() { if (!this.$Elm) { return; } @@ -56,10 +56,10 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ this.Loader.show(); Shipping.getShippingList().then((result) => { - const toggle = function (Btn) { - let data = Btn.getAttribute('data'), + const toggle = function(Btn) { + let data = Btn.getAttribute('data'), shippingId = data.id, - status = parseInt(data.active); + status = parseInt(data.active); Btn.setAttribute('icon', 'fa fa-spinner fa-spin'); @@ -74,11 +74,11 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ for (let i = 0, len = result.length; i < len; i++) { if (parseInt(result[i].active)) { result[i].status = { - icon : 'fa fa-check', + icon: 'fa fa-check', styles: { lineHeight: 20, - padding : 0, - width : 20 + padding: 0, + width: 20 }, events: { onClick: toggle @@ -86,18 +86,18 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ }; } else { result[i].status = { - icon : 'fa fa-remove', + icon: 'fa fa-remove', styles: { lineHeight: 20, - padding : 0, - width : 20 + padding: 0, + width: 20 }, events: { onClick: toggle } }; } - + result[i].shippingType_display = ''; if (typeOf(result[i].title) !== 'string') { @@ -108,7 +108,7 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ result[i].workingTitle = result[i].workingTitle[current]; } - if ("shippingType" in result[i] && result[i].shippingType) { + if ('shippingType' in result[i] && result[i].shippingType) { result[i].shippingType_display = result[i].shippingType.title; } } @@ -125,71 +125,71 @@ define('package/quiqqer/shipping/bin/backend/controls/ShippingWindow', [ }); }, - $onOpen: function () { + $onOpen: function() { this.Loader.show(); this.getContent().set('html', ''); const Container = new Element('div', { styles: { height: '100%', - width : '100%' + width: '100%' } }).inject(this.getContent()); this.$Grid = new Grid(Container, { columnModel: [ { - header : QUILocale.get('quiqqer/system', 'priority'), + header: QUILocale.get('quiqqer/system', 'priority'), dataIndex: 'priority', - dataType : 'number', - width : 50 + dataType: 'number', + width: 50 }, { - header : QUILocale.get('quiqqer/system', 'status'), + header: QUILocale.get('quiqqer/system', 'status'), dataIndex: 'status', - dataType : 'button', - width : 60 + dataType: 'button', + width: 60 }, { - header : QUILocale.get('quiqqer/system', 'title'), + header: QUILocale.get('quiqqer/system', 'title'), dataIndex: 'title', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 }, { - header : QUILocale.get('quiqqer/system', 'workingtitle'), + header: QUILocale.get('quiqqer/system', 'workingtitle'), dataIndex: 'workingTitle', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 }, { - header : QUILocale.get('quiqqer/system', 'id'), + header: QUILocale.get('quiqqer/system', 'id'), dataIndex: 'id', - dataType : 'number', - width : 30 + dataType: 'number', + width: 30 }, { - header : QUILocale.get(lg, 'shipping.type'), + header: QUILocale.get(lg, 'shipping.type'), dataIndex: 'shippingType_display', - dataType : 'string', - width : 200 + dataType: 'string', + width: 200 } ] }); this.$Grid.addEvents({ - onRefresh : this.refresh, + onRefresh: this.refresh, onDblClick: this.$onDblClick }); this.refresh(); }, - $onDblClick: function () { + $onDblClick: function() { this.submit(); }, - submit: function () { + submit: function() { const data = this.$Grid.getSelectedData(); if (!data.length) { diff --git a/bin/backend/controls/TrackingInput.js b/bin/backend/controls/TrackingInput.js index 9340c8d91e768d8f750332e7a9d3d4c60dc62b4c..633df5248b24c03ed81787618bde7d06046d0f59 100644 --- a/bin/backend/controls/TrackingInput.js +++ b/bin/backend/controls/TrackingInput.js @@ -11,20 +11,20 @@ define('package/quiqqer/shipping/bin/backend/controls/TrackingInput', [ 'css!package/quiqqer/shipping/bin/backend/controls/TrackingInput.css' -], function (QUI, QUIControl, QUISelect, QUIAjax) { - "use strict"; +], function(QUI, QUIControl, QUISelect, QUIAjax) { + 'use strict'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/TrackingInput', + Type: 'package/quiqqer/shipping/bin/backend/controls/TrackingInput', Binds: [ '$onImport', '$onChange' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$value = null; @@ -34,7 +34,7 @@ define('package/quiqqer/shipping/bin/backend/controls/TrackingInput', [ }); }, - $onImport: function () { + $onImport: function() { this.$Value = this.$Elm; this.$Value.setStyle('display', 'none'); @@ -79,7 +79,7 @@ define('package/quiqqer/shipping/bin/backend/controls/TrackingInput', [ * * @returns {Promise} */ - getTrackingList: function () { + getTrackingList: function() { return new Promise((resolve) => { QUIAjax.get('package_quiqqer_shipping_ajax_backend_tracking_getList', resolve, { 'package': 'quiqqer/shipping' @@ -87,17 +87,17 @@ define('package/quiqqer/shipping/bin/backend/controls/TrackingInput', [ }); }, - $onChange: function () { + $onChange: function() { const tracking = this.$TrackingType.getValue(); const trackingNumber = this.$Input.value; this.$Value.set('value', JSON.encode({ - type : tracking, + type: tracking, number: trackingNumber })); }, - setValue: function (value) { + setValue: function(value) { if (typeof value === 'string') { value = JSON.decode(value); } diff --git a/bin/backend/controls/products/fields/ShippingTimePeriod.js b/bin/backend/controls/products/fields/ShippingTimePeriod.js index cbae74decf7004b76723403cd9eb18cbf635b5d9..857c558c1a140406907bd90529a5a6ff510bc8a5 100644 --- a/bin/backend/controls/products/fields/ShippingTimePeriod.js +++ b/bin/backend/controls/products/fields/ShippingTimePeriod.js @@ -10,14 +10,14 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi 'css!package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTimePeriod.css' -], function (QUI, TimePeriod, QUILocale) { - "use strict"; +], function(QUI, TimePeriod, QUILocale) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: TimePeriod, - Type : 'package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTimePeriod', + Type: 'package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTimePeriod', Binds: [ '$onImport', @@ -36,13 +36,13 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi show_default_option: true }, - initialize: function (options) { + initialize: function(options) { this.parent(options); - this.$OptionsSelect = null; + this.$OptionsSelect = null; this.$CustomTextContainer = null; - this.$CustomTextInput = null; - this.$CustomText = null; + this.$CustomTextInput = null; + this.$CustomText = null; this.addEvents({ onImport: this.$onImport @@ -52,9 +52,9 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi /** * Event: onImport */ - $onImport: function () { - var self = this, - Elm = this.getElm(), + $onImport: function() { + var self = this, + Elm = this.getElm(), Value = false; this.parent(); @@ -65,13 +65,13 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi }).inject(this.$Content, 'top'); this.$OptionsSelect = new Element('select', { - name : 'option', + name: 'option', events: { change: this.$onOptionSelectChange } }).inject(OptionsContainer); - var options = this.getAttribute('selectOptions'), + var options = this.getAttribute('selectOptions'), lgPrefix = 'controls.products.fields.ShippingTimePeriod.'; if (this.getAttribute('show_default_option')) { @@ -83,30 +83,30 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi new Element('option', { value: option, - html : QUILocale.get(lg, lgPrefix + 'option.' + option) + html: QUILocale.get(lg, lgPrefix + 'option.' + option) }).inject(this.$OptionsSelect); } // Custom text input this.$CustomTextContainer = new Element('div', { - 'class': 'quiqqer-shipping-fields-shippingtimeperiod-customtext quiqqer-shipping-fields-shippingtimeperiod__hidden', + 'class': 'quiqqer-shipping-fields-shippingtimeperiod-customtext quiqqer-shipping-fields-shippingtimeperiod__hidden' }).inject( Elm.getParent().getElement('.quiqqer-products-fields-types-timeperiod') ); var CustomTextInput = new Element('input', { - type : 'text', + type: 'text', 'data-qui': 'package/quiqqer/products/bin/controls/fields/types/InputMultiLang' }).inject(this.$CustomTextContainer); - QUI.parse(this.$CustomTextContainer).then(function () { + QUI.parse(this.$CustomTextContainer).then(function() { self.$CustomText = QUI.Controls.getById( CustomTextInput.get('data-quiid') ); self.$CustomText.getElm().getElements('input').addEvent('change', self.$onOptionSelectChange); - (function () { + (function() { if (!Elm.value) { self.$OptionsSelect.value = 'timeperiod'; return; @@ -127,7 +127,7 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi /** * Executed if an option is selected */ - $onOptionSelectChange: function () { + $onOptionSelectChange: function() { var option = this.$OptionsSelect.value; if (option === 'timeperiod') { @@ -152,7 +152,7 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi /** * Set field value to input */ - $setValue: function () { + $setValue: function() { var customText = this.$CustomText.getValue().trim(); if (customText !== '') { @@ -160,11 +160,11 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi } this.getElm().value = JSON.encode({ - from : this.$FromInput.value.trim(), - to : this.$ToInput.value.trim(), - unit : this.$UnitSelect.value, + from: this.$FromInput.value.trim(), + to: this.$ToInput.value.trim(), + unit: this.$UnitSelect.value, option: this.$OptionsSelect.value, - text : customText + text: customText }); }, @@ -173,7 +173,7 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi * * @returns {Object} */ - getValue: function () { + getValue: function() { var customText = this.$CustomText.getValue().trim(); if (customText !== '') { @@ -181,11 +181,11 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi } return { - from : this.$FromInput.value.trim(), - to : this.$ToInput.value.trim(), - unit : this.$UnitSelect.value, + from: this.$FromInput.value.trim(), + to: this.$ToInput.value.trim(), + unit: this.$UnitSelect.value, option: this.$OptionsSelect.value, - text : customText + text: customText }; } }); diff --git a/bin/backend/controls/search/Shipping/Result.js b/bin/backend/controls/search/Shipping/Result.js index 84394dbbed40ae82926d9ca5cba98fc3a90ddfe1..fa635d0de82330c35e92ab6fc64f6ca8792013bd 100644 --- a/bin/backend/controls/search/Shipping/Result.js +++ b/bin/backend/controls/search/Shipping/Result.js @@ -15,14 +15,14 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ 'controls/grid/Grid', 'Locale' -], function (QUI, QUIControl, QUIButton, Grid, QUILocale) { - "use strict"; +], function(QUI, QUIControl, QUIButton, Grid, QUILocale) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', + Type: 'package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', Binds: [ '$onInject' @@ -32,7 +32,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ multipleSelection: true }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$Grid = null; @@ -46,51 +46,53 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ * Return the DOMNode Element * @returns {HTMLDivElement} */ - create: function () { + create: function() { var Elm = this.parent(); Elm.set('html', ''); Elm.setStyles({ - 'float' : 'left', + 'float': 'left', 'height': '100%', - 'width' : '100%' + 'width': '100%' }); var Container = new Element('div').inject(Elm); this.$Grid = new Grid(Container, { - filterInput : true, + filterInput: true, multipleSelection: this.getAttribute('multipleSelection'), - columnModel : [{ - header : QUILocale.get('quiqqer/system', 'id'), - dataIndex: 'id', - dataType : 'number', - width : 30 - }, { - header : QUILocale.get('quiqqer/system', 'priority'), - dataIndex: 'priority', - dataType : 'number', - width : 50 - }, { - header : QUILocale.get('quiqqer/system', 'title'), - dataIndex: 'currentTitle', - dataType : 'string', - width : 200 - }, { - header : QUILocale.get('quiqqer/system', 'workingtitle'), - dataIndex: 'currentWorkingTitle', - dataType : 'string', - width : 200 - }, { - header : QUILocale.get(lg, 'shipping.type'), - dataIndex: 'shippingType_display', - dataType : 'string', - width : 200 - }] + columnModel: [ + { + header: QUILocale.get('quiqqer/system', 'id'), + dataIndex: 'id', + dataType: 'number', + width: 30 + }, { + header: QUILocale.get('quiqqer/system', 'priority'), + dataIndex: 'priority', + dataType: 'number', + width: 50 + }, { + header: QUILocale.get('quiqqer/system', 'title'), + dataIndex: 'currentTitle', + dataType: 'string', + width: 200 + }, { + header: QUILocale.get('quiqqer/system', 'workingtitle'), + dataIndex: 'currentWorkingTitle', + dataType: 'string', + width: 200 + }, { + header: QUILocale.get(lg, 'shipping.type'), + dataIndex: 'shippingType_display', + dataType: 'string', + width: 200 + } + ] }); - this.$Grid.addEvent('onDblClick', function () { + this.$Grid.addEvent('onDblClick', function() { this.fireEvent('dblClick', [this]); }.bind(this)); @@ -100,7 +102,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ /** * event : on inject */ - $onInject: function () { + $onInject: function() { this.fireEvent('loaded'); }, @@ -109,13 +111,13 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ * * @param {Object} data - grid data */ - setData: function (data) { + setData: function(data) { if (!this.$Grid) { return; } for (var i = 0, len = data.length; i < len; i++) { - if ("shippingType" in data[i] && data[i].shippingType) { + if ('shippingType' in data[i] && data[i].shippingType) { data[i].shippingType_display = data[i].shippingType.title; } } @@ -130,7 +132,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ * * @returns {Array} */ - getSelected: function () { + getSelected: function() { if (!this.$Grid) { return []; } @@ -143,7 +145,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result', [ * * @return {Promise} */ - resize: function () { + resize: function() { var size = this.getElm().getSize(); this.$Grid.setWidth(size.x); diff --git a/bin/backend/controls/search/Shipping/Window.js b/bin/backend/controls/search/Shipping/Window.js index 7285e365475345b4d840f3f1fda1baae41bdb2dc..0f06f8f541d44a95bdc79d8b3ae3f49b759e4ae3 100644 --- a/bin/backend/controls/search/Shipping/Window.js +++ b/bin/backend/controls/search/Shipping/Window.js @@ -14,15 +14,15 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ 'css!package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window.css' -], function (QUI, QUIControl, QUIConfirm, Handler, QUILocale) { - "use strict"; +], function(QUI, QUIControl, QUIConfirm, Handler, QUILocale) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIConfirm, - Type : 'package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', + Type: 'package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', Binds: [ '$onOpen' @@ -30,22 +30,22 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ options: { maxHeight: 600, - maxWidth : 800, - icon : 'fa fa-globe', - title : QUILocale.get(lg, 'control.search.ShippingWindow.title'), + maxWidth: 800, + icon: 'fa fa-globe', + title: QUILocale.get(lg, 'control.search.ShippingWindow.title'), autoclose: false, cancel_button: { - text : QUILocale.get('quiqqer/system', 'cancel'), + text: QUILocale.get('quiqqer/system', 'cancel'), textimage: 'fa fa-remove' }, - ok_button : { - text : QUILocale.get('quiqqer/system', 'accept'), + ok_button: { + text: QUILocale.get('quiqqer/system', 'accept'), textimage: 'fa fa-truck' } }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$Result = null; @@ -60,8 +60,8 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ * * @returns {HTMLDivElement} */ - $onOpen: function (Win) { - var self = this, + $onOpen: function(Win) { + var self = this, Content = Win.getContent(); Win.Loader.show(); @@ -75,10 +75,10 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ require([ 'package/quiqqer/shipping/bin/backend/controls/search/Shipping/Result' - ], function (Result) { + ], function(Result) { self.$Result = new Result({ events: { - onDblClick: function () { + onDblClick: function() { self.submit(); } } @@ -86,7 +86,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ self.$Result.resize(); - Handler.getShippingList().then(function (result) { + Handler.getShippingList().then(function(result) { self.$Result.setData(result); Win.Loader.hide(); }); @@ -96,7 +96,7 @@ define('package/quiqqer/shipping/bin/backend/controls/search/Shipping/Window', [ /** * Submit */ - submit: function () { + submit: function() { if (!this.$Result) { return; } diff --git a/bin/backend/controls/settings/RuleFields.js b/bin/backend/controls/settings/RuleFields.js index aeda20eaa8430d5a4f7750a4cf52e3fbc463fe26..c171f101946b481d881b6b3a3594a32fbe7975a7 100644 --- a/bin/backend/controls/settings/RuleFields.js +++ b/bin/backend/controls/settings/RuleFields.js @@ -11,20 +11,20 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', [ 'css!package/quiqqer/shipping/bin/backend/controls/settings/RuleFields.css' -], function (QUI, QUIControl, QUILocale, QUIAjax) { - "use strict"; +], function(QUI, QUIControl, QUILocale, QUIAjax) { + 'use strict'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', + Type: 'package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', Binds: [ '$onImport', '$updateInput' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.addEvents({ @@ -35,9 +35,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', [ /** * event: on import */ - $onImport: function () { + $onImport: function() { this.$Input = this.getElm(); - this.$Elm = new Element('div', { + this.$Elm = new Element('div', { 'class': 'quiqqer-shipping-settings-ruleFields field-container-field' }).wraps(this.$Input); @@ -45,18 +45,18 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', [ html: '<span class="fa fa-spinner fa-spin"></span>' }).inject(this.$Elm); - var self = this, + var self = this, Container = this.$Elm; - this.$Elm - .getParent('.field-container') - .getElement('.field-container-item') - .addEvent('click', function (event) { + this.$Elm.getParent('.field-container').getElement('.field-container-item').addEvent( + 'click', + function(event) { event.stop(); - }); + } + ); - QUIAjax.get('package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFields', function (unitFields) { - Container.getChildren().forEach(function (Node) { + QUIAjax.get('package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFields', function(unitFields) { + Container.getChildren().forEach(function(Node) { if (Node.nodeName !== 'INPUT') { Node.destroy(); } @@ -65,8 +65,8 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', [ for (var i = 0, len = unitFields.length; i < len; i++) { new Element('label', { 'class': 'quiqqer-shipping-settings-ruleFields-entry', - html : '<input type="checkbox" value="' + unitFields[i].id + '" />' + unitFields[i].title, - events : { + html: '<input type="checkbox" value="' + unitFields[i].id + '" />' + unitFields[i].title, + events: { change: self.$updateInput } }).inject(Container); @@ -92,14 +92,14 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/RuleFields', [ /** * Refresh the input value */ - $updateInput: function () { + $updateInput: function() { var checkboxes = this.getElm().getElements('[type="checkbox"]'); - checkboxes = checkboxes.filter(function (Node) { + checkboxes = checkboxes.filter(function(Node) { return Node.checked; }); - checkboxes = checkboxes.map(function (Node) { + checkboxes = checkboxes.map(function(Node) { return Node.value; }); diff --git a/bin/backend/controls/settings/ShippingStatus.js b/bin/backend/controls/settings/ShippingStatus.js index f839cfcd8a407ba8910276c6dc0e85b72c4d8790..8f65f094f54e307204ada2475dc15332f0ca5d13 100644 --- a/bin/backend/controls/settings/ShippingStatus.js +++ b/bin/backend/controls/settings/ShippingStatus.js @@ -15,15 +15,15 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', 'text!package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus.html', 'css!package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus.css' -], function (QUI, QUIControl, QUIConfirm, ShippingStatus, Grid, QUILocale, Mustache, template) { - "use strict"; +], function(QUI, QUIControl, QUIConfirm, ShippingStatus, Grid, QUILocale, Mustache, template) { + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', + Type: 'package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', Binds: [ '$onChange', @@ -36,12 +36,12 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', '$onDeleteClick' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); - this.$Elm = null; + this.$Elm = null; this.$Input = null; - this.$Grid = null; + this.$Grid = null; this.addEvents({ onImport: this.$onImport @@ -51,15 +51,15 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * Refresh */ - refresh: function () { + refresh: function() { var self = this; - ShippingStatus.getList().then(function (result) { + ShippingStatus.getList().then(function(result) { for (var i = 0, len = result.data.length; i < len; i++) { result.data[i].colorNode = new Element('span', { - html : result.data[i].color, + html: result.data[i].color, 'class': 'quiqqer-shipping-shipping-status-color', - styles : { + styles: { backgroundColor: result.data[i].color } }); @@ -79,7 +79,7 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * resize the grid */ - resize: function () { + resize: function() { this.$Grid.setWidth( this.$Elm.getSize().x ); @@ -88,9 +88,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * event: on import */ - $onImport: function () { + $onImport: function() { this.$Input = this.getElm(); - this.$Elm = new Element('div').wraps(this.$Input); + this.$Elm = new Element('div').wraps(this.$Input); this.$Elm.setStyles({ width: '100%' @@ -101,63 +101,67 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', var Container = new Element('div', { styles: { height: 300, - width : w + width: w } }).inject(this.$Elm); this.$Grid = new Grid(Container, { - height : 300, - width : w, - buttons : [{ - name : 'add', - text : QUILocale.get('quiqqer/system', 'add'), - events: { - onClick: this.openCreateDialog - } - }, { - type: 'separator' - }, { - name : 'edit', - text : QUILocale.get('quiqqer/system', 'edit'), - disabled: true, - events : { - onClick: this.$onEditClick + height: 300, + width: w, + buttons: [ + { + name: 'add', + text: QUILocale.get('quiqqer/system', 'add'), + events: { + onClick: this.openCreateDialog + } + }, { + type: 'separator' + }, { + name: 'edit', + text: QUILocale.get('quiqqer/system', 'edit'), + disabled: true, + events: { + onClick: this.$onEditClick + } + }, { + name: 'delete', + text: QUILocale.get('quiqqer/system', 'remove'), + disabled: true, + events: { + onClick: this.$onDeleteClick + } } - }, { - name : 'delete', - text : QUILocale.get('quiqqer/system', 'remove'), - disabled: true, - events : { - onClick: this.$onDeleteClick + ], + columnModel: [ + { + header: QUILocale.get(lg, 'shippingStatus.grid.id'), + dataIndex: 'id', + dataType: 'integer', + width: 60 + }, { + header: QUILocale.get(lg, 'shippingStatus.grid.color'), + dataIndex: 'colorNode', + dataType: 'node', + width: 60 + }, { + header: QUILocale.get('quiqqer/system', 'title'), + dataIndex: 'title', + dataType: 'integer', + width: 200 + }, { + header: QUILocale.get(lg, 'shippingStatus.grid.notification'), + dataIndex: 'notificationStatus', + dataType: 'node', + width: 150 } - }], - columnModel: [{ - header : QUILocale.get(lg, 'shippingStatus.grid.id'), - dataIndex: 'id', - dataType : 'integer', - width : 60 - }, { - header : QUILocale.get(lg, 'shippingStatus.grid.color'), - dataIndex: 'colorNode', - dataType : 'node', - width : 60 - }, { - header : QUILocale.get('quiqqer/system', 'title'), - dataIndex: 'title', - dataType : 'integer', - width : 200 - }, { - header : QUILocale.get(lg, 'shippingStatus.grid.notification'), - dataIndex: 'notificationStatus', - dataType : 'node', - width : 150 - }] + ] }); this.$Grid.addEvents({ - onRefresh : this.refresh, - onClick : this.$refreshButtonStatus, + onRefresh: this.refresh, + onClick: this.$refreshButtonStatus, onDblClick: this.$onEditClick }); @@ -168,14 +172,14 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * Refresh the grid button status (disabled/enabled) */ - $refreshButtonStatus: function () { + $refreshButtonStatus: function() { var selected = this.$Grid.getSelectedIndices(); - var Edit = this.$Grid.getButtons().filter(function (Button) { + var Edit = this.$Grid.getButtons().filter(function(Button) { return Button.getAttribute('name') === 'edit'; })[0]; - var Delete = this.$Grid.getButtons().filter(function (Button) { + var Delete = this.$Grid.getButtons().filter(function(Button) { return Button.getAttribute('name') === 'delete'; })[0]; @@ -195,17 +199,17 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', * Opens the add dialog * - Create a Shipping Status */ - openCreateDialog: function () { + openCreateDialog: function() { var self = this; new QUIConfirm({ - icon : 'fa fa-plus', - title : QUILocale.get(lg, 'dialog.shippingStatus.create.title'), + icon: 'fa fa-plus', + title: QUILocale.get(lg, 'dialog.shippingStatus.create.title'), maxHeight: 470, - maxWidth : 600, + maxWidth: 600, autoclose: false, - events : { - onOpen: function (Win) { + events: { + onOpen: function(Win) { var Content = Win.getContent(); Win.Loader.show(); @@ -214,25 +218,25 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', Content.addClass('quiqqer-shipping-shipping-status-window'); Content.set('html', Mustache.render(template, { - labelTitle : QUILocale.get(lg, lgPrefix + 'labelTitle'), - labelStatusNo : QUILocale.get(lg, lgPrefix + 'labelStatusNo'), - labelColor : QUILocale.get(lg, lgPrefix + 'labelColor'), + labelTitle: QUILocale.get(lg, lgPrefix + 'labelTitle'), + labelStatusNo: QUILocale.get(lg, lgPrefix + 'labelStatusNo'), + labelColor: QUILocale.get(lg, lgPrefix + 'labelColor'), labelNotification: QUILocale.get(lg, lgPrefix + 'labelNotification'), - descNotification : QUILocale.get(lg, lgPrefix + 'descNotification') + descNotification: QUILocale.get(lg, lgPrefix + 'descNotification') })); var Form = Content.getElement('form'); - ShippingStatus.getNextId().then(function (nextId) { + ShippingStatus.getNextId().then(function(nextId) { Form.elements.id.value = nextId; return QUI.parse(Content); - }).then(function () { + }).then(function() { Win.Loader.hide(); }); }, - onSubmit: function (Win) { + onSubmit: function(Win) { Win.Loader.show(); var Form = Win.getContent().getElement('form'); @@ -240,8 +244,8 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', require([ 'qui/utils/Form', 'package/quiqqer/shipping/bin/backend/ShippingStatus' - ], function (FormUtils, ShippingStatus) { - var data = FormUtils.getFormData(Form), + ], function(FormUtils, ShippingStatus) { + var data = FormUtils.getFormData(Form), title = {}; try { @@ -254,9 +258,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', data.color, title, data.notification.checked - ).then(function () { + ).then(function() { return Win.close(); - }).then(function () { + }).then(function() { self.refresh(); }); }); @@ -270,9 +274,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', * * @param {Number|String} statusId - ID of the Status */ - openEditDialog: function (statusId) { + openEditDialog: function(statusId) { var self = this; - var data = this.$Grid.getData().filter(function (entry) { + var data = this.$Grid.getData().filter(function(entry) { return entry.id === statusId; }); @@ -283,17 +287,17 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', data = data[0]; new QUIConfirm({ - icon : 'fa fa-edit', - title : QUILocale.get(lg, 'dialog.shippingStatus.edit.title'), + icon: 'fa fa-edit', + title: QUILocale.get(lg, 'dialog.shippingStatus.edit.title'), maxHeight: 470, - maxWidth : 600, + maxWidth: 600, autoclose: false, ok_button: { - text : QUILocale.get('quiqqer/core', 'edit'), + text: QUILocale.get('quiqqer/core', 'edit'), textimage: 'fa fa-edit' }, - events : { - onOpen: function (Win) { + events: { + onOpen: function(Win) { var Content = Win.getContent(); Win.Loader.show(); @@ -302,28 +306,28 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', Content.addClass('quiqqer-order-shipping-status-window'); Content.set('html', Mustache.render(template, { - labelTitle : QUILocale.get(lg, lgPrefix + 'labelTitle'), - labelStatusNo : QUILocale.get(lg, lgPrefix + 'labelStatusNo'), - labelColor : QUILocale.get(lg, lgPrefix + 'labelColor'), + labelTitle: QUILocale.get(lg, lgPrefix + 'labelTitle'), + labelStatusNo: QUILocale.get(lg, lgPrefix + 'labelStatusNo'), + labelColor: QUILocale.get(lg, lgPrefix + 'labelColor'), labelNotification: QUILocale.get(lg, lgPrefix + 'labelNotification'), - descNotification : QUILocale.get(lg, lgPrefix + 'descNotification') + descNotification: QUILocale.get(lg, lgPrefix + 'descNotification') })); var Form = Content.getElement('form'); - ShippingStatus.getShippingStatus(data.id).then(function (details) { - Form.elements.id.value = details.id; - Form.elements.color.value = details.color; - Form.elements.title.value = JSON.encode(details.title); + ShippingStatus.getShippingStatus(data.id).then(function(details) { + Form.elements.id.value = details.id; + Form.elements.color.value = details.color; + Form.elements.title.value = JSON.encode(details.title); Form.elements.notification.checked = details.notification; return QUI.parse(Content); - }).then(function () { + }).then(function() { Win.Loader.hide(); }); }, - onSubmit: function (Win) { + onSubmit: function(Win) { Win.Loader.show(); var Form = Win.getContent().getElement('form'); @@ -331,8 +335,8 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', require([ 'qui/utils/Form', 'package/quiqqer/shipping/bin/backend/ShippingStatus' - ], function (FormUtils, ShippingStatus) { - var data = FormUtils.getFormData(Form), + ], function(FormUtils, ShippingStatus) { + var data = FormUtils.getFormData(Form), title = {}; try { @@ -345,9 +349,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', data.color, title, data.notification - ).then(function () { + ).then(function() { return Win.close(); - }).then(function () { + }).then(function() { self.refresh(); }); }); @@ -361,9 +365,9 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', * * @param {Number|String} statusId - ID of the Status */ - openDeleteDialog: function (statusId) { + openDeleteDialog: function(statusId) { var self = this; - var data = this.$Grid.getData().filter(function (entry) { + var data = this.$Grid.getData().filter(function(entry) { return entry.id === statusId; }); @@ -372,26 +376,26 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', } new QUIConfirm({ - icon : 'fa fa-trash', - texticon : 'fa fa-trash', - title : QUILocale.get(lg, 'dialog.shippingStatus.delete.title'), - text : QUILocale.get(lg, 'dialog.shippingStatus.delete.text'), + icon: 'fa fa-trash', + texticon: 'fa fa-trash', + title: QUILocale.get(lg, 'dialog.shippingStatus.delete.title'), + text: QUILocale.get(lg, 'dialog.shippingStatus.delete.text'), information: QUILocale.get(lg, 'dialog.shippingStatus.delete.information', { - id : data[0].id, + id: data[0].id, title: data[0].title }), - maxHeight : 400, - maxWidth : 600, - autoclose : false, - ok_button : { - text : QUILocale.get('quiqqer/core', 'remove'), + maxHeight: 400, + maxWidth: 600, + autoclose: false, + ok_button: { + text: QUILocale.get('quiqqer/core', 'remove'), textimage: 'fa fa-trash' }, - events : { - onSubmit: function (Win) { + events: { + onSubmit: function(Win) { Win.Loader.show(); - ShippingStatus.deleteShippingStatus(statusId).then(function () { + ShippingStatus.deleteShippingStatus(statusId).then(function() { Win.close(); self.refresh(); }); @@ -407,7 +411,7 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * event : on edit click */ - $onEditClick: function () { + $onEditClick: function() { var data = this.$Grid.getSelectedData(); if (data.length) { @@ -418,7 +422,7 @@ define('package/quiqqer/shipping/bin/backend/controls/settings/ShippingStatus', /** * event : on delete click */ - $onDeleteClick: function () { + $onDeleteClick: function() { var data = this.$Grid.getSelectedData(); if (data.length) { diff --git a/bin/backend/controls/shippingRules/CreateRuleWindow.js b/bin/backend/controls/shippingRules/CreateRuleWindow.js index c0d9b0972dd2e4da95e86bb9be772fbc6b56c5b0..01fc91ba6447a1e70b87d8702e0a066366a169b6 100644 --- a/bin/backend/controls/shippingRules/CreateRuleWindow.js +++ b/bin/backend/controls/shippingRules/CreateRuleWindow.js @@ -9,13 +9,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi 'package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRule', 'Locale' -], function (QUI, QUIConfirm, CreateRule, QUILocale) { - "use strict"; +], function(QUI, QUIConfirm, CreateRule, QUILocale) { + 'use strict'; return new Class({ Extends: QUIConfirm, - Type : 'package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWindow', + Type: 'package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWindow', Binds: [ '$onOpen', @@ -24,18 +24,18 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi options: { maxHeight: 800, - maxWidth : 600, + maxWidth: 600, autoclose: false }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ - title : QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'), - icon : 'fa fa-truck', + title: QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'), + icon: 'fa fa-truck', ok_button: { - text : QUILocale.get('quiqqer/shipping', 'window.shipping.entry.delete.rule.create'), + text: QUILocale.get('quiqqer/shipping', 'window.shipping.entry.delete.rule.create'), textimage: 'fa fa-trash' } }); @@ -43,7 +43,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi this.$Create = null; this.addEvents({ - onOpen : this.$onOpen, + onOpen: this.$onOpen, onSubmit: this.$onSubmit }); }, @@ -51,7 +51,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi /** * event: on inject */ - $onOpen: function () { + $onOpen: function() { var self = this; this.Loader.show(); @@ -59,7 +59,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi this.$Create = new CreateRule({ events: { - onLoad: function () { + onLoad: function() { self.Loader.hide(); } } @@ -69,11 +69,11 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRuleWi /** * event: on submit */ - $onSubmit: function () { + $onSubmit: function() { var self = this; this.Loader.hide(); - this.$Create.submit().then(function () { + this.$Create.submit().then(function() { self.Loader.hide(); self.close(); }); diff --git a/bin/backend/controls/shippingRules/Rule.js b/bin/backend/controls/shippingRules/Rule.js index 45e76685fa301c2785a4168ed60c427363eeae35..6c723cf1dd88a30d6ee19ec5e23fc9569a8ab1dd 100644 --- a/bin/backend/controls/shippingRules/Rule.js +++ b/bin/backend/controls/shippingRules/Rule.js @@ -21,18 +21,18 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ 'text!package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleUnit.html', 'css!package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule.css' -], function (QUI, QUIControl, ControlUtils, Translator, TranslateUpdater, InputMultiLang, Fields, - ShippingRules, FormUtils, ElementsUtils, QUILocale, Mustache, - template, templateUnit +], function(QUI, QUIControl, ControlUtils, Translator, TranslateUpdater, InputMultiLang, Fields, + ShippingRules, FormUtils, ElementsUtils, QUILocale, Mustache, + template, templateUnit ) { - "use strict"; + 'use strict'; var lg = 'quiqqer/shipping'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRule', + Type: 'package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRule', Binds: [ '$onInject', @@ -43,7 +43,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ ruleId: false }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$DataTitle = null; @@ -62,47 +62,50 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ * * @return {HTMLDivElement} */ - create: function () { + create: function() { this.$Elm = this.parent(); this.$Elm.addClass('quiqqer-shipping-rule-edit'); this.$Elm.setStyles({ overflow: 'hidden', - opacity : 0 + opacity: 0 }); this.$Elm.set('html', Mustache.render(template, { - generalHeader : QUILocale.get(lg, 'shipping.edit.template.general'), - title : QUILocale.get(lg, 'shipping.edit.template.title'), - workingTitle : QUILocale.get('quiqqer/system', 'workingtitle'), - calculationPriority : QUILocale.get(lg, 'shipping.edit.template.calculationPriority'), - discountTitle : QUILocale.get(lg, 'shipping.edit.template.discount'), - discountDescription : QUILocale.get(lg, 'shipping.edit.template.discount.description'), - discountAbsolute : QUILocale.get(lg, 'shipping.edit.template.discount.absolute'), - discountPercentage : QUILocale.get(lg, 'shipping.edit.template.discount.percentage'), + generalHeader: QUILocale.get(lg, 'shipping.edit.template.general'), + title: QUILocale.get(lg, 'shipping.edit.template.title'), + workingTitle: QUILocale.get('quiqqer/system', 'workingtitle'), + calculationPriority: QUILocale.get(lg, 'shipping.edit.template.calculationPriority'), + discountTitle: QUILocale.get(lg, 'shipping.edit.template.discount'), + discountDescription: QUILocale.get(lg, 'shipping.edit.template.discount.description'), + discountAbsolute: QUILocale.get(lg, 'shipping.edit.template.discount.absolute'), + discountPercentage: QUILocale.get(lg, 'shipping.edit.template.discount.percentage'), discountPercentageOrder: QUILocale.get(lg, 'shipping.edit.template.discount.percentageOrder'), - statusTitle : QUILocale.get(lg, 'shipping.edit.template.status'), - statusDescription : QUILocale.get(lg, 'shipping.edit.template.status.description'), - noRulesTitle : QUILocale.get(lg, 'shipping.edit.template.noRules'), - noRulesText : QUILocale.get(lg, 'shipping.edit.template.noRules.text'), - unitTitle : QUILocale.get(lg, 'shipping.edit.template.unit'), - unitHeader : QUILocale.get(lg, 'shipping.edit.template.unitTitle'), - usageHeader : QUILocale.get(lg, 'shipping.edit.template.usage'), - usageFrom : QUILocale.get(lg, 'shipping.edit.template.usage.from'), - usageTo : QUILocale.get(lg, 'shipping.edit.template.usage.to'), - usageAmountOf : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'), - usageAmountTo : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'), - usageValueOf : QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'), - usageValueTo : QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'), - usageAssignmentUser : QUILocale.get(lg, 'shipping.edit.template.assignment.user'), - usageAssignmentProduct : QUILocale.get(lg, 'shipping.edit.template.assignment.product'), - usageAssignmentArea : QUILocale.get(lg, 'shipping.edit.template.assignment.areas'), + statusTitle: QUILocale.get(lg, 'shipping.edit.template.status'), + statusDescription: QUILocale.get(lg, 'shipping.edit.template.status.description'), + noRulesTitle: QUILocale.get(lg, 'shipping.edit.template.noRules'), + noRulesText: QUILocale.get(lg, 'shipping.edit.template.noRules.text'), + unitTitle: QUILocale.get(lg, 'shipping.edit.template.unit'), + unitHeader: QUILocale.get(lg, 'shipping.edit.template.unitTitle'), + usageHeader: QUILocale.get(lg, 'shipping.edit.template.usage'), + usageFrom: QUILocale.get(lg, 'shipping.edit.template.usage.from'), + usageTo: QUILocale.get(lg, 'shipping.edit.template.usage.to'), + usageAmountOf: QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'), + usageAmountTo: QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'), + usageValueOf: QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'), + usageValueTo: QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'), + usageAssignmentUser: QUILocale.get(lg, 'shipping.edit.template.assignment.user'), + usageAssignmentProduct: QUILocale.get(lg, 'shipping.edit.template.assignment.product'), + usageAssignmentArea: QUILocale.get(lg, 'shipping.edit.template.assignment.areas'), usageAssignmentCategory: QUILocale.get(lg, 'shipping.edit.template.assignment.category'), - productHeader : QUILocale.get(lg, 'shipping.edit.template.assignment.product.header'), - usageAssignmentProductOnly : QUILocale.get(lg, 'shipping.edit.template.assignment.product.only'), - usageAssignmentProductOnlyText: QUILocale.get(lg, 'shipping.edit.template.assignment.product.only.text'), + productHeader: QUILocale.get(lg, 'shipping.edit.template.assignment.product.header'), + usageAssignmentProductOnly: QUILocale.get(lg, 'shipping.edit.template.assignment.product.only'), + usageAssignmentProductOnlyText: QUILocale.get( + lg, + 'shipping.edit.template.assignment.product.only.text' + ), usageAssignmentProductOnlyDesc: QUILocale.get(lg, 'shipping.edit.template.assignment.product.only.desc') })); @@ -112,13 +115,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ /** * event: on inject */ - $onInject: function () { - var self = this, + $onInject: function() { + var self = this, current = QUILocale.getCurrent(); - var getOptions = function (field) { + var getOptions = function(field) { var entries = field.options.entries, - result = []; + result = []; for (var i in entries) { if (!entries.hasOwnProperty(i)) { @@ -126,7 +129,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ } result.push({ - key : i, + key: i, title: entries[i].title[current] }); } @@ -134,7 +137,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ return result; }; - ShippingRules.getShippingRuleUnitFields().then(function (unitFields) { + ShippingRules.getShippingRuleUnitFields().then(function(unitFields) { var i, len, html, field; var Table = self.getElm().getElement('.unit-table'), @@ -148,8 +151,8 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ html = Mustache.render(templateUnit, { andText: QUILocale.get(lg, 'shipping.edit.template.and'), options: getOptions(field), - id : field.id, - title : field.title + id: field.id, + title: field.title }); new Element('tr', { @@ -159,9 +162,9 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ Tbody.getElements('select').set('disabled', false); Tbody.getElements('input').set('disabled', false); - }).then(function () { + }).then(function() { return ControlUtils.parse(self.getElm()); - }).then(function () { + }).then(function() { ElementsUtils.simulateEvent( self.getElm().getElement('.usage-table thead .data-table-toggle'), 'click' @@ -172,12 +175,12 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ 'click' ); - return new Promise(function (resolve) { + return new Promise(function(resolve) { resolve.delay(500); }); - }).then(function () { + }).then(function() { return QUI.parse(self.getElm()); - }).then(function () { + }).then(function() { // locale for title and working title self.$DataTitle = new InputMultiLang().replaces(self.$Elm.getElement('.shipping-title')); self.$DataWorkingTitle = new InputMultiLang().replaces(self.$Elm.getElement('.shipping-workingTitle')); @@ -195,39 +198,28 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ ); self.$UserGroups = QUI.Controls.getById( - self.$Elm - .getElement('[name="user_groups"]') - .getParent('.qui-elements-select') - .get('data-quiid') + self.$Elm.getElement('[name="user_groups"]').getParent('.qui-elements-select').get('data-quiid') ); self.$Areas = QUI.Controls.getById( - self.$Elm - .getElement('[name="areas"]') - .getParent('.qui-elements-select') - .get('data-quiid') + self.$Elm.getElement('[name="areas"]').getParent('.qui-elements-select').get('data-quiid') ); self.$Articles = QUI.Controls.getById( - self.$Elm - .getElement('[name="articles"]') - .getParent('.qui-elements-select') - .get('data-quiid') + self.$Elm.getElement('[name="articles"]').getParent('.qui-elements-select').get('data-quiid') ); self.$Categories = QUI.Controls.getById( - self.$Elm - .getElement('[name="categories"]') - .get('data-quiid') + self.$Elm.getElement('[name="categories"]').get('data-quiid') ); - return new Promise(function (resolve) { + return new Promise(function(resolve) { require([ 'package/quiqqer/shipping/bin/backend/ShippingRules', 'qui/controls/buttons/Switch', 'qui/utils/Form' - ], function (ShippingRules, QUISwitch, FormUtils) { - ShippingRules.getRule(self.getAttribute('ruleId')).then(function (rule) { + ], function(ShippingRules, QUISwitch, FormUtils) { + ShippingRules.getRule(self.getAttribute('ruleId')).then(function(rule) { self.$DataTitle.setData(rule.title); self.$DataWorkingTitle.setData(rule.workingTitle); @@ -250,7 +242,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ new QUISwitch({ status: parseInt(rule.active), - name : 'status' + name: 'status' }).inject(self.getElm().getElement('.field-shipping-rules')); FormUtils.setDataToForm(rule, self.getElm().getElement('form')); @@ -289,14 +281,14 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ }); }); }); - }).then(function () { + }).then(function() { self.getElm().setStyle('overflow', null); moofx(self.getElm()).animate({ opacity: 1 }, { duration: 200, - callback: function () { + callback: function() { self.getElm().setStyle('opacity', null); self.fireEvent('load', [self]); } @@ -309,7 +301,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ * * @return {Promise} */ - update: function () { + update: function() { if (!this.$DataTitle || !this.$DataWorkingTitle) { return Promise.reject('Missing DOMNode Elements'); } @@ -334,12 +326,12 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [ Label = UnitRows[i].getElement('label'); unitData.push({ - id : parseInt(Label.get('data-id')), - value : Value.value, + id: parseInt(Label.get('data-id')), + value: Value.value, value2: Value2.value, - term : Term.value, - term2 : Term2.value, - unit : Unit.value + term: Term.value, + term2: Term2.value, + unit: Unit.value }); } diff --git a/bin/backend/controls/shippingRules/RuleWindow.js b/bin/backend/controls/shippingRules/RuleWindow.js index 3ef97b41ac02fe0f11c0cf2faea7546cb03b2bdc..7870d8254ed44773cdcf4dc667c04390b99cd95f 100644 --- a/bin/backend/controls/shippingRules/RuleWindow.js +++ b/bin/backend/controls/shippingRules/RuleWindow.js @@ -12,13 +12,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', 'package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', 'Locale' -], function (QUI, QUIConfirm, Rule, QUILocale) { - "use strict"; +], function(QUI, QUIConfirm, Rule, QUILocale) { + 'use strict'; return new Class({ Extends: QUIConfirm, - Type : 'package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', + Type: 'package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', Binds: [ '$onOpen', @@ -27,19 +27,19 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', options: { maxHeight: 800, - maxWidth : 700, + maxWidth: 700, autoclose: false, - ruleId : false + ruleId: false }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ - title : QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'), - icon : 'fa fa-edit', + title: QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'), + icon: 'fa fa-edit', ok_button: { - text : QUILocale.get('quiqqer/shipping', 'window.shipping.rules.button.update'), + text: QUILocale.get('quiqqer/shipping', 'window.shipping.rules.button.update'), textimage: 'fa fa-edit' } }); @@ -47,7 +47,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', this.$Rule = null; this.addEvents({ - onOpen : this.$onOpen, + onOpen: this.$onOpen, onSubmit: this.$onSubmit }); }, @@ -55,7 +55,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', /** * event: on inject */ - $onOpen: function () { + $onOpen: function() { var self = this; this.Loader.show(); @@ -64,7 +64,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', this.$Rule = new Rule({ ruleId: this.getAttribute('ruleId'), events: { - onLoad: function () { + onLoad: function() { self.Loader.hide(); } } @@ -74,13 +74,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow', /** * event: on submit */ - $onSubmit: function () { + $onSubmit: function() { var self = this; this.fireEvent('updateBegin', [this]); this.Loader.show(); - this.$Rule.update().then(function () { + this.$Rule.update().then(function() { self.Loader.hide(); self.fireEvent('updateEnd', [self]); self.close(); diff --git a/bin/backend/controls/shippingRules/ShippingRuleList.js b/bin/backend/controls/shippingRules/ShippingRuleList.js index f8b4ad6a49ac51f4aa093f4d29ae7cb1871a30be..ffe1e6f05fabaa74feeb9f642cb55c19be6920ea 100644 --- a/bin/backend/controls/shippingRules/ShippingRuleList.js +++ b/bin/backend/controls/shippingRules/ShippingRuleList.js @@ -12,15 +12,15 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule 'controls/grid/Grid', 'Locale' -], function (QUI, QUIControl, ShippingRules, RuleWindow, ShippingUtils, Grid, QUILocale) { - "use strict"; +], function(QUI, QUIControl, ShippingRules, RuleWindow, ShippingUtils, Grid, QUILocale) { + 'use strict'; const lg = 'quiqqer/shipping'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleList', + Type: 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleList', options: { multiple: true @@ -36,13 +36,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule 'getSelected' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$Grid = null; this.addEvents({ - onInject : this.$onInject, + onInject: this.$onInject, onDestroy: this.$onDestroy }); }, @@ -50,9 +50,9 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * Resize the element */ - resize: function () { - const size = this.getElm().getSize(); - const width = size.x - 5; + resize: function() { + const size = this.getElm().getSize(); + const width = size.x - 5; const height = size.y; this.$Grid.setWidth(width); @@ -64,113 +64,117 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule * * @return {HTMLDivElement} */ - create: function () { + create: function() { this.$Elm = this.parent(); this.$Elm.addClass('quiqqer-shipping-rule-list'); this.$Elm.setStyles({ height: '100%', - width : '100%' + width: '100%' }); const Container = new Element('div', { styles: { height: '100%', - width : '100%' + width: '100%' } }).inject(this.getElm()); - const size = Container.getSize(), - width = size.x - 5, - height = size.y; + const size = Container.getSize(), + width = size.x - 5, + height = size.y; this.$Grid = new Grid(Container, { - height : height, - width : width, - pagination : true, + height: height, + width: width, + pagination: true, multipleSelection: this.getAttribute('multiple'), - serverSort : true, - buttons : [{ - name : 'create', - text : QUILocale.get('quiqqer/core', 'create'), - textimage: 'fa fa-plus', - events : { - onClick: this.$openCreateDialog - } - }, { - name : 'edit', - text : QUILocale.get('quiqqer/system', 'edit'), - textimage: 'fa fa-edit', - disabled : true, - events : { - onClick: this.$openEditDialog + serverSort: true, + buttons: [ + { + name: 'create', + text: QUILocale.get('quiqqer/core', 'create'), + textimage: 'fa fa-plus', + events: { + onClick: this.$openCreateDialog + } + }, { + name: 'edit', + text: QUILocale.get('quiqqer/system', 'edit'), + textimage: 'fa fa-edit', + disabled: true, + events: { + onClick: this.$openEditDialog + } + }, { + name: 'delete', + text: QUILocale.get('quiqqer/system', 'delete'), + textimage: 'fa fa-trash', + disabled: true, + events: { + onClick: this.$openDeleteDialog + } } - }, { - name : 'delete', - text : QUILocale.get('quiqqer/system', 'delete'), - textimage: 'fa fa-trash', - disabled : true, - events : { - onClick: this.$openDeleteDialog + ], + columnModel: [ + { + header: QUILocale.get('quiqqer/system', 'id'), + dataIndex: 'id', + dataType: 'number', + width: 50 + }, { + header: QUILocale.get('quiqqer/system', 'priority'), + dataIndex: 'priority', + dataType: 'number', + width: 50 + }, { + header: QUILocale.get('quiqqer/system', 'status'), + dataIndex: 'statusNode', + dataType: 'node', + width: 60 + }, { + header: QUILocale.get('quiqqer/system', 'title'), + dataIndex: 'title', + dataType: 'string', + width: 200, + sortable: false + }, { + header: QUILocale.get('quiqqer/system', 'workingtitle'), + dataIndex: 'workingTitle', + dataType: 'string', + width: 200, + sortable: false + }, { + header: QUILocale.get(lg, 'shipping.edit.template.discount'), + dataIndex: 'discount', + dataType: 'number', + width: 100, + className: 'grid-align-right' + }, { + header: QUILocale.get(lg, 'shipping.edit.template.discount.type'), + dataIndex: 'discount_type_text', + dataType: 'string', + width: 200 + }, { + header: QUILocale.get(lg, 'shipping.edit.template.discount.type'), + dataIndex: 'discount_type', + dataType: 'string', + hidden: true } - }], - columnModel : [{ - header : QUILocale.get('quiqqer/system', 'id'), - dataIndex: 'id', - dataType : 'number', - width : 50 - }, { - header : QUILocale.get('quiqqer/system', 'priority'), - dataIndex: 'priority', - dataType : 'number', - width : 50 - }, { - header : QUILocale.get('quiqqer/system', 'status'), - dataIndex: 'statusNode', - dataType : 'node', - width : 60 - }, { - header : QUILocale.get('quiqqer/system', 'title'), - dataIndex: 'title', - dataType : 'string', - width : 200, - sortable : false - }, { - header : QUILocale.get('quiqqer/system', 'workingtitle'), - dataIndex: 'workingTitle', - dataType : 'string', - width : 200, - sortable : false - }, { - header : QUILocale.get(lg, 'shipping.edit.template.discount'), - dataIndex: 'discount', - dataType : 'number', - width : 100, - className: 'grid-align-right' - }, { - header : QUILocale.get(lg, 'shipping.edit.template.discount.type'), - dataIndex: 'discount_type_text', - dataType : 'string', - width : 200 - }, { - header : QUILocale.get(lg, 'shipping.edit.template.discount.type'), - dataIndex: 'discount_type', - dataType : 'string', - hidden : true - }] + ] }); this.$Grid.addEvents({ - onRefresh : this.refresh, - onClick : () => { - let buttons = this.$Grid.getButtons(); + onRefresh: this.refresh, + onClick: () => { + let buttons = this.$Grid.getButtons(); let selected = this.$Grid.getSelectedData(); - const Edit = buttons.filter(function (Btn) { + const Edit = buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'edit'; })[0]; - buttons.filter(function (Btn) { + buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'delete'; })[0].enable(); @@ -191,10 +195,10 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule * * @return */ - refresh: function () { + refresh: function() { this.fireEvent('refreshBegin', this); - ShippingRules.getList(this.$Grid.options).then((result) => { + ShippingRules.getList(this.$Grid.getPaginationData()).then((result) => { this.fireEvent('refresh', [this, result, result.data]); result.data = ShippingUtils.parseRulesDataForGrid(result.data); @@ -202,11 +206,11 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule let buttons = this.$Grid.getButtons(); - buttons.filter(function (Btn) { + buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'delete'; })[0].disable(); - buttons.filter(function (Btn) { + buttons.filter(function(Btn) { return Btn.getAttribute('name') === 'edit'; })[0].disable(); @@ -219,7 +223,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * event: on inject */ - $onInject: function () { + $onInject: function() { this.refresh(); ShippingRules.addEvents({ @@ -232,7 +236,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * @event on Destroy */ - $onDestroy: function () { + $onDestroy: function() { ShippingRules.removeEvents({ onCreate: this.refresh, onUpdate: this.refresh, @@ -245,12 +249,12 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule * * @return {Array} */ - getSelected: function () { + getSelected: function() { if (!this.$Grid) { return []; } - return this.$Grid.getSelectedData().map(function (entry) { + return this.$Grid.getSelectedData().map(function(entry) { return parseInt(entry.id); }); }, @@ -258,7 +262,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * event: open create dialog */ - $openCreateDialog: function () { + $openCreateDialog: function() { this.fireEvent('openCreateRuleWindow', [this]); require([ @@ -277,11 +281,11 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * event: open edit dialog */ - $openEditDialog: function () { + $openEditDialog: function() { new RuleWindow({ ruleId: this.$Grid.getSelectedData()[0].id, events: { - onClose : () => { + onClose: () => { this.refresh(); }, updateEnd: (Win) => { @@ -294,18 +298,18 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * event: open delete dialog */ - $openDeleteDialog: function () { + $openDeleteDialog: function() { let selected = this.$Grid.getSelectedData(); if (!selected.length) { return; } - let ruleIds = selected.map(function (entry) { + let ruleIds = selected.map(function(entry) { return entry.id; }); - let idHtml = selected.map(function (entry) { + let idHtml = selected.map(function(entry) { return '<li>#' + entry.id + ' ' + entry.title + '</li>'; }).join(''); @@ -313,21 +317,21 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule require(['qui/controls/windows/Confirm'], (QUIConfirm) => { new QUIConfirm({ - icon : 'fa fa-trash', - texticon : 'fa fa-trash', - title : QUILocale.get(lg, 'window.shipping.entry.delete.rule.title'), - text : QUILocale.get(lg, 'window.shipping.entry.delete.rule.text'), + icon: 'fa fa-trash', + texticon: 'fa fa-trash', + title: QUILocale.get(lg, 'window.shipping.entry.delete.rule.title'), + text: QUILocale.get(lg, 'window.shipping.entry.delete.rule.text'), information: QUILocale.get(lg, 'window.shipping.entry.delete.rule.information', { ids: idHtml }), - maxHeight : 350, - maxWidth : 700, - autoclose : true, - ok_button : { - text : QUILocale.get(lg, 'window.shipping.entry.delete.rule.delete'), + maxHeight: 350, + maxWidth: 700, + autoclose: true, + ok_button: { + text: QUILocale.get(lg, 'window.shipping.entry.delete.rule.delete'), textimage: 'fa fa-trash' }, - events : { + events: { onSubmit: (Win) => { Win.Loader.show(); diff --git a/bin/backend/controls/shippingRules/ShippingRuleListWindow.js b/bin/backend/controls/shippingRules/ShippingRuleListWindow.js index 0b11f27b63b15291b106e7508746dd5db987baee..9627c597b8c19f26e55b49e44a049aa656eeb971 100644 --- a/bin/backend/controls/shippingRules/ShippingRuleListWindow.js +++ b/bin/backend/controls/shippingRules/ShippingRuleListWindow.js @@ -9,13 +9,13 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleList', 'Locale' -], function (QUI, QUIConfirm, List, QUILocale) { - "use strict"; +], function(QUI, QUIConfirm, List, QUILocale) { + 'use strict'; return new Class({ Extends: QUIConfirm, - Type : 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleListWindow', + Type: 'package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRuleListWindow', Binds: [ '$onOpen', @@ -24,15 +24,15 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule options: { maxHeight: 600, - maxWidth : 600 + maxWidth: 600 }, - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ title: QUILocale.get('quiqqer/shipping', 'window.shipping.rules.title'), - icon : 'fa fa-truck' + icon: 'fa fa-truck' }); this.addEvents({ @@ -43,7 +43,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule /** * event: on inject */ - $onOpen: function () { + $onOpen: function() { var self = this; this.Loader.show(); @@ -51,15 +51,15 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule this.$List = new List({ events: { - onRefresh: function () { + onRefresh: function() { self.Loader.hide(); }, - onOpenCreateRuleWindow: function () { + onOpenCreateRuleWindow: function() { self.close(); }, - onCloseCreateRuleWindow: function () { + onCloseCreateRuleWindow: function() { self.open(); self.$List.refresh(); } @@ -75,7 +75,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/ShippingRule * * @method qui/controls/windows/Confirm#submit */ - submit: function () { + submit: function() { this.fireEvent('submit', [this, this.$List.getSelected()]); if (this.getAttribute('autoclose')) { diff --git a/bin/backend/load.js b/bin/backend/load.js index cfd4a805a40e581f4b65307b5f0d2b4d00ce6666..ad3a56a60dd9312dcb39e7dcb4c0c88fb8a56489 100644 --- a/bin/backend/load.js +++ b/bin/backend/load.js @@ -1,48 +1,49 @@ -require(['qui/QUI'], function (QUI) { - "use strict"; +require(['qui/QUI'], function(QUI) { + 'use strict'; - function getShippingPrice(shippingId) { - return new Promise(function (resolve) { - require(['Ajax'], function (QUIAjax) { + function getShippingPrice(shippingId) + { + return new Promise(function(resolve) { + require(['Ajax'], function(QUIAjax) { QUIAjax.get('package_quiqqer_shipping_ajax_backend_articleList_getShippingPriceFactor', resolve, { - 'package' : 'quiqqer/shipping', + 'package': 'quiqqer/shipping', shippingId: shippingId }); }); }); } - QUI.addEvent('quiqqerErpPriceFactorWindow', function (PriceFactorWindow) { + QUI.addEvent('quiqqerErpPriceFactorWindow', function(PriceFactorWindow) { const Content = PriceFactorWindow.getContent(); const Buttons = Content.getElement('.quiqqer-erp-priceFactors-button'); const ArticleList = PriceFactorWindow.getArticleList(); - require(['Locale'], function (QUILocale) { + require(['Locale'], function(QUILocale) { new Element('button', { 'class': 'qui-button', - html : '<span class="fa fa-truck"></span>', - title : QUILocale.get('quiqqer/shipping', 'add.shipping.priceFactor'), - styles : { - 'float' : 'right', + html: '<span class="fa fa-truck"></span>', + title: QUILocale.get('quiqqer/shipping', 'add.shipping.priceFactor'), + styles: { + 'float': 'right', marginRight: '10px' }, - events : { - click: function (e) { + events: { + click: function(e) { e.stop(); require([ 'package/quiqqer/shipping/bin/backend/controls/ShippingWindow' - ], function (ShippingWindow) { + ], function(ShippingWindow) { new ShippingWindow({ events: { - onSubmit: function (Instance, value) { + onSubmit: function(Instance, value) { PriceFactorWindow.Loader.show(); const currency = ArticleList.getAttribute('currency'); const vat = ArticleList.getVat(); let shippingData; - getShippingPrice(value[0].id).then(function (result) { + getShippingPrice(value[0].id).then(function(result) { shippingData = result; return PriceFactorWindow.getPriceFactorData( @@ -52,20 +53,20 @@ require(['qui/QUI'], function (QUI) { ); }).then((data) => { let priceFactor = { - calculation : 2, + calculation: 2, calculation_basis: 2, - description : shippingData.title, - identifier : "", - index : ArticleList.countPriceFactors(), - nettoSum : data.nettoSum, + description: shippingData.title, + identifier: '', + index: ArticleList.countPriceFactors(), + nettoSum: data.nettoSum, nettoSumFormatted: data.nettoSumFormatted, - sum : data.sum, - sumFormatted : data.sumFormatted, - title : shippingData.title, - value : data.sum, - valueText : data.valueText, - vat : vat, - visible : 1 + sum: data.sum, + sumFormatted: data.sumFormatted, + title: shippingData.title, + value: data.sum, + valueText: data.valueText, + vat: vat, + visible: 1 }; ArticleList.addPriceFactor(priceFactor); diff --git a/bin/backend/utils/ShippingUtils.js b/bin/backend/utils/ShippingUtils.js index 61b21573247dc1ef834539ecfd48dd839890892a..32586526be2255b1b39cba1f11041b47c79ab04e 100644 --- a/bin/backend/utils/ShippingUtils.js +++ b/bin/backend/utils/ShippingUtils.js @@ -4,11 +4,11 @@ */ define('package/quiqqer/shipping/bin/backend/utils/ShippingUtils', [ - 'Locale', + 'Locale' -], function (QUILocale) { +], function(QUILocale) { - "use strict"; + 'use strict'; return { @@ -18,7 +18,7 @@ define('package/quiqqer/shipping/bin/backend/utils/ShippingUtils', [ * @param {Array} rules * @return {Array} */ - parseRulesDataForGrid: function (rules) { + parseRulesDataForGrid: function(rules) { return rules.map((entry) => { return this.parseRuleDataForGrid(entry); }); @@ -30,15 +30,15 @@ define('package/quiqqer/shipping/bin/backend/utils/ShippingUtils', [ * @param {Object} ruleData * @return {Object} */ - parseRuleDataForGrid: function (ruleData) { + parseRuleDataForGrid: function(ruleData) { let current = QUILocale.getCurrent(); - ruleData.title = ruleData.title[current]; + ruleData.title = ruleData.title[current]; ruleData.workingTitle = ruleData.workingTitle[current]; ruleData.statusNode = new Element('span', { 'class': parseInt(ruleData.active) ? 'fa fa-check' : 'fa fa-close', - styles : { + styles: { lineHeight: 26 } }); @@ -48,16 +48,18 @@ define('package/quiqqer/shipping/bin/backend/utils/ShippingUtils', [ 'quiqqer/shipping', 'discount.type.abs' ); - } else if (parseInt(ruleData.discount_type) === 2) { - ruleData.discount_type_text = QUILocale.get( - 'quiqqer/shipping', - 'discount.type.percentageOrder' - ); } else { - ruleData.discount_type_text = QUILocale.get( - 'quiqqer/shipping', - 'discount.type.percentage' - ); + if (parseInt(ruleData.discount_type) === 2) { + ruleData.discount_type_text = QUILocale.get( + 'quiqqer/shipping', + 'discount.type.percentageOrder' + ); + } else { + ruleData.discount_type_text = QUILocale.get( + 'quiqqer/shipping', + 'discount.type.percentage' + ); + } } return ruleData; diff --git a/bin/frontend/controls/ShippingInfo.js b/bin/frontend/controls/ShippingInfo.js index 45aabeca215c36b4c152f3ccaffcf2f3d9a30d8d..ae4ee30d33355e73bc479c9097c00c6c040be15e 100644 --- a/bin/frontend/controls/ShippingInfo.js +++ b/bin/frontend/controls/ShippingInfo.js @@ -11,19 +11,19 @@ define('package/quiqqer/shipping/bin/frontend/controls/ShippingInfo', [ 'qui/controls/Control', 'Locale' -], function (QUI, QUIControl, QUILocale) { - "use strict"; +], function(QUI, QUIControl, QUILocale) { + 'use strict'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/frontend/controls/ShippingInfo', + Type: 'package/quiqqer/shipping/bin/frontend/controls/ShippingInfo', Binds: [ 'showInfo', '$onImport' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.addEvents({ @@ -34,7 +34,7 @@ define('package/quiqqer/shipping/bin/frontend/controls/ShippingInfo', [ /** * event on import */ - $onImport: function () { + $onImport: function() { this.getElm().addEvent('click', this.showInfo); }, @@ -43,21 +43,21 @@ define('package/quiqqer/shipping/bin/frontend/controls/ShippingInfo', [ * * @param event */ - showInfo: function (event) { + showInfo: function(event) { event.stop(); require([ 'qui/controls/windows/Popup' - ], function (QUIPopup) { + ], function(QUIPopup) { new QUIPopup({ - 'maxWidth' : 700, + 'maxWidth': 700, 'maxHeight': 600, - 'icon' : 'fa fa-truck', - 'title' : QUILocale.get('quiqqer/shipping', 'frontend.shippingInfo.popup.title'), - 'content' : QUILocale.get('quiqqer/shipping', 'frontend.shippingInfo.popup.content'), - draggable : false, - resizable : false, - buttons : false + 'icon': 'fa fa-truck', + 'title': QUILocale.get('quiqqer/shipping', 'frontend.shippingInfo.popup.title'), + 'content': QUILocale.get('quiqqer/shipping', 'frontend.shippingInfo.popup.content'), + draggable: false, + resizable: false, + buttons: false }).open(); }); } diff --git a/bin/frontend/controls/order/Shipping.js b/bin/frontend/controls/order/Shipping.js index e8ffc7d9fa46c4f881e5c96ffea43b0b9835d01d..e07740726d12a1faf929274a0b437d705879e5da 100644 --- a/bin/frontend/controls/order/Shipping.js +++ b/bin/frontend/controls/order/Shipping.js @@ -12,20 +12,20 @@ define('package/quiqqer/shipping/bin/frontend/controls/order/Shipping', [ 'qui/QUI', 'qui/controls/Control' -], function (QUI, QUIControl) { - "use strict"; +], function(QUI, QUIControl) { + 'use strict'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/shipping/bin/frontend/controls/order/Shipping', + Type: 'package/quiqqer/shipping/bin/frontend/controls/order/Shipping', Binds: [ '$onImport', '$onClick' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.$Input = null; @@ -38,7 +38,7 @@ define('package/quiqqer/shipping/bin/frontend/controls/order/Shipping', [ /** * event: on import */ - $onImport: function () { + $onImport: function() { this.getElm().addEvent('click', this.$onClick); this.$Input = this.getElm().getElement('input'); @@ -51,15 +51,13 @@ define('package/quiqqer/shipping/bin/frontend/controls/order/Shipping', [ /** * event: on click */ - $onClick: function (event) { + $onClick: function(event) { if (event.target.nodeName !== 'INPUT') { event.stop(); } - this.getElm() - .getParent('.quiqqer-order-step-shipping-list') - .getElements('.quiqqer-order-step-shipping-list-entry') - .removeClass('selected'); + this.getElm().getParent('.quiqqer-order-step-shipping-list').getElements( + '.quiqqer-order-step-shipping-list-entry').removeClass('selected'); this.$Input.checked = true; this.getElm().addClass('selected'); diff --git a/captainhook.json b/captainhook.json new file mode 100644 index 0000000000000000000000000000000000000000..3702e1a358868bedd5ff4c7eae40bb1abb589267 --- /dev/null +++ b/captainhook.json @@ -0,0 +1,13 @@ +{ + "pre-commit": { + "enabled": true, + "actions": [ + { + "action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting" + }, + { + "action": "composer test" + } + ] + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 6cf029508a02e4c21f40bbd1de76fb80f7f5c8b9..940e7a6c3b59c39fb69919a23feff8963df742b5 100644 --- a/composer.json +++ b/composer.json @@ -1,38 +1,80 @@ { - "name": "quiqqer/shipping", - "type": "quiqqer-plugin", - "description": "Provided the shipping management for QUIQQER. Can manage shipping methods", - "license": [ - "GPL-3.0+", - "PCSG QEL-1.0" - ], - "authors": [ - { - "name": "Henning Leutz", - "email": "leutz@pcsg.de", - "homepage": "https://www.pcsg.de", - "role": "Developer" + "name": "quiqqer/shipping", + "type": "quiqqer-plugin", + "description": "Provided the shipping management for QUIQQER. Can manage shipping methods", + "license": [ + "GPL-3.0+", + "PCSG QEL-1.0" + ], + "authors": [ + { + "name": "Henning Leutz", + "email": "leutz@pcsg.de", + "homepage": "https://www.pcsg.de", + "role": "Developer" + }, + { + "name": "Moritz Scholz", + "email": "scholz@pcsg.de", + "homepage": "https://www.pcsg.de", + "role": "Developer" + } + ], + "support": { + "email": "support@pcsg.de" }, - { - "name": "Moritz Scholz", - "email": "scholz@pcsg.de", - "homepage": "https://www.pcsg.de", - "role": "Developer" - } - ], - "support": { - "email": "support@pcsg.de" - }, - "require": { - "quiqqer/core": "^2", - "quiqqer/erp": "^3.2", - "quiqqer/areas": "^2", - "quiqqer/order": "^2", - "quiqqer/products": "^2" - }, - "autoload": { - "psr-4": { - "QUI\\ERP\\Shipping\\": "src/QUI/ERP/Shipping" + "require": { + "quiqqer/core": "^2", + "quiqqer/erp": "^3.2", + "quiqqer/areas": "^2", + "quiqqer/order": "^2", + "quiqqer/products": "^2" + }, + "autoload": { + "psr-4": { + "QUI\\ERP\\Shipping\\": "src/QUI/ERP/Shipping" + } + }, + "scripts": { + "test": [ + "@dev:lint", + "@dev:phpunit" + ], + "dev:phpunit": "./tools/phpunit", + "dev:lint": [ + "@dev:lint:phpstan", + "@dev:lint:style" + ], + "dev:lint:phpstan": "./tools/phpstan", + "dev:lint:style": "./tools/phpcs", + "dev:lint:style:fix": "./tools/phpcbf", + "dev:init": [ + "@dev:init:check-requirements", + "@dev:init:tools", + "@dev:init:git-hooks" + ], + "dev:init:check-requirements": [ + "which composer > /dev/null || (echo 'Error: composer has to be globally installed'; exit 1)", + "which phive > /dev/null || (echo 'Error: PHIVE has to be globally installed'; exit 1)" + ], + "dev:init:tools": "phive install --temporary", + "dev:init:git-hooks": "./tools/captainhook install --only-enabled --force" + }, + "scripts-aliases": { + "test": [ + "dev:test" + ] + }, + "scripts-descriptions": { + "test": "Runs linting, static analysis, and unit tests.", + "dev:phpunit": "Run PHPUnit test suites", + "dev:lint": "Run PHPStan and code style check", + "dev:lint:phpstan": "Run PHPStan", + "dev:lint:style": "Run code style check (PHP_CodeSniffer)", + "dev:lint:style:fix": "Try to fix code style errors automatically", + "dev:init": "Initialize the developer tooling (tools and git hooks)", + "dev:init:check-requirements": "Check if the necessary requirements are met", + "dev:init:tools": "Install all developer tools (requires PHIVE)", + "dev:init:git-hooks": "Install all git hooks (may require tools to be installed)" } - } -} +} \ No newline at end of file diff --git a/locale.xml b/locale.xml index 12b2fb5f1dcb2e64405dbdf86a5d8e1931b15605..4b44ea5168a17951d1bc3113328b29961e988bdf 100644 --- a/locale.xml +++ b/locale.xml @@ -541,8 +541,8 @@ </locale> <locale name="shipping.status.notification.subject"> - <de><![CDATA[Änderung Ihrer Bestellung [orderNo]]]></de> - <en><![CDATA[Change of your order [orderNo]]]></en> + <de><![CDATA[Änderung Ihrer Bestellung [prefixedNumber]]]></de> + <en><![CDATA[Change of your order [prefixedNumber]]]></en> </locale> <locale name="shipping.status.notification.template" html="true"> <de><![CDATA[ diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..d48084fbdc86a2dbfb78dd89ab2e0b0ff2322ba7 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<ruleset> + <!-- Use PSR-12 ruleset --> + <rule ref="PSR12"/> + + <!-- Only scan *.php files --> + <arg name="extensions" value="php"/> + + <!-- Ignore warnings --> + <arg name="warning-severity" value="0"/> + + <!-- Process 64 (or number of CPU cores) files in parallel --> + <arg name="parallel" value="64"/> + + <!-- Output relative file paths, by setting the current folder as the basepath --> + <arg name="basepath" value="."/> + + <!-- Show colored output --> + <arg name="colors"/> + + <!-- Scan everything in the current folder --> + <file>.</file> +</ruleset> diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8fb0e0c1fd0a752576f1be8c94d6c729b2be9921 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -0,0 +1,261 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(array, array\\)\\: int, Closure\\(mixed, mixed\\)\\: bool given\\.$#" + count: 1 + path: ajax/backend/rules/getRules.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:setTitle\\(\\)\\.$#" + count: 1 + path: ajax/backend/rules/update.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:setWorkingTitle\\(\\)\\.$#" + count: 1 + path: ajax/backend/rules/update.php + + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\Invoice\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceView\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Order\\\\AbstractOrder\\:\\:save\\(\\)\\.$#" + count: 5 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Offset 'options' does not exist on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\}\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Offset 'options' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) does not exist\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Offset 'public' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) always exists and is not falsy\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Offset 'standard' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) always exists and is not falsy\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Parameter \\#1 \\$Locale of method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:toPriceFactor\\(\\) expects null, QUI\\\\Locale given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Parameter \\$Offer of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerOffersCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Parameter \\$Sales of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerSalesOrdersCreated\\(\\) has invalid type QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Parameter \\$TemporaryInvoice of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerInvoiceTemporaryInvoiceCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/EventHandler.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Order\\\\AbstractOrder\\:\\:save\\(\\)\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Order/Shipping.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimeFrontendView\\:\\:getValue\\(\\) should return array\\|string but returns null\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php + + - + message: "#^Variable \\$Field in PHPDoc tag @var does not match assigned variable \\$value\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php + + - + message: "#^Return type \\(QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimeFrontendView\\) of method QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimePeriod\\:\\:getFrontendView\\(\\) should be compatible with return type \\(QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\UnitSelectFrontendView\\) of method QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\TimePeriod\\:\\:getFrontendView\\(\\)$#" + count: 1 + path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Rules\\\\Factory\\:\\:createChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule but returns QUI\\\\CRUD\\\\Child\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Rules/Factory.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Rules\\\\Factory\\:\\:getChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Rules/Factory.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\ErpEntityInterface\\:\\:count\\(\\)\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Rules/ShippingRule.php + + - + message: "#^Parameter \\#1 \\$precision of method QUI\\\\ERP\\\\Accounting\\\\CalculationValue\\:\\:precision\\(\\) expects bool, int given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Rules/ShippingRule.php + + - + message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:setValue\\(\\) expects string\\|null, int given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/ShippingStatus/Factory.php + + - + message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:del\\(\\) expects string\\|null, int given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/ShippingStatus/Handler.php + + - + message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:setValue\\(\\) expects string\\|null, int given\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/ShippingStatus/Handler.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Tracking/Tracking.php + + - + message: "#^Call to an undefined method QUI\\\\CRUD\\\\Child\\:\\:getShippingType\\(\\)\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Types/Factory.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\Factory\\:\\:createChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/Factory.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\Factory\\:\\:getChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/Factory.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:canUsedIn\\(\\)\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getPriority\\(\\)\\.$#" + count: 2 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:isValid\\(\\)\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + + - + message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:noRulesAfter\\(\\)\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + + - + message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:getShippingRules\\(\\) should return array\\<QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule\\> but returns array\\<int\\<0, max\\>, QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\>\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + + - + message: "#^Parameter \\#1 \\$Rule of method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:addShippingRule\\(\\) expects QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule, QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry given\\.$#" + count: 1 + path: src/QUI/ERP/Shipping/Types/ShippingEntry.php diff --git a/phpstan.dist.neon b/phpstan.dist.neon index a545a041a3c5b0c758d99bf8c1c49b2a83252eaa..18db987295f4cd08f7b698474102b19b6ecf75da 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 1 + level: 5 paths: - src - ajax diff --git a/phpunit.dist.xml b/phpunit.dist.xml new file mode 100644 index 0000000000000000000000000000000000000000..f6c7becf0c12757beb871a9333e2d81e02aa7cae --- /dev/null +++ b/phpunit.dist.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit bootstrap="tests/phpunit-bootstrap.php"> + <testsuites> + <testsuite name="Tests"> + <directory>tests/</directory> + </testsuite> + </testsuites> +</phpunit> diff --git a/src/QUI/ERP/Shipping/Debug.php b/src/QUI/ERP/Shipping/Debug.php index 0b0bf0ade5c9aa9bce18bf30c94f39d17efa19d7..24cc099ef15c2a33dc4bb8ebed0d0adf4138e268 100644 --- a/src/QUI/ERP/Shipping/Debug.php +++ b/src/QUI/ERP/Shipping/Debug.php @@ -12,6 +12,7 @@ use QUI\ERP\Shipping\Types\ShippingEntry; use function class_exists; +use function defined; /** * Class Debug @@ -122,6 +123,10 @@ public static function generateShippingEntryDebuggingLog( $result, $debuggingLog ): void { + if (defined('QUIQQER_AJAX')) { + return; + } + if (self::isRuleAlreadyDebugged($Entry->getId())) { return; } diff --git a/src/QUI/ERP/Shipping/EventHandler.php b/src/QUI/ERP/Shipping/EventHandler.php index 1813d7829bf47e0abb40bbb0d9a6d0ff6080238d..a19143ed3d9656b7838f9ecbcd3baecd9d4537f5 100644 --- a/src/QUI/ERP/Shipping/EventHandler.php +++ b/src/QUI/ERP/Shipping/EventHandler.php @@ -19,6 +19,8 @@ use QUI\Smarty\Collector; use function array_merge; +use function class_exists; +use function count; use function explode; use function json_decode; use function method_exists; @@ -296,6 +298,15 @@ public static function onQuiqqerOrderOrderProcessCheckoutOutput( return; } + $Customer = $Order->getCustomer(); + + if ( + class_exists('QUI\ERP\Order\Guest\GuestOrderUser') + && $Customer->getId() === 6 + ) { + return; + } + $DeliveryAddress = $Order->getDeliveryAddress(); if ($DeliveryAddress->getId() === 0 || $DeliveryAddress->getUUID() == 0) { @@ -538,9 +549,14 @@ public static function onQuiqqerProductsPriceEnd(Collector $Collector, QUI\ERP\P public static function onQuiqqerOrderFactoryCreate(AbstractOrder $Order): void { try { - self::addDefaultShipping($Order->getArticles()); + $Process = new QUI\ERP\Process($Order->getGlobalProcessId()); - $Order->update(QUI::getUsers()->getSystemUser()); + // wenn verknüpfte entities, dann nicht standard versand setzen + // by mor + if (count($Process->getEntities()) <= 1) { + self::addDefaultShipping($Order->getArticles()); + $Order->update(QUI::getUsers()->getSystemUser()); + } } catch (QUI\Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); } @@ -560,9 +576,15 @@ public static function onQuiqqerInvoiceTemporaryInvoiceCreated( } try { - self::addDefaultShipping($TemporaryInvoice->getArticles()); - $TemporaryInvoice->addCustomDataEntry(self::DEFAULT_SHIPPING_TIME_KEY, time()); - $TemporaryInvoice->update(QUI::getUsers()->getSystemUser()); + $Process = new QUI\ERP\Process($TemporaryInvoice->getGlobalProcessId()); + + // wenn verknüpfte entities, dann nicht standard versand setzen + // by mor + if (count($Process->getEntities()) <= 1) { + self::addDefaultShipping($TemporaryInvoice->getArticles()); + $TemporaryInvoice->addCustomDataEntry(self::DEFAULT_SHIPPING_TIME_KEY, time()); + $TemporaryInvoice->update(QUI::getUsers()->getSystemUser()); + } } catch (QUI\Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); } @@ -581,9 +603,15 @@ public static function onQuiqqerOffersCreated(AbstractOffer $Offer): void } try { - self::addDefaultShipping($Offer->getArticles()); - $Offer->addCustomDataEntry(self::DEFAULT_SHIPPING_TIME_KEY, time()); - $Offer->update(QUI::getUsers()->getSystemUser()); + $Process = new QUI\ERP\Process($Offer->getGlobalProcessId()); + + // wenn verknüpfte entities, dann nicht standard versand setzen + // by mor + if (count($Process->getEntities()) <= 1) { + self::addDefaultShipping($Offer->getArticles()); + $Offer->addCustomDataEntry(self::DEFAULT_SHIPPING_TIME_KEY, time()); + $Offer->update(QUI::getUsers()->getSystemUser()); + } } catch (Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); } @@ -598,8 +626,14 @@ public static function onQuiqqerOffersCreated(AbstractOffer $Offer): void public static function onQuiqqerSalesOrdersCreated(SalesOrder $Sales): void { try { - self::addDefaultShipping($Sales->getArticles()); - $Sales->update(); + $Process = new QUI\ERP\Process($Sales->getGlobalProcessId()); + + // wenn verknüpfte entities, dann nicht standard versand setzen + // by mor + if (count($Process->getEntities()) <= 1) { + self::addDefaultShipping($Sales->getArticles()); + $Sales->update(); + } } catch (QUI\Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); } diff --git a/src/QUI/ERP/Shipping/Order/Shipping.php b/src/QUI/ERP/Shipping/Order/Shipping.php index 52bfd0457ee192519f793620f903a5a8d4dcf59c..63c5807997966fec4022ca1d3685e6cf7745b4bc 100644 --- a/src/QUI/ERP/Shipping/Order/Shipping.php +++ b/src/QUI/ERP/Shipping/Order/Shipping.php @@ -11,6 +11,7 @@ use function array_merge; use function count; +use function defined; use function dirname; use function implode; @@ -70,7 +71,7 @@ public function getBody(): string $shippingList = $this->getValidShipping(); // debugging logger - if (QUI\ERP\Shipping\Shipping::getInstance()->debuggingEnabled()) { + if (QUI\ERP\Shipping\Shipping::getInstance()->debuggingEnabled() && !defined('QUIQQER_AJAX')) { QUI\ERP\Shipping\Debug::clearLogStock(); $debugStack = []; diff --git a/src/QUI/ERP/Shipping/Rules/ShippingRule.php b/src/QUI/ERP/Shipping/Rules/ShippingRule.php index b86b833c6529d79b61cae6d78c1d1b23217c5832..7d67255c374537c03a206516e61718bfecd72dad 100644 --- a/src/QUI/ERP/Shipping/Rules/ShippingRule.php +++ b/src/QUI/ERP/Shipping/Rules/ShippingRule.php @@ -8,6 +8,7 @@ use QUI; use QUI\CRUD\Factory; +use QUI\ERP\Address; use QUI\ERP\Areas\Utils as AreaUtils; use QUI\ERP\Products\Handler\Fields; use QUI\ERP\Products\Handler\Products; @@ -333,11 +334,15 @@ public function canUsedBy(QUI\Interfaces\Users\User $User): bool /** * Is this shipping rule allowed for this address? * - * @param QUI\ERP\Address|QUI\Users\Address $Address + * @param Address|QUI\Users\Address|null $Address * @return bool */ - public function canUsedWithAddress(QUI\ERP\Address|QUI\Users\Address $Address): bool + public function canUsedWithAddress(QUI\ERP\Address|QUI\Users\Address $Address = null): bool { + if (!$Address) { + return false; + } + $areasValue = $this->getAttribute('areas'); if ($areasValue) { diff --git a/src/QUI/ERP/Shipping/Shipping.php b/src/QUI/ERP/Shipping/Shipping.php index 1888cec761cc8906c90ecdc147a6558ee7224bff..70bdd4252b8ee6e829b1ced28e68e6fa3e827be7 100644 --- a/src/QUI/ERP/Shipping/Shipping.php +++ b/src/QUI/ERP/Shipping/Shipping.php @@ -541,7 +541,7 @@ public function getVat(QUI\ERP\ErpEntityInterface $ErpEntity): mixed /** * Notify customer about an Order status change (via e-mail) * - * @param QUI\ERP\Order\AbstractOrder $Order + * @param QUI\ERP\Order\AbstractOrder $ErpEntity * @param int $statusId * @param string|null $message (optional) - Custom notification message [default: default status change message] * @return void @@ -549,16 +549,16 @@ public function getVat(QUI\ERP\ErpEntityInterface $ErpEntity): mixed * @throws QUI\Exception */ public function sendStatusChangeNotification( - AbstractOrder $Order, + ErpEntityInterface $ErpEntity, int $statusId, string $message = null ): void { - $Customer = $Order->getCustomer(); + $Customer = $ErpEntity->getCustomer(); $customerEmail = $Customer->getAttribute('email'); if (empty($customerEmail)) { QUI\System\Log::addWarning( - 'Status change notification for order #' . $Order->getPrefixedId() . ' cannot be sent' + 'Status change notification for erp entity #' . $ErpEntity->getPrefixedNumber() . ' cannot be sent' . ' because customer #' . $Customer->getUUID() . ' has no e-mail address.' ); @@ -567,15 +567,15 @@ public function sendStatusChangeNotification( if (empty($message)) { $Status = ShippingStatus\Handler::getInstance()->getShippingStatus($statusId); - $message = $Status->getStatusChangeNotificationText($Order); + $message = $Status->getStatusChangeNotificationText($ErpEntity); } $Mailer = new QUI\Mail\Mailer(); - $Locale = $Order->getCustomer()->getLocale(); + $Locale = $ErpEntity->getCustomer()->getLocale(); $Mailer->setSubject( $Locale->get('quiqqer/shipping', 'shipping.status.notification.subject', [ - 'orderNo' => $Order->getPrefixedId() + 'prefixedNumber' => $ErpEntity->getPrefixedNumber() ]) ); @@ -584,7 +584,10 @@ public function sendStatusChangeNotification( try { $Mailer->send(); - $Order->addStatusMail($message); + + if (method_exists($ErpEntity, 'addStatusMail')) { + $ErpEntity->addStatusMail($message); + } } catch (\Exception $Exception) { QUI\System\Log::writeException($Exception); } diff --git a/src/QUI/ERP/Shipping/ShippingStatus/Handler.php b/src/QUI/ERP/Shipping/ShippingStatus/Handler.php index 7fbf919d078931833827e670eed2afe7bab7328c..f4de39755edaab9c1ba5ac3ae0b1fa3660a008a7 100644 --- a/src/QUI/ERP/Shipping/ShippingStatus/Handler.php +++ b/src/QUI/ERP/Shipping/ShippingStatus/Handler.php @@ -267,21 +267,24 @@ public function createNotificationTranslations(int $id): void /** * Notify customer about an Order status change (via e-mail) * - * @param AbstractOrder $Order + * @param AbstractOrder $ErpEntity * @param int $statusId * @param string|null $message (optional) - Custom notification message [default: default status change message] * @return void * * @throws QUI\Exception */ - public function sendStatusChangeNotification(AbstractOrder $Order, int $statusId, string $message = null): void - { - $Customer = $Order->getCustomer(); + public function sendStatusChangeNotification( + QUI\ERP\ErpEntityInterface $ErpEntity, + int $statusId, + string $message = null + ): void { + $Customer = $ErpEntity->getCustomer(); $customerEmail = $Customer->getAttribute('email'); if (empty($customerEmail)) { QUI\System\Log::addWarning( - 'Status change notification for order #' . $Order->getPrefixedId() . ' cannot be sent' + 'Status change notification for entity #' . $ErpEntity->getPrefixedNumber() . ' cannot be sent' . ' because customer #' . $Customer->getUUID() . ' has no e-mail address.' ); @@ -290,15 +293,15 @@ public function sendStatusChangeNotification(AbstractOrder $Order, int $statusId if (empty($message)) { $Status = $this->getShippingStatus($statusId); - $message = $Status->getStatusChangeNotificationText($Order); + $message = $Status->getStatusChangeNotificationText($ErpEntity); } $Mailer = new QUI\Mail\Mailer(); - $Locale = $Order->getCustomer()->getLocale(); + $Locale = $ErpEntity->getCustomer()->getLocale(); $Mailer->setSubject( $Locale->get('quiqqer/shipping', 'shipping.status.notification.subject', [ - 'orderNo' => $Order->getPrefixedId() + 'prefixedNumber' => $ErpEntity->getPrefixedNumber() ]) ); @@ -307,7 +310,7 @@ public function sendStatusChangeNotification(AbstractOrder $Order, int $statusId try { $Mailer->send(); - $Order->addStatusMail($message); + $ErpEntity->addStatusMail($message); } catch (\Exception $Exception) { QUI\System\Log::writeException($Exception); } diff --git a/src/QUI/ERP/Shipping/Types/ShippingEntry.php b/src/QUI/ERP/Shipping/Types/ShippingEntry.php index bb558f96c7fe906aa775c37d58c705ad06fbd1b3..50104b96fa12d0279ecc6f7291b549aa8dfe27a4 100644 --- a/src/QUI/ERP/Shipping/Types/ShippingEntry.php +++ b/src/QUI/ERP/Shipping/Types/ShippingEntry.php @@ -721,7 +721,7 @@ public function getShippingRules(): array } // debug shipping entry / rules - if ($debugging) { + if ($debugging && !defined('QUIQQER_AJAX')) { QUI\ERP\Shipping\Debug::enable(); QUI\ERP\Shipping\Debug::generateShippingEntryDebuggingLog($this, $result, $debuggingLog); QUI\ERP\Shipping\Debug::disable(); diff --git a/tests/phpunit-bootstrap.php b/tests/phpunit-bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..eca92fd67bed8ae4ec424ed82d300119d792f042 --- /dev/null +++ b/tests/phpunit-bootstrap.php @@ -0,0 +1,11 @@ +<?php + +if (!defined('QUIQQER_SYSTEM')) { + define('QUIQQER_SYSTEM', true); +} + +if (!defined('QUIQQER_AJAX')) { + define('QUIQQER_AJAX', true); +} + +require_once __DIR__ . '/../../../../bootstrap.php';