1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2025-02-19 19:10:09 +02:00

Частичная поддержка шаблона ОбъектМетаданных

This commit is contained in:
salexdv 2022-02-02 07:31:44 +03:00
parent 80def87a83
commit 9d595ebb05
2 changed files with 52 additions and 4 deletions

View File

@ -561,14 +561,14 @@ class bslHelper {
}
/**
* Get array of metadata object names by snippet action
* Get array of metadata object by metadata name
*
* @param {string} action type of action from snippet
* @param {string} metadataName name of metadata object
* @param {completionItem} completionItem current item of suggestion list
*
* @returns {array} array of metadata object names
*/
getSnippetMetadataItemsByAction(action, completionItem) {
getSnippetMetadataItemsByName(metadataName, completionItem) {
let items = [];
@ -607,7 +607,7 @@ class bslHelper {
relations['ВыберитеКонстанту'] = 'constants';
relations['РегистрРасчета'] = 'calcRegs';
let relation = relations[action];
let relation = relations[metadataName];
if (relation)
items = this.getSnippetMetadataItems(relation, completionItem);
@ -616,6 +616,33 @@ class bslHelper {
}
/**
* Get array of metadata object names by snippet action
*
* @param {string} action type of action from snippet
* @param {completionItem} completionItem current item of suggestion list
*
* @returns {array} array of metadata object names
*/
getSnippetMetadataItemsByAction(action, completionItem) {
let items = [];
if (0 <= action.indexOf('ОбъектМетаданных:')) {
action = action.replace('ОбъектМетаданных:', '');
let metadata_array = action.split(',');
metadata_array.forEach((name) => {
let metadata_items = this.getSnippetMetadataItemsByName(name, completionItem);
items = items.concat(metadata_items);
});
}
else
items = this.getSnippetMetadataItemsByName(action, completionItem);
return items;
}
/**
* Replace standart choice elements with metadata objects
* or other additional transformations

View File

@ -65,6 +65,7 @@ class SnippetsParser {
if (1 < template_arr.length) {
let action = template_arr[1].trim();
if (action == 'ВыборВарианта') {
template_arr = template_arr.slice(2);
@ -88,6 +89,26 @@ class SnippetsParser {
placeholder = '${CURRENT_DATE}.${CURRENT_MONTH}.${CURRENT_YEAR} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}';
fix_placeholder = true;
}
else if (action == 'ОбъектМетаданных') {
template_arr = template_arr.slice(2);
let options = [];
template_arr.forEach((value) => {
let option = value.replace(/"/g, '').trim();
if (option.indexOf('.') == -1 && options.indexOf(option) == -1)
options.push(option);
});
if (options.length)
if (options.length == 1)
placeholder = options[0];
else
placeholder = 'ОбъектМетаданных:' + options.join();
else
placeholder = action;
}
else {
placeholder = action;
}