Browse Source

refactoring

pull/12820/head
mpetrov 2 years ago
parent
commit
69f0aa9691
  1. 3
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts
  2. 3
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol-editor.models.ts
  3. 4
      ui-ngx/src/app/shared/components/js-func.component.ts
  4. 3
      ui-ngx/src/app/shared/models/ace/ace.models.ts
  5. 12
      ui-ngx/src/app/shared/models/calculated-field.models.ts

3
ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts

@ -44,7 +44,8 @@ import {
CalculatedFieldTestScriptDialogData, CalculatedFieldTestScriptDialogData,
getCalculatedFieldArgumentsEditorCompleter, getCalculatedFieldArgumentsEditorCompleter,
getCalculatedFieldArgumentsHighlights, getCalculatedFieldArgumentsHighlights,
CalculatedFieldTypeTranslations, CalculatedFieldType, CalculatedFieldTypeTranslations,
CalculatedFieldType,
} from '@shared/models/calculated-field.models'; } from '@shared/models/calculated-field.models';
import { import {
CalculatedFieldDebugDialogComponent, CalculatedFieldDebugDialogComponent,

3
ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol-editor.models.ts

@ -36,7 +36,6 @@ import {
AceHighlightRules, AceHighlightRules,
dotOperatorHighlightRule, dotOperatorHighlightRule,
endGroupHighlightRule, endGroupHighlightRule,
identifierRe
} from '@shared/models/ace/ace.models'; } from '@shared/models/ace/ace.models';
import { HelpLinks, ValueType } from '@shared/models/constants'; import { HelpLinks, ValueType } from '@shared/models/constants';
import { formPropertyCompletions } from '@shared/models/dynamic-form.models'; import { formPropertyCompletions } from '@shared/models/dynamic-form.models';
@ -925,6 +924,8 @@ export class ScadaSymbolElement {
} }
const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/;
const scadaSymbolCtxObjectHighlightRule: AceHighlightRule = { const scadaSymbolCtxObjectHighlightRule: AceHighlightRule = {
token: 'tb.scada-symbol-ctx', token: 'tb.scada-symbol-ctx',
regex: /\bctx\b/, regex: /\bctx\b/,

4
ui-ngx/src/app/shared/components/js-func.component.ts

@ -587,6 +587,10 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
newMode.$highlightRules.$rules[group] = this.highlightRules[group]; newMode.$highlightRules.$rules[group] = this.highlightRules[group];
} }
} }
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
if (identifierRule) {
identifierRule.next = 'start';
}
// @ts-ignore // @ts-ignore
this.jsEditor.session.$onChangeMode(newMode); this.jsEditor.session.$onChangeMode(newMode);
} }

3
ui-ngx/src/app/shared/models/ace/ace.models.ts

@ -376,7 +376,4 @@ export const endGroupHighlightRule: AceHighlightRule = {
next: 'no_regex' next: 'no_regex'
}; };
export const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/;

12
ui-ngx/src/app/shared/models/calculated-field.models.ts

@ -33,7 +33,6 @@ import {
AceHighlightRules, AceHighlightRules,
dotOperatorHighlightRule, dotOperatorHighlightRule,
endGroupHighlightRule, endGroupHighlightRule,
identifierRe
} from '@shared/models/ace/ace.models'; } from '@shared/models/ace/ace.models';
export interface CalculatedField extends Omit<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasEntityDebugSettings, HasTenantId, ExportableEntity<CalculatedFieldId> { export interface CalculatedField extends Omit<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasEntityDebugSettings, HasTenantId, ExportableEntity<CalculatedFieldId> {
@ -536,17 +535,6 @@ export const getCalculatedFieldArgumentsHighlights = (
? 'calculatedFieldRollingArgumentValue' ? 'calculatedFieldRollingArgumentValue'
: 'calculatedFieldSingleArgumentValue' : 'calculatedFieldSingleArgumentValue'
})), })),
no_regex: [
{
token: 'tb.identifier',
regex: identifierRe,
},
{
token: 'tb.paren.lparen',
regex: '\\(',
next: 'start'
}
],
...calculatedFieldSingleArgumentValueHighlightRules, ...calculatedFieldSingleArgumentValueHighlightRules,
...calculatedFieldRollingArgumentValueHighlightRules, ...calculatedFieldRollingArgumentValueHighlightRules,
...calculatedFieldTimeWindowArgumentValueHighlightRules ...calculatedFieldTimeWindowArgumentValueHighlightRules

Loading…
Cancel
Save