|
|
|
@ -43,6 +43,10 @@ import { |
|
|
|
CellClickColumnInfo, |
|
|
|
defaultWidgetAction, |
|
|
|
WidgetActionSource, |
|
|
|
WidgetHeaderActionButtonType, |
|
|
|
widgetHeaderActionButtonTypeMap, |
|
|
|
WidgetHeaderActionButtonTypes, |
|
|
|
widgetHeaderActionButtonTypeTranslationMap, |
|
|
|
widgetType |
|
|
|
} from '@shared/models/widget.models'; |
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
@ -85,6 +89,11 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia |
|
|
|
configuredColumns: Array<CellClickColumnInfo> = []; |
|
|
|
usedCellClickColumns: Array<number> = []; |
|
|
|
|
|
|
|
widgetHeaderActionButtonType = WidgetHeaderActionButtonType |
|
|
|
widgetHeaderActionButtonTypes = WidgetHeaderActionButtonTypes; |
|
|
|
widgetHeaderActionButtonTypeTranslationMap = widgetHeaderActionButtonTypeTranslationMap; |
|
|
|
widgetHeaderActionButtonTypeMap = widgetHeaderActionButtonTypeMap; |
|
|
|
|
|
|
|
@ViewChild('columnIndexSelect') columnIndexSelect: MatSelect; |
|
|
|
columnIndexPlaceholderText = this.translate.instant('widget-config.select-column-index'); |
|
|
|
|
|
|
|
@ -120,12 +129,19 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia |
|
|
|
actionSourceId: [this.action.actionSourceId, Validators.required], |
|
|
|
columnIndex: [{value: this.checkColumnIndex(this.action.columnIndex), disabled: true}, Validators.required], |
|
|
|
name: [this.action.name, [this.validateActionName(), Validators.required]], |
|
|
|
buttonType: [isDefinedAndNotNull(this.action.buttonType) ? this.action.buttonType : WidgetHeaderActionButtonType.icon, []], |
|
|
|
showIcon: [isDefinedAndNotNull(this.action.showIcon) ? this.action.showIcon : true, []], |
|
|
|
icon: [this.action.icon, Validators.required], |
|
|
|
buttonColor: [isDefinedAndNotNull(this.action.buttonColor) ? this.action.buttonColor : 'rgba(0, 0, 0, 0.87)', []], |
|
|
|
buttonFillColor: [isDefinedAndNotNull(this.action.buttonFillColor) ? this.action.buttonFillColor : '#3F52DD', []], |
|
|
|
buttonBorderColor: [isDefinedAndNotNull(this.action.buttonBorderColor) ? this.action.buttonBorderColor : '#3F52DD', []], |
|
|
|
customButtonStyle: [isDefinedAndNotNull(this.action.customButtonStyle) ? this.action.customButtonStyle : '', []], |
|
|
|
useShowWidgetActionFunction: [this.action.useShowWidgetActionFunction], |
|
|
|
showWidgetActionFunction: [this.action.showWidgetActionFunction || 'return true;'], |
|
|
|
widgetAction: [actionDescriptorToAction(toWidgetActionDescriptor(this.action)), Validators.required] |
|
|
|
}); |
|
|
|
this.updateShowWidgetActionForm(); |
|
|
|
this.widgetHeaderButtonValidators(); |
|
|
|
this.widgetActionFormGroup.get('actionSourceId').valueChanges.pipe( |
|
|
|
takeUntil(this.destroy$) |
|
|
|
).subscribe((value) => { |
|
|
|
@ -143,6 +159,9 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia |
|
|
|
).subscribe(() => { |
|
|
|
this.updateShowWidgetActionForm(); |
|
|
|
}); |
|
|
|
this.widgetActionFormGroup.get('buttonType').valueChanges.pipe( |
|
|
|
takeUntil(this.destroy$) |
|
|
|
).subscribe(() => this.widgetHeaderButtonValidators()); |
|
|
|
setTimeout(() => { |
|
|
|
if (this.action?.actionSourceId === 'cellClick') { |
|
|
|
this.widgetActionFormGroup.get('columnIndex').enable(); |
|
|
|
@ -160,6 +179,31 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia |
|
|
|
super.ngOnDestroy(); |
|
|
|
} |
|
|
|
|
|
|
|
widgetHeaderButtonValidators() { |
|
|
|
const buttonType = this.widgetActionFormGroup.get('buttonType').value; |
|
|
|
this.widgetActionFormGroup.get('showIcon').disable({emitEvent: false}); |
|
|
|
this.widgetActionFormGroup.get('buttonFillColor').disable({emitEvent: false}); |
|
|
|
this.widgetActionFormGroup.get('buttonBorderColor').disable({emitEvent: false}); |
|
|
|
switch (buttonType) { |
|
|
|
case WidgetHeaderActionButtonType.basic: |
|
|
|
this.widgetActionFormGroup.get('showIcon').enable({emitEvent: false}); |
|
|
|
break; |
|
|
|
case WidgetHeaderActionButtonType.raised: |
|
|
|
this.widgetActionFormGroup.get('showIcon').enable({emitEvent: false}); |
|
|
|
this.widgetActionFormGroup.get('buttonFillColor').enable({emitEvent: false}); |
|
|
|
break; |
|
|
|
case WidgetHeaderActionButtonType.stroked: |
|
|
|
case WidgetHeaderActionButtonType.flat: |
|
|
|
this.widgetActionFormGroup.get('showIcon').enable({emitEvent: false}); |
|
|
|
this.widgetActionFormGroup.get('buttonFillColor').enable({emitEvent: false}); |
|
|
|
this.widgetActionFormGroup.get('buttonBorderColor').enable({emitEvent: false}); |
|
|
|
break; |
|
|
|
case WidgetHeaderActionButtonType.miniFab: |
|
|
|
this.widgetActionFormGroup.get('buttonFillColor').enable({emitEvent: false}); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
displayShowWidgetActionForm(): boolean { |
|
|
|
return !!this.data.actionsData.actionSources[this.widgetActionFormGroup.get('actionSourceId').value]?.hasShowCondition; |
|
|
|
} |
|
|
|
|