BPMSoft Snippets
Набор сниппетов для Frontend-разработки под платформу BPMSoft. Адаптировано под пространство имен BPMSoft, переведено на синтаксис ES6.
Основано на открытом проекте от Banza (MIT License).
🚀 Утилиты и Inline-сниппеты
esqSelectInline
Быстрый линейный ESQ запрос (Чтение)
Template
const esq = this.Ext.create("BPMSoft.EntitySchemaQuery", {
rootSchemaName: "SchemaName"
});
esq.addColumn("Id");
esq.addColumn("ColumnName", "Alias");
esq.filters.add("FilterName", BPMSoft.createColumnFilterWithParameter(
BPMSoft.ComparisonType.EQUAL, "FilterColumn", Value
));
esq.getEntityCollection(function(response) {
if (response.success && response.collection && !response.collection.isEmpty()) {
const item = response.collection.first();
// Обработка item.get("Alias")
}
}, this);
esqUpdateInline
Быстрый линейный ESQ запрос (Обновление)
Template
const updateQuery = this.Ext.create("BPMSoft.UpdateQuery", {
rootSchemaName: "SchemaName"
});
const filter = BPMSoft.createColumnFilterWithParameter(
BPMSoft.ComparisonType.EQUAL, "Id", recordId
);
updateQuery.filters.add("IdFilter", filter);
updateQuery.setParameterValue("ColumnName", newValue, BPMSoft.DataValueType.TEXT);
updateQuery.execute(function(response) {
if (response.success) {
// Успешно обновлено
}
}, this);
esqDeleteInline
Быстрый линейный ESQ запрос (Удаление)
Template
const deleteQuery = this.Ext.create("BPMSoft.DeleteQuery", {
rootSchemaName: "SchemaName"
});
const filter = BPMSoft.createColumnFilterWithParameter(
BPMSoft.ComparisonType.EQUAL, "Id", recordId
);
deleteQuery.filters.add("IdFilter", filter);
deleteQuery.execute(function(response) {
if (response.success) {
// Успешно удалено
}
}, this);
callServiceInline
Быстрый линейный вызов ServiceHelper
Template
ServiceHelper.callService({
serviceName: "CustomServiceName",
methodName: "MethodName",
data: {
paramName: paramValue
},
callback: function(response) {
const result = response.MethodNameResult;
if (result && result.success) {
// Успешное выполнение
} else {
const error = result ? result.errorInfo.message : "Unknown error";
this.showInformationDialog(error);
}
},
scope: this
});
featureCheck
Проверка доступности Feature Toggle
Template
if (BPMSoft.Features.getIsEnabled("FeatureCode")) {
// Логика, если фича включена
} else {
// Логика, если фича выключена
}
showConfirmation
Окно подтверждения (Да/Нет)
Template
this.showConfirmationDialog(this.get("Resources.Strings.ConfirmMessage"), function(returnCode) {
if (returnCode === BPMSoft.MessageBoxButtons.YES.returnCode) {
// Логика при нажатии ДА
}
}, ["yes", "no"]);
openLookup
Программное открытие справочника
Template
const config = {
entitySchemaName: "EntitySchemaName",
multiSelect: false,
columns: ["Name"]
};
this.openLookup(config, function(args) {
const collection = args.selectedRows;
if (collection.isEmpty()) {
return;
}
const selectedItem = collection.getByIndex(0);
this.set("AttributeName", selectedItem);
}, this);
pushHistoryState
Переход на другую страницу
Template
this.sandbox.publish("PushHistoryState", {
hash: "CardModuleV2/EntitySchemaNamePage/edit/RecordId"
});
serverChannelOn
Подписка на сообщения от ServerChannel
Template
BPMSoft.ServerChannel.on(BPMSoft.EventName.ON_MESSAGE, function(scope, message) {
if (message && message.Header && message.Header.Sender === "SenderName") {
const body = BPMSoft.decode(message.Body);
// Логика обработки сообщения от сервера
}
}, this);
rndGuid
Генерация случайного GUID
Template
${UUID}
📦 Базовые структуры (Define / Ext)
def
Стандартный шаблон define
Template
define("SchemaName", [
"SchemaNameResources"
], function(resources) {
return {
entitySchemaName: "EntitySchemaName",
mixins: {},
attributes: {},
details: /**SCHEMA_DETAILS*/ {} /**SCHEMA_DETAILS*/ ,
messages: {},
rules: {},
businessRules: /**SCHEMA_BUSINESS_RULES*/ {} /**SCHEMA_BUSINESS_RULES*/ ,
modules: /**SCHEMA_MODULES*/ {} /**SCHEMA_MODULES*/ ,
methods: {},
diff: /**SCHEMA_DIFF*/ [] /**SCHEMA_DIFF*/
};
});
defModalBox
Шаблон модального окна
Template
define("SchemaName", [
"SchemaNameResources",
"ModalBox",
], function(resources) {
return {
mixins: {},
attributes: {},
details: {},
messages: {},
methods: {
getModalBoxInitialConfig: function() {
return {
modalBoxConfig: {
boxClasses: ["auto-resize-modal-box"]
}
};
},
},
diff: /**SCHEMA_DIFF*/ [
{
"operation": "insert",
"name": "CardButtonsContainer",
"parentName": "CardContentContainer",
"propertyName": "items",
"values": {
"itemType": BPMSoft.ViewItemType.CONTAINER,
"wrapClass": ["modal-box-buttons-content-wrap"],
"items": []
}
},
{
"operation": "insert",
"name": "CancelButton",
"parentName": "CardButtonsContainer",
"propertyName": "items",
"values": {
"itemType": BPMSoft.ViewItemType.BUTTON,
"caption": { "bindTo": "Resources.Strings.CancelButtonCaption" },
"click": { "bindTo": "close" },
"style": BPMSoft.controls.ButtonEnums.style.GREY,
"classes": { "textClass": "left-margin" }
}
}
] /**SCHEMA_DIFF*/
};
});
defRod
Шаблон детали "Только для чтения"
Template
define("SchemaName", [
"SchemaNameResources"
], function(resources) {
return {
entitySchemaName: "EntitySchemaName",
mixins: {},
attributes: {},
messages: {},
methods: {
getAddRecordButtonVisible: function() { return false; },
getAddTypedRecordButtonVisible: function() { return false; },
addRecordOperationsMenuItems: BPMSoft.emptyFn,
editCurrentRecord: BPMSoft.emptyFn
},
diff: /**SCHEMA_DIFF*/ [] /**SCHEMA_DIFF*/
};
});
defEd
Шаблон детали c редактируемым реестром
Template
define("SchemaName", [
"SchemaNameResources",
"ConfigurationGrid",
"ConfigurationGridGenerator",
"ConfigurationGridUtilities"
], function(resources) {
return {
entitySchemaName: "EntitySchemaName",
attributes: {
"IsEditable": {
"dataValueType": BPMSoft.DataValueType.BOOLEAN,
"type": BPMSoft.ViewModelColumnType.VIRTUAL_COLUMN,
"value": true
}
},
mixins: {
ConfigurationGridUtilities: "BPMSoft.ConfigurationGridUtilities"
},
methods: {},
diff: /**SCHEMA_DIFF*/ [
{
"operation": "merge",
"name": "DataGrid",
"values": {
"className": "BPMSoft.ConfigurationGrid",
"generator": "ConfigurationGridGenerator.generatePartial",
"generateControlsConfig": { "bindTo": "generateActiveRowControlsConfig" },
"changeRow": { "bindTo": "changeRow" },
"unSelectRow": { "bindTo": "unSelectRow" },
"onGridClick": { "bindTo": "onGridClick" },
"activeRowActions": [
// save, cancel, card, copy, remove
],
"initActiveRowKeyMap": { "bindTo": "initActiveRowKeyMap" },
"activeRowAction": { "bindTo": "onActiveRowAction" },
"multiSelect": { "bindTo": "MultiSelect" }
}
}
] /**SCHEMA_DIFF*/
};
});
defDetailLookup
Шаблон детали с множественным добавлением из справочника
Template
define("SchemaName", [
"SchemaNameResources",
"LookupMultiAddMixin"
], function(resources) {
return {
entitySchemaName: "EntitySchemaName",
mixins: {
LookupMultiAddMixin: "BPMSoft.LookupMultiAddMixin"
},
methods: {
init: function() {
this.callParent(arguments);
this.mixins.LookupMultiAddMixin.init.call(this);
},
getAddRecordButtonVisible: function() {
return this.getToolsVisible();
},
onCardSaved: function() {
this.openLookupWithMultiSelect();
},
addRecord: function() {
this.openLookupWithMultiSelect(true);
},
getMultiSelectLookupConfig: function() {
return {
rootEntitySchemaName: "EntitySchemaName",
rootColumnName: "BnzEducation",
relatedEntitySchemaName: "BnzEducationSpecification",
relatedColumnName: "BnzSpecification"
};
}
},
diff: /**SCHEMA_DIFF*/ [] /**SCHEMA_DIFF*/
};
});
defExt
Шаблон Ext.define
Template
define("SchemaName", [
"SchemaNameResources"
], function(resources) {
Ext.define("BPMSoft.configuration.SchemaName", {
alternateClassName: "BPMSoft.SchemaName"
});
return Ext.create("BPMSoft.SchemaName");
});
defExtOvrd
Шаблон Ext override
Template
define("SchemaName", [
"SchemaNameResources",
"OverrideSchemaName"
], function(resources) {
Ext.define("BPMSoft.configuration.SchemaName", {
override: "BPMSoft.OverrideSchemaName"
});
});
defExtConst
Шаблон Ext констант
Template
define("SchemaName", [
"SchemaNameResources"
], function(resources) {
Ext.define("BPMSoft.configuration.SchemaName", {
alternateClassName: "BPMSoft.SchemaName",
singleton: true,
Entity: {
Record: ""
}
});
return BPMSoft.SchemaName;
});
defExtMixin
Шаблон Ext миксина
Template
define("SchemaName", [
"SchemaNameResources"
], function(resources) {
Ext.define("BPMSoft.configuration.mixins.SchemaName", {
alternateClassName: "BPMSoft.SchemaName",
});
return Ext.create("BPMSoft.SchemaName");
});
🗄 Работа с данными (ESQ)
esqSelect
ESQ Select
Template
selectQueryName: function(callback, scope) {
const esq = this.getSelectQueryNameESQ();
esq.getEntityCollection(function(result) {
this.esqSelectQueryNameCallback(result, callback, scope);
}, this);
},
getSelectQueryNameESQ: function() {
const esq = Ext.create("BPMSoft.EntitySchemaQuery", {
rootSchemaName: "RootSchemaName"
});
this.initSelectQueryNameESQColumns(esq);
this.initSelectQueryNameESQFilters(esq);
return esq;
},
initSelectQueryNameESQColumns: function(esq) {
esq.addColumn("Id");
},
initSelectQueryNameESQFilters: function(esq) {
esq.filters.add("", BPMSoft.createColumnFilterWithParameter(
BPMSoft.ComparisonType.EQUAL, "", BPMSoft.GUID_EMPTY
));
},
esqSelectQueryNameCallback: function(result, callback, scope) {
if (!result.success) {
this.showInformationDialog(result.errorInfo.message);
return;
}
const entity = result.collection.first();
Ext.callback(callback, scope, []);
},
esqDelete
ESQ Delete
Template
deleteQueryName: function(id, callback, scope) {
const query = this.getDeleteQueryNameQuery(id);
query.execute(callback, scope);
},
getDeleteQueryNameQuery: function(id) {
const query = Ext.create("BPMSoft.DeleteQuery", {
rootSchemaName: "RootSchemaName"
});
this.initDeleteQueryNameQueryFilters(query, id);
return query;
},
initDeleteQueryNameQueryFilters: function(query, id) {
query.filters.add("Id", BPMSoft.createColumnFilterWithParameter(
BPMSoft.ComparisonType.EQUAL, "Id", id
));
},
esqUpdate
ESQ Update
Template
updateQueryName: function(id, callback, scope) {
const query = this.getUpdateQueryNameQuery(id);
query.execute(callback, scope);
},
getUpdateQueryNameQuery: function(id) {
const query = Ext.create("BPMSoft.UpdateQuery", {
rootSchemaName: "RootSchemaName"
});
this.initUpdateQueryNameQueryParameters(query);
this.initUpdateQueryNameQueryFilters(query, id);
return query;
},
initUpdateQueryNameQueryParameters: function(query) {
query.setParameterValue("Name", "...", BPMSoft.DataValueType.TEXT);
},
initUpdateQueryNameQueryFilters: function(query, id) {
query.enablePrimaryColumnFilter(id);
},
esqInsert
ESQ Insert
Template
insertQueryName: function(id, callback, scope) {
const query = this.getInsertQueryNameQuery(id);
query.execute(callback, scope);
},
getInsertQueryNameQuery: function(id) {
const query = Ext.create("BPMSoft.InsertQuery", {
rootSchemaName: "RootSchemaName"
});
this.initInsertQueryNameQueryParameters(query);
return query;
},
initInsertQueryNameQueryParameters: function(query) {
query.setParameterValue("Name", "...", BPMSoft.DataValueType.TEXT);
},
Фильтры ESQ
Template
esq.filters.add("UUID", esqFprop); // esqF
BPMSoft.ComparisonType.EQUAL; // esqCT
BPMSoft.createColumnFilterWithParameter(BPMSoft.ComparisonType.EQUAL, "Id", BPMSoft.GUID_EMPTY) // esqFProp
BPMSoft.createColumnBetweenFilterWithParameters("CreatedOn", date1, date2) // esqFBetween
BPMSoft.createColumnInFilterWithParameters("Id", array) // esqFIn
BPMSoft.createColumnIsNullFilter("Id") // esqFNull
BPMSoft.createColumnIsNotNullFilter("Id") // esqFNotNull
BPMSoft.createExistsFilter("[Account:Owner:Id].Id") // esqFExists
BPMSoft.createNotExistsFilter("[Account:Owner:Id].Id") // esqFNotExists
esqFGroup
ESQ Группа фильтров
Template
const filterGroup = BPMSoft.createFilterGroup();
filterGroup.logicalOperation = BPMSoft.LogicalOperatorType.AND;
filterGroup.add("UUID", esqfprop);
!result
Обработка ошибки ответа
Template
if (!result.success) {
this.showInformationDialog(result.errorInfo.message);
return;
}
esqAllColumn / esqRowCount
Template
esq.allColumns = true;
esq.rowCount = 1;
🧩 Виртуальные атрибуты (Attributes)
attrVBoolean / attrVText / attrVInteger / attrVFloat
Template
"AttributeName": {
"dataValueType": BPMSoft.DataValueType.BOOLEAN, // TEXT, INTEGER, FLOAT
"type": BPMSoft.ViewModelColumnType.VIRTUAL_COLUMN,
"value": false // BPMSoft.emptyString, 0, 0.0
},
attrVDate / attrVTime / attrVDateTime
Template
"AttributeName": {
"dataValueType": BPMSoft.DataValueType.DATE_TIME, // DATE, TIME
"type": BPMSoft.ViewModelColumnType.VIRTUAL_COLUMN,
"value": new Date()
},
attrVLookup
Template
"AttributeName": {
"type": BPMSoft.ViewModelColumnType.VIRTUAL_COLUMN,
"dataValueType": BPMSoft.DataValueType.LOOKUP,
"referenceSchemaName": "Contact",
"isLookup": true
},
attrVCollection
Template
"AttributeName": {
"type": BPMSoft.ViewModelColumnType.VIRTUAL_COLUMN,
"dataValueType": BPMSoft.DataValueType.COLLECTION,
"value": Ext.create("BPMSoft.Collection"),
"isCollection": true
},
🎨 Пользовательский интерфейс (Diff)
diffRemove
Template
{
"operation": "remove",
"name": "Field"
}
diffMove
Template
{
"operation": "move",
"name": "Field",
"parentName": "Parent",
"propertyName": "items",
"index": 0
}
diffMerge
Template
{
"operation": "merge",
"name": "Field",
"values": {
"layout": { "colSpan": 24, "column": 0, "row": 1 },
"enabled": { "bindTo": "" },
"isRequired": { "bindTo": "" }
}
},
diffField
Template
{
"operation": "insert",
"name": "Field",
"parentName": "Header",
"propertyName": "items",
"values": {
"bindTo": "Field",
"layout": { "colSpan": 24, "column": 0, "row": 0 },
"enabled": true,
"isRequired": false,
"visible": true
}
},
diffTab / diffContainer / diffGridLayout / diffControlGroup
Template
{
"operation": "insert",
"name": "NameContainer",
"parentName": "Parent",
"propertyName": "items",
"values": {
"itemType": BPMSoft.ViewItemType.CONTAINER, // TAB, GRID_LAYOUT, CONTROL_GROUP
"items": []
}
},
Template
{
"operation": "insert",
"name": "NameButton",
"parentName": "LeftContainer",
"propertyName": "items",
"values": {
"itemType": BPMSoft.ViewItemType.BUTTON,
"caption": { "bindTo": "Resources.Strings.NameButtonCaption" },
"visible": { "bindTo" : "IsNameVisible" },
"enabled": { "bindTo" : "IsNameEnabled" },
"click": { "bindTo": "onNameClick" },
"style": BPMSoft.controls.ButtonEnums.style.GREEN
}
},
layout / bind / bindRes
Template
"layout": { "column": 0, "colSpan": 12, "row": 0, "rowSpan": 0 },
{ "bindTo": "Field" }
{ "bindTo": "Resources.Strings.StringName" }
⚙️ Бизнес-правила (Business Rules)
ruleFilterConst / ruleFilterAttr / ruleFilterSysSetting / ruleFilterSysValue
Template
"FilterName": {
"ruleType": BusinessRuleModule.enums.RuleType.FILTRATION,
"baseAttributePatch": "BaseField",
"comparisonType": BPMSoft.ComparisonType.EQUAL,
"type": BusinessRuleModule.enums.ValueType.ATTRIBUTE, // CONSTANT, SYSSETTING, SYSVALUE
"attribute": "CompareField" // value: ...
},
ruleEnabled / ruleRequired / ruleVisible
Template
"RuleName": {
"uId": "UUID",
"ruleType": BusinessRuleModule.enums.RuleType.BINDPARAMETER,
"property": BusinessRuleModule.enums.Property.ENABLED, // REQUIRED, VISIBLE
"conditions": [ ... ]
},
ruleCondEqAttr / ruleCondIsNull / ruleCondIsNotNull
Template
{
"leftExpression": {
"type": BusinessRuleModule.enums.ValueType.ATTRIBUTE,
"attribute": "Owner"
},
"comparisonType": BPMSoft.ComparisonType.EQUAL, // IS_NULL, IS_NOT_NULL
"rightExpression": {
"type": BusinessRuleModule.enums.ValueType.CONSTANT,
"value": BPMSoft.SysValue.CURRENT_USER_CONTACT.value
}
},
🔄 Жизненный цикл и Методы
init / onEntityInitialized / onSaved / onDiscardChangesClick / destroy
Template
init: function() {
this.callParent(arguments);
},
initCallback
Template
init: function(callback, scope) {
this.callParent([function() {
Ext.callback(callback, scope);
}, this]);
},
asyncValidate
Template
asyncValidate: function(callback, scope) {
this.callParent([function(response) {
if (!this.validateResponse(response)) return;
this.validateMethod(function(result) {
Ext.callback(callback, scope, [result]);
});
}, this]);
},
this_asyncValidate
Template
this.asyncValidate(function(result) {
if (!result.success) {
this.showInformationDialog(result.message);
return;
}
this.save({
isSilent: true,
callback: this.method,
scope: this
});
}, this);
setValidationConfig
Template
setValidationConfig: function() {
this.callParent(arguments);
this.addColumnValidator("FieldName", this.FieldNameValidator);
},
FieldNameValidator: function() {
return { invalidMessage: BPMSoft.emptyString };
},
setDefaultValues
Template
setDefaultValues: function() {
this.callParent(arguments);
this.setDefaultField();
},
chain
Template
BPMSoft.chain(
function(next) {
next();
}, this
);
🍔 Действия (Actions)
getActions / getSectionActions
Template
getActions: function() {
const actionMenuItems = this.callParent(arguments);
actionMenuItems.add("MenuSeparator", this.getButtonMenuItem({ "Type": "BPMSoft.MenuSeparator" }));
actionMenuItems.add("ActionName", this.getButtonMenuItem({
"Caption": { "bindTo": "Resources.Strings.ActionNameCaption" },
"Tag": "onActionNameClick",
"Visible": { "bindTo": "IsActionNameVisible" },
"Enabled": { "bindTo": "IsActionNameEnabled" },
}));
return actionMenuItems;
},
methodGetSet
Template
getIsNameVisible: function() { return true; },
setIsNameVisible: function() {
const isVisible = this.getIsNameVisible();
this.set("IsNameVisible", isVisible, { publishToSection: true });
},
🔌 Системные функции и Интеграции
callService
Template
callServiceNameServiceMethod: function(callback, scope) {
this.showBodyMask();
ServiceHelper.callService({
serviceName: "ServiceName",
methodName: "ServiceMethod",
data: this.getServiceNameServiceMethodConfig(),
callback: function(response, success) {
this.hideBodyMask();
const result = response.ServiceMethodResult;
// logic
},
scope: this
});
},
startBusinessProcess / startBusinessProcessFast
Template
BPMSoft.ProcessModuleUtilities.startBusinessProcess({
name: "ProcessName",
parameters: {}
});
querySysSettingsItem / querySysSettings
Template
BPMSoft.SysSettings.querySysSettingsItem("SysSettingName", function(result) {
this.set("SysSettingName", result);
Ext.callback(callback, scope);
}, this);
checkCanExecuteOperation / checkCanExecuteOperations
Template
RightUtilities.checkCanExecuteOperation({ operation: "OperationName" }, function(result) {
this.set("OperationName", result);
Ext.callback(callback, scope);
}, this);
loadModalBoxModule
Template
const moduleName = "ModalBoxSchemaModule";
const schemaName = "ModalBoxPageName";
const moduleId = Ext.String.format("{0}_{1}_{2}", this.sandbox.id, moduleName, schemaName);
this.sandbox.loadModule(moduleName, {
id: moduleId,
instanceConfig: {
moduleInfo: { schemaName: schemaName },
parameters: { viewModelConfig: {} }
}
});
loadLookupDisplayValue
Template
this.loadLookupDisplayValue("LookupField", value, callback, scope);
Template
this.getPrimaryColumnValue();
this.showInformationDialog("Text");
✉️ Сообщения и Sandbox
msgPublish / msgSubscribe / msgBidirectional
Template
"MessageName": {
"mode": BPMSoft.MessageMode.PTP,
"direction": BPMSoft.MessageDirectionType.PUBLISH // SUBSCRIBE, BIDIRECTIONAL
},
subscribeSandboxEvents / subscribeDetailEvents
Template
subscribeSandboxEvents: function() {
this.callParent(arguments);
this.sandbox.subscribe("...", this.method, this, [this.sandbox.id]);
},
getDetailInfo
Template
getDetailInfo: function(detail) {
const info = this.callParent(arguments);
if (detail.detailName === "...") { }
return info;
},
initQueryColumns
Template
initQueryColumns: function(esq) {
this.callParent(arguments);
if (!esq.columns.contains("ColumnName")) {
esq.addColumn("ColumnName");
}
},
detail
Template
"DetailName": {
"schemaName": "SchemaName",
"entitySchemaName": "EntitySchemaName",
"filter": { "detailColumn": "Column", "masterColumn": "Id" }
}
publishPropertyValueToSection
Template
this.publishPropertyValueToSection("Attribute", value);
📝 JSDoc
const / prt / inher / ovrd / rg
Template
/** @constant */
/** @protected */
/** @inheritdoc # */
/** @inheritdoc # \n * @override */
/** @Region: */ ... /** @EndRegion: */
| |