Article
How do I make the elements of the [Addresses] detail on an account page uneditable?
17:52 Jun 14, 2018
Question
How do I make all elements of the [Addresses] detail on an account page uneditable? Version 7.2.0.
Answer
Below you can find an example of implementing the function for the AddressDetail schema:
1) You can add a new enableDetailControls method:
this.methods.enableDetailControls = function(viewConfig, enabled) { if (!viewConfig.items) { return; } viewConfig.items.forEach(function(item) { item.enabled = enabled; }, this); };
2) Call this method within the "getCustomItemView" method after complete generation of the view configuration and add the necessary conditions. For example, in front of the "return viewConfig" string:
this.methods.getCustomItemView = function(viewModel, itemKey, action, types, itemViewModel) { var viewConfig = {}; ... var enableControls = (action === "edit") && (/*любые другие условия*/); this.enableDetailControls(viewConfig, enableControls); return viewConfig; };
It is recommended to receive the values of the necessary conditions before this, since after you execute getCustomItemView, the control function will be passed to the base detail module (DetailModule), where the model connection to the view and detail rendering are performed.