Is it possible so that a new line is added to the product detail every time enter is pressed?
This way adding products is greatly sped up (compared to clicking + and going through the Product page).
Does anybody know how to achieve this?
Like
Turns out using plain enter would conflict with the need of the dropdown lookup. I picked alt+enter. This is how:
define("OrderProductDetailV2", [], function() { return { entitySchemaName: "OrderProduct", messages: { }, attributes: { }, methods: { /** * add Alt+Enter as a shortcut to an active record */ initActiveRowKeyMap: function (keyMap) { keyMap.push({ key: Ext.EventObject.ENTER, alt: true, defaultEventAction: "preventDefault", fn: this.onAltEnterKeyPressed, scope: this }); this.callParent(arguments); }, /** * Enable the logic for saving the current row and * creating a new one */ onAltEnterKeyPressed: function () { var activeRow = this.getActiveRow(); this.unfocusRowControls(activeRow); Terrasoft.chain(function(next) { this.saveRowChanges(activeRow, next); }, function(next) { this.activeRowSaved(activeRow, next); }, function() { this.addRecord(); }, this); } }, diff: /**SCHEMA_DIFF*/[ // this overides the little + button to skip the OrderProductPage { "operation": "merge", "name": "AddRecordButton", "values": { "click": {"bindTo": "addRecord"} } } ]/**SCHEMA_DIFF*/ }; });
Turns out using plain enter would conflict with the need of the dropdown lookup. I picked alt+enter. This is how:
define("OrderProductDetailV2", [], function() { return { entitySchemaName: "OrderProduct", messages: { }, attributes: { }, methods: { /** * add Alt+Enter as a shortcut to an active record */ initActiveRowKeyMap: function (keyMap) { keyMap.push({ key: Ext.EventObject.ENTER, alt: true, defaultEventAction: "preventDefault", fn: this.onAltEnterKeyPressed, scope: this }); this.callParent(arguments); }, /** * Enable the logic for saving the current row and * creating a new one */ onAltEnterKeyPressed: function () { var activeRow = this.getActiveRow(); this.unfocusRowControls(activeRow); Terrasoft.chain(function(next) { this.saveRowChanges(activeRow, next); }, function(next) { this.activeRowSaved(activeRow, next); }, function() { this.addRecord(); }, this); } }, diff: /**SCHEMA_DIFF*/[ // this overides the little + button to skip the OrderProductPage { "operation": "merge", "name": "AddRecordButton", "values": { "click": {"bindTo": "addRecord"} } } ]/**SCHEMA_DIFF*/ }; });
Hi Jonas,
To avoid opening the "Products" section and simply switch to a new line, you can press the "Tab" button and add a new product to the detail, choosing it from an appeared lookup.
Regards,
Anastasiia
That is technically possible, but not what the customer requested.
Jonas,
Sure, there is one more option you can use.
1. Create a replacing client module schema for the detail schema ("ProductDetailV2", UIv2 package). Here is the article on how you can do it:
https://academy.creatio.com/documents/technic-sdk/7-16/creating-custom-…
2. In a new replacing client schema, please set the parent object (Base detail - Products ( UIv2 )) and insert the code below:
define("ProductDetailV2", ["terrasoft", "ConfigurationEnums", "MaskHelper", "ConfigurationGrid", "ConfigurationGridGenerator", "ConfigurationGridUtilities"], function(Terrasoft, enums, MaskHelper) { return { mixins: {}, attributes: {}, messages: {}, methods: {}, diff: /**SCHEMA_DIFF*/[ { "operation": "merge", "name": "AddRecordButton", "values": { "click":{"bindTo":"addRow"} } } ]/**SCHEMA_DIFF*/ }; });
3. Save your changes and hard-reload the page. Now, you are able to add a new line by clicking plus.
Regards,
Anastasiia
True, but that does not enable adding a new line through a shortcut when in edit mode, which was the original question, that I solved per my answer above.