-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
179 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* UI component to render cell data as a decimal number. | ||
* | ||
* Based on "./magento/module-ui/view/base/web/js/grid/columns/column.js" | ||
*/ | ||
define([ | ||
"Magento_Ui/js/grid/columns/column" | ||
], function (Column) { | ||
"use strict"; | ||
/** | ||
* Formatting function. | ||
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat | ||
*/ | ||
const language = 'en-US'; | ||
const fraction = 2; | ||
const options = { | ||
minimumFractionDigits: fraction, | ||
maximumFractionDigits: fraction | ||
}; | ||
const formatter = new Intl.NumberFormat(language, options); | ||
const fnFormat = function (num) { | ||
const value = Number(num); | ||
const result = formatter.format(value); | ||
return result; | ||
} | ||
|
||
/** | ||
* Magento UI component based on 'Column': | ||
*/ | ||
return Column.extend({ | ||
defaults: { | ||
bodyTmpl: 'Flancer32_Base/grid/cells/number', | ||
}, | ||
|
||
/** | ||
* Override parent function to format numeric value. | ||
* | ||
* @param {Object} row | ||
* @returns {String} | ||
*/ | ||
getLabel: function (row) { | ||
const num = Column.prototype.getLabel.apply(this, [row]); | ||
return fnFormat(num); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* UI component to render cell data as an integer number. | ||
* | ||
* Based on "./magento/module-ui/view/base/web/js/grid/columns/column.js" | ||
*/ | ||
define([ | ||
"Magento_Ui/js/grid/columns/column" | ||
], function (Column) { | ||
"use strict"; | ||
/** | ||
* Magento UI component based on "Column": | ||
*/ | ||
return Column.extend({ | ||
defaults: { | ||
bodyTmpl: "Flancer32_Base/grid/cells/number", | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Base UI component to render row data as link to other adminhtml routes. | ||
*/ | ||
define([ | ||
"Magento_Ui/js/grid/columns/column", | ||
"mageUtils" | ||
], function (Column, utils) { | ||
"use strict"; | ||
|
||
|
||
/** | ||
* Remove route part from BASE URL (http://.../admin/customer/ => http://.../admin). | ||
* | ||
* BASE_URL see at "./module-backend/view/adminhtml/templates/page/js/require_js.phtml" | ||
*/ | ||
const ROOT_URL = function () { | ||
const length = BASE_URL.length; | ||
const lastCharOff = BASE_URL.substr(0, length - 1); | ||
const lastSlashPos = lastCharOff.lastIndexOf('/'); | ||
const result = BASE_URL.substr(0, lastSlashPos); | ||
return result; | ||
}(); | ||
|
||
return Column.extend({ | ||
defaults: { | ||
/** | ||
* Replace idAttrName & route in children. | ||
*/ | ||
/* name of the identification attribute */ | ||
idAttrName: "customerId", | ||
/* route part to the page */ | ||
route: "/customer/index/edit/id/", | ||
bodyTmpl: "ui/grid/cells/link" | ||
}, | ||
|
||
/** | ||
* Returns link to given record. | ||
* | ||
* @param {object} record - grid row data. | ||
* @returns {string} | ||
*/ | ||
getLink: function (record) { | ||
const id = utils.nested(record, this.idAttrName); | ||
const result = ROOT_URL + this.route + id; | ||
return result; | ||
}, | ||
|
||
/** | ||
* Check if link attribute exists in record. | ||
* | ||
* @param {object} record - grid row data. | ||
* @returns {boolean} | ||
*/ | ||
isLink: function (record) { | ||
const result = !!utils.nested(record, this.idAttrName); | ||
return result; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!-- Template for grid cells that contain numeric info (right justified) --> | ||
<div class="data-grid-cell-content"> | ||
<div style="float: right" text="$col.getLabel($row())"/> | ||
</div> |