Browse Source

UI: Introduce borderRadius widget card setting. Improve widget style json field.

pull/8917/head
Igor Kulikov 3 years ago
parent
commit
2fea229aa1
  1. 7
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html
  2. 2
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts
  3. 5
      ui-ngx/src/app/modules/home/models/dashboard-component.models.ts
  4. 15
      ui-ngx/src/app/shared/components/json-object-edit.component.ts
  5. 1
      ui-ngx/src/app/shared/models/widget.models.ts
  6. 1
      ui-ngx/src/assets/locale/locale.constant-en_US.json

7
ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

@ -114,6 +114,12 @@
<input matInput formControlName="margin" placeholder="{{ 'widget-config.set' | translate }}"> <input matInput formControlName="margin" placeholder="{{ 'widget-config.set' | translate }}">
</mat-form-field> </mat-form-field>
</div> </div>
<div class="tb-widget-config-row space-between">
<div>{{ 'widget-config.border-radius' | translate }}</div>
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
</mat-form-field>
</div>
<mat-slide-toggle class="mat-slide slide-block" formControlName="dropShadow"> <mat-slide-toggle class="mat-slide slide-block" formControlName="dropShadow">
{{ 'widget-config.drop-shadow' | translate }} {{ 'widget-config.drop-shadow' | translate }}
</mat-slide-toggle> </mat-slide-toggle>
@ -126,7 +132,6 @@
<ng-template matExpansionPanelContent> <ng-template matExpansionPanelContent>
<tb-json-object-edit <tb-json-object-edit
[editorStyle]="{minHeight: '100px'}" [editorStyle]="{minHeight: '100px'}"
required
label="{{ 'widget-config.widget-style' | translate }}" label="{{ 'widget-config.widget-style' | translate }}"
formControlName="widgetStyle" formControlName="widgetStyle"
></tb-json-object-edit> ></tb-json-object-edit>

2
ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts

@ -224,6 +224,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe
color: [null, []], color: [null, []],
padding: [null, []], padding: [null, []],
margin: [null, []], margin: [null, []],
borderRadius: [null, []],
widgetStyle: [null, []], widgetStyle: [null, []],
widgetCss: [null, []], widgetCss: [null, []],
titleStyle: [null, []], titleStyle: [null, []],
@ -484,6 +485,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe
color: config.color, color: config.color,
padding: config.padding, padding: config.padding,
margin: config.margin, margin: config.margin,
borderRadius: config.borderRadius,
widgetStyle: isDefined(config.widgetStyle) ? config.widgetStyle : {}, widgetStyle: isDefined(config.widgetStyle) ? config.widgetStyle : {},
widgetCss: isDefined(config.widgetCss) ? config.widgetCss : '', widgetCss: isDefined(config.widgetCss) ? config.widgetCss : '',
titleStyle: isDefined(config.titleStyle) ? config.titleStyle : { titleStyle: isDefined(config.titleStyle) ? config.titleStyle : {

5
ui-ngx/src/app/modules/home/models/dashboard-component.models.ts

@ -328,6 +328,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
backgroundColor: string; backgroundColor: string;
padding: string; padding: string;
margin: string; margin: string;
borderRadius: string;
title: string; title: string;
customTranslatedTitle: string; customTranslatedTitle: string;
@ -427,6 +428,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
this.backgroundColor = this.widget.config.backgroundColor || '#fff'; this.backgroundColor = this.widget.config.backgroundColor || '#fff';
this.padding = this.widget.config.padding || '8px'; this.padding = this.widget.config.padding || '8px';
this.margin = this.widget.config.margin || '0px'; this.margin = this.widget.config.margin || '0px';
this.borderRadius = this.widget.config.borderRadius;
this.title = isDefined(this.widgetContext.widgetTitle) this.title = isDefined(this.widgetContext.widgetTitle)
&& this.widgetContext.widgetTitle.length ? this.widgetContext.widgetTitle : this.widget.config.title; && this.widgetContext.widgetTitle.length ? this.widgetContext.widgetTitle : this.widget.config.title;
@ -478,7 +480,8 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
color: this.color, color: this.color,
backgroundColor: this.backgroundColor, backgroundColor: this.backgroundColor,
padding: this.padding, padding: this.padding,
margin: this.margin}; margin: this.margin,
borderRadius: this.borderRadius};
if (this.widget.config.widgetStyle) { if (this.widget.config.widgetStyle) {
this.style = {...this.style, ...this.widget.config.widgetStyle}; this.style = {...this.style, ...this.widget.config.widgetStyle};
} }

15
ui-ngx/src/app/shared/components/json-object-edit.component.ts

@ -14,7 +14,16 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; import {
ChangeDetectorRef,
Component,
ElementRef,
forwardRef,
Input,
OnDestroy,
OnInit,
ViewChild
} from '@angular/core';
import { ControlValueAccessor, UntypedFormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms'; import { ControlValueAccessor, UntypedFormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms';
import { Ace } from 'ace-builds'; import { Ace } from 'ace-builds';
import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { coerceBooleanProperty } from '@angular/cdk/coercion';
@ -104,7 +113,8 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
constructor(public elementRef: ElementRef, constructor(public elementRef: ElementRef,
protected store: Store<AppState>, protected store: Store<AppState>,
private raf: RafService) { private raf: RafService,
private cd: ChangeDetectorRef) {
} }
ngOnInit(): void { ngOnInit(): void {
@ -283,6 +293,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
} }
this.modelValue = data; this.modelValue = data;
this.propagateChange(data); this.propagateChange(data);
this.cd.markForCheck();
} }
} }

1
ui-ngx/src/app/shared/models/widget.models.ts

@ -637,6 +637,7 @@ export interface WidgetConfig {
backgroundColor?: string; backgroundColor?: string;
padding?: string; padding?: string;
margin?: string; margin?: string;
borderRadius?: string;
widgetStyle?: {[klass: string]: any}; widgetStyle?: {[klass: string]: any};
widgetCss?: string; widgetCss?: string;
titleStyle?: {[klass: string]: any}; titleStyle?: {[klass: string]: any};

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

@ -4190,6 +4190,7 @@
"enable-fullscreen": "Enable fullscreen", "enable-fullscreen": "Enable fullscreen",
"background-color": "Background color", "background-color": "Background color",
"text-color": "Text color", "text-color": "Text color",
"border-radius": "Border radius",
"padding": "Padding", "padding": "Padding",
"margin": "Margin", "margin": "Margin",
"widget-style": "Widget style", "widget-style": "Widget style",

Loading…
Cancel
Save