How can I hide adding buttons for some section types?

Question

How can I hide the [Add] buttons for some section types?

Answer

Create the section replacing schema:

define("DocumentSectionV2", ["VisaHelper", "ConfigurationConstants", "BaseFiltersGenerateModule"],
    function(VisaHelper, ConfigurationConstants, BaseFiltersGenerateModule) {
        return {
            entitySchemaName: "Document",
            methods: {
                initEditPages: function() {
                    var enabledEditPages = new this.Terrasoft.Collection();
                    this.callParent(arguments);
                    var editPages = this.get("EditPages");
                    var items = editPages.getItems();
                    for (var i = 0; i < items.length; i++) {
                        if (items[i].values.Id !== "2015b538-40d0-4cbf-9301-fa8cae37ae94") {
                            enabledEditPages.add(items[i]);
                        }
                    }
                    this.set("EnabledEditPages", enabledEditPages);
                }
            },
            diff: /**SCHEMA_DIFF*/[
                {
                    "operation": "merge",
                    "name": "SeparateModeAddRecordButton",
                    "parentName": "SeparateModeActionButtonsLeftContainer",
                    "propertyName": "items",
                    "values": {
                        "controlConfig": {
                            "menu": {
                                "items": {
                                    "bindTo": "EnabledEditPages",
                                    "bindConfig": {
                                        "converter": function(editPages) {
                                            if (editPages.getCount() > 1) {
                                                return editPages;
                                            } else {
                                                return null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                {
                    "operation": "merge",
                    "name": "CombinedModeAddRecordButton",
                    "parentName": "CombinedModeActionButtonsSectionContainer",
                    "propertyName": "items",
                    "values": {
                        "controlConfig": {
                            "menu": {
                                "items": {
                                    "bindTo": "EnabledEditPages",
                                    "bindConfig": {
                                        "converter": function(editPages) {
                                            if (editPages.getCount() > 1) {
                                                return editPages;
                                            } else {
                                                return null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            ]/**SCHEMA_DIFF*/
        };
    }
);

 

Like 0

Like

Share

0 comments
Show all comments