Browse Source

UI: Improvment for generator node

pull/11220/head
Artem Dzhereleiko 2 years ago
parent
commit
f85fada6a1
  1. 3
      ui-ngx/src/app/core/http/entity.service.ts
  2. 2
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
  3. 5
      ui-ngx/src/app/shared/components/entity/entity-select.component.html
  4. 5
      ui-ngx/src/app/shared/components/entity/entity-select.component.ts
  5. 1
      ui-ngx/src/app/shared/components/js-func.component.html
  6. 7
      ui-ngx/src/app/shared/components/script-lang.component.html
  7. 11
      ui-ngx/src/app/shared/components/script-lang.component.scss
  8. 5
      ui-ngx/src/app/shared/components/script-lang.component.ts
  9. 10
      ui-ngx/src/app/shared/models/entity-type.models.ts
  10. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

3
ui-ngx/src/app/core/http/entity.service.ts

@ -756,6 +756,9 @@ export class EntityService {
}
}
if (allowedEntityTypes && allowedEntityTypes.length) {
if (allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) {
entityTypes.push(AliasEntityType.CURRENT_RULE_NODE);
}
for (let index = entityTypes.length - 1; index >= 0; index--) {
if (allowedEntityTypes.indexOf(entityTypes[index]) === -1) {
entityTypes.splice(index, 1);

2
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

@ -414,6 +414,8 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
} else {
return EntityType.CUSTOMER;
}
} else if (entityType === AliasEntityType.CURRENT_RULE_NODE) {
return EntityType.RULE_NODE;
}
return entityType;
}

5
ui-ngx/src/app/shared/components/entity/entity-select.component.html

@ -15,7 +15,7 @@
limitations under the License.
-->
<div [formGroup]="entitySelectFormGroup">
<div [formGroup]="entitySelectFormGroup" class="tb-entity-select">
<tb-entity-type-select
*ngIf="displayEntityTypeSelect"
[showLabel]="true"
@ -27,7 +27,8 @@
<tb-entity-autocomplete
*ngIf="modelValue.entityType && modelValue.entityType !== AliasEntityType.CURRENT_TENANT
&& modelValue.entityType !== AliasEntityType.CURRENT_USER
&& modelValue.entityType !== AliasEntityType.CURRENT_USER_OWNER"
&& modelValue.entityType !== AliasEntityType.CURRENT_USER_OWNER
&& modelValue.entityType !== AliasEntityType.CURRENT_RULE_NODE"
[required]="required"
[entityType]="modelValue.entityType"
formControlName="entityId">

5
ui-ngx/src/app/shared/components/entity/entity-select.component.ts

@ -15,7 +15,7 @@
///
import { AfterViewInit, Component, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { TranslateService } from '@ngx-translate/core';
@ -145,7 +145,8 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
if (this.modelValue.entityType === AliasEntityType.CURRENT_TENANT
|| this.modelValue.entityType === AliasEntityType.CURRENT_USER
|| this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) {
|| this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER
|| this.modelValue.entityType === AliasEntityType.CURRENT_RULE_NODE) {
this.modelValue.id = NULL_UUID;
} else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) {
this.modelValue.id = NULL_UUID;

1
ui-ngx/src/app/shared/components/js-func.component.html

@ -24,6 +24,7 @@
{{ functionLabel }}
</label>
<span fxFlex></span>
<ng-content select="[toolbarSuffixScriptLang]"></ng-content>
<button type='button' *ngIf="!disabled" mat-button class="tidy" (click)="beautifyJs()">
{{'js-func.tidy' | translate }}
</button>

7
ui-ngx/src/app/shared/components/script-lang.component.html

@ -16,10 +16,11 @@
-->
<div [formGroup]="scriptLangFormGroup" fxLayout="row" fxLayoutAlign="center">
<mat-button-toggle-group class="tb-script-lang-toggle-group"
style="width: 320px;"
<mat-button-toggle-group class="tb-script-lang-toggle-group" [ngClass]="{ 'tb-script-lang-toggle-group-short': shortLang}"
formControlName="scriptLang" aria-label="Script language">
<mat-button-toggle fxFlex value="{{ scriptLanguage.TBEL }}">{{ 'rulenode.script-lang-tbel' | translate }}</mat-button-toggle>
<mat-button-toggle fxFlex value="{{ scriptLanguage.JS }}">{{ 'rulenode.script-lang-java-script' | translate }}</mat-button-toggle>
<mat-button-toggle fxFlex value="{{ scriptLanguage.JS }}">
{{ (shortLang ? 'rulenode.script-lang-java-script-short' : 'rulenode.script-lang-java-script') | translate }}
</mat-button-toggle>
</mat-button-toggle-group>
</div>

11
ui-ngx/src/app/shared/components/script-lang.component.scss

@ -14,6 +14,7 @@
* limitations under the License.
*/
.mat-button-toggle-group.tb-script-lang-toggle-group {
width: 320px;
&.mat-button-toggle-group-appearance-standard {
border: none;
border-radius: 18px;
@ -57,3 +58,13 @@
opacity: .01;
}
}
.mat-button-toggle-group.tb-script-lang-toggle-group-short {
width: 120px;
.mat-button-toggle {
height: 24px;
}
.mat-button-toggle-appearance-standard .mat-button-toggle-label-content {
line-height: 20px;
font-size: 12px;
}
}

5
ui-ngx/src/app/shared/components/script-lang.component.ts

@ -20,6 +20,7 @@ import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { ScriptLanguage } from '@shared/models/rule-node.models';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
selector: 'tb-script-lang',
@ -43,6 +44,10 @@ export class TbScriptLangComponent extends PageComponent implements ControlValue
@Input()
disabled: boolean;
@Input()
@coerceBoolean()
shortLang = true;
private propagateChange = null;
constructor(protected store: Store<AppState>,

10
ui-ngx/src/app/shared/models/entity-type.models.ts

@ -51,7 +51,8 @@ export enum AliasEntityType {
CURRENT_CUSTOMER = 'CURRENT_CUSTOMER',
CURRENT_TENANT = 'CURRENT_TENANT',
CURRENT_USER = 'CURRENT_USER',
CURRENT_USER_OWNER = 'CURRENT_USER_OWNER'
CURRENT_USER_OWNER = 'CURRENT_USER_OWNER',
CURRENT_RULE_NODE = 'CURRENT_RULE_NODE'
}
export interface EntityTypeTranslation {
@ -323,6 +324,13 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
list: 'entity.type-current-user-owner'
}
],
[
AliasEntityType.CURRENT_RULE_NODE,
{
type: 'entity.type-current-rule-node',
list: 'entity.type-current-rule-node'
}
],
[
EntityType.TB_RESOURCE,
{

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2264,6 +2264,7 @@
"type-current-tenant": "Current Tenant",
"type-current-user": "Current User",
"type-current-user-owner": "Current User Owner",
"type-current-rule-node": "Current Rule Node",
"type-widgets-bundle": "Widgets bundle",
"type-widgets-bundles": "Widgets bundles",
"list-of-widgets-bundles": "{ count, plural, =1 {One widgets bundle} other {List of # widget bundles} }",
@ -4216,6 +4217,7 @@
"invalid-target-rulechain": "Unable to resolve target rule chain!",
"test-script-function": "Test script function",
"script-lang-java-script": "JavaScript",
"script-lang-java-script-short": "JS",
"script-lang-tbel": "TBEL",
"message": "Message",
"message-type": "Message type",

Loading…
Cancel
Save