Простой клиентский модуль с нуля: как добавить свой элемент и удалить преднастроенные?

Коллеги, приветствую.

Есть некоторый код простого клиентского модуля, который должен показать простую карточку с текстовым полем и кнопками "Отмена" и "Далее".

 

define("UsrPlanningTasksForCustomer", ["CustomProcessPageV2Utilities"], function() {
        return {
                entitySchemaName: "Contact",
                mixins: {
                        BaseProcessViewModel: "Terrasoft.CustomProcessPageV2Utilities"
                },
                attributes: {
                        "Employee": {
                        caption: { "bindTo": "Resources.Strings.EmployeeCaption" },
                        dataValueType: Terrasoft.DataValueType.TEXT
                        }
                },
                details: {
                },
                methods: {
                        getHeader: function() {
                                return this.get("Resources.Strings.PageHeaderCaption");
                        },
                        onMyCancelButtonClick: function() {
                                this.set("Result", "RejectedByCustomer");
                                this.acceptProcessElement();
                        },
                        onNextButtonClick: function() {
                                this.set("Result", "Next");
                                this.acceptProcessElement();
                        }
                },
                diff:
                [
                       
                        {
                                "operation": "remove",
                                "name": "DelayExecutionButton"
                        },
                        {
                                "operation": "remove",
                                "name": "actions"
                        },
                        {
                                "operation": "remove",
                                "name": "SaveButton"
                        },
                        {
                                "operation": "remove",
                                "name": "CancelButton"
                        },
                        {
                                "operation": "remove",
                                "name": "DiscardChangesButton"
                        },
                        {
                                "operation": "remove",
                                "name": "ViewOptionsButton"
                        },
                        {
                                "operation": "remove",
                                "name": "PrintButton"
                        },
                        {
                                "operation": "remove",
                                "name": "CloseButton"
                        },
                       
                        {
                                "operation": "insert",
                                "parentName": "LeftContainer",
                                "propertyName": "items",
                                "name": "MyCancelButton",
                                "values": {
                                        caption: { "bindTo": "Resources.Strings.MyCancelButton" },
                                        itemType: Terrasoft.ViewItemType.BUTTON,
                                        classes: {textClass: "actions-button-margin-right"},
                                        style: Terrasoft.controls.ButtonEnums.style.RED,
                                        click: {bindTo: "onMyCancelButtonClick"}
                                }
                        },
                        {
                                "operation": "insert",
                                "parentName": "LeftContainer",
                                "propertyName": "items",
                                "name": "NextButton",
                                "values": {
                                        caption: { "bindTo": "Resources.Strings.NextButtonCaption" },
                                        itemType: Terrasoft.ViewItemType.BUTTON,
                                        classes: {textClass: "actions-button-margin-right"},
                                        style: Terrasoft.controls.ButtonEnums.style.GREEN,
                                        click: {bindTo: "onNextButtonClick"}
                                }
                        },
                       
                        {
                        "operation": "insert",
                        "parentName": "Header",
                        "name": "DataGroup",
                        "propertyName": "items",
                        "values": {
                                itemType: Terrasoft.ViewItemType.CONTROL_GROUP,
                                items: [],
                                "caption": {"bindTo": "Resources.Strings.DataGroupCaption"},
                                "layout": { "column": 18, "row": 0, "colSpan": 18 },
                                controlConfig: {collapsed: false}
                        }
                        },
                        {
                        "operation": "insert",
                        "name": "TopCenterInfoBlock",
                        "parentName": "DataGroup",
                        "propertyName": "items",
                        "values": {
                                "layout": { "column": 0, "row": 0 },//, "colSpan": 15 },
                                "itemType": Terrasoft.ViewItemType.GRID_LAYOUT,
                                "items": []
                        }                                      
                ]
        };
});

 

Собственно, кнопки "Отмена" и "Далее" отображаются, но не отображается мое текстовое поле и, ко всему, появляются ряд полей, которые я не определял, как то "Продукт", "Прайс-лист", "Цена", "Валюта", "Налог".

Как удалить преднастроенные элементы и отобразить текстовое поле?

Был бы весьма признателен за информацию.

Спасибо.

--
С уважением, Алексей Быков.

Нравится

4 комментария

Так, собственно, как текстовое поле добавить примерно понял - нужно добавить соответствующий атрибут и в блоке diff определить контейнер, в него вложить метку и само поле:

attributes: {
	"EmployeeTextField": {
		caption: { "bindTo": "Resources.Strings.EmployeeCaption" },
		dataValueType: Terrasoft.DataValueType.TEXT
	}
}
...
 
diff:
[
	...
	{
		"operation": "insert",
		"parentName": "ProductGeneralInfoBlock",
		"propertyName": "items",
		"name": "PlanningBlock",
		"values": {
			"itemType": this.Terrasoft.ViewItemType.GRID_LAYOUT,
			"layout": { "column": 1, "row": 2, "colSpan": 24 },
			"items": []
		}
	},
	{
		"operation": "insert",
		"parentName": "PlanningBlock",
		"name": "EmployeeLabel",
		"propertyName": "items",
		"values": {
			"itemType": this.Terrasoft.ViewItemType.LABEL,
			"caption": { "bindTo": "Reources.Strings.EmployeeCaption" },
			"layout": { "column": 0, "row": 0, "colSpan": 2 }
		 }
	},
	{
		"operation": "insert",
		"parentName": "PlanningBlock",
		"propertyName": "items",
		"name": "EmployeeTextField",
		"values": {
			"itemType": this.Terrasoft.ViewItemType.TEXT,
			"layout": { "column": 2, "row": 0, "colSpan": 20 }
		}
	}
]

Но как удалить преднастроенные поля?

По всей видимости, нужно пронаследоваться от пустой схемы...

Да, нужно указать родительский объект "Базовая схема карточки ( NUI )"

Думаю как то так.
{
"operation": "remove",
"name": "PlanningBlock"

},

Показать все комментарии