12265 lines
353 KiB
Plaintext
12265 lines
353 KiB
Plaintext
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.component.html
|
|
|
|
<!-- Component Template -->
|
|
<ng-container *ngIf="getValue(wrapWithCard) | async; else formRef">
|
|
<x-card
|
|
class="x-card"
|
|
[showActions]="true"
|
|
[color]="getValue(cardColor) | async"
|
|
[ngClass]="getValue(cssClass) | async"
|
|
[isInPage]="getValue(isInPage) | async"
|
|
[showHeader]="
|
|
(notEmptyValue(cardTitle) | async) ||
|
|
(notEmptyValue(cardSubTitle) | async)
|
|
"
|
|
[subTitle]="getResourceValue(cardSubTitle)"
|
|
[title]="getResourceValue(cardTitle) | async"
|
|
[showFooter]="getValue(cardShowFooter) | async"
|
|
[showActions]="getValue(cardShowActions) | async"
|
|
[foregroundColor]="getValue(cardForegroundColor) | async"
|
|
>
|
|
<!-- Content -->
|
|
<ng-container *ngTemplateOutlet="formRef"></ng-container>
|
|
|
|
<!-- Actions -->
|
|
<div [ngClass]="getFormCardActionsCssClass() | async" actions>
|
|
<ng-content select="[actions]"></ng-content>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div
|
|
footer
|
|
*ngIf="getValue(cardShowFooter) | async"
|
|
[ngClass]="getFormCardFooterCssClass() | async"
|
|
>
|
|
<ng-content select="[footer]"></ng-content>
|
|
</div>
|
|
</x-card>
|
|
</ng-container>
|
|
|
|
<!-- Form itSelf Template -->
|
|
<ng-template #formRef>
|
|
<!-- Form Wrapper -->
|
|
<div
|
|
*ngIf="form"
|
|
class="x-form x-wrapper"
|
|
[class.mobile]="isMobileUi$ | async"
|
|
>
|
|
<!-- Form Element -->
|
|
<form
|
|
*ngIf="form"
|
|
[formGroup]="form"
|
|
[ngClass]="getFormCssClass() | async"
|
|
style="width: 100%"
|
|
>
|
|
<ng-container *ngIf="hasChildValue(getFormControls()) | async">
|
|
<!-- Presenting Props -->
|
|
<ng-container
|
|
*ngFor="
|
|
let control of getFormControls() | async;
|
|
index as controlIndex
|
|
"
|
|
>
|
|
<!-- Check Control Exists -->
|
|
<ng-container *ngIf="control">
|
|
<ng-container
|
|
*ngIf="getControlType(control) | async as controlType"
|
|
>
|
|
<!-- 1- Input Type (Text/Number/Password/Email/Url/Color/Tel) Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
controlType === ControlTypes.Text ||
|
|
controlType === ControlTypes.Number ||
|
|
controlType === ControlTypes.Password ||
|
|
controlType === ControlTypes.Color ||
|
|
controlType === ControlTypes.Email ||
|
|
controlType === ControlTypes.Url ||
|
|
controlType === ControlTypes.Tel
|
|
"
|
|
>
|
|
<!-- Auto Complete Wrapper -->
|
|
<div
|
|
class="x-auto-complete-wrapper"
|
|
(xOnOutsideClicked)="
|
|
handleAutoCompleteOutsideClicked(control)
|
|
"
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div>
|
|
<!-- Not None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) !==
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- Mat Form Field -->
|
|
<mat-form-field
|
|
class="x-mat-form-field"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[appearance]="getControlAppearance(control) | async"
|
|
>
|
|
<!-- label -->
|
|
<mat-label
|
|
class="x-field-label"
|
|
*ngIf="
|
|
notEmptyValue(getControlLabel(control)) | async
|
|
"
|
|
>{{ getControlLabel(control) | async }}</mat-label
|
|
>
|
|
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="controlHasFormatter(control) | async"
|
|
>
|
|
<input
|
|
matInput
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[inputFormatterType]="
|
|
getFormatterType(control) | async
|
|
"
|
|
[formControlName]="control.propName.toString()"
|
|
[enabledInputFormatter]="
|
|
controlHasFormatter(control) | async
|
|
"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[stringInputFormatterType]="
|
|
getFormatterInputType(control) | async
|
|
"
|
|
[currencyLable]="
|
|
getFormatterCurrencyLabel(control) | async
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
[stringFormatter]="
|
|
getFormatterStringFormatter(control) | async
|
|
"
|
|
(xOnEscape)="handleAutoCompleteEscaped(control)"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[readonly]="isInputControlReadOnly(control) | async"
|
|
[seperator]="getFormatterSeperator(control) | async"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="!(controlHasFormatter(control) | async)"
|
|
>
|
|
<input
|
|
matInput
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(xOnEscape)="handleAutoCompleteEscaped(control)"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[readonly]="isInputControlReadOnly(control) | async"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Prefix Icon -->
|
|
<span
|
|
matPrefix
|
|
*ngIf="controlHasPrefixIcon(control) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</span>
|
|
|
|
<!-- Suffix Icon -->
|
|
<span
|
|
matSuffix
|
|
*ngIf="controlHasSuffixIcon(control) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</span>
|
|
</mat-form-field>
|
|
</ng-container>
|
|
|
|
<!-- None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) ===
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
byIconLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="controlHasFormatter(control) | async"
|
|
>
|
|
<input
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[inputFormatterType]="
|
|
getFormatterType(control) | async
|
|
"
|
|
[formControlName]="control.propName.toString()"
|
|
[enabledInputFormatter]="
|
|
controlHasFormatter(control) | async
|
|
"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
[stringInputFormatterType]="
|
|
getFormatterInputType(control) | async
|
|
"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
[currencyLable]="
|
|
getFormatterCurrencyLabel(control) | async
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
[stringFormatter]="
|
|
getFormatterStringFormatter(control) | async
|
|
"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[seperator]="getFormatterSeperator(control) | async"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="!(controlHasFormatter(control) | async)"
|
|
>
|
|
<input
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
hintRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Auto Complete -->
|
|
<div
|
|
[id]="getAutoCompleteId(control)"
|
|
[ngClass]="getAutoCompleteCssClass(control) | async"
|
|
[class.open]="getAutoCompleteOpened(control) | async"
|
|
*ngIf="
|
|
(controlHasAutoComplete(control) | async) &&
|
|
(hasChildValue(getAutoCompleteItems(control)) | async)
|
|
"
|
|
>
|
|
<ng-container
|
|
*ngIf="
|
|
getControlAutoCompleteConfig(control)
|
|
| async as autoComplete
|
|
"
|
|
>
|
|
<ng-container
|
|
*ngIf="getAutoCompleteItems(control) as items"
|
|
>
|
|
<x-list
|
|
[items]="items"
|
|
[showEmpty]="false"
|
|
[showToolbar]="false"
|
|
[wrapWithCard]="false"
|
|
[clickableItems]="true"
|
|
[uiDisabled]="uiDisabled"
|
|
[color]="getAutoCompleteColor(control) | async"
|
|
(itemSelected)="
|
|
handleAutoCompleteResultSelected(
|
|
control,
|
|
autoComplete,
|
|
$event
|
|
)
|
|
"
|
|
[itemTemplate]="
|
|
getAutoCompleteItemTemplate(control) | async
|
|
"
|
|
></x-list>
|
|
</ng-container>
|
|
</ng-container>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 2- Select -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasSelectConfig(control) | async) &&
|
|
controlType === ControlTypes.Select
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- Not None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) !==
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- Mat Form Field -->
|
|
<mat-form-field
|
|
class="x-mat-form-field"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[appearance]="getControlAppearance(control) | async"
|
|
>
|
|
<!-- label -->
|
|
<mat-label
|
|
class="x-field-label"
|
|
*ngIf="notEmptyValue(getControlLabel(control)) | async"
|
|
>{{ getControlLabel(control) | async }}</mat-label
|
|
>
|
|
|
|
<!-- Select -->
|
|
<mat-select
|
|
[formControlName]="control.propName.toString()"
|
|
[multiple]="getSelectMultiple(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[class.multiple]="getSelectMultiple(control) | async"
|
|
[panelClass]="getSelectPanelClasses(control) | async"
|
|
[placeholder]="getControlPlaceHolder(control) | async"
|
|
>
|
|
<mat-option
|
|
[value]="getValue(option.value) | async"
|
|
[ngClass]="getOptionClassName(option) | async"
|
|
*ngFor="
|
|
let option of getSelectOptions(control) | async
|
|
"
|
|
>
|
|
{{ getResourceValue(option.viewValue) | async }}
|
|
</mat-option>
|
|
</mat-select>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Prefix Icon -->
|
|
<span
|
|
matPrefix
|
|
*ngIf="controlHasPrefixIcon(control) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</span>
|
|
|
|
<!-- Suffix Icon -->
|
|
<span
|
|
matSuffix
|
|
*ngIf="controlHasSuffixIcon(control) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</span>
|
|
</mat-form-field>
|
|
</ng-container>
|
|
|
|
<!-- None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) ===
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
byIconLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Select -->
|
|
<mat-select
|
|
[formControlName]="control.propName.toString()"
|
|
[multiple]="getSelectMultiple(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[class.multiple]="getSelectMultiple(control) | async"
|
|
[panelClass]="getSelectPanelClasses(control) | async"
|
|
[placeholder]="getControlPlaceHolder(control) | async"
|
|
>
|
|
<mat-option
|
|
[value]="getValue(option.value) | async"
|
|
[ngClass]="getOptionClassName(option) | async"
|
|
*ngFor="
|
|
let option of getSelectOptions(control) | async
|
|
"
|
|
>
|
|
{{ getResourceValue(option.viewValue) | async }}
|
|
</mat-option>
|
|
</mat-select>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 3- Radio Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasRadioConfig(control) | async) &&
|
|
controlType === ControlTypes.Radio
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
byIconLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Content -->
|
|
<mat-radio-group
|
|
[formControlName]="control.propName.toString()"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[labelPosition]="getRadioLabelPosition(control) | async"
|
|
>
|
|
<mat-radio-button
|
|
#radioButton
|
|
class="x-radio-button"
|
|
[class.active]="radioButton.checked"
|
|
[value]="getValue(option.value) | async"
|
|
[ngClass]="getOptionClassName(option) | async"
|
|
*ngFor="let option of getRadioOptions(control) | async"
|
|
>
|
|
{{ getResourceValue(option.viewValue) | async }}
|
|
</mat-radio-button>
|
|
</mat-radio-group>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 4- Checkbox Type -->
|
|
<ng-container *ngIf="controlType === ControlTypes.CheckBox">
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
>
|
|
<!-- Content -->
|
|
<x-slotter
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[hasStartOrTopSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasPrefixIcon(control) | async)
|
|
"
|
|
[hasEndOrBottomSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasSuffixIcon(control) | async)
|
|
"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<mat-checkbox
|
|
[formControlName]="control.propName.toString()"
|
|
[labelPosition]="
|
|
getCheckboxLabelPosition(control) | async
|
|
"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[class.has-icon]="controlHasIcons(control) | async"
|
|
(change)="
|
|
handleCheckboxCheckedChange(control, $event.checked)
|
|
"
|
|
>
|
|
<!-- label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultFieldLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</mat-checkbox>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 5- Toggle Type -->
|
|
<ng-container *ngIf="controlType === ControlTypes.Toggle">
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
>
|
|
<!-- Content -->
|
|
<x-slotter
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[hasStartOrTopSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasPrefixIcon(control) | async)
|
|
"
|
|
[hasEndOrBottomSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasSuffixIcon(control) | async)
|
|
"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<!-- Content -->
|
|
<mat-slide-toggle
|
|
[formControlName]="control.propName.toString()"
|
|
[labelPosition]="
|
|
getToggleLabelPosition(control) | async
|
|
"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[class.has-icon]="controlHasIcons(control) | async"
|
|
>
|
|
<!-- label -->
|
|
<mat-label
|
|
class="x-field-label"
|
|
*ngIf="
|
|
notEmptyValue(getControlLabel(control)) | async
|
|
"
|
|
>
|
|
{{ getControlLabel(control) | async }}
|
|
</mat-label>
|
|
</mat-slide-toggle>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 6- Slider Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasSliderConfig(control) | async) &&
|
|
controlType === ControlTypes.Slider
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
byIconLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Content -->
|
|
<!-- [disabled]="getControlDisabled(control) | async" -->
|
|
<mat-slider
|
|
[formControlName]="control.propName.toString()"
|
|
[min]="getSliderMin(control) | async"
|
|
[max]="getSliderMax(control) | async"
|
|
[step]="getSliderStep(control) | async"
|
|
[invert]="getSliderInvert(control) | async"
|
|
[vertical]="isSliderVertical(control) | async"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[displayWith]="getSliderFormatter(control) | async"
|
|
[thumbLabel]="showSliderThumbLabel(control) | async"
|
|
[class.vertical]="isSliderVertical(control) | async"
|
|
>
|
|
</mat-slider>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 7- Date Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasDateConfig(control) | async) &&
|
|
controlType === ControlTypes.Date
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- Not None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) !==
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- Form Field -->
|
|
<mat-form-field
|
|
class="x-mat-form-field"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[appearance]="getControlAppearance(control) | async"
|
|
>
|
|
<!-- label -->
|
|
<mat-label
|
|
class="x-field-label"
|
|
*ngIf="notEmptyValue(getControlLabel(control)) | async"
|
|
>{{ getControlLabel(control) | async }}</mat-label
|
|
>
|
|
|
|
<!-- Date Input -->
|
|
<input
|
|
matInput
|
|
autocomplete="off"
|
|
[matDatepicker]="dp"
|
|
[formControlName]="control.propName.toString()"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerInputDisabled(control) | async)
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[matDatepickerFilter]="getDateFilter(control) | async"
|
|
[placeholder]="getControlPlaceHolder(control) | async"
|
|
(dateInput)="
|
|
handleDatePickerDateInput(control.propName.toString(), $event)
|
|
"
|
|
(dateChange)="
|
|
handleDatePickerDateChange(control.propName.toString(), $event)
|
|
"
|
|
/>
|
|
|
|
<!-- Date Toggler Icon -->
|
|
<!-- Prefix -->
|
|
<mat-datepicker-toggle
|
|
[for]="dp"
|
|
matPrefix
|
|
[disabled]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerToggleDisabled(control) | async)
|
|
"
|
|
*ngIf="isDatePickerHasPrefixIcon(control) | async"
|
|
>
|
|
<x-icon
|
|
[selectable]="true"
|
|
matDatepickerToggleIcon
|
|
class="x-date-picker-icon"
|
|
[name]="getDatePickerIcon(control) | async"
|
|
[color]="getDatePickerIconColor(control) | async"
|
|
[matTooltip]="
|
|
getDatePickerIconTooltip(control) | async
|
|
"
|
|
[class.x-status-handler]="
|
|
getDatePickerIconApplyStateColor(control) | async
|
|
"
|
|
>
|
|
</x-icon>
|
|
</mat-datepicker-toggle>
|
|
|
|
<!-- Suffix -->
|
|
<mat-datepicker-toggle
|
|
[for]="dp"
|
|
matSuffix
|
|
[disabled]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerToggleDisabled(control) | async)
|
|
"
|
|
*ngIf="isDatePickerHasSuffixIcon(control) | async"
|
|
>
|
|
<x-icon
|
|
[selectable]="true"
|
|
[color]="'cb-inherit'"
|
|
matDatepickerToggleIcon
|
|
class="x-date-picker-icon"
|
|
[name]="getDatePickerIcon(control) | async"
|
|
[color]="getDatePickerIconColor(control) | async"
|
|
[matTooltip]="
|
|
getDatePickerIconTooltip(control) | async
|
|
"
|
|
[class.x-status-handler]="
|
|
getDatePickerIconApplyStateColor(control) | async
|
|
"
|
|
>
|
|
</x-icon>
|
|
</mat-datepicker-toggle>
|
|
|
|
<!-- Date Picker Component -->
|
|
<mat-datepicker
|
|
#dp
|
|
[touchUi]="isMobileUi$ | async"
|
|
[startAt]="getDateStartAt(control) | async"
|
|
[disabled]="getControlDisabled(control) | async"
|
|
[ngClass]="getDatePickerClasses(control) | async"
|
|
[panelClass]="getDatePickerClasses(control) | async"
|
|
></mat-datepicker>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</mat-form-field>
|
|
</ng-container>
|
|
|
|
<!-- None Appearance -->
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlAppearanceObject(control) | async) ===
|
|
FormControlAppearances.None
|
|
"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
byIconLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Content -->
|
|
<x-slotter
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[centerSlotCssClass]="'full-heigh'"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
[hasStartOrTopSlot]="
|
|
isDatePickerHasPrefixIcon(control) | async
|
|
"
|
|
[hasEndOrBottomSlot]="
|
|
isDatePickerHasSuffixIcon(control) | async
|
|
"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Date Toggler Icon -->
|
|
<!-- Prefix -->
|
|
<mat-datepicker-toggle
|
|
[for]="dp"
|
|
matPrefix
|
|
[disabled]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerToggleDisabled(control) | async)
|
|
"
|
|
*ngIf="isDatePickerHasPrefixIcon(control) | async"
|
|
>
|
|
<x-icon
|
|
[selectable]="true"
|
|
matDatepickerToggleIcon
|
|
class="x-date-picker-icon"
|
|
[name]="getDatePickerIcon(control) | async"
|
|
[color]="getDatePickerIconColor(control) | async"
|
|
[matTooltip]="
|
|
getDatePickerIconTooltip(control) | async
|
|
"
|
|
[class.x-status-handler]="
|
|
getDatePickerIconApplyStateColor(control)
|
|
| async
|
|
"
|
|
>
|
|
</x-icon>
|
|
</mat-datepicker-toggle>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<!-- Date Input -->
|
|
<input
|
|
matInput
|
|
autocomplete="off"
|
|
[matDatepicker]="dp"
|
|
(dateInput)="
|
|
handleDatePickerDateInput(
|
|
control.propName.toString(),
|
|
$event
|
|
)
|
|
"
|
|
(dateChange)="
|
|
handleDatePickerDateChange(
|
|
control.propName.toString(),
|
|
$event
|
|
)
|
|
"
|
|
[matDatepickerFilter]="
|
|
getDateFilter(control) | async
|
|
"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerInputDisabled(control) | async)
|
|
"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
/>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Date Toggler Icon -->
|
|
<!-- Suffix -->
|
|
<mat-datepicker-toggle
|
|
[for]="dp"
|
|
matSuffix
|
|
[disabled]="
|
|
(getControlDisabled(control) | async) ||
|
|
(isDatePickerToggleDisabled(control) | async)
|
|
"
|
|
*ngIf="isDatePickerHasSuffixIcon(control) | async"
|
|
>
|
|
<x-icon
|
|
[selectable]="true"
|
|
[color]="'cb-inherit'"
|
|
matDatepickerToggleIcon
|
|
class="x-date-picker-icon"
|
|
[name]="getDatePickerIcon(control) | async"
|
|
[color]="getDatePickerIconColor(control) | async"
|
|
[matTooltip]="
|
|
getDatePickerIconTooltip(control) | async
|
|
"
|
|
[class.x-status-handler]="
|
|
getDatePickerIconApplyStateColor(control)
|
|
| async
|
|
"
|
|
>
|
|
</x-icon>
|
|
</mat-datepicker-toggle>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Date Picker Component -->
|
|
<mat-datepicker
|
|
#dp
|
|
[touchUi]="isMobileUi$ | async"
|
|
[startAt]="getDateStartAt(control) | async"
|
|
[disabled]="getControlDisabled(control) | async"
|
|
[ngClass]="getDatePickerClasses(control) | async"
|
|
[panelClass]="getDatePickerClasses(control) | async"
|
|
></mat-datepicker>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 8- Hidden Type -->
|
|
<ng-container *ngIf="controlType === ControlTypes.Hidden">
|
|
<input
|
|
type="hidden"
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- 9- Markdown Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasMarkdownConfig(control) | async) &&
|
|
controlType === ControlTypes.MarkDown
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
markdownRef;
|
|
context: {
|
|
$implicit: control,
|
|
controlIndex: controlIndex
|
|
}
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 10- Avatar Upload -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasAvatarConfig(control) | async) &&
|
|
controlType === ControlTypes.AvatarUpload
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
avatarRef;
|
|
context: {
|
|
$implicit: control,
|
|
controlIndex: controlIndex
|
|
}
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 11- Map Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasMapConfig(control) | async) &&
|
|
controlType === ControlTypes.Map
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultFieldLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Control Input Element -->
|
|
<x-slotter
|
|
[hasStartOrTopSlot]="true"
|
|
[hasEndOrBottomSlot]="true"
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Prefix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Prefix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="controlHasFormatter(control) | async"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[seperator]="getFormatterSeperator(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisableInput(control) | async) ||
|
|
(getControlDisabled(control) | async)
|
|
"
|
|
[inputFormatterType]="
|
|
getFormatterType(control) | async
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[currencyLable]="
|
|
getFormatterCurrencyLabel(control) | async
|
|
"
|
|
[enabledInputFormatter]="
|
|
controlHasFormatter(control) | async
|
|
"
|
|
[stringFormatter]="
|
|
getFormatterStringFormatter(control) | async
|
|
"
|
|
[stringInputFormatterType]="
|
|
getFormatterInputType(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="!(controlHasFormatter(control) | async)"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisableInput(control) | async) ||
|
|
(getControlDisabled(control) | async)
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Suffix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Suffix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Content -->
|
|
<ng-container
|
|
*ngIf="!(isMapPresentWithDialog(control) | async)"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
mapContentRef;
|
|
context: { $implicit: control }
|
|
"
|
|
>
|
|
</ng-container>
|
|
</ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 12- ColorPicker Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasColorPickerConfig(control) | async) &&
|
|
controlType === ControlTypes.ColorPicker
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultFieldLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Control Input Element -->
|
|
<x-slotter
|
|
[hasStartOrTopSlot]="true"
|
|
[hasEndOrBottomSlot]="true"
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Prefix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Prefix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<div fxLayout="row" fxLayoutAlign="none">
|
|
<!-- Input Box -->
|
|
<div fxFlex>
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="controlHasFormatter(control) | async"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[xFocus]="
|
|
getControlFocusHandler(control) | async
|
|
"
|
|
[matTooltip]="
|
|
getControlTooltip(control) | async
|
|
"
|
|
[seperator]="
|
|
getFormatterSeperator(control) | async
|
|
"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisableInput(control) | async) ||
|
|
(getControlDisabled(control) | async)
|
|
"
|
|
[inputFormatterType]="
|
|
getFormatterType(control) | async
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[currencyLable]="
|
|
getFormatterCurrencyLabel(control) | async
|
|
"
|
|
[enabledInputFormatter]="
|
|
controlHasFormatter(control) | async
|
|
"
|
|
[stringFormatter]="
|
|
getFormatterStringFormatter(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(getControlDisableInput(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
[stringInputFormatterType]="
|
|
getFormatterInputType(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="!(controlHasFormatter(control) | async)"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[xFocus]="
|
|
getControlFocusHandler(control) | async
|
|
"
|
|
[matTooltip]="
|
|
getControlTooltip(control) | async
|
|
"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisableInput(control) | async) ||
|
|
(getControlDisabled(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
</div>
|
|
|
|
<!-- Color Preview -->
|
|
<div
|
|
*ngIf="
|
|
isColorPickerPresentWithDialog(control) | async
|
|
"
|
|
>
|
|
<x-color
|
|
[size]="22"
|
|
[showLabel]="false"
|
|
[value]="{
|
|
key: 'color',
|
|
value: getControl(control.propName.toString()).value
|
|
}"
|
|
[borderWidth]="
|
|
getColorPickerColorViewBorderWidth(control)
|
|
| async
|
|
"
|
|
[borderStyle]="
|
|
getColorPickerColorViewBorderStyle(control)
|
|
| async
|
|
"
|
|
[borderColor]="
|
|
getColorPickerColorViewBorderColor(control)
|
|
| async
|
|
"
|
|
></x-color>
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Suffix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Suffix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Content -->
|
|
<ng-container
|
|
*ngIf="!(isColorPickerPresentWithDialog(control) | async)"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
colorPickerContentRef;
|
|
context: { $implicit: control }
|
|
"
|
|
>
|
|
</ng-container>
|
|
</ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- 13- Selector Type -->
|
|
<ng-container
|
|
*ngIf="
|
|
(hasSelectorConfig(control) | async) &&
|
|
controlType === ControlTypes.Selector
|
|
"
|
|
>
|
|
<!-- Form Control Wrapper -->
|
|
<div
|
|
[hidden]="getControlHidden(control) | async"
|
|
[class.show]="!(getControlHidden(control) | async)"
|
|
[ngClass]="getFormControlWrapperClasses(control) | async"
|
|
[class.readonly]="isInputControlReadOnly(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[enableHandler]="
|
|
!uiDisabled &&
|
|
!loading &&
|
|
!(getControlDisabled(control) | async)
|
|
"
|
|
[class.apply-status]="
|
|
getValue(applyStatusOnControls) | async
|
|
"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultFieldLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Control Input Element -->
|
|
<x-slotter
|
|
[hasStartOrTopSlot]="true"
|
|
[hasEndOrBottomSlot]="true"
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
prefixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Prefix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Prefix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="controlHasFormatter(control) | async"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[seperator]="getFormatterSeperator(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(getControlDisableInput(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
[inputFormatterType]="
|
|
getFormatterType(control) | async
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
[currencyLable]="
|
|
getFormatterCurrencyLabel(control) | async
|
|
"
|
|
[enabledInputFormatter]="
|
|
controlHasFormatter(control) | async
|
|
"
|
|
[stringFormatter]="
|
|
getFormatterStringFormatter(control) | async
|
|
"
|
|
[stringInputFormatterType]="
|
|
getFormatterInputType(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container
|
|
*ngIf="!(controlHasFormatter(control) | async)"
|
|
>
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[placeholder]="
|
|
getControlPlaceHolder(control) | async
|
|
"
|
|
[readonly]="
|
|
(getControlDisabled(control) | async) ||
|
|
(getControlDisableInput(control) | async) ||
|
|
(isInputControlReadOnly(control) | async)
|
|
"
|
|
[ngClass]="
|
|
getControlInputElementClasses(control) | async
|
|
"
|
|
/>
|
|
</ng-container>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
suffixIconRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
|
|
<!-- Action Suffix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Suffix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
loadingRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
errorsRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</form>
|
|
|
|
<!-- Custom Content -->
|
|
<ng-content select="[contents]"></ng-content>
|
|
|
|
<!-- Form Error Handlers -->
|
|
<div
|
|
[ngClass]="getFormErrorsClasses() | async"
|
|
*ngIf="errors && (formHasErrorHandlers() | async)"
|
|
>
|
|
<!-- Errors -->
|
|
<ng-container *ngIf="getFormErrorHandlers() | async as errorHandlers">
|
|
<mat-error
|
|
*ngFor="let handler of errorHandlers"
|
|
[class.show]="formHasError(handler) | async"
|
|
[ngClass]="getFormErrorClasses(handler) | async"
|
|
>
|
|
<span class="x-error-message">
|
|
{{ getErrorHandlerErrorMessage(handler) | async }}
|
|
</span>
|
|
</mat-error>
|
|
</ng-container>
|
|
</div>
|
|
</div>
|
|
</ng-template>
|
|
|
|
<!-- 9- MarkDown Template -->
|
|
<ng-template #markdownRef let-control let-controlIndex="controlIndex">
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
xFormFieldRef;
|
|
context: {
|
|
$implicit: control,
|
|
controlIndex: controlIndex,
|
|
fieldLabelRef: byIconLabelRef,
|
|
fieldContentRef: markdownContentRef
|
|
}
|
|
"
|
|
>
|
|
</ng-container>
|
|
</ng-template>
|
|
|
|
<!-- 10 -Avatar Template -->
|
|
<ng-template #avatarRef let-control let-controlIndex="controlIndex">
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
xFormFieldRef;
|
|
context: {
|
|
$implicit: control,
|
|
controlIndex: controlIndex,
|
|
fieldLabelRef: defaultFieldLabelRef,
|
|
fieldContentRef: avatarContentRef
|
|
}
|
|
"
|
|
>
|
|
</ng-container>
|
|
</ng-template>
|
|
|
|
<!-- //#region Templates -->
|
|
<!-- MarkDown Content Template -->
|
|
<ng-template #markdownContentRef let-control>
|
|
<!-- Markdown Component -->
|
|
<x-markdown
|
|
[mode]="getMarkdownMode(control) | async"
|
|
[isInPage]="isMarkdownInPage(control) | async"
|
|
[content]="getMarkDownContent(control) | async"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
[cssClass]="getMarkdownCssClass(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[cardTitle]="getMarkdownCardTitle(control) | async"
|
|
[cardColor]="getMarkdownCardColor(control) | async"
|
|
[toolbarForegroundColor]="
|
|
getMarkDownToolbarForegroundColor(control) | async
|
|
"
|
|
[hasToolbar]="getMarkDownHasToolbar(control) | async"
|
|
[wrapWithCard]="isMarkdownWrapWithCard(control) | async"
|
|
[cardSubTitle]="getMarkdownCardSubTitle(control) | async"
|
|
[toolbarColor]="getMarkDownToolbarColor(control) | async"
|
|
[toolbarConfig]="getMarkdownToolbarConfig(control) | async"
|
|
[actionProvider]="getMarkdownActionProvider(control) | async"
|
|
[editorBoxColor]="getMarkdownEditorBoxColor(control) | async"
|
|
[previewBoxColor]="getMarkdownPreviewBoxColor(control) | async"
|
|
[toolbarCssClass]="getMarkdownToolbarCssClass(control) | async"
|
|
[uiDisabled]="uiDisabled || (getControlDisabled(control) | async)"
|
|
[cardForegroundColor]="getMarkdownCardForegroundColor(control) | async"
|
|
(contentChange)="handleMarkDownContentChanged(control.propName.toString(), $event)"
|
|
></x-markdown>
|
|
</ng-template>
|
|
|
|
<!-- Avatar Content Template -->
|
|
<ng-template #avatarContentRef let-control>
|
|
<!-- Avatar Upload -->
|
|
<x-avatar-upload
|
|
[color]="getAvatarColor(control) | async"
|
|
[isInPage]="isAvatarInPage(control) | async"
|
|
[actions]="getAvatarActions(control) | async"
|
|
[cssClass]="getAvatarCssClass(control) | async"
|
|
[cardColor]="getAvatarCardColor(control) | async"
|
|
[cardTitle]="getAvatarCardTitle(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[fileDropAreaForegroundColor]="
|
|
isAvatarDropAreaForegroundColor(control) | async
|
|
"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[fileDropAreaActionProvider]="
|
|
getAvatarDropAreaActionProvider(control) | async
|
|
"
|
|
[fileDropAreaDisableFileCheck]="
|
|
isAvatarDropAreaDisableFileCheck(control) | async
|
|
"
|
|
[fileDropAreaContentTemplate]="
|
|
getAvatarDropAreaContentTemplate(control) | async
|
|
"
|
|
[notAllowedFileException]="
|
|
getAvatarNotAllowedFileException(control) | async
|
|
"
|
|
[fileDropAreaAllowedExtensions]="
|
|
getAvatarDropAreaAllowedExtensions(control) | async
|
|
"
|
|
[wrapWithCard]="isAvatarWrapWithCard(control) | async"
|
|
[fileDropAreaCardForegroundColor]="
|
|
isAvatarDropAreaCardForegroundColor(control) | async
|
|
"
|
|
[cardSubTitle]="getAvatarCardSubTitle(control) | async"
|
|
[minAllowedFileSizeException]="
|
|
getAvatarMinAllowedFileSizeException(control) | async
|
|
"
|
|
[cardShowFooter]="avatarCardShowFooter(control) | async"
|
|
[maxAllowedFileSizeException]="
|
|
getAvatarMaxAllowedFileSizeException(control) | async
|
|
"
|
|
[fileDropAreaSupportsMultipleFiles]="
|
|
isAvatarDropAreaSupportsMultipleFiles(control) | async
|
|
"
|
|
(avatarChange)="handleAvatarAvatarChange(control, $event)"
|
|
[actionProvider]="getAvatarActionProvider(control) | async"
|
|
[fileDropAreaIcon]="getAvatarDropAreaIcon(control) | async"
|
|
[foregroundColor]="isAvatarForegroundColor(control) | async"
|
|
(fileDropAreaFilesChangeEmiter)="
|
|
handleAvatarFileDropAreaFilesChangeEmitter(control, $event)
|
|
"
|
|
[fileDropAreaColor]="getAvatarDropAreaColor(control) | async"
|
|
[fileDropAreaIsInPage]="isAvatarDropAreaInPage(control) | async"
|
|
[fileDropAreaMessage]="getAvatarDropAreaMessage(control) | async"
|
|
[allowedExtensions]="getAvatarAllowedExtensions(control) | async"
|
|
[placeHolderAvatar]="getAvatarPlaceHolderAvatar(control) | async"
|
|
[uiDisabled]="uiDisabled || (getControlDisabled(control) | async)"
|
|
[fileDropAreaCssClass]="getAvatarDropAreaCssClass(control) | async"
|
|
[emptyFileException]="getAvatarEmptyFileException(control) | async"
|
|
[minAllowedFileSize]="getAvatarMinAllowedFileSize(control) | async"
|
|
[maxAllowedFileSize]="getAvatarMaxAllowedFileSize(control) | async"
|
|
[cardForegroundColor]="isAvatarCardForegroundColor(control) | async"
|
|
[fileDropAreaCardColor]="getAvatarDropAreaCardColor(control) | async"
|
|
[fileDropAreaCardTitle]="getAvatarDropAreaCardTitle(control) | async"
|
|
[fileDropAreaErrorColor]="getAvatarDropAreaErrorColor(control) | async"
|
|
[fileDropAreaWrapWithCard]="isAvatarDropAreaWrapWithCard(control) | async"
|
|
[fileDropAreaDragDisabled]="isAvatarDropAreaDragDisabled(control) | async"
|
|
[fileDropAreaAccentColor]="getAvatarDropAreaAccesntColor(control) | async"
|
|
[fileDropAreaSuccessColor]="getAvatarDropAreaSuccessColor(control) | async"
|
|
[fileDropAreaCardSubTitle]="getAvatarDropAreaCardSubTitle(control) | async"
|
|
[fileDropAreaCardShowFooter]="avatarDropAreaCardShowFooter(control) | async"
|
|
[showFileDropArea]="
|
|
!(isMobileUi$ | async) && (avatarCanDrop(control) | async)
|
|
"
|
|
>
|
|
</x-avatar-upload>
|
|
</ng-template>
|
|
|
|
<!-- Map Content Template -->
|
|
<ng-template #mapContentRef let-control>
|
|
<!-- Map Component -->
|
|
<x-map
|
|
[zoom]="getMapZoom(control) | async"
|
|
[loading]="getValue(loading) | async"
|
|
(isReady)="handleMapIsReady(control)"
|
|
[isInPage]="isMapInPage(control) | async"
|
|
[showZoom]="mapShowZoom(control) | async"
|
|
[canSelect]="mapCanSelect(control) | async"
|
|
[cssClass]="getMapCssClass(control) | async"
|
|
[latitude]="getMapLatitude(control) | async"
|
|
[showRotate]="mapShowRotate(control) | async"
|
|
[showLocator]="mapShowLocator(control) | async"
|
|
[cardTitle]="getMapCardTitle(control) | async"
|
|
[longitude]="getMapLongitude(control) | async"
|
|
[cardColor]="getMapCardColor(control) | async"
|
|
[searchBarCancelButtonIcon]="
|
|
getMapSearchBarCancelButtonIcon(control) | async
|
|
"
|
|
*ngIf="!(isMapPresentWithDialog(control) | async)"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[markerStyle]="getMapMarkerStyle(control) | async"
|
|
[wrapWithCard]="isMapWrapWithCard(control) | async"
|
|
[showSearchBar]="mapShowSearchBar(control) | async"
|
|
[searchBarCancelButtonTitle]="
|
|
getMapSearchBarCancelButtonTitle(control) | async
|
|
"
|
|
[cardSubTitle]="getMapCardSubTitle(control) | async"
|
|
[cardShowFooter]="mapCardShowFooter(control) | async"
|
|
[showZoomSlider]="mapShowZoomSlider(control) | async"
|
|
[searchBarType]="getMapSearchBarType(control) | async"
|
|
[showClearMarker]="mapShowClearMarker(control) | async"
|
|
[showProgressBar]="mapShowProgressBar(control) | async"
|
|
[actionProvider]="getMapActionProvider(control) | async"
|
|
[searchBarColor]="getMapSearchBarColor(control) | async"
|
|
[searchBarValue]="getMapSearchBarValue(control) | async"
|
|
[searchBarTitle]="getMapSearchBarTitle(control) | async"
|
|
[locatorPosition]="getMapLocatorPosition(control) | async"
|
|
[showGoMarkedPlace]="mapShowGoMarkedPlace(control) | async"
|
|
[progressBarColor]="getMapProgressBarColor(control) | async"
|
|
[searchBarForegroundSearchInputColor]="
|
|
getMapSearchBarForegroundSearchInputColor(control) | async
|
|
"
|
|
[searchBarDebounce]="getMapSearchBarDebounce(control) | async"
|
|
[searchBarCssClass]="getMapSearchBarCssClass(control) | async"
|
|
[searchBarPosition]="getMapSearchBarPosition(control) | async"
|
|
(locationSelected)="handleMapLocationSelected(control, $event)"
|
|
[cardForegroundColor]="isMapCardForegroundColor(control) | async"
|
|
[showSelectedLocation]="mapShowSelectedLocation(control) | async"
|
|
[searchPlaceProvider]="getMapSearchPlaceProvider(control) | async"
|
|
[uiDisabled]="uiDisabled || (getControlDisabled(control) | async)"
|
|
[clearMarkerPosition]="getMapClearMarkerPosition(control) | async"
|
|
[searchPlaceProvider]="getMapSearchPlaceProvider(control) | async"
|
|
[searchBarSpellcheck]="getMapSearchBarSpellcheck(control) | async"
|
|
[searchBarSearchInputColor]="
|
|
getMapSearchBarSearchInputColor(control) | async
|
|
"
|
|
[progressBarPosition]="getMapProgressBarPosition(control) | async"
|
|
[searchResultListColor]="getMapSearchResultListColor(control) | async"
|
|
(searchBarQueryChange)="handleMapSearchBarQueryChange(control, $event)"
|
|
[searchBarActionProvider]="getMapSearchBarActionProvider(control) | async"
|
|
[searchBarShowCancelButton]="mapShowSearchBarCancelButton(control) | async"
|
|
[searchBarClearButtonIcon]="getMapSearchBarClearButtonIcon(control) | async"
|
|
[searchBarForegroundColor]="getMapSearchBarForegroundColor(control) | async"
|
|
[selectedLocationPosition]="getMapSelectedLocationPosition(control) | async"
|
|
[searchBarClearButtonIconColor]="
|
|
getMapSearchBarClearButtonIconColor(control) | async
|
|
"
|
|
[searchBarSearchButtonIconColor]="
|
|
getMapSearchBarSearchButtonIconColor(control) | async
|
|
"
|
|
>
|
|
</x-map>
|
|
<!-- (zoomChanged)="handleMapZoomChanged(control, $event)" -->
|
|
</ng-template>
|
|
|
|
<!-- ColorPicker Content Template -->
|
|
<ng-template #colorPickerContentRef let-control>
|
|
<!-- ColorPicker Component -->
|
|
<x-color-picker
|
|
[color]="getColorPickerColor(control) | async"
|
|
[isInPage]="isColorPickerInPage(control) | async"
|
|
[ngClass]="getFormControlClasses(control) | async"
|
|
[cssClass]="getColorPickerCssClass(control) | async"
|
|
[cardColor]="getColorPickerCardColor(control) | async"
|
|
[showSelectedColorPreview]="
|
|
colorPickerShowSelectedColorPreview(control) | async
|
|
"
|
|
[cardTitle]="getColorPickerCardTitle(control) | async"
|
|
[representColorFormats]="
|
|
getColorPickerRepresentColorFormats(control) | async
|
|
"
|
|
[presetColorsLableColor]="
|
|
getColorPickerPresetColorsLableColor(control) | async
|
|
"
|
|
[copyToClipboardIconColor]="
|
|
getColorPickerCopyToClipboardIconColor(control) | async
|
|
"
|
|
[copyToClipboardIconLabel]="
|
|
getColorPickerCopyToClipboardIconLabel(control) | async
|
|
"
|
|
[cursorColor]="getColorPickerCursorColor(control) | async"
|
|
*ngIf="!(isColorPickerPresentWithDialog(control) | async)"
|
|
[wrapWithCard]="isColorPickerWrapWithCard(control) | async"
|
|
[cardSubTitle]="getColorPickerCardSubTitle(control) | async"
|
|
[presetColors]="getColorPickerPresetColors(control) | async"
|
|
[outputFormat]="getColorPickerOutputFormat(control) | async"
|
|
[cardShowFooter]="colorPickercardShowFooter(control) | async"
|
|
[showHueChannel]="colorPickerShowHueChannel(control) | async"
|
|
[showColorValue]="colorPickerShowColorValue(control) | async"
|
|
[showColorInput]="colorPickerShowColorInput(control) | async"
|
|
[selectedColor]="getColorPickerSelectedColor(control) | async"
|
|
[actionProvider]="getColorPickerActionProvider(control) | async"
|
|
[colorTextColor]="getColorPickerColorTextColor(control) | async"
|
|
[foregroundColor]="isColorPickerForegroundColor(control) | async"
|
|
[showPresetColors]="colorPickerShowPresetColors(control) | async"
|
|
[showAlphaChannel]="colorPickerShowAlphaChannel(control) | async"
|
|
(colorSelected)="handleColorPickerColorSelected(control, $event)"
|
|
[uiDisabled]="uiDisabled || (getControlDisabled(control) | async)"
|
|
[showPaletteChannel]="colorPickerShowPaletteChannel(control) | async"
|
|
[presetColorsLable]="getColorPickerPresetColorsLable(control) | async"
|
|
[showCopyToClipboard]="colorPickerShowCopyToClipboard(control) | async"
|
|
[cardForegroundColor]="isColorPickerCardForegroundColor(control) | async"
|
|
[clearColorIconColor]="getColorPickerClearColorIconColor(control) | async"
|
|
[clearColorIconLabel]="getColorPickerClearColorIconLabel(control) | async"
|
|
[colorInputIconColor]="getColorPickerColorInputIconColor(control) | async"
|
|
[colorInputIconLabel]="getColorPickerColorInputIconLabel(control) | async"
|
|
>
|
|
</x-color-picker>
|
|
</ng-template>
|
|
<!-- //#endregion -->
|
|
|
|
<!-- By Icon Label Template -->
|
|
<ng-template #byIconLabelRef let-control>
|
|
<!-- Label and Icons -->
|
|
<x-slotter
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[hasStartOrTopSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasPrefixIcon(control) | async)
|
|
"
|
|
[hasEndOrBottomSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasSuffixIcon(control) | async)
|
|
"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="prefixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<!-- label -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultFieldLabelRef;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="suffixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
</ng-template>
|
|
|
|
<!-- By Icon Label Template -->
|
|
<ng-template #byIconContentRef let-control let-contentRef="contentRef">
|
|
<!-- Label and Icons -->
|
|
<x-slotter
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[hasStartOrTopSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasPrefixIcon(control) | async)
|
|
"
|
|
[hasEndOrBottomSlot]="
|
|
(controlHasIcons(control) | async) &&
|
|
(controlHasSuffixIcon(control) | async)
|
|
"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="prefixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<ng-container *ngIf="contentRef">
|
|
<ng-container
|
|
*ngTemplateOutlet="contentRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</ng-container>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="suffixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
</ng-template>
|
|
|
|
<!-- Prefix Icon Template -->
|
|
<ng-template #prefixIconRef let-control>
|
|
<!-- Prefix Icon -->
|
|
<x-icon
|
|
matPrefix
|
|
[name]="getControlIconName(icon) | async"
|
|
(clicked)="handleControlIconClicked(icon)"
|
|
[color]="getControlIconColor(icon) | async"
|
|
[matTooltip]="getControlIconTooltip(icon) | async"
|
|
*ngIf="getControlPrefixIcon(control) | async as icon"
|
|
[clickable]="notNullOrUndefinedValue(icon.handler) | async"
|
|
[uiDisabled]="(getValue(uiDisabled) | async) && !icon.handler"
|
|
[class.x-status-handler]="getControlIconApplyStateColor(icon) | async"
|
|
>
|
|
</x-icon>
|
|
</ng-template>
|
|
|
|
<!-- Suffix Icon Template -->
|
|
<ng-template #suffixIconRef let-control>
|
|
<!-- Suffix Icon -->
|
|
<x-icon
|
|
matSuffix
|
|
[name]="getControlIconName(icon) | async"
|
|
(clicked)="handleControlIconClicked(icon)"
|
|
[color]="getControlIconColor(icon) | async"
|
|
[matTooltip]="getControlIconTooltip(icon) | async"
|
|
*ngIf="getControlSuffixIcon(control) | async as icon"
|
|
[clickable]="notNullOrUndefinedValue(icon.handler) | async"
|
|
[uiDisabled]="(getValue(uiDisabled) | async) && !icon.handler"
|
|
[class.x-status-handler]="getControlIconApplyStateColor(icon) | async"
|
|
>
|
|
</x-icon>
|
|
</ng-template>
|
|
|
|
<!-- Loading Ref Template -->
|
|
<ng-template #loadingRef let-control>
|
|
<ion-progress-bar
|
|
type="indeterminate"
|
|
[color]="getProgressBarColor(control) | async"
|
|
*ngIf="
|
|
(controlHasProgressBar(control) | async) &&
|
|
getControlStatus(control) === FormStatuses.Pending
|
|
"
|
|
></ion-progress-bar>
|
|
</ng-template>
|
|
|
|
<!-- Hint Template -->
|
|
<ng-template #hintRef let-control>
|
|
<mat-hint
|
|
[ngClass]="getFormControlHintClasses(control) | async"
|
|
*ngIf="notEmptyValue(getControlHint(control) | async) | async"
|
|
>{{ getControlHint(control) | async }}</mat-hint
|
|
>
|
|
</ng-template>
|
|
|
|
<!-- Errors Ref Template -->
|
|
<ng-template #errorsRef let-control>
|
|
<div
|
|
*ngIf="
|
|
(controlHasErrors(control) | async) &&
|
|
(controlHasErrorHandlers(control) | async)
|
|
"
|
|
[ngClass]="getControlErrorsClasses(control) | async"
|
|
>
|
|
<ng-container
|
|
*ngIf="getControlErrorHandlers(control) | async as errorHandlers"
|
|
>
|
|
<mat-error
|
|
*ngFor="let handler of errorHandlers"
|
|
[class.show]="controlHasError(control, handler) | async"
|
|
[ngClass]="getControlErrorClasses(control, handler) | async"
|
|
>
|
|
<span class="x-error-message">
|
|
{{ getErrorHandlerErrorMessage(handler, control) | async }}
|
|
</span>
|
|
</mat-error>
|
|
</ng-container>
|
|
</div>
|
|
</ng-template>
|
|
|
|
<!-- XFormField Template -->
|
|
<ng-template
|
|
#xFormFieldRef
|
|
let-control
|
|
let-controlIndex="controlIndex"
|
|
let-fieldLabelRef="fieldLabelRef"
|
|
let-fieldInputRef="fieldInputRef"
|
|
let-fieldContentRef="fieldContentRef"
|
|
>
|
|
<!-- XForm Field -->
|
|
<div
|
|
xFocusHandler
|
|
[tabIndex]="controlIndex"
|
|
[ngClass]="getFormFieldClasses(control) | async"
|
|
[class.apply-status]="getValue(applyStatusOnControls) | async"
|
|
[enableHandler]="
|
|
!uiDisabled && !loading && !(getControlDisabled(control) | async)
|
|
"
|
|
>
|
|
<!-- Label -->
|
|
<ng-container *ngIf="fieldLabelRef">
|
|
<div [ngClass]="getFormControlFieldLabelClasses(control) | async">
|
|
<ng-container
|
|
*ngTemplateOutlet="fieldLabelRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</div>
|
|
</ng-container>
|
|
|
|
<!-- Input -->
|
|
<ng-container *ngIf="fieldInputRef">
|
|
<ng-container
|
|
*ngTemplateOutlet="fieldInputRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</ng-container>
|
|
|
|
<!-- Show hint in below of input if exists -->
|
|
<ng-container *ngIf="fieldInputRef">
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="loadingRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</ng-container>
|
|
|
|
<!-- Content -->
|
|
<ng-container
|
|
*ngTemplateOutlet="fieldContentRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Show hint in below of content when input not exists -->
|
|
<ng-container *ngIf="!fieldInputRef">
|
|
<!-- Progressbar for Loading -->
|
|
<ng-container
|
|
*ngTemplateOutlet="loadingRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</ng-container>
|
|
</div>
|
|
|
|
<!-- Hint -->
|
|
<ng-container
|
|
*ngTemplateOutlet="hintRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Errors -->
|
|
<ng-container
|
|
*ngTemplateOutlet="errorsRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
</ng-template>
|
|
|
|
<!-- XField Label Template -->
|
|
<ng-template #defaultFieldLabelRef let-control>
|
|
<!-- label -->
|
|
<mat-label
|
|
class="x-field-label"
|
|
*ngIf="notEmptyValue(getControlLabel(control)) | async"
|
|
>{{ getControlLabel(control) | async }}</mat-label
|
|
>
|
|
</ng-template>
|
|
|
|
<!-- byIcon Input Element Template -->
|
|
<ng-template #byIconInputElemntRef let-control>
|
|
<!-- Control Input Element -->
|
|
<x-slotter
|
|
[hasStartOrTopSlot]="true"
|
|
[hasEndOrBottomSlot]="true"
|
|
[layout]="SlotLayouts.HORIZONTAL"
|
|
[startTopSlotCssClass]="'auto-size-flex'"
|
|
[endBottomSlotCssClass]="'auto-size-flex'"
|
|
*ngIf="notNullOrUndefinedValue(control) | async"
|
|
>
|
|
<!-- Start -->
|
|
<x-slot [name]="SlotNames.START">
|
|
<!-- Prefix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="prefixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Action Prefix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Prefix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- Center -->
|
|
<x-slot [name]="SlotNames.CENTER">
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
defaultXInputElement;
|
|
context: { $implicit: control }
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
|
|
<!-- End -->
|
|
<x-slot [name]="SlotNames.END">
|
|
<!-- Suffix Icon -->
|
|
<ng-container
|
|
*ngTemplateOutlet="suffixIconRef; context: { $implicit: control }"
|
|
></ng-container>
|
|
|
|
<!-- Action Suffix Icons -->
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconsRef;
|
|
context: {
|
|
$implicit: control,
|
|
position: ControlIconPositions.Suffix
|
|
}
|
|
"
|
|
></ng-container>
|
|
</x-slot>
|
|
</x-slotter>
|
|
</ng-template>
|
|
|
|
<!-- Default X Input Element Template -->
|
|
<ng-template #defaultXInputElement let-control>
|
|
<!-- Has Formatter Input Control -->
|
|
<ng-container *ngIf="controlHasFormatter(control) | async">
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
xFromInputFormatter
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
[locale]="getFormatterLocale(control) | async"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[seperator]="getFormatterSeperator(control) | async"
|
|
[placeholder]="getControlPlaceHolder(control) | async"
|
|
[inputFormatterType]="getFormatterType(control) | async"
|
|
[ngClass]="getControlInputElementClasses(control) | async"
|
|
[currencyLable]="getFormatterCurrencyLabel(control) | async"
|
|
[enabledInputFormatter]="controlHasFormatter(control) | async"
|
|
[stringFormatter]="getFormatterStringFormatter(control) | async"
|
|
[stringInputFormatterType]="getFormatterInputType(control) | async"
|
|
/>
|
|
</ng-container>
|
|
|
|
<!-- Has not Formatter Input Control -->
|
|
<ng-container *ngIf="!(controlHasFormatter(control) | async)">
|
|
<input
|
|
class="x-input"
|
|
autocomplete="off"
|
|
[formControlName]="control.propName.toString()"
|
|
[id]="getControlInputElementId(control)"
|
|
[type]="getControlType(control) | async"
|
|
(blur)="handleControlBlured(control.propName.toString())"
|
|
(focus)="handleControlFocused(control.propName.toString())"
|
|
[matTooltip]="getControlTooltip(control) | async"
|
|
[xFocus]="getControlFocusHandler(control) | async"
|
|
[placeholder]="getControlPlaceHolder(control) | async"
|
|
[ngClass]="getControlInputElementClasses(control) | async"
|
|
/>
|
|
</ng-container>
|
|
</ng-template>
|
|
|
|
<!-- Action Icons Template -->
|
|
<ng-template #actionIconsRef let-control let-position="position">
|
|
<!-- Clear -->
|
|
<ng-container
|
|
*ngIf="
|
|
controlHasValue(control.propName.toString()) &&
|
|
(hasControlClearIcon(control) | async) &&
|
|
(notNullOrUndefinedValue(control) | async)
|
|
"
|
|
>
|
|
<ng-container *ngIf="getControlClearIcon(control) | async as descriptor">
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlIconDescriptorPosition(descriptor) | async) === position
|
|
"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconRef;
|
|
context: {
|
|
$implicit: descriptor,
|
|
role: ControlIconRoles.Clear,
|
|
control: control
|
|
}
|
|
"
|
|
></ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
|
|
<!-- Select -->
|
|
<ng-container *ngIf="getControlType(control) | async as controlType">
|
|
<!-- Recieve Control Type for Handling Without Dialog Actions -->
|
|
<ng-container
|
|
*ngIf="
|
|
(controlType !== ControlTypes.Map &&
|
|
controlType !== ControlTypes.ColorPicker) ||
|
|
(controlType === ControlTypes.Map &&
|
|
(isMapPresentWithDialog(control) | async)) ||
|
|
(controlType === ControlTypes.ColorPicker &&
|
|
(isColorPickerPresentWithDialog(control) | async))
|
|
"
|
|
>
|
|
<!-- if Map/ColorPicker Control Presented Without Dialog, there is no need to has Select icon ... -->
|
|
<ng-container *ngIf="getControlSelectIcon(control) | async as descriptor">
|
|
<ng-container
|
|
*ngIf="
|
|
(getControlIconDescriptorPosition(descriptor) | async) === position
|
|
"
|
|
>
|
|
<ng-container
|
|
*ngTemplateOutlet="
|
|
actionIconRef;
|
|
context: {
|
|
control: control,
|
|
$implicit: descriptor,
|
|
role: ControlIconRoles.Select
|
|
}
|
|
"
|
|
></ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-container>
|
|
</ng-template>
|
|
|
|
<!-- Action Icon Template -->
|
|
<ng-template
|
|
#actionIconRef
|
|
let-descriptor
|
|
let-role="role"
|
|
let-control="control"
|
|
>
|
|
<x-icon
|
|
[clickable]="true"
|
|
class="x-action-icon"
|
|
[uiDisabled]="getValue(uiDisabled) | async"
|
|
[uiDisabled]="
|
|
(getControlDisabled(control) | async) ||
|
|
(getControlDisableIcon(control) | async)
|
|
"
|
|
[class.x-status-handler]="
|
|
getControlIconDescriptorApplyStateColor(descriptor) | async
|
|
"
|
|
[name]="getControlIconDescriptorName(role, descriptor) | async"
|
|
[color]="getControlIconDescriptorColor(role, descriptor) | async"
|
|
(clicked)="handleControlActionIconClicked(role, descriptor, control)"
|
|
[matTooltip]="getControlIconDescriptorTooltip(role, descriptor) | async"
|
|
>
|
|
</x-icon>
|
|
</ng-template>
|
|
|
|
<!-- Nothing Template -->
|
|
<ng-template #nothingRef></ng-template>
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.component.scss
|
|
|
|
//
|
|
:host {
|
|
//
|
|
--regular-color: var(--x-color-dark);
|
|
--valid-color: var(--x-color-success);
|
|
--hint-color: var(--x-color-tertiary);
|
|
--invalid-color: var(--x-color-danger);
|
|
--active-color: var(--x-color-tertiary);
|
|
--pending-color: var(--x-color-warning);
|
|
--disabled-color: var(--x-color-medium);
|
|
--accent-color: var(--x-color-secondary);
|
|
--fill-color: var(--x-color-secondary-tint);
|
|
--disabled-fill-color: var(--x-color-light-shade);
|
|
|
|
//
|
|
--hint-text-size: 7pt;
|
|
--error-text-size: 7pt;
|
|
|
|
//
|
|
--form-fields-vertical-margin: 16px;
|
|
}
|
|
|
|
//
|
|
//#region Mixins ...
|
|
//
|
|
@mixin formFieldRegularProps {
|
|
//
|
|
x-icon {
|
|
--size: 20px;
|
|
}
|
|
|
|
//
|
|
.x-field-label {
|
|
}
|
|
|
|
//
|
|
.auto-size-flex {
|
|
flex: 0 0 auto !important;
|
|
}
|
|
|
|
//
|
|
.full-heigh {
|
|
* {
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formInputElementProps {
|
|
//
|
|
.mat-input-element {
|
|
@include colorHandler(var(--regular-color), false);
|
|
}
|
|
|
|
//
|
|
.x-form-input-element {
|
|
width: 100%;
|
|
border: unset;
|
|
outline: unset;
|
|
border-color: transparent;
|
|
|
|
//
|
|
&:focus {
|
|
// outline: var(--active-color) auto 1px;
|
|
}
|
|
|
|
//
|
|
@include colorHandler(var(--regular-color), false);
|
|
@include backgroundColorHandler(transparent, false);
|
|
}
|
|
|
|
//
|
|
.x-form-date-input-element,
|
|
.x-form-input-element:not(.mat-input-element) {
|
|
height: 100% !important;
|
|
}
|
|
}
|
|
|
|
@mixin formFieldHintProps(
|
|
$color: var(--hint-color),
|
|
$size: var(--hint-text-size)
|
|
) {
|
|
.x-form-control-hint {
|
|
//
|
|
color: $color;
|
|
font-size: $size;
|
|
}
|
|
}
|
|
|
|
@mixin formFieldErrorProps(
|
|
$color: var(--invalid-color),
|
|
$size: var(--error-text-size)
|
|
) {
|
|
//
|
|
//
|
|
$duration: 250ms;
|
|
$transform-show: scaleY(1);
|
|
$transform-hide: scaleY(0);
|
|
.x-form-error,
|
|
.x-form-field-error {
|
|
//
|
|
color: $color;
|
|
font-size: $size;
|
|
|
|
//
|
|
height: 0;
|
|
|
|
//
|
|
transform: $transform-hide;
|
|
-ms-transform: $transform-hide;
|
|
-webkit-transform: $transform-hide;
|
|
//
|
|
transition: transform;
|
|
-webkit-transition: transform;
|
|
//
|
|
transition-duration: $duration;
|
|
-webkit-transition-duration: $duration;
|
|
|
|
//
|
|
&.show {
|
|
//
|
|
height: auto !important;
|
|
//
|
|
transform: $transform-show;
|
|
-ms-transform: $transform-show;
|
|
-webkit-transform: $transform-show;
|
|
//
|
|
transition-duration: $duration;
|
|
-webkit-transition-duration: $duration;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formFieldProps {
|
|
//
|
|
.x-form-field {
|
|
//
|
|
@include dateProps;
|
|
@include sliderProps;
|
|
@include radioButtonProps;
|
|
@include selectOptionProps;
|
|
@include toogleColorHandler;
|
|
@include checkBoxColorHandler;
|
|
@include formFieldRegularProps;
|
|
@include formInputElementProps;
|
|
@include formFieldAppearanceHandler;
|
|
@include colorHandler(var(--regular-color), false);
|
|
@include backgroundColorHandler(transparent !important);
|
|
|
|
//
|
|
&.x-mat-form-field {
|
|
//
|
|
width: 100%;
|
|
|
|
//
|
|
&.mat-focused {
|
|
@include formFieldFocusHandler;
|
|
}
|
|
}
|
|
|
|
//
|
|
&.x-form-radio-field {
|
|
//
|
|
outline: unset;
|
|
|
|
//
|
|
&.x-focused {
|
|
//
|
|
@include formFieldFocusHandler;
|
|
@include iconStatusColorHandler(var(--active-color));
|
|
}
|
|
}
|
|
|
|
//
|
|
&:not(.x-mat-form-field):not(.x-form-radio-field) {
|
|
//
|
|
outline: unset;
|
|
|
|
//
|
|
&.x-focused {
|
|
//
|
|
@include formFieldFocusHandler;
|
|
border-color: var(--active-color);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin autoCompleteProps {
|
|
/* Auto Complete Styling */
|
|
//
|
|
$duration: 250ms;
|
|
$transform-show: scaleY(1);
|
|
$transform-hide: scaleY(0);
|
|
|
|
.x-auto-complete-wrapper {
|
|
position: unset;
|
|
display: unset;
|
|
}
|
|
|
|
.x-auto-complete {
|
|
//
|
|
position: content;
|
|
|
|
//
|
|
&.x-auto-complete-margin {
|
|
margin-top: 0;
|
|
}
|
|
|
|
//
|
|
height: calc(50%);
|
|
max-height: 300px;
|
|
|
|
//
|
|
left: 8px;
|
|
right: 8px;
|
|
overflow-y: scroll;
|
|
|
|
//
|
|
z-index: 113;
|
|
|
|
//
|
|
transform: $transform-hide;
|
|
-ms-transform: $transform-hide;
|
|
-webkit-transform: $transform-hide;
|
|
|
|
//
|
|
transition: transform;
|
|
-webkit-transition: transform;
|
|
|
|
//
|
|
transition-duration: $duration;
|
|
-webkit-transition-duration: $duration;
|
|
|
|
//
|
|
&.open {
|
|
//
|
|
transform: $transform-show;
|
|
-ms-transform: $transform-show;
|
|
-webkit-transform: $transform-show;
|
|
|
|
//
|
|
transition-duration: $duration;
|
|
-webkit-transition-duration: $duration;
|
|
}
|
|
}
|
|
/* END Auto Complete Styling */
|
|
}
|
|
|
|
@mixin selectOptionProps {
|
|
//
|
|
.x-select-option {
|
|
width: 100%;
|
|
margin-bottom: 4px;
|
|
|
|
&:last-child {
|
|
margin-bottom: 8px;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin dateProps {
|
|
//
|
|
.mat-icon-button {
|
|
display: table-cell;
|
|
vertical-align: bottom;
|
|
}
|
|
}
|
|
|
|
@mixin radioButtonProps($disabled: false) {
|
|
//
|
|
.x-radio-button {
|
|
//
|
|
@include radioColorHandler(var(--regular-color), true, false);
|
|
|
|
//
|
|
&.active {
|
|
//
|
|
@include radioColorHandler(var(--active-color) !important, true, true);
|
|
}
|
|
}
|
|
|
|
&.x-form-radio-field {
|
|
//
|
|
outline: unset;
|
|
|
|
//
|
|
&.x-focused {
|
|
//
|
|
.x-field-label {
|
|
color: var(--active-color) !important;
|
|
}
|
|
border-color: var(--active-color) !important;
|
|
|
|
//
|
|
@include iconStatusColorHandler(var(--active-color));
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formFieldFocusHandler {
|
|
//
|
|
.mat-form-field-ripple {
|
|
@include backgroundColorHandler(var(--active-color) !important, false);
|
|
}
|
|
|
|
//
|
|
@include iconStatusColorHandler(var(--active-color));
|
|
@include formFieldLabelColorHandler(var(--active-color));
|
|
@include formFieldWrapperColorHandler(var(--active-color));
|
|
@include matFormFieldOutlineColorHandler(var(--active-color) !important);
|
|
}
|
|
|
|
@mixin formFieldAppearanceHandler($disabled: false) {
|
|
//
|
|
// Label Colors ...
|
|
@if $disabled {
|
|
//
|
|
@include formFieldLabelColorHandler(var(--disabled-color));
|
|
|
|
//
|
|
.x-form-field-appearance-fill:not(.x-mat-form-field) {
|
|
border-color: var(--disabled-fill-color);
|
|
}
|
|
|
|
//
|
|
.mat-select-value-text {
|
|
color: var(--disabled-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-select-value-text {
|
|
color: var(--regular-color);
|
|
}
|
|
|
|
//
|
|
// None ...
|
|
.x-form-field-appearance-none {
|
|
//
|
|
@if $disabled {
|
|
@include formFieldLabelColorHandler(var(--disabled-color));
|
|
} @else {
|
|
}
|
|
}
|
|
|
|
//
|
|
// Legacy ...
|
|
// Standard ...
|
|
.x-form-field-appearance-legacy,
|
|
.x-form-field-appearance-standard {
|
|
//
|
|
@if $disabled {
|
|
@include matFormFieldUnderlineColorHandler(
|
|
var(--disabled-fill-color) !important,
|
|
true
|
|
);
|
|
} @else {
|
|
@include matFormFieldUnderlineColorHandler(var(--fill-color) !important);
|
|
}
|
|
|
|
//
|
|
&:not(.x-mat-form-field) {
|
|
@if $disabled {
|
|
} @else {
|
|
//
|
|
padding: 8px;
|
|
border-radius: 0;
|
|
border-bottom-width: 1px;
|
|
border-bottom-style: solid;
|
|
border-color: var(--fill-color);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Outline ...
|
|
.x-form-field-appearance-outline {
|
|
//
|
|
@if $disabled {
|
|
@include matFormFieldOutlineColorHandler(var(--disabled-fill-color));
|
|
} @else {
|
|
@include formFieldLabelColorHandler(var(--regular-color));
|
|
@include matFormFieldOutlineColorHandler(var(--fill-color));
|
|
}
|
|
|
|
//
|
|
&:not(.x-mat-form-field) {
|
|
@if $disabled {
|
|
@include backgroundColorHandler(transaprent!important, false);
|
|
} @else {
|
|
//
|
|
padding: 8px;
|
|
border-radius: 3px;
|
|
border-width: 1px;
|
|
border-style: solid;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Fill ...
|
|
.x-form-field-appearance-fill {
|
|
//
|
|
&.x-mat-form-field:not(.x-form-field-disabled) {
|
|
//
|
|
@if $disabled {
|
|
//
|
|
.mat-form-field-flex {
|
|
@include colorHandler(var(--disabled-fill-color) !important, false);
|
|
@include backgroundColorHandler(
|
|
var(--disabled-fill-color) !important,
|
|
false
|
|
);
|
|
}
|
|
|
|
//
|
|
@include matFormFieldUnderlineColorHandler(var(--disabled-color));
|
|
} @else {
|
|
//
|
|
@include backgroundColorHandler(var(--fill-color) !important, false);
|
|
|
|
//
|
|
.mat-form-field-flex {
|
|
@include colorHandler(var(--regular-color), false);
|
|
@include backgroundColorHandler(var(--fill-color) !important, false);
|
|
}
|
|
|
|
//
|
|
@include matFormFieldUnderlineColorHandler(var(--accent-color));
|
|
}
|
|
}
|
|
|
|
//
|
|
@if $disabled {
|
|
//
|
|
&.x-form-field-disabled {
|
|
background-color: var(--disabled-fill-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-form-field-flex {
|
|
@include colorHandler(var(--disabled-color) !important, false);
|
|
@include backgroundColorHandler(
|
|
var(--disabled-fill-color) !important,
|
|
false
|
|
);
|
|
}
|
|
|
|
//
|
|
.x-form-slider-control {
|
|
//
|
|
.mat-slider-thumb {
|
|
background-color: var(--disabled-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-slider-wrapper,
|
|
.mat-slider-track-wrapper {
|
|
background-color: var(--disabled-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
@include matFormFieldUnderlineColorHandler(var(--disabled-color));
|
|
} @else {
|
|
//
|
|
.x-form-slider-control {
|
|
.mat-slider-wrapper,
|
|
.mat-slider-track-wrapper {
|
|
background-color: var(--regular-color) !important;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
&:not(.x-mat-form-field) {
|
|
@if $disabled {
|
|
@include backgroundColorHandler(
|
|
var(--disabled-fill-color) !important,
|
|
false
|
|
);
|
|
} @else {
|
|
//
|
|
padding: 8px;
|
|
border-radius: 3px;
|
|
border-bottom-width: 1px;
|
|
border-bottom-style: solid;
|
|
border-bottom-left-radius: 0;
|
|
border-bottom-right-radius: 0;
|
|
border-color: var(--regular-color);
|
|
|
|
//
|
|
@include backgroundColorHandler(var(--fill-color) !important, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formFieldStatusHandler {
|
|
//
|
|
// Global ...
|
|
@include formFieldAppearanceHandler(false);
|
|
|
|
//
|
|
// Disabled ...
|
|
&.x-form-field-wrapper-disabled {
|
|
//
|
|
* {
|
|
cursor: default;
|
|
pointer-events: none;
|
|
}
|
|
|
|
//
|
|
x-icon.x-action-icon > * {
|
|
color: var(--disabled-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-form-field-disabled {
|
|
color: var(--disabled-color) !important;
|
|
}
|
|
|
|
//
|
|
.x-form-input-element {
|
|
//
|
|
opacity: 1 !important;
|
|
border-color: var(--disabled-fill-color) !important;
|
|
|
|
//
|
|
@include colorHandler(var(--disabled-color) !important, false);
|
|
}
|
|
|
|
//
|
|
.x-form-control {
|
|
opacity: 1 !important;
|
|
@include colorHandler(var(--disabled-color) !important, false);
|
|
}
|
|
|
|
//
|
|
.mat-slide-toggle-bar {
|
|
background-color: var(--disabled-fill-color) !important;
|
|
}
|
|
|
|
//
|
|
@include sliderProps(true);
|
|
@include formFieldAppearanceHandler(true);
|
|
@include formFieldHintProps(var(--disabled-color));
|
|
@include formFieldErrorProps(var(--disabled-color));
|
|
@include checkBoxColorHandler(--disabled-color, true);
|
|
@include iconStatusColorHandler(var(--disabled-color), true);
|
|
@include formFieldWrapperColorHandler(var(--disabled-color) !important);
|
|
@include radioColorHandler(var(--disabled-color) !important, true, true);
|
|
}
|
|
|
|
//
|
|
// Valid ...
|
|
&.x-form-field-wrapper-valid {
|
|
//
|
|
@include iconStatusColorHandler(var(--valid-color), true);
|
|
|
|
//
|
|
&.apply-status {
|
|
@include formFieldWrapperColorHandler(var(--valid-color));
|
|
}
|
|
}
|
|
|
|
//
|
|
// Invalid ...
|
|
&.x-form-field-wrapper-invalid {
|
|
//
|
|
@include iconStatusColorHandler(var(--invalid-color), true);
|
|
|
|
//
|
|
&.apply-status {
|
|
@include formFieldWrapperColorHandler(var(--invalid-color));
|
|
}
|
|
}
|
|
|
|
//
|
|
// Pending ...
|
|
&.x-form-field-wrapper-pending {
|
|
//
|
|
@include iconStatusColorHandler(var(--pending-color), true);
|
|
|
|
//
|
|
&.apply-status {
|
|
@include formFieldWrapperColorHandler(var(--pending-color));
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin colorHandler($color: var(--regular-color), $applyToChilds: true) {
|
|
color: $color;
|
|
|
|
//
|
|
@if $applyToChilds {
|
|
* {
|
|
:not(x-icon):not(x-icon > *) {
|
|
color: $color;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
@include matFormFieldOutlineColorHandler($color);
|
|
}
|
|
|
|
@mixin backgroundColorHandler($color: transaprent, $applyToChilds: true) {
|
|
//
|
|
background-color: $color;
|
|
|
|
//
|
|
@if $applyToChilds {
|
|
*:not(.x-field-label):not(.x-field-label
|
|
*):not(.mat-form-field-ripple):not(.mat-slide-toggle-thumb):not(.mat-slide-toggle-bar):not(.mat-checkbox-frame):not(.mat-radio-inner-circle):not(.mat-form-field-underline):not(.mat-slide):not(.mat-slider
|
|
*):not(.x-markdown *):not(.x-color *):not(.x-map
|
|
*):not(.x-selected-color):not(.x-color-palette):not(.x-color-alpha) {
|
|
background-color: $color;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formFieldWrapperColorHandler($color: var(--regular-color)) {
|
|
//
|
|
.x-form-input-element {
|
|
// outline: $color auto 1px;
|
|
}
|
|
|
|
//
|
|
.x-form-field:not(.x-mat-form-field) {
|
|
border-color: $color;
|
|
}
|
|
|
|
//
|
|
@include sliderProps;
|
|
@include toogleColorHandler($color);
|
|
@include checkBoxColorHandler($color);
|
|
@include formFieldLabelColorHandler($color);
|
|
@include matFormFieldOutlineColorHandler($color);
|
|
@include iconStatusColorHandler($color !important);
|
|
@include matFormFieldUnderlineColorHandler($color !important);
|
|
}
|
|
|
|
@mixin radioColorHandler(
|
|
$color: var(--regular-color),
|
|
$applyOnOuterCircle: false,
|
|
$applyOnInnerCircle: false
|
|
) {
|
|
//
|
|
.mat-radio-label {
|
|
//
|
|
color: $color;
|
|
|
|
//
|
|
@if $applyOnOuterCircle {
|
|
.mat-radio-outer-circle {
|
|
border-color: $color;
|
|
}
|
|
}
|
|
|
|
//
|
|
@if $applyOnInnerCircle {
|
|
.mat-radio-inner-circle {
|
|
background-color: $color;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin checkBoxColorHandler($color: var(--regular-color), $disabled: false) {
|
|
//
|
|
.mat-checkbox-frame {
|
|
@if $disabled {
|
|
border-color: var(--disabled-color) !important;
|
|
} @else {
|
|
border-color: var(--regular-color);
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-checkbox-checked {
|
|
.mat-checkbox-frame,
|
|
.mat-checkbox-background {
|
|
background-color: var(--active-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-checkbox-label {
|
|
.x-field-label {
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
//
|
|
.x-form-control {
|
|
&.has-icon {
|
|
.mat-checkbox-layout {
|
|
margin: {
|
|
left: 4px;
|
|
right: 4px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin toogleColorHandler($color: var(--regular-color)) {
|
|
//
|
|
:not(.x-form-field-disabled) {
|
|
.mat-slide-toggle-bar {
|
|
background-color: var(--active-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
.x-form-field-disabled {
|
|
.mat-slide-toggle-bar {
|
|
background-color: var(--disabled-color) !important;
|
|
}
|
|
.mat-slide-toggle-thumb {
|
|
background-color: var(--disabled-fill-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-slide-toggle-thumb {
|
|
background-color: $color !important;
|
|
}
|
|
|
|
//
|
|
.x-form-control {
|
|
&.has-icon {
|
|
.mat-slide-toggle-label {
|
|
margin: {
|
|
left: 4px;
|
|
right: 4px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin sliderProps($disabled: false) {
|
|
//
|
|
.x-form-slider-control {
|
|
//
|
|
@if $disabled {
|
|
//
|
|
cursor: default;
|
|
pointer-events: none;
|
|
}
|
|
|
|
//
|
|
&:not(.vertical) {
|
|
width: 100%;
|
|
}
|
|
|
|
//
|
|
&.vertical {
|
|
display: block;
|
|
margin: {
|
|
left: auto;
|
|
right: auto;
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-slider-wrapper,
|
|
.mat-slider-track-wrapper {
|
|
//
|
|
@if $disabled {
|
|
background-color: var(--disabled-fill-color) !important;
|
|
} @else {
|
|
background-color: var(--fill-color);
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-slider-thumb,
|
|
.mat-slider-thumb-label,
|
|
.mat-slider-thumb-label-text {
|
|
//
|
|
@if $disabled {
|
|
color: var(--disabled-color) !important;
|
|
background-color: var(--disabled-fill-color) !important;
|
|
} @else {
|
|
color: var(--accent-color);
|
|
background-color: var(--active-color);
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-slider-track-fill {
|
|
//
|
|
@if $disabled {
|
|
background-color: var(--disabled-color) !important;
|
|
} @else {
|
|
background-color: var(--active-color);
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-slider-vertical {
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin formFieldLabelColorHandler($color: var(--regular-color)) {
|
|
//
|
|
.mat-form-field-label {
|
|
color: $color;
|
|
}
|
|
|
|
//
|
|
.x-field-label {
|
|
color: $color;
|
|
}
|
|
|
|
//
|
|
.mat-select-placeholder {
|
|
color: $color;
|
|
}
|
|
}
|
|
|
|
@mixin iconStatusColorHandler($color: var(--regular-color), $important: false) {
|
|
//
|
|
x-icon.x-status-handler > * {
|
|
//
|
|
@if $important {
|
|
color: $color !important;
|
|
} @else {
|
|
color: $color;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin matFormFieldUnderlineColorHandler(
|
|
$color: var(--fill-color),
|
|
$clearBackground: false
|
|
) {
|
|
//
|
|
.mat-form-field-underline {
|
|
//
|
|
border-color: $color;
|
|
background-color: $color;
|
|
|
|
//
|
|
&::before {
|
|
background-color: $color;
|
|
}
|
|
|
|
//
|
|
@if $clearBackground {
|
|
background-image: none;
|
|
}
|
|
}
|
|
|
|
//
|
|
.mat-select-arrow {
|
|
color: $color;
|
|
}
|
|
}
|
|
|
|
@mixin matFormFieldOutlineColorHandler($color: var(--regular-color)) {
|
|
//
|
|
color: $color;
|
|
|
|
//
|
|
.mat-form-field-outline-start,
|
|
.mat-form-field-outline-end,
|
|
.mat-form-field-outline-gap {
|
|
border-width: 1px !important;
|
|
}
|
|
|
|
//
|
|
.mat-form-field-outline,
|
|
.mat-form-field-outline-thick {
|
|
color: $color;
|
|
border-width: 1px !important;
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
::ng-deep.cdk-overlay-pane {
|
|
//
|
|
transform: translateY(0px) !important;
|
|
|
|
//
|
|
.mat-datepicker-content-container {
|
|
height: auto !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
::ng-deep.x-form-select-control {
|
|
//
|
|
min-width: 100% !important;
|
|
|
|
//
|
|
&:not(.x-form-select-control-panel) {
|
|
max-width: 100% !important;
|
|
}
|
|
|
|
//
|
|
&.x-form-select-control-panel {
|
|
}
|
|
|
|
// //
|
|
// .mat-select-value-text {
|
|
// color: var(--regular-color) !important;
|
|
// }
|
|
|
|
//
|
|
.x-select-option {
|
|
//
|
|
color: var(--regular-color) !important;
|
|
background-color: var(--fill-color) !important;
|
|
|
|
//
|
|
&.mat-active {
|
|
color: var(--active-color) !important;
|
|
}
|
|
|
|
//
|
|
&.mat-selected {
|
|
//
|
|
color: var(--active-color) !important;
|
|
|
|
//
|
|
.mat-pseudo-checkbox-checked {
|
|
background: var(--active-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-pseudo-checkbox::after {
|
|
color: var(--accent-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
&:hover {
|
|
$level: 0.5;
|
|
filter: brightness($level);
|
|
-webkit-filter: brightness($level);
|
|
color: var(--active-color) !important;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
::ng-deep.x-form-control-date-picker {
|
|
//
|
|
&.mat-calendar {
|
|
//
|
|
color: var(--regular-color) !important;
|
|
background-color: var(--fill-color) !important;
|
|
|
|
//
|
|
.mat-calendar-arrow {
|
|
border-top-color: unset;
|
|
}
|
|
|
|
//
|
|
.mat-calendar-body-today {
|
|
color: var(--active-color);
|
|
border-color: var(--acttive-color);
|
|
}
|
|
|
|
//
|
|
.mat-calendar-table-header {
|
|
color: var(--accent-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-calendar-body-selected {
|
|
//
|
|
color: var(--accent-color);
|
|
background-color: var(--active-color);
|
|
border-color: var(--accent-color);
|
|
}
|
|
|
|
//
|
|
.mat-calendar-next-button,
|
|
.mat-calendar-previous-button,
|
|
.mat-calendar-period-button {
|
|
color: var(--active-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-calendar-body-label {
|
|
color: var(--active-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-calendar-body-cell-content {
|
|
color: var(--regular-color) !important;
|
|
}
|
|
|
|
//
|
|
.mat-calendar-body-disabled {
|
|
color: var(--disabled-color) !important;
|
|
filter: contrast(0.5) !important;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
:host ::ng-deep .x-form {
|
|
//
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
flex-direction: row;
|
|
|
|
//
|
|
.x-form-field-wrapper {
|
|
//
|
|
width: 100%;
|
|
margin-bottom: var(--form-fields-vertical-margin);
|
|
|
|
//
|
|
.mat-form-field-wrapper {
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
//
|
|
.mat-form-field-underline {
|
|
position: initial;
|
|
}
|
|
|
|
//
|
|
.ng-invalid,
|
|
.mat-form-field-invalid {
|
|
//
|
|
*:not(.x-field-label):not(ion-icon):not(.mat-form-field-outline):not(.mat-form-field-outline-thick):not(.mat-form-field-outline-end):not(.mat-form-field-outline-gap):not(.mat-form-field-outline-start) {
|
|
color: var(--regular-color);
|
|
}
|
|
|
|
//
|
|
&.apply-status {
|
|
* {
|
|
color: var(--invalid-color) !important;
|
|
}
|
|
}
|
|
|
|
*:not(.x-field-label) {
|
|
background-color: transparent;
|
|
}
|
|
}
|
|
|
|
//
|
|
&.readonly {
|
|
//
|
|
.x-field-label {
|
|
color: var(--disabled-color) !important;
|
|
}
|
|
|
|
//
|
|
.x-form-control {
|
|
color: var(--disabled-color) !important;
|
|
}
|
|
}
|
|
|
|
//
|
|
@include formFieldProps;
|
|
@include autoCompleteProps;
|
|
@include formFieldStatusHandler;
|
|
@include formFieldAppearanceHandler(false);
|
|
@include formFieldHintProps(var(--hint-color), var(--hint-text-size));
|
|
@include formFieldErrorProps(var(--invalid-color), var(--error-text-size));
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.component.ts
|
|
|
|
import {
|
|
FormGroup,
|
|
FormControl,
|
|
AbstractControl,
|
|
ValidationErrors,
|
|
} from '@angular/forms';
|
|
import {
|
|
defaultFormControlClearIcon,
|
|
defaultFormControlSelectIcon,
|
|
} from './x-form.tools';
|
|
import {
|
|
keys,
|
|
sort,
|
|
nameof,
|
|
XColor,
|
|
isDate,
|
|
assign,
|
|
entries,
|
|
XUiEvent,
|
|
hasChild,
|
|
isFunction,
|
|
parseXColor,
|
|
momentToDate,
|
|
XResourceIDs,
|
|
XBorderStyle,
|
|
XExceptionIDs,
|
|
XDialogResult,
|
|
XOneOrManyType,
|
|
isNullOrUndefined,
|
|
isNullOrEmptyString,
|
|
XColorWithBrightness,
|
|
getXColorCssVariableName,
|
|
} from 'x-framework-core';
|
|
import {
|
|
XFormCssVar,
|
|
XFormStatus,
|
|
XFormUpdateOn,
|
|
XFormBaseAction,
|
|
XFormControlType,
|
|
XFormActionModel,
|
|
XControlIconRole,
|
|
XFormErrorHandler,
|
|
XFormControlConfig,
|
|
XFormControlAction,
|
|
XFormIconDescriptor,
|
|
XControlIconPosition,
|
|
XFormStatusIdentifier,
|
|
XFormMapControlConfig,
|
|
XControlIconDescriptor,
|
|
XFormControlAppearance,
|
|
XFormInputControlConfig,
|
|
XFormRadioControlConfig,
|
|
XFormContainerComponent,
|
|
XFormSelectControlConfig,
|
|
XFormSliderControlConfig,
|
|
XFormSelectControlOption,
|
|
XFormControlLabelPosition,
|
|
XControlIconRoleIdentifier,
|
|
XFormMarkdownControlConfig,
|
|
XFormControlNameIdentifier,
|
|
XFormMapControlPresentType,
|
|
XFormCheckBoxControlConfig,
|
|
XFormSelectorControlConfig,
|
|
XBaseFormControlActionModel,
|
|
XFormDatePickerControlConfig,
|
|
XFormColorPickerControlConfig,
|
|
XFormControlAutoCompleteConfig,
|
|
XFormAvatarUploadControlConfig,
|
|
XFormControlAppearanceDescriptor,
|
|
XFormControlValueChangeEventModel,
|
|
XFormControlStatusChangeEventModel,
|
|
XFormColorPickerControlPresentType,
|
|
XFormDatePickerControlPickerPosition,
|
|
} from './x-form.typings';
|
|
import {
|
|
XMapAction,
|
|
XMapLocation,
|
|
XMapActionModel,
|
|
XMapItemPosition,
|
|
defaultMarkerStyle,
|
|
defaultMapSearchPlaceProvider,
|
|
} from '../x-map/x-map.typings';
|
|
import { isMoment } from 'moment';
|
|
import {
|
|
XMarkdownMode,
|
|
XMarkdownActionModel,
|
|
} from '../x-markdown/x-markdown.typings';
|
|
import {
|
|
XSearchBarType,
|
|
XSearchBarActionModel,
|
|
XSearchBarEnterKeyHint,
|
|
} from '../x-search-bar/x-search-bar.typings';
|
|
import {
|
|
XColorPickerActionModel,
|
|
XColorPickerOutputFormat,
|
|
} from '../x-color-picker/x-color-picker.typings';
|
|
import {
|
|
XAvatarUploadActionModel,
|
|
defaultAvatarUploadActionButtons,
|
|
} from '../x-avatar-upload/x-avatar-upload.typings';
|
|
import { map, concatMap, tap } from 'rxjs/operators';
|
|
import { XIconNames } from '../x-icon/x-icon.typings';
|
|
import { toLongLat, fromLongLat } from '../x-map/x-map.tools';
|
|
import { XStringInputFormatType } from 'x-framework-services';
|
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
|
import { MatFormFieldAppearance } from '@angular/material/form-field';
|
|
import { of, Subject, Subscription, Observable, forkJoin } from 'rxjs';
|
|
import { MatDatepickerInputEvent } from '@angular/material/datepicker';
|
|
import { XSlotName, XSlotLayout } from '../x-slotter/x-slotter.typings';
|
|
import { XMapDialogConfig } from '../x-map/x-map-dialog/x-map-dialog.typings';
|
|
import { XFileDropAreaActionModel } from '../x-file-drop-area/x-file-drop-area.typings';
|
|
import { XColorPickerDialogConfig } from '../x-color-picker/x-color-picker-dialog/x-color-picker-dialog.typings';
|
|
|
|
@Component({
|
|
// tslint:disable-next-line:component-selector
|
|
selector: 'x-form',
|
|
templateUrl: './x-form.component.html',
|
|
styleUrls: ['./x-form.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class XFormComponent extends XFormContainerComponent {
|
|
//
|
|
//#region Props ...
|
|
//
|
|
private VALUE: any;
|
|
private FORM: FormGroup;
|
|
private FORM_CONFIG: any;
|
|
private ERRORS: ValidationErrors;
|
|
private actionProviders: any = {};
|
|
private STATUS: XFormStatusIdentifier;
|
|
private ACTION_PROVIDER_SUBSCRIPTION: Subscription;
|
|
|
|
//
|
|
readonly SlotNames = Object.assign({}, XSlotName);
|
|
readonly SlotLayouts = Object.assign({}, XSlotLayout);
|
|
readonly FormStatuses = Object.assign({}, XFormStatus);
|
|
readonly ControlTypes = Object.assign({}, XFormControlType);
|
|
readonly ControlIconRoles = Object.assign({}, XControlIconRole);
|
|
readonly ControlIconPositions = Object.assign({}, XControlIconPosition);
|
|
readonly FormControlAppearances = Object.assign({}, XFormControlAppearance);
|
|
|
|
//
|
|
currentInputFocus: string;
|
|
|
|
//
|
|
get value() {
|
|
return this.VALUE;
|
|
}
|
|
|
|
get status() {
|
|
return this.STATUS;
|
|
}
|
|
|
|
get errors() {
|
|
return this.ERRORS;
|
|
}
|
|
|
|
get isStatusValid() {
|
|
return this.status === XFormStatus.Valid;
|
|
}
|
|
|
|
get form() {
|
|
return this.FORM;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region LifeCycles ...
|
|
async onInit() {
|
|
super.onInit();
|
|
|
|
//
|
|
await this.applyColors();
|
|
}
|
|
|
|
async onChange(changeKeys: string[]) {
|
|
super.onChange(changeKeys);
|
|
|
|
//
|
|
// Form Config ...
|
|
const isFormConfigChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('formConfig')
|
|
);
|
|
if (isFormConfigChanged) {
|
|
await this.prepareFormGroup();
|
|
}
|
|
|
|
//
|
|
// Action Provider ...
|
|
const isActionProviderChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('actionProvider')
|
|
);
|
|
if (isActionProviderChanged) {
|
|
await this.registerActionProvider();
|
|
}
|
|
|
|
//
|
|
//#region UI Disabled or Loading ...
|
|
const isUiDisabledChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('uiDisabled')
|
|
);
|
|
if (isUiDisabledChanged) {
|
|
await this.handleUiDisabledChanged();
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Color Change Detecotrs ...
|
|
//
|
|
const isRegularColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('regularColor')
|
|
);
|
|
if (isRegularColorChanged) {
|
|
await this.applyRegularColor();
|
|
}
|
|
|
|
//
|
|
const isAccentColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('accentColor')
|
|
);
|
|
if (isAccentColorChanged) {
|
|
await this.applyAccentColor();
|
|
}
|
|
|
|
//
|
|
const isHintColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('hintColor')
|
|
);
|
|
if (isHintColorChanged) {
|
|
await this.applyHintColor();
|
|
}
|
|
|
|
//
|
|
const isPendingColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('pendingColor')
|
|
);
|
|
if (isPendingColorChanged) {
|
|
await this.applyPendingColor();
|
|
}
|
|
|
|
//
|
|
const isActiveColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('activeColor')
|
|
);
|
|
if (isActiveColorChanged) {
|
|
await this.applyActiveColor();
|
|
}
|
|
|
|
//
|
|
const isValidColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('validColor')
|
|
);
|
|
if (isValidColorChanged) {
|
|
await this.applyValidColor();
|
|
}
|
|
|
|
//
|
|
const isInvalidColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('invalidColor')
|
|
);
|
|
if (isInvalidColorChanged) {
|
|
await this.applyInvalidColor();
|
|
}
|
|
|
|
//
|
|
const isFillColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('fillColor')
|
|
);
|
|
if (isFillColorChanged) {
|
|
await this.applyFillColor();
|
|
}
|
|
|
|
//
|
|
const isDisabledColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('disabledColor')
|
|
);
|
|
if (isDisabledColorChanged) {
|
|
await this.applyDisabledColor();
|
|
}
|
|
|
|
//
|
|
const isDisabledFillColorChanged = changeKeys.includes(
|
|
nameof<XFormComponent>('disabledFillColor')
|
|
);
|
|
if (isDisabledFillColorChanged) {
|
|
await this.applyDisabledFillColor();
|
|
}
|
|
//#endregion
|
|
}
|
|
|
|
async afterViewInit() {
|
|
super.afterViewInit();
|
|
|
|
//
|
|
this.managerService.dispatchResizeEvent();
|
|
setTimeout(() => this.managerService.dispatchResizeEvent(), 500);
|
|
this.detectChanges();
|
|
}
|
|
|
|
onDestroy() {
|
|
super.onDestroy();
|
|
|
|
//
|
|
this.unregisterActionProvider();
|
|
}
|
|
|
|
registerViewHandlers() {
|
|
super.registerViewHandlers();
|
|
|
|
//
|
|
this.registerActionProvider();
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region UI Providers ...
|
|
//
|
|
//#region Form Providers ...
|
|
//
|
|
//#region Form Config ...
|
|
/**
|
|
* prepare form config object
|
|
*/
|
|
getFormConfig() {
|
|
return this.getValue(this.formConfig);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Model ...
|
|
/**
|
|
* get form name ...
|
|
*/
|
|
getFormName() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) => this.getValue(formConfig.name))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Css Class Lists...
|
|
/**
|
|
* retrieve form cssClasses ...
|
|
*/
|
|
getFormCssClass() {
|
|
return this.getArrayValue(this.cssClass).pipe(
|
|
concatMap((cssClasses) =>
|
|
this.getFormName().pipe(
|
|
map((formName) => {
|
|
return {
|
|
name: formName,
|
|
cssClasses,
|
|
};
|
|
})
|
|
)
|
|
),
|
|
map((descriptor) => {
|
|
return descriptor.cssClasses.concat(
|
|
'x-form',
|
|
`x-status-${this.STATUS}`,
|
|
`x-form-${descriptor.name}`
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form control wrapper classes list ...
|
|
*
|
|
* @param control form control config ...
|
|
*/
|
|
getFormControlWrapperClasses(control: XFormControlConfig) {
|
|
return this.getControlInfo(control).pipe(
|
|
map((cInfo) => {
|
|
//
|
|
const fControl = this.getControl(control.propName);
|
|
const isFocused =
|
|
this.getControlInputElementId(control) === this.currentInputFocus;
|
|
|
|
//
|
|
return [
|
|
'x-form-field-wrapper',
|
|
`x-form-${cInfo.type}-field-wrapper`,
|
|
`x-form-field-${control.index.toString()}-wrapper`,
|
|
`x-form-field-${control.propName.toString()}-wrapper`,
|
|
`x-form-field-appearance-${cInfo.appearance
|
|
.toString()
|
|
.toLowerCase()}-wrapper`,
|
|
//
|
|
// Focused ...
|
|
...(isFocused ? ['x-focused'] : []),
|
|
//
|
|
// Disabled ...
|
|
...(cInfo.disabled || fControl.disabled
|
|
? ['x-form-field-wrapper-disabled']
|
|
: []),
|
|
//
|
|
// Valid ...
|
|
...(fControl.valid ? ['x-form-field-wrapper-valid'] : []),
|
|
//
|
|
// Invalid ...
|
|
...(fControl.invalid ? ['x-form-field-wrapper-invalid'] : []),
|
|
//
|
|
// Pending ...
|
|
...(fControl.pending ? ['x-form-field-wrapper-pending'] : []),
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form errors classes ...
|
|
*/
|
|
getFormErrorsClasses() {
|
|
return this.getFormName().pipe(
|
|
map((formName) => {
|
|
return ['x-form-errors', `x-form-${formName}-errors`];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form specific error's class lists ...
|
|
*
|
|
* @param handler form error handler ...
|
|
*/
|
|
getFormErrorClasses(handler: XFormErrorHandler) {
|
|
return this.getFormName().pipe(
|
|
concatMap((formName) =>
|
|
this.getErrorHandlerErrorName(handler).pipe(
|
|
map((errorName) => {
|
|
return {
|
|
formName,
|
|
errorName,
|
|
};
|
|
})
|
|
)
|
|
),
|
|
map((descriptor) => {
|
|
return [
|
|
'x-form-error',
|
|
`x-form-${descriptor.formName}-error`,
|
|
`x-form-${descriptor.errorName}-error`,
|
|
`x-form-${descriptor.formName}-${descriptor.errorName}-error`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form card footer css classes ...
|
|
*/
|
|
getFormCardFooterCssClass() {
|
|
return this.getFormName().pipe(
|
|
map((formName) => {
|
|
return ['x-form-footer', `x-form-${formName}-footer`];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form card actions css classes ...
|
|
*/
|
|
getFormCardActionsCssClass() {
|
|
return this.getFormName().pipe(
|
|
map((formName) => {
|
|
return ['x-form-actions', `x-form-${formName}-actions`];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form field classes list ...
|
|
*
|
|
* @param control form control config ...
|
|
*/
|
|
getFormFieldClasses(control: XFormControlConfig) {
|
|
return this.getControlInfo(control).pipe(
|
|
map((cInfo) => {
|
|
//
|
|
const fControl = this.getControl(control.propName);
|
|
const isFocused =
|
|
this.getControlInputElementId(control) === this.currentInputFocus;
|
|
|
|
//
|
|
return [
|
|
'x-form-field',
|
|
`x-form-${cInfo.type}-field`,
|
|
`x-form-field-${control.index.toString()}`,
|
|
`x-form-field-${control.propName.toString()}`,
|
|
`x-form-field-appearance-${cInfo.appearance
|
|
.toString()
|
|
.toLowerCase()}`,
|
|
//
|
|
// Focused ...
|
|
...(isFocused ? ['x-focused'] : []),
|
|
//
|
|
// Disabled ...
|
|
...(cInfo.disabled || fControl.disabled
|
|
? ['x-form-field-disabled']
|
|
: []),
|
|
//
|
|
// Valid ...
|
|
...(fControl.valid ? ['x-form-field-valid'] : []),
|
|
//
|
|
// Invalid ...
|
|
...(fControl.invalid ? ['x-form-field-invalid'] : []),
|
|
//
|
|
// Pending ...
|
|
...(fControl.pending ? ['x-form-field-pending'] : []),
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form control classes list ...
|
|
*
|
|
* @param control form control config ...
|
|
*/
|
|
getFormControlClasses(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
map((type) => {
|
|
return [
|
|
'x-form-control',
|
|
`x-form-${type}-control`,
|
|
`x-form-control-${control.index.toString()}`,
|
|
`x-form-control-${control.propName.toString()}`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve focusHandler of a form control ...
|
|
*
|
|
* @param control form control config ...
|
|
*/
|
|
getControlFocusHandler(control: XFormControlConfig) {
|
|
return this.getValue(control).pipe(map((config) => config.focusHandler));
|
|
}
|
|
|
|
/**
|
|
* retriev a form control label classes ...
|
|
*/
|
|
getFormControlFieldLabelClasses(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
map((type) => {
|
|
return [
|
|
'x-form-field-label',
|
|
`x-form-${type}-field-label`,
|
|
`x-form-field-label-${control.index.toString()}`,
|
|
`x-form-field-label-${control.propName.toString()}`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve form control hint class list
|
|
*/
|
|
getFormControlHintClasses(control: XFormControlConfig) {
|
|
return this.getControlInfo(control).pipe(
|
|
map((cInfo) => {
|
|
return [
|
|
'x-form-control-hint',
|
|
`x-form-${cInfo.type}-control-hint`,
|
|
`x-form-control-${control.index.toString()}-hint`,
|
|
`x-form-control-${control.propName.toString()}-hint`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Model ...
|
|
/**
|
|
* retrieve for model which provide's initial input for each field.
|
|
* if the form model is <T> this type is Partial<T> ...
|
|
*/
|
|
getFormModel() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) => this.getOptionalValue(formConfig.model))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines the form has intial value provider or not ...
|
|
*/
|
|
formHasModel() {
|
|
return this.getFormModel().pipe(
|
|
map((formModel) => !isNullOrUndefined(formModel))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Updte On ...
|
|
/**
|
|
* retrieve form update strategy identifier ...
|
|
*/
|
|
getFormUpdateOn() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) =>
|
|
this.getOptionalValue(formConfig.updateOn).pipe(
|
|
map((updateOn) => (updateOn ? updateOn : XFormUpdateOn.CHANGE))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Validators ...
|
|
/**
|
|
* retrieve form Validators object ...
|
|
*/
|
|
getFormValidators() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) => this.getOptionalValue(formConfig.validators))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines form has Validators or not ...
|
|
*/
|
|
formHasValidators() {
|
|
return this.getFormValidators().pipe(
|
|
map((formValidators) => !isNullOrUndefined(formValidators))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Controls ...
|
|
/**
|
|
* retrieve form Controls Configs ...
|
|
*/
|
|
getFormControls() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) =>
|
|
this.getArrayValue(formConfig.controls).pipe(
|
|
map((arrVal) => sort(arrVal, (v1, v2) => v1.index - v2.index))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Error Handlers ...
|
|
/**
|
|
* retrieve form Error Handlers Descriptor object ...
|
|
*/
|
|
getFormErrorHandlers() {
|
|
return this.getFormConfig().pipe(
|
|
concatMap((formConfig) => this.getArrayValue(formConfig.errorHandlers))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines form has Error Handlers or not ...
|
|
*/
|
|
formHasErrorHandlers() {
|
|
return this.hasChildValue(this.getFormErrorHandlers());
|
|
}
|
|
|
|
/**
|
|
* determines for has specific error or not ...
|
|
*
|
|
* @param handler form error handler ...
|
|
*/
|
|
formHasError(handler: XFormErrorHandler) {
|
|
return this.getValue(handler.errorName).pipe(
|
|
map((errorName) => {
|
|
return (
|
|
!isNullOrUndefined(this.ERRORS) &&
|
|
keys(this.ERRORS).includes(errorName) &&
|
|
!isNullOrUndefined(this.ERRORS[errorName])
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determine form has specific error by name ...
|
|
*
|
|
* @param name error name ...
|
|
*/
|
|
formHasErrorByName(name: string) {
|
|
return (
|
|
!isNullOrUndefined(this.ERRORS) &&
|
|
keys(this.ERRORS).includes(name) &&
|
|
!isNullOrUndefined(this.ERRORS[name])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve specific error from form ...
|
|
*
|
|
* @param handler form error handler ...
|
|
*/
|
|
getFormError(handler: XFormErrorHandler) {
|
|
return this.getErrorHandlerErrorName(handler).pipe(
|
|
concatMap((errorName) =>
|
|
this.formHasError(handler).pipe(
|
|
map((hasError) => {
|
|
return {
|
|
errorName,
|
|
hasError,
|
|
};
|
|
})
|
|
)
|
|
),
|
|
map((descriptor) =>
|
|
descriptor.hasError ? this.ERRORS[descriptor.errorName] : null
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve specific form error by name ...
|
|
*
|
|
* @param name error name ...
|
|
*/
|
|
getFormErrorByName(name: string) {
|
|
return this.formHasErrorByName(name) ? this.ERRORS[name] : null;
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Control Providers ...
|
|
/**
|
|
* retrieve specific control config ...
|
|
*
|
|
* @param name control name
|
|
*/
|
|
getFormControl(name: XFormControlNameIdentifier) {
|
|
return this.getFormControls().pipe(
|
|
map((controls) => controls.find((c) => c.propName === name))
|
|
);
|
|
}
|
|
|
|
//
|
|
getControlInputElementId(control: XFormControlConfig) {
|
|
return `x-form-${control.propName.toString()}-input-element`;
|
|
}
|
|
|
|
//
|
|
getControlInputElementIdByName(name: XFormControlNameIdentifier) {
|
|
return `x-form-${name.toString()}-input-element`;
|
|
}
|
|
|
|
//
|
|
getControlInputElementClasses(control: XFormControlConfig) {
|
|
return this.getControlInputElementCssClasses(control).pipe(
|
|
concatMap((inpCss) =>
|
|
this.getControlType(control).pipe(
|
|
map((type) => {
|
|
//
|
|
return [
|
|
'x-form-input-element',
|
|
`x-form-${type}-input-element`,
|
|
`x-form-${control.index.toString()}-input-element`,
|
|
`x-form-${control.propName.toString()}-input-element`,
|
|
//
|
|
...inpCss.map((i) => i.toString()),
|
|
];
|
|
})
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
//
|
|
getControlInputElementCssClasses(control: XFormControlConfig) {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getArrayValue(
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.inputCssClass)
|
|
? config.inputCssClass
|
|
: []
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
getControlDisableInput(control: XFormControlConfig) {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.disableInput)
|
|
? config.disableInput
|
|
: false
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
isInputControlReadOnly(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
concatMap((type) => {
|
|
//
|
|
if (type === XFormControlType.Text) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config && (config as XFormInputControlConfig)
|
|
? this.getOptionalValue(
|
|
(config as XFormInputControlConfig).readonly
|
|
)
|
|
: of(false)
|
|
)
|
|
);
|
|
} else {
|
|
return this.getValue(false);
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
getControlDisableIcon(control: XFormControlConfig) {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.disableIcon)
|
|
? config.disableIcon
|
|
: false
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
//#region Control Type Providers ...
|
|
//
|
|
//#region Type Descriptor ...
|
|
/**
|
|
* retrieve a control type descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlTypeDescriptor(control: XFormControlConfig) {
|
|
return this.getValue(control.type);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Type ...
|
|
/**
|
|
* retrieve a control type ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlType(control: XFormControlConfig) {
|
|
return this.getControlTypeDescriptor(control).pipe(
|
|
concatMap((typeDesc) =>
|
|
this.getValue(
|
|
typeDesc && typeDesc.type ? typeDesc.type : XFormControlType.Hidden
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Type Config ...
|
|
/**
|
|
* retrieve a control type specific config object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlTypeConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeDescriptor(control).pipe(
|
|
concatMap((typeDesc) => this.getOptionalValue(typeDesc.config))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Action Icon Configs ...
|
|
/**
|
|
* determines a custom control has clear icon or not ...
|
|
*/
|
|
hasControlClearIcon(control: XFormControlConfig): Observable<boolean> {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
map((config) => {
|
|
return (
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.clearIcon)
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve custom control clear icon
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlClearIcon(
|
|
control: XFormControlConfig
|
|
): Observable<XControlIconDescriptor> {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return !isNullOrUndefined(config)
|
|
? this.getValue(config.clearIcon)
|
|
: of(null);
|
|
}),
|
|
map((iconSelector) => {
|
|
return !isNullOrUndefined(iconSelector)
|
|
? iconSelector
|
|
: defaultFormControlClearIcon;
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a custom control has select icon or not ...
|
|
*/
|
|
hasControlSelectIcon(control: XFormControlConfig): Observable<boolean> {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
map((config) => {
|
|
return (
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.selectIcon)
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve custom control select icon
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlSelectIcon(
|
|
control: XFormControlConfig
|
|
): Observable<XControlIconDescriptor> {
|
|
return this.getCustomControlConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return !isNullOrUndefined(config)
|
|
? this.getValue(config.selectIcon)
|
|
: of(null);
|
|
}),
|
|
map((iconSelector) => {
|
|
return !isNullOrUndefined(iconSelector)
|
|
? iconSelector
|
|
: defaultFormControlSelectIcon;
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
//#region XForm Custom Control IconDescriptor Providers ...
|
|
/**
|
|
* retrieve Custom Control Action Icon's Name ...
|
|
*
|
|
* @param role Icon Action Descriptor...
|
|
* @param descriptor Selector icon descriptor ...
|
|
*/
|
|
getControlIconDescriptorName(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor
|
|
) {
|
|
return this.getValue(descriptor.name).pipe(
|
|
map((name) => {
|
|
return !isNullOrUndefined(name) && !isNullOrEmptyString(name.toString())
|
|
? name
|
|
: role === this.ControlIconRoles.Select
|
|
? XIconNames.touch
|
|
: XIconNames.clear;
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve Custom Control Action Icon's color ...
|
|
*
|
|
* @param role Icon Action Descriptor...
|
|
* @param descriptor Selector icon descriptor ...
|
|
*/
|
|
getControlIconDescriptorColor(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor
|
|
) {
|
|
return this.getValue(descriptor.color).pipe(
|
|
map((color) => {
|
|
return !isNullOrEmptyString(color)
|
|
? color
|
|
: role === this.ControlIconRoles.Select
|
|
? XColorWithBrightness.Success
|
|
: XColorWithBrightness.Danger;
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve Custom Control Action Icon's applyStateColor ...
|
|
*
|
|
* @param descriptor Selector icon descriptor ...
|
|
*/
|
|
getControlIconDescriptorApplyStateColor(descriptor: XControlIconDescriptor) {
|
|
return this.getOptionalValue(descriptor.applyStateColor);
|
|
}
|
|
|
|
/**
|
|
* retrieve Custom Control Action Icon's tooltip ...
|
|
*
|
|
* @param role Icon Action Descriptor...
|
|
* @param descriptor Selector icon descriptor ...
|
|
*/
|
|
getControlIconDescriptorTooltip(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor
|
|
) {
|
|
return this.getResourceValue(descriptor.tooltip).pipe(
|
|
map((tooltip) => {
|
|
return !isNullOrEmptyString(tooltip)
|
|
? tooltip
|
|
: role === this.ControlIconRoles.Select
|
|
? this.resourceProvider(this.ResourceIDs.select)
|
|
: this.resourceProvider(this.ResourceIDs.clear);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve Custom Control Action Icon's position ...
|
|
*
|
|
* @param descriptor Selector icon descriptor ...
|
|
*/
|
|
getControlIconDescriptorPosition(descriptor: XControlIconDescriptor) {
|
|
return this.getValue(descriptor.position).pipe(
|
|
map((position) => {
|
|
return !isNullOrEmptyString(position)
|
|
? position
|
|
: XControlIconPosition.Suffix;
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Type Configs
|
|
//
|
|
//#region Markdown Config ...
|
|
/**
|
|
* retrieve Markdown Control Config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormMarkdownControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines control has Markdown Config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasMarkdownConfig(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines markdown Card is In Page or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMarkdownInPage(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.isInPage);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown has toolbar ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkDownHasToolbar(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.hasToolbar);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown wrap with card ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMarkdownWrapWithCard(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.wrapWithCard);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown card color ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownCardColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getValue(
|
|
config && config.cardColor ? config.cardColor : XColor.Light
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown editorBoxColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownEditorBoxColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getValue(
|
|
config && config.editorBoxColor ? config.editorBoxColor : XColor.Light
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown previewBoxColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownPreviewBoxColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getValue(
|
|
config && config.previewBoxColor
|
|
? config.previewBoxColor
|
|
: XColorWithBrightness.MediumTint
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines markdown toolbar color is foreground color or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownCardForegroundColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.cardForegroundColor);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown mode ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownMode(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.mode || null)),
|
|
map((mode) => (mode ? mode : XMarkdownMode.PREVIEW))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown Toolbar Color ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkDownToolbarColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getValue(
|
|
config && config.toolbarColor ? config.toolbarColor : XColor.Light
|
|
);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown Card Title ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownCardTitle(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.cardTitle);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown action provider ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownActionProvider(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
if (!config.actionProvider) {
|
|
//
|
|
if (!this.actionProviders[control.propName]) {
|
|
this.actionProviders[control.propName] =
|
|
new Subject<XMarkdownActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[
|
|
control.propName
|
|
] as Subject<XMarkdownActionModel>;
|
|
} else {
|
|
return config.actionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines markdown toolbar color is foreground color or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkDownToolbarForegroundColor(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.toolbarForegroundColor);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown cssClass ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownCssClass(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getArrayValue(config.cssClass);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown content ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkDownContent(control: XFormControlConfig) {
|
|
return this.getValue(control).pipe(
|
|
map((ctrl) => {
|
|
//
|
|
if (!this.hasControl(ctrl.propName)) {
|
|
return '';
|
|
}
|
|
|
|
//
|
|
const xFormControl = this.getControl(ctrl.propName);
|
|
if (!xFormControl) {
|
|
return '';
|
|
}
|
|
|
|
//
|
|
return (xFormControl.value || '') as string;
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown Card SubTitle ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownCardSubTitle(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getResourceValue(config.cardSubTitle);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown toolbar css class ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownToolbarCssClass(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getArrayValue(config.toolbarCssClass);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve markdown toolbar config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMarkdownToolbarConfig(control: XFormControlConfig) {
|
|
return this.getMarkdownConfig(control).pipe(
|
|
concatMap((config) => {
|
|
return this.getOptionalValue(config.toolbarConfig);
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Select/Radio Config ...
|
|
/**
|
|
* retrieve select control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSelectConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormSelectControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines select control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasSelectConfig(control: XFormControlConfig) {
|
|
return this.getSelectConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve select control options ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSelectOptions(control: XFormControlConfig) {
|
|
return this.getSelectConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.options))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines select control can select multiple or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSelectMultiple(control: XFormControlConfig) {
|
|
return this.getSelectConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.multiple))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve Select Control Panel Calsses ...
|
|
*/
|
|
getSelectPanelClasses(control: XFormControlConfig) {
|
|
return this.getFormControlClasses(control).pipe(
|
|
concatMap((classes) =>
|
|
this.getSelectMultiple(control).pipe(
|
|
map((isMultiple) => ({ classes, isMultiple }))
|
|
)
|
|
),
|
|
map((selectInfo) => {
|
|
return [
|
|
...selectInfo.classes,
|
|
'x-form-select-control-panel',
|
|
...(selectInfo.isMultiple ? ['multiple'] : []),
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve select control option css classes ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getOptionClassName(option: XFormSelectControlOption) {
|
|
return this.getValue(option).pipe(
|
|
map((opt) => ['x-select-option', `x-select-${opt.value}-option`])
|
|
);
|
|
}
|
|
|
|
//
|
|
// Radio ...
|
|
/**
|
|
* retrieve radio control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getRadioConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormRadioControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines radio control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasRadioConfig(control: XFormControlConfig) {
|
|
return this.getRadioConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve radio control options ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getRadioOptions(control: XFormControlConfig) {
|
|
return this.getRadioConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.options))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a radio control options label position ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getRadioLabelPosition(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.labelPosition
|
|
: XFormControlLabelPosition.After
|
|
).pipe(map((result) => result as 'before' | 'after'))
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region CheckBox Config ...
|
|
/**
|
|
* retrieve checkbox control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getCheckboxConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormCheckBoxControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines checkbox control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasCheckboxConfig(control: XFormControlConfig) {
|
|
return this.getCheckboxConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a checkbox control label position ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getCheckboxLabelPosition(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.labelPosition
|
|
: XFormControlLabelPosition.After
|
|
).pipe(map((result) => result as 'before' | 'after'))
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Date Picker Config ...
|
|
/**
|
|
* retrieve date control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDateConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormDatePickerControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines date control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasDateConfig(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve date control start at ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDateStartAt(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.startAt))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve date control picker position ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerPosition(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.datePickerPosition))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve date control filter ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDateFilter(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.dateFilter))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve date control input handler ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDateInputHandler(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.dateInput))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve date control change handler ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDateChangeHandler(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.dateChange))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines date control input field disabled or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isDatePickerInputDisabled(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.disableInput))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines date control input field disabled or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isDatePickerToggleDisabled(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.disablePicker))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retriece date control classes ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerClasses(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
map((type) => {
|
|
return [
|
|
'x-date-picker',
|
|
`x-form-control-${type}-picker`,
|
|
`x-form-control-${control.propName.toString()}-date-picker`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retriece date control toggle icon name ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerIcon(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.toggleIcon)),
|
|
map((icon) => (icon ? icon : XIconNames.calendar))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retriece date control toggle icon color ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerIconColor(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.iconColor)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retriece date control toggle icon tooltip ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerIconTooltip(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.iconTooltip))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retriece date control toggle apply color state ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getDatePickerIconApplyStateColor(control: XFormControlConfig) {
|
|
return this.getDateConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.applyStateColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines date control icon position is suffix or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isDatePickerHasSuffixIcon(control: XFormControlConfig) {
|
|
return this.getDatePickerPosition(control).pipe(
|
|
map(
|
|
(position) => position === XFormDatePickerControlPickerPosition.Suffix
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines date control icon position is prefix or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isDatePickerHasPrefixIcon(control: XFormControlConfig) {
|
|
return this.getDatePickerPosition(control).pipe(
|
|
map(
|
|
(position) => position === XFormDatePickerControlPickerPosition.Prefix
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Slider Config ...
|
|
/**
|
|
* retrieve slider control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSliderConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormSliderControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines slider control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasSliderConfig(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve slider control min value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSliderMin(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.min)),
|
|
map((min) => (min ? min : 0))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve slider control max value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSliderMax(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.max)),
|
|
map((max) => (max ? max : 99))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve slider control step value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSliderStep(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.step)),
|
|
map((step) => (step ? step : 1))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve slider control invert value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSliderInvert(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.invert))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines slider control is vertical or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isSliderVertical(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.vertical))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines slider control show thumb label or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
showSliderThumbLabel(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.thumbLabel))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve slider formatter function ...
|
|
*/
|
|
getSliderFormatter(control: XFormControlConfig) {
|
|
return this.getSliderConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.formatter))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Toggle Config ...
|
|
/**
|
|
* retrieve a checkbox control label position ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getToggleLabelPosition(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.labelPosition
|
|
: XFormControlLabelPosition.After
|
|
).pipe(map((result) => result as 'before' | 'after'))
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Map Config ...
|
|
/**
|
|
* retrieve map control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormMapControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasMapConfig(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map component's selected point value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSelectedPoint(control: XFormControlConfig): Observable<XMapLocation> {
|
|
//
|
|
const fControl = this.getControl(control.propName);
|
|
if (!fControl || !fControl.value) {
|
|
return of(null);
|
|
}
|
|
|
|
//
|
|
const fValue = fControl.value as string;
|
|
if (isNullOrEmptyString(fValue)) {
|
|
return of(null);
|
|
}
|
|
|
|
//
|
|
const result = fromLongLat(fValue);
|
|
this.getMapActionProvider(control).pipe(
|
|
tap((actionProvider) => {
|
|
//
|
|
if (actionProvider) {
|
|
//
|
|
actionProvider.next({
|
|
action: XMapAction.SetCenter,
|
|
payload: result,
|
|
});
|
|
}
|
|
})
|
|
);
|
|
|
|
//
|
|
return of(result);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control zoom value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapLatitude(control: XFormControlConfig) {
|
|
return this.getMapSelectedPoint(control).pipe(
|
|
map((point) => (point && point.latitude ? +point.latitude : 0))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control zoom value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapLongitude(control: XFormControlConfig) {
|
|
return this.getMapSelectedPoint(control).pipe(
|
|
map((point) => (point && point.longitude ? +point.longitude : 0))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control zoom value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapZoom(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => (config.zoom ? this.getValue(config.zoom) : of(0)))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control markerStyle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapMarkerStyle(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.markerStyle)),
|
|
map((markerStyle) => (markerStyle ? markerStyle : defaultMarkerStyle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control cssClass value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapCssClass(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.cssClass))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control canSelect or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapCanSelect(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.canSelect))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showProgressBar or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowProgressBar(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showProgressBar)),
|
|
map((canShow) => (isNullOrUndefined(canShow) ? true : canShow))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control progressBarColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapProgressBarColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.progressBarColor)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control progressBarPosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapProgressBarPosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.progressBarPosition)),
|
|
map((position) =>
|
|
isNullOrEmptyString(position) ? XMapItemPosition.TOP : position
|
|
)
|
|
);
|
|
}
|
|
|
|
//
|
|
//#region Map Search Bar ...
|
|
/**
|
|
* determines map control showSearchBar or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowSearchBar(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showSearchBar)),
|
|
map((result) => (isNullOrUndefined(result) ? true : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarType value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarType(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.searchBarType)),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XSearchBarType.Search : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarValue value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarValue(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.searchBarValue))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarDebounce value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarDebounce(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.searchBarDebounce)),
|
|
map((result) =>
|
|
isNullOrUndefined(result)
|
|
? this.config.defaultSearchDebounceTime
|
|
: result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarSpellcheck value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarSpellcheck(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.searchBarSpellcheck)),
|
|
map((result) => (isNullOrUndefined(result) ? false : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchPlaceProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchPlaceProvider(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.searchPlaceProvider)),
|
|
map((result) =>
|
|
isNullOrUndefined(result) ? defaultMapSearchPlaceProvider : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.searchBarColor)),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XColorWithBrightness.Primary : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarForegroundColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarForegroundColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarForegroundColor)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarClearIcon value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarClearButtonIcon(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarClearButtonIcon)
|
|
),
|
|
map((result) => (isNullOrUndefined(result) ? XIconNames.clear : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarTitle(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.searchBarTitle)),
|
|
map((result) =>
|
|
isNullOrUndefined(result) ? XResourceIDs.search : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarSearchIcon value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarSearchButtonIcon(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarSearchButtonIcon)
|
|
),
|
|
map((result) => (isNullOrUndefined(result) ? XIconNames.search : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarInputColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarSearchInputColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarSearchInputColor)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XColorWithBrightness.Primary : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarForegroundInputColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarForegroundSearchInputColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarForegroundSearchInputColor)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchResultListColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchResultListColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchResultListColor)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XColorWithBrightness.Light : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarActionProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarActionProvider(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
const key = `${control.propName.toString()}_SearchBar`;
|
|
if (!config.searchBarActionProvider) {
|
|
//
|
|
if (!this.actionProviders[key]) {
|
|
this.actionProviders[key] = new Subject<XSearchBarActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[key] as Subject<XSearchBarActionModel>;
|
|
} else {
|
|
return config.searchBarActionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarClearIconColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarClearButtonIconColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarClearButtonIconColor)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XColorWithBrightness.Light : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarCssClass value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarCssClass(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.searchBarCssClass))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarSearchIconColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarSearchButtonIconColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarSearchButtonIconColor)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XColorWithBrightness.Light : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarCancelButtonIcon value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarCancelButtonIcon(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarCancelButtonIcon)
|
|
),
|
|
map((result) => (isNullOrUndefined(result) ? XIconNames.cancel : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarPosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarPosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.searchBarPosition)),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XMapItemPosition.TOP : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarKeyboardType value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarKeyboardType(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarKeyboardType)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XSearchBarType.Search : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarCancelButtonTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarCancelButtonTitle(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.searchBarCancelButtonTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control searchBarEnterKeyHint value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSearchBarEnterKeyHint(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarEnterKeyHint)
|
|
),
|
|
map((result) =>
|
|
isNullOrEmptyString(result) ? XSearchBarEnterKeyHint.Search : result
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control searchBarShowCancelButton or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowSearchBarCancelButton(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.searchBarShowCancelButton)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
/**
|
|
* determines map control showSelectedLocation or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowSelectedLocation(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showSelectedLocation)),
|
|
map((result) => (isNullOrUndefined(result) ? false : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control selectedLocationPosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapSelectedLocationPosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.selectedLocationPosition)
|
|
),
|
|
map((position) =>
|
|
isNullOrEmptyString(position) ? XMapItemPosition.TOP : position
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showGoMarkedPlace or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowGoMarkedPlace(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showGoMarkedPlace)),
|
|
map((result) => (isNullOrUndefined(result) ? true : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control goMarkedPlacePosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapGoMarkedPlacePosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.goMarkedPlacePosition)
|
|
),
|
|
map((position) =>
|
|
isNullOrEmptyString(position) ? XMapItemPosition.TOP : position
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showClearMarker or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowClearMarker(control: XFormControlConfig) {
|
|
//
|
|
// Clear Marker in Form Components only must shown when user decide to it and the present Type is with dialog
|
|
// since the clear value handle clear marker actions in without dialog mode ...
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) =>
|
|
forkJoin({
|
|
showClearMarker: this.getOptionalValue(config.showClearMarker),
|
|
withDialog: this.isMapPresentWithDialog(control),
|
|
})
|
|
),
|
|
map(
|
|
(info) =>
|
|
(isNullOrUndefined(info.showClearMarker)
|
|
? true
|
|
: info.showClearMarker) && info.withDialog
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control clearMarkerPosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapClearMarkerPosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.clearMarkerPosition)),
|
|
map((position) =>
|
|
isNullOrEmptyString(position) ? XMapItemPosition.TOP : position
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showLocator or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowLocator(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showLocator)),
|
|
map((result) => (isNullOrUndefined(result) ? true : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control locatorPosition value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapLocatorPosition(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.locatorPosition)),
|
|
map((position) =>
|
|
isNullOrEmptyString(position) ? XMapItemPosition.TOP : position
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showZoom or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowZoom(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showZoom)),
|
|
map((result) => (isNullOrUndefined(result) ? true : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showRotate or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowRotate(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showRotate)),
|
|
map((result) => (isNullOrUndefined(result) ? true : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showZoomSlider or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapShowZoomSlider(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showZoomSlider)),
|
|
map((result) => (isNullOrUndefined(result) ? false : result))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control isInPage or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMapInPage(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.isInPage))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control wrapWithCard or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMapWrapWithCard(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.wrapWithCard))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control cardColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapCardColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardColor)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control cardForegroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMapCardForegroundColor(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardForegroundColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control cardTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapCardTitle(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control cardSubTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapCardSubTitle(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardSubTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showCardFooter or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
mapCardShowFooter(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardShowFooter))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve map control actionProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapActionProvider(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
if (!config.actionProvider) {
|
|
//
|
|
if (!this.actionProviders[control.propName]) {
|
|
this.actionProviders[control.propName] =
|
|
new Subject<XMapActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[
|
|
control.propName
|
|
] as Subject<XMapActionModel>;
|
|
} else {
|
|
return config.actionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
//#region Map Present Types ...
|
|
/**
|
|
* retrieve map control presentType value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getMapPresentType(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.presentType)),
|
|
map((presentType) =>
|
|
!isNullOrEmptyString(presentType)
|
|
? presentType
|
|
: XFormMapControlPresentType.WithoutDialog
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control present WithoutDialog or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMapPresentWithoutDialog(control: XFormControlConfig) {
|
|
return this.getMapPresentType(control).pipe(
|
|
map(
|
|
(presentType) =>
|
|
presentType === XFormMapControlPresentType.WithoutDialog
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control present WithDialog or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isMapPresentWithDialog(control: XFormControlConfig) {
|
|
return this.getMapPresentType(control).pipe(
|
|
map(
|
|
(presentType) => presentType === XFormMapControlPresentType.WithDialog
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region ColorPicker Config ...
|
|
/**
|
|
* retrieve color picker control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormColorPickerControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasColorPickerConfig(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control color value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.color)),
|
|
map((color) => (isNullOrEmptyString(color) ? XColor.Light : color))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control colorViewBorderColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorViewBorderColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.colorViewBorderColor)),
|
|
map((color) => (isNullOrEmptyString(color) ? XColor.Light : color))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control colorViewBorderStyle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorViewBorderStyle(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.colorViewBorderStyle)),
|
|
map((style) => (isNullOrEmptyString(style) ? XBorderStyle.Solid : style))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control colorViewBorderWidth value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorViewBorderWidth(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.colorViewBorderWidth))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control cssClass value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCssClass(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.cssClass))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control cardColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCardColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control cardTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCardTitle(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control cursorColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCursorColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.cursorColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Dark))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control presetColors value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerPresetColors(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.presetColors))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control outputFormat value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerOutputFormat(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.outputFormat)),
|
|
map((format) =>
|
|
!isNullOrEmptyString(format) ? format : XColorPickerOutputFormat.XHEX
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control cardSubTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCardSubTitle(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardSubTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control colorTextColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorTextColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.colorTextColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Dark))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showColorValue or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowColorValue(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showColorValue ? this.getValue(config.showColorValue) : of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showHueChannel or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowHueChannel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showHueChannel ? this.getValue(config.showHueChannel) : of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control foregroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerForegroundColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.foregroundColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showPresetColors or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowPresetColors(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showPresetColors
|
|
? this.getValue(config.showPresetColors)
|
|
: of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showAlphaChannel or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowAlphaChannel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showAlphaChannel
|
|
? this.getValue(config.showAlphaChannel)
|
|
: of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control presetColorsLable value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerPresetColorsLable(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.presetColorsLable)),
|
|
map((value) =>
|
|
isNullOrEmptyString(value) ? XResourceIDs.preset_colors : value
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control copyToClipboardIconLabel value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCopyToClipboardIconLabel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getResourceValue(config.copyToClipboardIconLabel)
|
|
),
|
|
map((value) =>
|
|
isNullOrEmptyString(value) ? XResourceIDs.copy_to_clipboard : value
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control colorInputIconLabel value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorInputIconLabel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.colorInputIconLabel)),
|
|
map((value) => (isNullOrEmptyString(value) ? XResourceIDs.input : value))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control clearColorIconLabel value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerClearColorIconLabel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.clearColorIconLabel)),
|
|
map((value) => (isNullOrEmptyString(value) ? XResourceIDs.clear : value))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showPaletteChannel or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowPaletteChannel(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showPaletteChannel
|
|
? this.getValue(config.showPaletteChannel)
|
|
: of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control cardForegroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerCardForegroundColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardForegroundColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showCopyToClipboard or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowCopyToClipboard(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showCopyToClipboard
|
|
? this.getValue(config.showCopyToClipboard)
|
|
: of(false)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showColorInput or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowColorInput(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showCopyToClipboard
|
|
? this.getValue(config.showColorInput)
|
|
: of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control representColorFormats value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerRepresentColorFormats(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.representColorFormats)),
|
|
map((formats) =>
|
|
hasChild(formats) ? formats : [XColorPickerOutputFormat.XHEX]
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control presetColorsLableColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerPresetColorsLableColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.presetColorsLableColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Dark))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control copyToClipboardIconColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerCopyToClipboardIconColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.copyToClipboardIconColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Tertiary))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control copyToClipboardIconColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerColorInputIconColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.colorInputIconColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Secondary))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control clearColorIconColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerClearColorIconColor(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.clearColorIconColor)),
|
|
map((color) => (!isNullOrEmptyString(color) ? color : XColor.Danger))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showSelectedColorPreview or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickerShowSelectedColorPreview(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
config.showSelectedColorPreview
|
|
? this.getValue(config.showSelectedColorPreview)
|
|
: of(true)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control isInPage or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerInPage(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.isInPage))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control wrapWithCard or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerWrapWithCard(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.wrapWithCard))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control showCardFooter or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
colorPickercardShowFooter(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showCardFooter))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker component's selected value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerSelectedColor(control: XFormControlConfig) {
|
|
//
|
|
const fControl = this.getControl(control.propName);
|
|
if (!fControl) {
|
|
return of('');
|
|
}
|
|
|
|
//
|
|
const fValue = fControl.value as string;
|
|
if (isNullOrEmptyString(fValue)) {
|
|
return of('');
|
|
}
|
|
|
|
//
|
|
return of(fValue);
|
|
}
|
|
|
|
/**
|
|
* retrieve color picker control actionProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerActionProvider(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
if (!config.actionProvider) {
|
|
//
|
|
if (!this.actionProviders[control.propName]) {
|
|
this.actionProviders[control.propName] =
|
|
new Subject<XMapActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[
|
|
control.propName
|
|
] as Subject<XColorPickerActionModel>;
|
|
} else {
|
|
return config.actionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
//#region ColorPicker Present Types ...
|
|
/**
|
|
* retrieve color picker control presentType value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getColorPickerPresentType(control: XFormControlConfig) {
|
|
return this.getColorPickerConfig(control).pipe(
|
|
concatMap((config) =>
|
|
!isNullOrUndefined(config) && !isNullOrUndefined(config.presentType)
|
|
? this.getOptionalValue(config.presentType)
|
|
: of(null)
|
|
),
|
|
map((presentType) =>
|
|
!isNullOrEmptyString(presentType)
|
|
? presentType
|
|
: XFormColorPickerControlPresentType.WithoutDialog
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control present WithoutDialog or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerPresentWithoutDialog(control: XFormControlConfig) {
|
|
return this.getColorPickerPresentType(control).pipe(
|
|
map(
|
|
(presentType) =>
|
|
presentType === XFormColorPickerControlPresentType.WithoutDialog
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines color picker control present WithDialog or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isColorPickerPresentWithDialog(control: XFormControlConfig) {
|
|
return this.getColorPickerPresentType(control).pipe(
|
|
map(
|
|
(presentType) =>
|
|
presentType === XFormColorPickerControlPresentType.WithDialog
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Avatar Config ...
|
|
/**
|
|
* retrieve avatar upload control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormAvatarUploadControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasAvatarConfig(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control canDrop or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
avatarCanDrop(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.canDrop))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control isInPage or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarInPage(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.isInPage))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control wrapWithCard or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarWrapWithCard(control: XFormControlConfig) {
|
|
return this.getMapConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.wrapWithCard))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control color value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.color)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control showCardFooter or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
avatarCardShowFooter(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.showCardFooter))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control foregroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarForegroundColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.foregroundColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control placeHolderAvatar value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarPlaceHolderAvatar(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.placeHolderAvatar))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control minAllowedFileSize value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarMinAllowedFileSize(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.minAllowedFileSize)),
|
|
map((minAllowedFileSize) =>
|
|
minAllowedFileSize ? minAllowedFileSize : this.config.minAllowedFileSize
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control maxAllowedFileSize value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarMaxAllowedFileSize(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.maxAllowedFileSize)),
|
|
map((maxAllowedFileSize) =>
|
|
maxAllowedFileSize
|
|
? maxAllowedFileSize
|
|
: this.config.maxProfileImageSize
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control cardColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarCardColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardColor)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control cardForegroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarCardForegroundColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.cardForegroundColor))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaIsInPage or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaInPage(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.fileDropAreaIsInPage))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control cardTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarCardTitle(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control cssClass value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarCssClass(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.cssClass))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaWrapWithCard or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaWrapWithCard(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaWrapWithCard)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaIcon value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaIcon(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getValue(config.fileDropAreaIcon)),
|
|
map((icon) => (icon ? icon : XIconNames.arrow_down))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaDragDisabled or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaDragDisabled(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaDragDisabled)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control cardSubTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarCardSubTitle(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.cardSubTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar control actionProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarActionProvider(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
if (!config.actionProvider) {
|
|
//
|
|
if (!this.actionProviders[control.propName]) {
|
|
this.actionProviders[control.propName] =
|
|
new Subject<XAvatarUploadActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[
|
|
control.propName
|
|
] as Subject<XAvatarUploadActionModel>;
|
|
} else {
|
|
return config.actionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines map control fileDropAreaShowCardFooter or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
avatarDropAreaCardShowFooter(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaShowCardFooter)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.fileDropAreaColor)),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaForegroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaForegroundColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaForegroundColor)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaDisableFileCheck or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaDisableFileCheck(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaDisableFileCheck)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaCardColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaCardColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaCardColor)
|
|
),
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaCardForegroundColor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaCardForegroundColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaCardForegroundColor)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control emptyFileException value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarEmptyFileException(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.emptyFileException)),
|
|
map((exception) => (exception ? exception : XExceptionIDs.EmptyFile))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaErrorColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaErrorColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaErrorColor)
|
|
),
|
|
map((color) => (color ? color : XColor.Danger))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaMessage value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaMessage(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getOptionalValue(config.fileDropAreaMessage)),
|
|
map((message) => (message ? message : XResourceIDs.drag_drop_here)),
|
|
concatMap((resource) => this.getResourceValue(resource))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaAccentColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaAccesntColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaAccentColor)
|
|
),
|
|
map((color) => (color ? color : XColor.Secondary))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control allowedExtensions value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarAllowedExtensions(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.allowedExtensions)),
|
|
map((allowedExtensions) =>
|
|
hasChild(allowedExtensions)
|
|
? allowedExtensions
|
|
: this.config.allowedImageExtensions
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaCardTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaCardTitle(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getResourceValue(config.fileDropAreaCardTitle))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaSuccessColor value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaSuccessColor(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaSuccessColor)
|
|
),
|
|
map((color) => (color ? color : XColor.Success))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines avatar upload control fileDropAreaSupportsMultipleFiles or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
isAvatarDropAreaSupportsMultipleFiles(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaSupportsMultipleFiles)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaCssClass value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaCssClass(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.fileDropAreaCssClass))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaCardSubTitle value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaCardSubTitle(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getResourceValue(config.fileDropAreaCardSubTitle)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control emptyFileException value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarNotAllowedFileException(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.notAllowedFileException)
|
|
),
|
|
map((exception) => (exception ? exception : XExceptionIDs.InavlidFile))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control fileDropAreaContentTemplate value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaContentTemplate(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.fileDropAreaContentTemplate)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control minAllowedFileSizeException value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarMinAllowedFileSizeException(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.minAllowedFileSizeException)
|
|
),
|
|
map((exception) =>
|
|
exception ? exception : XExceptionIDs.MinFilesSizeExceeded
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control maxAllowedFileSizeException value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarMaxAllowedFileSizeException(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getOptionalValue(config.maxAllowedFileSizeException)
|
|
),
|
|
map((exception) =>
|
|
exception ? exception : XExceptionIDs.MaxFilesSizeExceeded
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar control actions value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarActions(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) => this.getArrayValue(config.actions)),
|
|
concatMap((actions) =>
|
|
hasChild(actions)
|
|
? of(actions)
|
|
: this.getArrayValue(defaultAvatarUploadActionButtons)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar control fileDropAreaActionProvider value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaActionProvider(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
map((config) => {
|
|
//
|
|
const key = `${control.propName.toString()}_drop_area`;
|
|
|
|
//
|
|
if (!config.fileDropAreaActionProvider) {
|
|
//
|
|
if (!this.actionProviders[key]) {
|
|
this.actionProviders[key] = new Subject<XFileDropAreaActionModel>();
|
|
}
|
|
|
|
//
|
|
return this.actionProviders[key] as Subject<XFileDropAreaActionModel>;
|
|
} else {
|
|
return config.fileDropAreaActionProvider;
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve avatar upload control allowedExtensions value ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAvatarDropAreaAllowedExtensions(control: XFormControlConfig) {
|
|
return this.getAvatarConfig(control).pipe(
|
|
concatMap((config) =>
|
|
this.getArrayValue(config.fileDropAreaAllowedExtensions)
|
|
),
|
|
map((allowedExtensions) =>
|
|
hasChild(allowedExtensions)
|
|
? allowedExtensions
|
|
: this.config.allowedImageExtensions
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Selector Config ...
|
|
/**
|
|
* retrieve selector control config ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getSelectorConfig(control: XFormControlConfig) {
|
|
return this.getControlTypeConfig(control).pipe(
|
|
map((config) => config as XFormSelectorControlConfig)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines selector control has config or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
hasSelectorConfig(control: XFormControlConfig) {
|
|
return this.getSelectorConfig(control).pipe(
|
|
map((config) => !isNullOrUndefined(config))
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Update On ...
|
|
/**
|
|
* retrieve a control UpdateOn strategy ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlUpdateOn(control: XFormControlConfig) {
|
|
return this.getOptionalValue(control.updateOn).pipe(
|
|
map((updateOn) => (updateOn ? updateOn : XFormUpdateOn.CHANGE))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Validators ...
|
|
/**
|
|
* retrieve a control validators descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlValidators(control: XFormControlConfig) {
|
|
return this.getOptionalValue(control.validators);
|
|
}
|
|
|
|
/**
|
|
* determines a control has Validators or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasValidators(control: XFormControlConfig) {
|
|
return this.getControlValidators(control).pipe(
|
|
map((controlValidators) => !isNullOrUndefined(controlValidators))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Event Handlers ...
|
|
/**
|
|
* retrieve a control event handlers descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlEventHandlers(control: XFormControlConfig) {
|
|
return this.getOptionalValue(control.eventHandlers);
|
|
}
|
|
|
|
/**
|
|
* determines a control has validators or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasEventHandlers(control: XFormControlConfig) {
|
|
return this.getControlEventHandlers(control).pipe(
|
|
map((eventHandlers) => !isNullOrUndefined(eventHandlers))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Appearance Descriptor ...
|
|
/**
|
|
* retrieve a control appearance descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlAppearanceDesc(
|
|
control: XFormControlConfig
|
|
): Observable<XFormControlAppearanceDescriptor> {
|
|
return !isNullOrUndefined(control)
|
|
? this.getValue(control.appearance)
|
|
: of(null);
|
|
}
|
|
|
|
//
|
|
//#region Appearance Parts ...
|
|
//
|
|
//#region Control Hidden ...
|
|
/**
|
|
* determines a control hidden or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlHidden(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.hidden : true
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Disabled ...
|
|
/**
|
|
* determines a control is disabled or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlDisabled(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.disabled
|
|
: true
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Hint ...
|
|
/**
|
|
* retrieve a control hint ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlHint(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getResourceValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.hint : ''
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Label ...
|
|
/**
|
|
* retrieve a control label ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlLabel(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getResourceValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.label : ''
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Tooltip ...
|
|
/**
|
|
* retrieve a control tooltip ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlTooltip(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getResourceValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.tooltip : ''
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control PlaceHolder ...
|
|
/**
|
|
* retrieve a control placeholder ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlPlaceHolder(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getResourceValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.placeholder
|
|
: ''
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control CssClass ...
|
|
/**
|
|
* retrieve a control cssClaases ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlCssClass(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getArrayValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.cssClass : []
|
|
)
|
|
),
|
|
concatMap((cssClasses) =>
|
|
this.getControlType(control).pipe(
|
|
map((type) => {
|
|
return {
|
|
type,
|
|
cssClasses,
|
|
};
|
|
})
|
|
)
|
|
),
|
|
map((descriptor) => {
|
|
return descriptor.cssClasses.concat(
|
|
'x-form-control',
|
|
`x-form-control-${control.index}`,
|
|
`x-form-control-${descriptor.type}`
|
|
);
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Icons Descriptor ...
|
|
/**
|
|
* retrieve a control icons descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlIconDesc(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig) ? appearanceConfig.icons : null
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a control has icons descriptor object or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasIcons(control: XFormControlConfig) {
|
|
return this.getControlIconDesc(control).pipe(
|
|
map((iconDesc) => !isNullOrUndefined(iconDesc))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a control has suffix icon or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasSuffixIcon(control: XFormControlConfig) {
|
|
return this.getControlIconDesc(control).pipe(
|
|
concatMap((iconDesc) =>
|
|
this.getOptionalValue(iconDesc ? iconDesc.suffix : null).pipe(
|
|
map((iconSuffix) => !isNullOrUndefined(iconSuffix))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control suffix icon object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlSuffixIcon(control: XFormControlConfig) {
|
|
return this.getControlIconDesc(control).pipe(
|
|
concatMap((iconDesc) =>
|
|
this.getOptionalValue(iconDesc ? iconDesc.suffix : null)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a control has prefix icon or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasPrefixIcon(control: XFormControlConfig) {
|
|
return this.getControlIconDesc(control).pipe(
|
|
concatMap((iconDesc) =>
|
|
this.getOptionalValue(iconDesc ? iconDesc.prefix : null).pipe(
|
|
map((iconPrefix) => !isNullOrUndefined(iconPrefix))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control prefix icon ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlPrefixIcon(control: XFormControlConfig) {
|
|
return this.getControlIconDesc(control).pipe(
|
|
concatMap((iconDesc) =>
|
|
this.getOptionalValue(iconDesc ? iconDesc.prefix : null)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve an icon descriptor's icon name ...
|
|
*
|
|
* @param icon form control icon descriptor ...
|
|
*/
|
|
getControlIconName(icon: XFormIconDescriptor) {
|
|
return this.getValue(icon.name);
|
|
}
|
|
|
|
/**
|
|
* retrieve an icon descriptor's icon color ...
|
|
*
|
|
* @param icon form control icon descriptor ...
|
|
*/
|
|
getControlIconColor(icon: XFormIconDescriptor) {
|
|
return this.getOptionalValue(icon.color).pipe(
|
|
map((color) => (color ? color : XColor.Light))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve an icon descriptor's icon tooltip ...
|
|
*
|
|
* @param icon form control icon descriptor ...
|
|
*/
|
|
getControlIconTooltip(icon: XFormIconDescriptor) {
|
|
return this.getResourceValue(icon.tooltip);
|
|
}
|
|
|
|
/**
|
|
* retrieve an icon descriptor's apply state color ...
|
|
*
|
|
* @param icon form control icon descriptor ...
|
|
*/
|
|
getControlIconApplyStateColor(icon: XFormIconDescriptor) {
|
|
return this.getOptionalValue(icon.applyStateColor);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Formatter Config ...
|
|
/**
|
|
* retrieve a control formatter config descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlFormatterConfig(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.formatter
|
|
: null
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a control has formatter config descriptor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasFormatter(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
map((formatterConfig) => !isNullOrUndefined(formatterConfig))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter locale ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterLocale(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) => this.getValue(formatterConfig.locale))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter seperator ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterSeperator(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) =>
|
|
this.getOptionalValue(formatterConfig.seperator)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter type ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterType(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) => this.getValue(formatterConfig.type))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter currency label ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterCurrencyLabel(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) =>
|
|
isNullOrUndefined(formatterConfig.currencyLable)
|
|
? of('')
|
|
: this.getResourceValue(formatterConfig.currencyLable)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter string formatter ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterStringFormatter(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) =>
|
|
this.getArrayValue(formatterConfig.stringFormatter)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control formatter string formatter ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getFormatterInputType(control: XFormControlConfig) {
|
|
return this.getControlFormatterConfig(control).pipe(
|
|
concatMap((formatterConfig) =>
|
|
isNullOrUndefined(formatterConfig.inputType)
|
|
? of(XStringInputFormatType.None)
|
|
: this.getValue(formatterConfig.inputType)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Progressbar ...
|
|
/**
|
|
* retrieve a control progress bar config descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlProgressBarConfig(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.progressBar
|
|
: null
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control has progress bar object descriptor or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasProgressBar(control: XFormControlConfig) {
|
|
return this.getControlProgressBarConfig(control).pipe(
|
|
map((progressBarConfig) => !isNullOrUndefined(progressBarConfig))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control progressbar color ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getProgressBarColor(control: XFormControlConfig) {
|
|
return this.getControlProgressBarConfig(control).pipe(
|
|
concatMap((progressBarConfig) => this.getValue(progressBarConfig.color))
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control AutoComplete ...
|
|
/**
|
|
* retrieve an id number for form control auto complete view ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteId(control: XFormControlConfig) {
|
|
return `x-${control.propName.toString()}-auto-complete`;
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete config object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlAutoCompleteConfig(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.autoComplete
|
|
: null
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control has autocomplete or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasAutoComplete(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
map((autoConpleteConfig) => !isNullOrUndefined(autoConpleteConfig))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete opened ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteOpened(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) =>
|
|
this.getOptionalValue(autoCompleteConfig.opened)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete item template ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteItemTemplate(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) =>
|
|
this.getValue(autoCompleteConfig.itemTemplate)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete color ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteColor(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) =>
|
|
this.getOptionalValue(autoCompleteConfig.color).pipe(
|
|
map((color) => (color ? color : XColor.Light))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete onSelect ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteOnSelect(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) =>
|
|
this.getValue(autoCompleteConfig.onSelect)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control autocomplete Items ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteItems(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) => {
|
|
return !isNullOrUndefined(autoCompleteConfig.items) &&
|
|
isFunction(autoCompleteConfig.items)
|
|
? this.getArrayValue(autoCompleteConfig.items())
|
|
: this.getValue([]);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve autocomplete CssClass ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getAutoCompleteCssClass(control: XFormControlConfig) {
|
|
return this.getControlAutoCompleteConfig(control).pipe(
|
|
concatMap((autoCompleteConfig) =>
|
|
this.getArrayValue(autoCompleteConfig.cssClass).pipe(
|
|
map((cssClasses) =>
|
|
cssClasses.concat(
|
|
'x-auto-complete',
|
|
`x-${control.propName.toString()}-auto-complete`
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve control errors classes ...
|
|
*
|
|
* @param control form control config ...
|
|
*/
|
|
getControlErrorsClasses(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
map((type) => {
|
|
return [
|
|
'x-form-control-errors',
|
|
`x-form-${type}-control-errors`,
|
|
`x-form-control-${control.index.toString()}-errors`,
|
|
`x-form-control-${control.propName.toString()}-errors`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve special control's special error's class list ...
|
|
*
|
|
* @param control form control config ...
|
|
* @param handler form error handler instance ...
|
|
*/
|
|
getControlErrorClasses(
|
|
control: XFormControlConfig,
|
|
handler: XFormErrorHandler
|
|
) {
|
|
return this.getControlType(control).pipe(
|
|
concatMap((type) =>
|
|
this.getErrorHandlerErrorName(handler).pipe(
|
|
map((errorName) => {
|
|
return {
|
|
type,
|
|
errorName,
|
|
};
|
|
})
|
|
)
|
|
),
|
|
map((descriptor) => {
|
|
return [
|
|
'x-form-field-error',
|
|
`x-form-field-${descriptor.type}-error`,
|
|
`x-form-field-${descriptor.errorName}-error`,
|
|
`x-form-field-${control.propName.toString()}-error`,
|
|
`x-form-field-${descriptor.type}-${descriptor.errorName}-error`,
|
|
];
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Appearance ...
|
|
/**
|
|
* retrieve a control appearance ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlAppearance(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig) &&
|
|
!isNullOrUndefined(appearanceConfig.appearance)
|
|
? appearanceConfig.appearance
|
|
: XFormControlAppearance.Fill
|
|
).pipe(map((result) => result as MatFormFieldAppearance))
|
|
)
|
|
);
|
|
}
|
|
getControlAppearanceObject(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig) &&
|
|
!isNullOrUndefined(appearanceConfig.appearance)
|
|
? appearanceConfig.appearance
|
|
: XFormControlAppearance.Fill
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Label Position ...
|
|
/**
|
|
* retrieve a control label position ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlLabelPosition(control: XFormControlConfig) {
|
|
return this.getControlAppearanceDesc(control).pipe(
|
|
concatMap((appearanceConfig) =>
|
|
this.getOptionalValue(
|
|
!isNullOrUndefined(appearanceConfig)
|
|
? appearanceConfig.labelPosition
|
|
: XFormControlLabelPosition.Before
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Error Handlers ...
|
|
/**
|
|
* retrieve a control error handlers descriptor object ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
getControlErrorHandlers(control: XFormControlConfig) {
|
|
return this.getArrayValue(control.errorHandlers);
|
|
}
|
|
|
|
/**
|
|
* determines a control has error handlers descriptors object or not ...
|
|
*
|
|
* @param control form control config object ...
|
|
*/
|
|
controlHasErrorHandlers(control: XFormControlConfig) {
|
|
return this.hasChildValue(this.getControlErrorHandlers(control));
|
|
}
|
|
|
|
controlHasErrors(control: XFormControlConfig) {
|
|
return this.getValue(control).pipe(
|
|
concatMap((ctrl) =>
|
|
this.getValue(this.getControl(ctrl.propName)).pipe(
|
|
map((fControl) => ({ ctrl, fControl }))
|
|
)
|
|
),
|
|
map((ctrlInfo) => {
|
|
return isNullOrUndefined(ctrlInfo.ctrl) ||
|
|
isNullOrUndefined(ctrlInfo.fControl)
|
|
? false
|
|
: !isNullOrUndefined(ctrlInfo.fControl.errors);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* determines a control has specific error or not ...
|
|
*
|
|
* @param controlName control name ...
|
|
* @param errorName error name ...
|
|
*/
|
|
controlHasErrorByName(
|
|
controlName: XFormControlNameIdentifier,
|
|
errorName: string
|
|
) {
|
|
//
|
|
const control = this.getControl(controlName);
|
|
if (!control) {
|
|
return false;
|
|
}
|
|
|
|
//
|
|
const result =
|
|
!isNullOrUndefined(control.errors) &&
|
|
keys(control.errors).includes(errorName) &&
|
|
!isNullOrUndefined(control.errors[errorName]);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* determine a control has specific error or not ...
|
|
*
|
|
* @param control form control config ...
|
|
* @param handler form error handler instance ...
|
|
*/
|
|
controlHasError(control: XFormControlConfig, handler: XFormErrorHandler) {
|
|
return this.getErrorHandlerErrorName(handler).pipe(
|
|
map((errorName) => {
|
|
return this.controlHasErrorByName(control.propName, errorName);
|
|
})
|
|
);
|
|
}
|
|
|
|
controlGetError(control: XFormControlConfig, handler: XFormErrorHandler) {
|
|
return this.getErrorHandlerErrorName(handler).pipe(
|
|
map((errorName) => {
|
|
return this.controlHasErrorByName(control.propName, errorName);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve specific error of a control ...
|
|
*
|
|
* @param controlName control name ...
|
|
* @param errorName error name ...
|
|
*/
|
|
getControlErrorByName(
|
|
controlName: XFormControlNameIdentifier,
|
|
errorName: string
|
|
) {
|
|
//
|
|
const control = this.getControl(controlName);
|
|
if (!this.controlHasErrorByName(controlName, errorName)) {
|
|
return false;
|
|
}
|
|
|
|
//
|
|
return control.errors[errorName] || null;
|
|
}
|
|
|
|
/**
|
|
* retrieve specific error of a control ...
|
|
*
|
|
* @param control form control config ...
|
|
* @param handler form error handler instance ...
|
|
*/
|
|
getControlError(control: XFormControlConfig, handler: XFormErrorHandler) {
|
|
return this.getErrorHandlerErrorName(handler).pipe(
|
|
map((errorName) => {
|
|
if (!isNullOrUndefined(control)) {
|
|
return this.getControlErrorByName(control.propName, errorName);
|
|
} else {
|
|
return this.getFormErrorByName(errorName);
|
|
}
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Error Handler Providers ...
|
|
/**
|
|
* retrieve an error handler error name ...
|
|
*
|
|
* @param errorHandler an error handler descriptor object ...
|
|
*/
|
|
getErrorHandlerErrorName(errorHandler: XFormErrorHandler) {
|
|
return this.getValue(errorHandler.errorName);
|
|
}
|
|
|
|
/**
|
|
* retrieve an error handler error message ...
|
|
*
|
|
* @param errorHandler an error handler descriptor object ...
|
|
*/
|
|
getErrorHandlerErrorMessage(
|
|
errorHandler: XFormErrorHandler,
|
|
control?: XFormControlConfig
|
|
) {
|
|
//
|
|
if (
|
|
errorHandler.errorDataProvider &&
|
|
isFunction(errorHandler.errorDataProvider)
|
|
) {
|
|
//
|
|
return this.getControlError(control, errorHandler).pipe(
|
|
concatMap((controlError) =>
|
|
this.getResourceValue(errorHandler.errorDataProvider(controlError))
|
|
)
|
|
);
|
|
} else {
|
|
return this.getResourceValue(errorHandler.errorMessage);
|
|
}
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region UI Handlers ...
|
|
//
|
|
//#region Common Controls UI Handlers ...
|
|
async handleControlBlured(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM_CONFIG || !this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(name));
|
|
if (!control) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const eventModel: XBaseFormControlActionModel = {
|
|
name: control.propName,
|
|
};
|
|
|
|
//
|
|
this.controlBlured.emit(eventModel);
|
|
|
|
//
|
|
const eventHandlers = await this.getValueAsync(
|
|
this.getControlEventHandlers(control)
|
|
);
|
|
if (!eventHandlers || !eventHandlers.onBlured) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(eventHandlers.onBlured(eventModel));
|
|
}
|
|
|
|
async handleControlFocused(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM_CONFIG || !this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(name));
|
|
if (!control) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const inputId = await this.getValueAsync(
|
|
this.getControlInputElementId(control)
|
|
);
|
|
this.currentInputFocus = inputId;
|
|
|
|
//
|
|
const eventModel: XBaseFormControlActionModel = {
|
|
name: control.propName,
|
|
};
|
|
|
|
//
|
|
this.controlFocused.emit(eventModel);
|
|
|
|
//
|
|
const eventHandlers = await this.getValueAsync(
|
|
this.getControlEventHandlers(control)
|
|
);
|
|
if (!eventHandlers || !eventHandlers.onFocused) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(eventHandlers.onFocused(eventModel));
|
|
}
|
|
|
|
async handleControlValueChanged(event: XFormControlValueChangeEventModel) {
|
|
//
|
|
if (
|
|
!this.FORM ||
|
|
this.uiDisabled ||
|
|
!this.FORM_CONFIG ||
|
|
!this.hasControl(event.name)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(event.name));
|
|
if (control) {
|
|
//
|
|
const isDisabled = await this.getValueAsync(
|
|
this.getControlDisabled(control)
|
|
);
|
|
if (isDisabled) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
//
|
|
this.controlValueChanged.emit(event);
|
|
}
|
|
|
|
async handleControlStatusChanged(event: XFormControlStatusChangeEventModel) {
|
|
//
|
|
if (
|
|
!this.FORM ||
|
|
this.uiDisabled ||
|
|
!this.FORM_CONFIG ||
|
|
!this.hasControl(event.name)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(event.name));
|
|
if (control) {
|
|
//
|
|
const isDisabled = await this.getValueAsync(
|
|
this.getControlDisabled(control)
|
|
);
|
|
if (isDisabled) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
//
|
|
this.controlStatusChanged.emit(event);
|
|
}
|
|
|
|
async handleControlIconClicked(icon: XFormIconDescriptor) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG || !icon.handler) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(icon.handler());
|
|
}
|
|
|
|
async handleControlActionIconClicked(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor,
|
|
control: XFormControlConfig
|
|
) {
|
|
//
|
|
const type = await this.getValueAsync(this.getControlType(control));
|
|
|
|
//
|
|
switch (type) {
|
|
//
|
|
case XFormControlType.Map:
|
|
//
|
|
await this.handleMapIconClicked(role, descriptor, control);
|
|
break;
|
|
|
|
//
|
|
case XFormControlType.Selector:
|
|
await this.handleItemSelectorIconClicked(role, descriptor, control);
|
|
break;
|
|
|
|
//
|
|
case XFormControlType.ColorPicker:
|
|
//
|
|
await this.handleColorPickerIconClicked(role, descriptor, control);
|
|
break;
|
|
|
|
//
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region DatePicker UI Handlers ...
|
|
async handleDatePickerDateInput(
|
|
name: XFormControlNameIdentifier,
|
|
event: MatDatepickerInputEvent<any>
|
|
) {
|
|
//
|
|
let result: Date = null;
|
|
const isDateInput = isDate(event.value);
|
|
const isMomentInput = isMoment(event.value);
|
|
if (isMomentInput) {
|
|
result = momentToDate(event.value);
|
|
} else if (isDateInput) {
|
|
result = event.value as Date;
|
|
}
|
|
|
|
//
|
|
await this.setValue(name, result);
|
|
|
|
//
|
|
if (!this.FORM_CONFIG || !this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(name));
|
|
if (!control) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const handler = await this.getValueAsync(this.getDateInputHandler(control));
|
|
if (!handler) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Fire Hanlder ...
|
|
await this.getValueAsync(handler(result));
|
|
}
|
|
|
|
async handleDatePickerDateChange(
|
|
name: XFormControlNameIdentifier,
|
|
event: MatDatepickerInputEvent<any>
|
|
) {
|
|
//
|
|
let result: Date = null;
|
|
const isDateInput = isDate(event.value);
|
|
const isMomentInput = isMoment(event.value);
|
|
if (isMomentInput) {
|
|
result = momentToDate(event.value);
|
|
} else if (isDateInput) {
|
|
result = event.value as Date;
|
|
}
|
|
|
|
//
|
|
await this.setValue(name, result);
|
|
|
|
//
|
|
if (!this.FORM_CONFIG || !this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = await this.getValueAsync(this.getFormControl(name));
|
|
if (!control) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const handler = await this.getValueAsync(
|
|
this.getDateChangeHandler(control)
|
|
);
|
|
if (!handler) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Fire Hanlder ...
|
|
await this.getValueAsync(handler(result));
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Auto Complete Controls UI Handlers ...
|
|
async handleAutoCompleteResultSelected(
|
|
control: XFormControlConfig,
|
|
autoComplete: XFormControlAutoCompleteConfig,
|
|
event: any
|
|
) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG || !this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const formCtrl = this.getControl(control.propName);
|
|
if (!formCtrl) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
formCtrl.setValue(event.data);
|
|
const formInputControl = this.getElementById(
|
|
this.getControlInputElementId(control)
|
|
);
|
|
if (formInputControl) {
|
|
(formInputControl as HTMLInputElement).select();
|
|
}
|
|
|
|
//
|
|
if (autoComplete.onSelect && isFunction(autoComplete.onSelect)) {
|
|
await this.getValueAsync(autoComplete.onSelect(event));
|
|
}
|
|
|
|
//
|
|
this.focusOnControl(control.propName);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
async handleAutoCompleteEscaped(control: XFormControlConfig) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG || !this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const autoComplete = await this.getValueAsync(
|
|
this.getControlAutoCompleteConfig(control)
|
|
);
|
|
if (
|
|
autoComplete &&
|
|
autoComplete.onEscape &&
|
|
isFunction(autoComplete.onEscape)
|
|
) {
|
|
await this.getValueAsync(autoComplete.onEscape());
|
|
}
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
async handleAutoCompleteOutsideClicked(control: XFormControlConfig) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG || !this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const autoComplete = await this.getValueAsync(
|
|
this.getControlAutoCompleteConfig(control)
|
|
);
|
|
if (
|
|
autoComplete &&
|
|
autoComplete.onOutsideClicked &&
|
|
isFunction(autoComplete.onOutsideClicked)
|
|
) {
|
|
await this.getValueAsync(autoComplete.onOutsideClicked());
|
|
}
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Markdown Control UI Handlers ...
|
|
async handleMarkDownContentChanged(
|
|
name: XFormControlNameIdentifier,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.setValue(name, event);
|
|
|
|
//
|
|
const controlConfig = await this.getValueAsync(this.getFormControl(name));
|
|
if (!controlConfig) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const markDownConfig = await this.getValueAsync(
|
|
this.getMarkdownConfig(controlConfig)
|
|
);
|
|
if (!markDownConfig || !markDownConfig.contentChanged) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(markDownConfig.contentChanged(event));
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Checkbox Control UI Handlers ...
|
|
async handleCheckboxCheckedChange(
|
|
control: XFormControlConfig,
|
|
checked: boolean
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getCheckboxConfig(control));
|
|
if (!config || !config.checkedChanged) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.checkedChanged(checked));
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Map UI Handlers ...
|
|
async handleMapIsReady(control: XFormControlConfig) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getMapConfig(control));
|
|
if (!config || !config.isReady) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
config.isReady.emit();
|
|
}
|
|
|
|
async handleMapZoomChanged(control: XFormControlConfig, zoom: number) {
|
|
}
|
|
|
|
async handleMapLocationSelected(
|
|
control: XFormControlConfig,
|
|
event: XMapLocation
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const longLat = event ? toLongLat(event) : null;
|
|
await this.setValue(control.propName, longLat);
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getMapConfig(control));
|
|
if (!config || !config.locationSelected) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
config.locationSelected.emit(event);
|
|
}
|
|
|
|
async handleMapIconClicked(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor,
|
|
control: XFormControlConfig
|
|
) {
|
|
//
|
|
const presentType = await this.getValueAsync(
|
|
this.getMapPresentType(control)
|
|
);
|
|
|
|
//
|
|
switch (role) {
|
|
//
|
|
case this.ControlIconRoles.Clear:
|
|
await this.managerService.dialogService.presentAreYouSureYesNoDialog(
|
|
async () => {
|
|
//
|
|
await this.setValue(control.propName, undefined);
|
|
|
|
//
|
|
const mapControlActionPtovider = await this.getValueAsync(
|
|
this.getMapActionProvider(control)
|
|
);
|
|
if (
|
|
mapControlActionPtovider &&
|
|
presentType === XFormMapControlPresentType.WithoutDialog
|
|
) {
|
|
//
|
|
// Clear Marker ...
|
|
mapControlActionPtovider.next({
|
|
action: XMapAction.ClearMarker,
|
|
});
|
|
}
|
|
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
}
|
|
);
|
|
break;
|
|
|
|
//
|
|
case this.ControlIconRoles.Select:
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
|
|
//
|
|
let center: XMapLocation = null;
|
|
const longLatControl = this.getControl(control.propName);
|
|
if (longLatControl) {
|
|
//
|
|
const longLat = longLatControl.value as string;
|
|
if (!isNullOrEmptyString(longLat)) {
|
|
center = fromLongLat(longLat);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Prevent go forward if map control present type does't support map dialog ...
|
|
if (presentType === XFormMapControlPresentType.WithoutDialog) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Prepare Selector Dialog Config ...
|
|
const controlConfig = await this.getValueAsync(
|
|
this.getMapConfig(control)
|
|
);
|
|
const dialogConfig: XMapDialogConfig = {
|
|
...controlConfig,
|
|
//
|
|
latitude: center && center.latitude ? +center.latitude : 0,
|
|
longitude: center && center.longitude ? +center.longitude : 0,
|
|
|
|
//
|
|
showSelectedLocation: true,
|
|
};
|
|
|
|
//
|
|
// Open Dialog ...
|
|
await this.mapDialogService.openDialog(dialogConfig);
|
|
|
|
//
|
|
// Wait for Handle Dialog Result ...
|
|
const s = this.mapDialogService.onResult
|
|
.asObservable()
|
|
.subscribe(async (result) => {
|
|
//
|
|
let value: any;
|
|
|
|
//
|
|
if (
|
|
!isNullOrUndefined(result) &&
|
|
!isNullOrUndefined(result.payload) &&
|
|
result.result === XDialogResult.Ok
|
|
) {
|
|
value = toLongLat(result.payload);
|
|
}
|
|
|
|
//
|
|
if (!isNullOrUndefined(value)) {
|
|
await this.setValue(control.propName, value);
|
|
}
|
|
|
|
//
|
|
s.unsubscribe();
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
async handleMapControlInputValueChanged(
|
|
control: XFormControlConfig,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getMapConfig(control));
|
|
if (
|
|
!config ||
|
|
!config.inputValueChanged ||
|
|
!isFunction(config.inputValueChanged)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.inputValueChanged(event));
|
|
}
|
|
|
|
async handleMapSearchBarQueryChange(
|
|
control: XFormControlConfig,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getMapConfig(control));
|
|
if (!config || !config.searchBarQueryChange) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
config.searchBarQueryChange.emit(event);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region ColorPicker UI Handlers ...
|
|
async handleColorPickerIconClicked(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor,
|
|
control: XFormControlConfig
|
|
) {
|
|
//
|
|
switch (role) {
|
|
//
|
|
case this.ControlIconRoles.Clear:
|
|
await this.managerService.dialogService.presentAreYouSureYesNoDialog(
|
|
async () => {
|
|
//
|
|
await this.setValue(control.propName, undefined);
|
|
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
}
|
|
);
|
|
break;
|
|
|
|
//
|
|
case this.ControlIconRoles.Select:
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
|
|
//
|
|
const presentType = await this.getValueAsync(
|
|
this.getColorPickerPresentType(control)
|
|
);
|
|
|
|
//
|
|
// Prevent go forward if color picker control present type does't support map dialog ...
|
|
if (presentType === XFormColorPickerControlPresentType.WithoutDialog) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
let selectedColor: string = null;
|
|
const colorPickerControl = this.getControl(control.propName);
|
|
if (colorPickerControl) {
|
|
//
|
|
const colorVal = colorPickerControl.value as string;
|
|
if (!isNullOrEmptyString(colorVal)) {
|
|
selectedColor = colorVal;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Prepare Selector Dialog Config ...
|
|
const controlConfig = await this.getValueAsync(
|
|
this.getColorPickerConfig(control)
|
|
);
|
|
const dialogConfig: XColorPickerDialogConfig = {
|
|
...controlConfig,
|
|
|
|
//
|
|
selectedColor,
|
|
};
|
|
|
|
//
|
|
// Open Dialog ...
|
|
await this.colorPickerDialogService.openDialog(dialogConfig);
|
|
|
|
//
|
|
// Wait for Handle Dialog Result ...
|
|
const s = this.colorPickerDialogService.onResult
|
|
.asObservable()
|
|
.subscribe(async (result) => {
|
|
//
|
|
let value: any;
|
|
|
|
//
|
|
if (
|
|
!isNullOrUndefined(result) &&
|
|
!isNullOrUndefined(result.payload) &&
|
|
result.result === XDialogResult.Ok
|
|
) {
|
|
value = result.payload;
|
|
}
|
|
|
|
//
|
|
if (!isNullOrUndefined(value)) {
|
|
await this.setValue(control.propName, value);
|
|
}
|
|
|
|
//
|
|
s.unsubscribe();
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
async handleColorPickerControlInputValueChanged(
|
|
control: XFormControlConfig,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getColorPickerConfig(control));
|
|
if (
|
|
!config ||
|
|
!config.inputValueChanged ||
|
|
!isFunction(config.inputValueChanged)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.inputValueChanged(event));
|
|
}
|
|
|
|
async handleColorPickerColorSelected(
|
|
control: XFormControlConfig,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.setValue(control.propName, event);
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getColorPickerConfig(control));
|
|
if (!config || !config.colorSelected) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
config.colorSelected.emit(event);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Avatar UI Handlers ...
|
|
async handleAvatarFileDropAreaFilesChangeEmitter(
|
|
control: XFormControlConfig,
|
|
event?: XOneOrManyType<File>
|
|
) {
|
|
//
|
|
if (!event || !this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getAvatarConfig(control));
|
|
if (
|
|
!config ||
|
|
!config.fileDropAreaFilesChangeEmiter ||
|
|
!isFunction(config.fileDropAreaFilesChangeEmiter)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.fileDropAreaFilesChangeEmiter(event));
|
|
}
|
|
|
|
async handleAvatarAvatarChange(control: XFormControlConfig, event?: File) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.setValue(control.propName, event);
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getAvatarConfig(control));
|
|
if (!config || !config.avatarChange || !isFunction(config.avatarChange)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.avatarChange(event));
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Selector UI Handlers ...
|
|
async handleItemSelectorIconClicked(
|
|
role: XControlIconRoleIdentifier,
|
|
descriptor: XControlIconDescriptor,
|
|
control: XFormControlConfig
|
|
) {
|
|
//
|
|
switch (role) {
|
|
//
|
|
case this.ControlIconRoles.Clear:
|
|
await this.managerService.dialogService.presentAreYouSureYesNoDialog(
|
|
async () => {
|
|
//
|
|
await this.setValue(control.propName, undefined);
|
|
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
}
|
|
);
|
|
break;
|
|
|
|
//
|
|
case this.ControlIconRoles.Select:
|
|
//
|
|
// Notify Handler ...
|
|
if (
|
|
!isNullOrUndefined(descriptor) &&
|
|
!isNullOrUndefined(descriptor.handler) &&
|
|
isFunction(descriptor.handler)
|
|
) {
|
|
await this.getValueAsync(descriptor.handler());
|
|
}
|
|
|
|
//
|
|
// Prepare Selector Dialog Config ...
|
|
const controlConfig = await this.getValueAsync(
|
|
this.getSelectorConfig(control)
|
|
);
|
|
const dialogConfig: XFormSelectorControlConfig = {
|
|
...controlConfig,
|
|
};
|
|
|
|
//
|
|
// Open Dialog ...
|
|
await this.selectorDialogService.openDialog(dialogConfig);
|
|
|
|
//
|
|
// Wait for Handle Dialog Result ...
|
|
const s = this.selectorDialogService.onResult
|
|
.asObservable()
|
|
.subscribe(async (result) => {
|
|
//
|
|
let content: any;
|
|
|
|
//
|
|
if (
|
|
!isNullOrUndefined(result) &&
|
|
!isNullOrUndefined(result.payload) &&
|
|
result.result === XDialogResult.Ok
|
|
) {
|
|
content = result.payload;
|
|
}
|
|
|
|
//
|
|
if (!isNullOrUndefined(content)) {
|
|
//
|
|
const value =
|
|
!controlConfig ||
|
|
!controlConfig.formatSelectedItem ||
|
|
!isFunction(controlConfig.formatSelectedItem)
|
|
? content
|
|
: await this.getValueAsync(
|
|
controlConfig.formatSelectedItem(content)
|
|
);
|
|
|
|
//
|
|
await this.setValue(control.propName, value);
|
|
}
|
|
|
|
//
|
|
s.unsubscribe();
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
async handleSelectorControlInputValueChanged(
|
|
control: XFormControlConfig,
|
|
event: string
|
|
) {
|
|
//
|
|
if (!this.hasControl(control.propName)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const config = await this.getValueAsync(this.getSelectorConfig(control));
|
|
if (
|
|
!config ||
|
|
!config.inputValueChanged ||
|
|
!isFunction(config.inputValueChanged)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
await this.getValueAsync(config.inputValueChanged(event));
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Actions ...
|
|
/**
|
|
* determine a control exists or not ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
hasControl(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return false;
|
|
}
|
|
|
|
//
|
|
const controlName = this.getControlName(name);
|
|
if (!controlName) {
|
|
return false;
|
|
}
|
|
|
|
//
|
|
return (
|
|
this.FORM.contains(controlName) ||
|
|
!isNullOrUndefined(this.FORM.controls[controlName])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* retrieve a control based on it's name ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
getControl(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.hasControl(name)) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
const controlName = this.getControlName(name);
|
|
if (!controlName) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
return this.FORM.get(controlName) || null;
|
|
}
|
|
|
|
/**
|
|
* retrieve a form control status if exists in form ...
|
|
*
|
|
* @param control a form control config ...
|
|
*/
|
|
getControlStatus(control: XFormControlConfig) {
|
|
//
|
|
const mControl = this.getControl(control.propName);
|
|
if (!mControl) {
|
|
return XFormStatus.UnKnown;
|
|
}
|
|
|
|
//
|
|
return mControl.status as XFormStatus;
|
|
}
|
|
|
|
/**
|
|
* focus on a control ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
focusOnControl(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const inputElement = this.getElementById(
|
|
this.getControlInputElementIdByName(name)
|
|
);
|
|
if (!inputElement) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
setTimeout(() => inputElement.focus(), 100);
|
|
}
|
|
|
|
/**
|
|
* blur from a control ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
blurOfControl(name: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.hasControl(name)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const inputElement = this.getElementById(
|
|
this.getControlInputElementIdByName(name)
|
|
);
|
|
if (!inputElement) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
setTimeout(() => inputElement.blur(), 100);
|
|
}
|
|
|
|
/**
|
|
* determines specific control has value or not ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
controlHasValue(name: XFormControlNameIdentifier) {
|
|
return !this.hasControl(name)
|
|
? false
|
|
: this.getControl(name).value &&
|
|
!isNullOrEmptyString(this.getControl(name).value.toString());
|
|
}
|
|
|
|
/**
|
|
* retrieve an specific control value ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
getControlValue(name: XFormControlNameIdentifier) {
|
|
return !this.hasControl(name) ? undefined : this.getControl(name).value;
|
|
}
|
|
|
|
/**
|
|
* determines a control has error by it's name ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
controlHasErrorByControlName(name: XFormControlNameIdentifier) {
|
|
return !this.hasControl(name)
|
|
? false
|
|
: !isNullOrUndefined(this.getControl(name).errors);
|
|
}
|
|
|
|
/**
|
|
* set a value to an specific control or form ...
|
|
*
|
|
* @param name a control name ...
|
|
* @param value a value of any type ...
|
|
*/
|
|
async setValue(name?: XFormControlNameIdentifier, value?: any) {
|
|
//
|
|
if (!name) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (name) {
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.setValue(value);
|
|
} else {
|
|
this.FORM.setValue(value, { emitEvent: true });
|
|
}
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger markAsDirty on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async markAsDirty(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG || this.uiDisabled) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.markAsDirty();
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.markAsDirty();
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger markAsTouched on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async markAsTouched(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.markAsTouched();
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.markAsTouched();
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger markAsPending on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async markAsPending(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.markAsPending();
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.markAsPending();
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger markAsPristine on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async markAsPristine(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.markAsPristine();
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.markAsPristine();
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger markAsUntouched on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async markAsUnTouched(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.markAsUntouched();
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.markAsUntouched();
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger updateValueAndValidity on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async updateValueAndValidity(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.updateValueAndValidity({ emitEvent: true });
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.updateValueAndValidity({ emitEvent: true });
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* trigger setError on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param errors: an instance of ValidationErrors object ...
|
|
* @param name a control name ...
|
|
*/
|
|
async setError(errors: ValidationErrors, name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.setErrors(errors, { emitEvent: true });
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.setErrors(errors, { emitEvent: true });
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* clearErrors on form or specific control ...
|
|
* if provide a control name and it's exists ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async clearError(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.setErrors(null, { emitEvent: true });
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.setErrors(null, { emitEvent: true });
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* enable form or form control ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async enable(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.enable({ emitEvent: true });
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.enable({ emitEvent: true });
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* disable form or form control ...
|
|
*
|
|
* @param name a control name ...
|
|
*/
|
|
async disable(name?: XFormControlNameIdentifier) {
|
|
//
|
|
if (!this.FORM || !this.FORM_CONFIG) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const control = this.getControl(name);
|
|
if (!control) {
|
|
//
|
|
this.FORM.disable({ emitEvent: true });
|
|
this.detectChanges();
|
|
return;
|
|
}
|
|
|
|
//
|
|
control.disable({ emitEvent: true });
|
|
this.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* remove all data and form elements ...
|
|
*/
|
|
async clearData() {
|
|
//
|
|
// this.formConfig = null;
|
|
this.FORM_CONFIG = null;
|
|
this.FORM = null;
|
|
|
|
//
|
|
this.detectChanges();
|
|
|
|
//
|
|
await this.prepareFormGroup();
|
|
}
|
|
|
|
/**
|
|
* refresh component ...
|
|
*/
|
|
async refresh() {
|
|
this.detectChanges();
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Private ...
|
|
//
|
|
//#region Prepare Form Group ...
|
|
private async prepareFormGroup() {
|
|
//
|
|
//#region Form Config ...
|
|
//
|
|
this.currentInputFocus = undefined;
|
|
const modelFormConfig = await this.getValueAsync(this.formConfig);
|
|
if (!modelFormConfig) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const formConfig = {
|
|
name: await this.getValueAsync(this.getFormName()),
|
|
model: (await this.getValueAsync(this.formHasModel()))
|
|
? await this.getValueAsync(this.getFormModel())
|
|
: undefined,
|
|
updateOn: await this.getValueAsync(this.getFormUpdateOn()),
|
|
controls: await Promise.all(
|
|
(
|
|
await this.getValueAsync(this.getFormControls())
|
|
).map(async (c) => {
|
|
//
|
|
//#region Action Provider ...
|
|
let actionProvider = c.actionProvider ? c.actionProvider : undefined;
|
|
|
|
//
|
|
if (!actionProvider) {
|
|
//
|
|
if (!this.actionProviders[c.propName]) {
|
|
this.actionProviders[c.propName] = new Subject<any>();
|
|
}
|
|
|
|
//
|
|
actionProvider = this.actionProviders[c.propName];
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control ...
|
|
return {
|
|
index: c.index,
|
|
propName: c.propName,
|
|
type: {
|
|
type: await this.getValueAsync(this.getControlType(c)),
|
|
config: await this.getValueAsync(this.getControlTypeConfig(c)),
|
|
},
|
|
updateOn: await this.getValueAsync(this.getControlUpdateOn(c)),
|
|
validators: (await this.getValueAsync(this.controlHasValidators(c)))
|
|
? await this.getValueAsync(this.getControlValidators(c))
|
|
: undefined,
|
|
actionProvider,
|
|
eventHandlers: (await this.getValueAsync(
|
|
this.controlHasEventHandlers(c)
|
|
))
|
|
? await this.getValueAsync(this.getControlEventHandlers(c))
|
|
: undefined,
|
|
appearance: {
|
|
hidden: await this.getValueAsync(this.getControlHidden(c)),
|
|
disabled: await this.getValueAsync(this.getControlDisabled(c)),
|
|
hint: await this.getValueAsync(this.getControlHint(c)),
|
|
label: await this.getValueAsync(this.getControlLabel(c)),
|
|
tooltip: await this.getValueAsync(this.getControlTooltip(c)),
|
|
placeholder: await this.getValueAsync(
|
|
this.getControlPlaceHolder(c)
|
|
),
|
|
cssClass: await this.getValueAsync(this.getControlCssClass(c)),
|
|
icons: (await this.getValueAsync(this.controlHasIcons(c)))
|
|
? {
|
|
suffix: (await this.getValueAsync(
|
|
this.controlHasSuffixIcon(c)
|
|
))
|
|
? {
|
|
name: await this.getValueAsync(
|
|
this.getControlIconName(
|
|
await this.getValueAsync(
|
|
this.getControlSuffixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
color: await this.getValueAsync(
|
|
this.getControlIconColor(
|
|
await this.getValueAsync(
|
|
this.getControlSuffixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
applyStateColor: await this.getValueAsync(
|
|
this.getControlIconApplyStateColor(
|
|
await this.getValueAsync(
|
|
this.getControlSuffixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
handler: (
|
|
await this.getValueAsync(
|
|
this.getControlSuffixIcon(c)
|
|
)
|
|
).handler,
|
|
}
|
|
: undefined,
|
|
prefix: (await this.getValueAsync(
|
|
this.controlHasPrefixIcon(c)
|
|
))
|
|
? {
|
|
name: await this.getValueAsync(
|
|
this.getControlIconName(
|
|
await this.getValueAsync(
|
|
this.getControlPrefixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
color: await this.getValueAsync(
|
|
this.getControlIconColor(
|
|
await this.getValueAsync(
|
|
this.getControlPrefixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
applyStateColor: await this.getValueAsync(
|
|
this.getControlIconApplyStateColor(
|
|
await this.getValueAsync(
|
|
this.getControlPrefixIcon(c)
|
|
)
|
|
)
|
|
),
|
|
handler: (
|
|
await this.getValueAsync(
|
|
this.getControlPrefixIcon(c)
|
|
)
|
|
).handler,
|
|
}
|
|
: undefined,
|
|
}
|
|
: undefined,
|
|
formatter: (await this.getValueAsync(this.controlHasFormatter(c)))
|
|
? {
|
|
locale: await this.getValueAsync(
|
|
this.getFormatterLocale(c)
|
|
),
|
|
seperator: await this.getValueAsync(
|
|
this.getFormatterSeperator(c)
|
|
),
|
|
type: await this.getValueAsync(this.getFormatterType(c)),
|
|
currencyLable: await this.getValueAsync(
|
|
this.getFormatterCurrencyLabel(c)
|
|
),
|
|
inputType: await this.getValueAsync(
|
|
this.getFormatterInputType(c)
|
|
),
|
|
stringFormatter: await this.getValueAsync(
|
|
this.getFormatterStringFormatter(c)
|
|
),
|
|
}
|
|
: undefined,
|
|
progressBar: (await this.getValueAsync(
|
|
this.controlHasProgressBar(c)
|
|
))
|
|
? {
|
|
color: await this.getValueAsync(
|
|
this.getProgressBarColor(c)
|
|
),
|
|
}
|
|
: undefined,
|
|
autoComplete: (await this.getValueAsync(
|
|
this.controlHasAutoComplete(c)
|
|
))
|
|
? {
|
|
itemTemplate: await this.getValueAsync(
|
|
this.getAutoCompleteItemTemplate(c)
|
|
),
|
|
opened: await this.getValueAsync(
|
|
this.getAutoCompleteOpened(c)
|
|
),
|
|
color: await this.getValueAsync(
|
|
this.getAutoCompleteColor(c)
|
|
),
|
|
onSelect: await this.getValueAsync(
|
|
this.getAutoCompleteOnSelect(c)
|
|
),
|
|
items: await this.getValueAsync(
|
|
this.getAutoCompleteItems(c)
|
|
),
|
|
cssClass: await this.getValueAsync(
|
|
this.getAutoCompleteCssClass(c)
|
|
),
|
|
}
|
|
: undefined,
|
|
appearance: await this.getValueAsync(
|
|
this.getControlAppearance(c)
|
|
),
|
|
labelPosition: await this.getValueAsync(
|
|
this.getControlLabelPosition(c)
|
|
),
|
|
},
|
|
errorHandlers: (await this.getValueAsync(
|
|
this.controlHasErrorHandlers(c)
|
|
))
|
|
? await Promise.all(
|
|
(
|
|
await this.getValueAsync(this.getControlErrorHandlers(c))
|
|
).map(async (e) => {
|
|
return {
|
|
errorName: await this.getValueAsync(e.errorName),
|
|
errorMessage: await this.getResourceValueAsync(
|
|
e.errorMessage
|
|
),
|
|
};
|
|
})
|
|
)
|
|
: undefined,
|
|
};
|
|
//#endregion
|
|
})
|
|
),
|
|
validators: (await this.getValueAsync(this.formHasValidators()))
|
|
? await this.getValueAsync(this.getFormValidators())
|
|
: undefined,
|
|
errorHandlers: (await this.getValueAsync(this.formHasErrorHandlers()))
|
|
? await Promise.all(
|
|
(
|
|
await this.getValueAsync(this.getFormErrorHandlers())
|
|
).map(async (e) => {
|
|
return {
|
|
errorName: await this.getValueAsync(e.errorName),
|
|
errorMessage: await this.getResourceValueAsync(e.errorMessage),
|
|
};
|
|
})
|
|
)
|
|
: undefined,
|
|
};
|
|
|
|
//
|
|
if (!this.FORM_CONFIG) {
|
|
this.FORM_CONFIG = formConfig;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Preparing Form Controls ...
|
|
const controls = assign(
|
|
{},
|
|
...formConfig.controls
|
|
.map((c) => {
|
|
//
|
|
const initialValue = {
|
|
value:
|
|
!isNullOrUndefined(formConfig.model) &&
|
|
!isNullOrUndefined(formConfig.model[c.propName.toString()])
|
|
? formConfig.model[c.propName.toString()]
|
|
: null,
|
|
disabled:
|
|
this.uiDisabled ||
|
|
(c.appearance && c.appearance.disabled
|
|
? c.appearance.disabled
|
|
: false),
|
|
};
|
|
|
|
//
|
|
const formControl = new FormControl(initialValue, {
|
|
updateOn: c.updateOn.toString() as 'change' | 'blur' | 'submit',
|
|
validators: c.validators ? c.validators.validators : null,
|
|
asyncValidators: c.validators ? c.validators.asyncValidators : null,
|
|
});
|
|
|
|
//
|
|
//#region Apply Event Handlers ...
|
|
//
|
|
//#region Value Change ...
|
|
formControl.valueChanges.subscribe(async (res) => {
|
|
//
|
|
const eventModel: XFormControlValueChangeEventModel = {
|
|
name: c.propName,
|
|
value: res,
|
|
};
|
|
|
|
//
|
|
if (
|
|
c.eventHandlers &&
|
|
c.eventHandlers.valueChanged &&
|
|
isFunction(c.eventHandlers.valueChanged)
|
|
) {
|
|
c.eventHandlers.valueChanged(eventModel);
|
|
}
|
|
|
|
//
|
|
await this.handleControlValueChanged(eventModel);
|
|
|
|
//
|
|
//#region Handle Map Control Input Value Change Action ...
|
|
const controlConfig = await this.getValueAsync(
|
|
this.getFormControl(c.propName)
|
|
);
|
|
if (controlConfig) {
|
|
//
|
|
const type = await this.getValueAsync(
|
|
this.getControlType(controlConfig)
|
|
);
|
|
|
|
//
|
|
if (type === XFormControlType.Map) {
|
|
await this.handleMapControlInputValueChanged(
|
|
controlConfig,
|
|
res
|
|
);
|
|
} else if (type === XFormControlType.ColorPicker) {
|
|
await this.handleColorPickerControlInputValueChanged(
|
|
controlConfig,
|
|
res
|
|
);
|
|
} else if (type === XFormControlType.Selector) {
|
|
await this.handleSelectorControlInputValueChanged(
|
|
controlConfig,
|
|
res
|
|
);
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
this.detectChanges();
|
|
});
|
|
|
|
//
|
|
// Notify Initial Value ...
|
|
if (
|
|
!isNullOrUndefined(initialValue) &&
|
|
!isNullOrUndefined(initialValue.value)
|
|
) {
|
|
//
|
|
const eventModel: XFormControlValueChangeEventModel = {
|
|
name: c.propName,
|
|
value: initialValue.value,
|
|
};
|
|
|
|
//
|
|
if (
|
|
c.eventHandlers &&
|
|
c.eventHandlers.valueChanged &&
|
|
isFunction(c.eventHandlers.valueChanged)
|
|
) {
|
|
c.eventHandlers.valueChanged(eventModel);
|
|
}
|
|
|
|
//
|
|
this.controlValueChanged.emit(eventModel);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Status Change ...
|
|
formControl.statusChanges.subscribe(async (res) => {
|
|
//
|
|
const eventModel: XFormControlStatusChangeEventModel = {
|
|
name: c.propName,
|
|
status: res,
|
|
};
|
|
|
|
//
|
|
if (
|
|
c.eventHandlers &&
|
|
c.eventHandlers.statusChanged &&
|
|
isFunction(c.eventHandlers.statusChanged)
|
|
) {
|
|
c.eventHandlers.statusChanged(eventModel);
|
|
}
|
|
|
|
//
|
|
await this.handleControlStatusChanged(eventModel);
|
|
|
|
//
|
|
this.detectChanges();
|
|
});
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Apply Action Provider ...
|
|
if (c.actionProvider) {
|
|
//
|
|
c.actionProvider.asObservable().subscribe(async (model) => {
|
|
//
|
|
if (
|
|
!model ||
|
|
!model.name ||
|
|
isNullOrEmptyString(model.name.toString()) ||
|
|
!this.hasControl(model.name)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
switch (model.action) {
|
|
//
|
|
case XFormBaseAction.Enable:
|
|
await this.enable(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.Disable:
|
|
await this.disable(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.SetError:
|
|
//
|
|
const errors = model.payload as ValidationErrors;
|
|
if (model.payload && errors) {
|
|
await this.setError(errors, model.name);
|
|
}
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.ClearError:
|
|
await this.clearError(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsDirty:
|
|
await this.markAsDirty(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsTouched:
|
|
await this.markAsTouched(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsPending:
|
|
await this.markAsPending(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsPristine:
|
|
await this.markAsPending(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsUnTouched:
|
|
await this.markAsTouched(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.UpdateValueAndValidity:
|
|
await this.updateValueAndValidity(model.name);
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
return { name: c.propName, control: formControl };
|
|
})
|
|
.map((fc) => {
|
|
return { key: fc.name.toString(), value: fc.control };
|
|
})
|
|
) as { [key: string]: AbstractControl };
|
|
//#endregion
|
|
|
|
//
|
|
//#region Prepare Form Group ...
|
|
if (!this.FORM) {
|
|
//
|
|
this.FORM = new FormGroup(
|
|
controls,
|
|
formConfig.validators
|
|
? {
|
|
updateOn: formConfig.updateOn.toString() as
|
|
| 'change'
|
|
| 'blur'
|
|
| 'submit',
|
|
validators: formConfig.validators.validators || null,
|
|
asyncValidators: formConfig.validators.asyncValidators || null,
|
|
}
|
|
: null
|
|
);
|
|
|
|
//
|
|
// Form Value Changed ...
|
|
this.FORM.valueChanges.subscribe((res) => {
|
|
//
|
|
if (this.uiDisabled) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.valueChanged.emit({
|
|
name: formConfig.name,
|
|
value: res,
|
|
});
|
|
|
|
//
|
|
this.VALUE = res;
|
|
|
|
//
|
|
this.detectChanges();
|
|
});
|
|
|
|
//
|
|
// Form Status Changed ...
|
|
this.FORM.statusChanges.subscribe((res) => {
|
|
//
|
|
if (this.uiDisabled) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.STATUS = res;
|
|
|
|
//
|
|
if (this.FORM.errors) {
|
|
this.ERRORS = this.FORM.errors;
|
|
} else {
|
|
this.ERRORS = null;
|
|
}
|
|
|
|
//
|
|
this.statusChanged.emit({
|
|
name: formConfig.name,
|
|
status: res,
|
|
});
|
|
|
|
//
|
|
this.detectChanges();
|
|
});
|
|
} else {
|
|
//
|
|
entries(controls).forEach((ctrlEtry) => {
|
|
//
|
|
const name = ctrlEtry[0];
|
|
const control = ctrlEtry[1] as AbstractControl;
|
|
|
|
//
|
|
if (this.FORM.contains(name)) {
|
|
this.FORM.setControl(name, control);
|
|
}
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
this.FORM.markAllAsTouched();
|
|
this.FORM.updateValueAndValidity();
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Config Object ...
|
|
//
|
|
private getControlName(name?: XFormControlNameIdentifier) {
|
|
return name ? name.toString() : null;
|
|
}
|
|
|
|
//
|
|
private getCustomControlConfig(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
concatMap((type) => {
|
|
switch (type) {
|
|
//
|
|
case XFormControlType.Map:
|
|
return this.getMapConfig(control);
|
|
|
|
//
|
|
case XFormControlType.Selector:
|
|
return this.getSelectorConfig(control);
|
|
|
|
//
|
|
case XFormControlType.ColorPicker:
|
|
return this.getColorPickerConfig(control);
|
|
|
|
//
|
|
default:
|
|
return of(null);
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
//
|
|
private getControlInfo(control: XFormControlConfig) {
|
|
return this.getControlType(control).pipe(
|
|
concatMap((type) =>
|
|
this.getControlDisabled(control).pipe(
|
|
map((disabled) => ({ type, disabled }))
|
|
)
|
|
),
|
|
concatMap((typeInfo) =>
|
|
this.getControlAppearance(control).pipe(
|
|
map((appearance) => ({ ...typeInfo, appearance }))
|
|
)
|
|
)
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
private registerActionProvider() {
|
|
//
|
|
this.unregisterActionProvider();
|
|
|
|
//
|
|
if (!this.actionProvider) {
|
|
this.actionProvider = new Subject<XFormActionModel>();
|
|
}
|
|
|
|
//
|
|
this.ACTION_PROVIDER_SUBSCRIPTION = this.actionProvider
|
|
.asObservable()
|
|
.subscribe(async (model) => {
|
|
//
|
|
if (!model) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
switch (model.action) {
|
|
//
|
|
case XFormBaseAction.Enable:
|
|
await this.enable(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.Disable:
|
|
await this.disable(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.Refresh:
|
|
await this.refresh();
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.SetError:
|
|
//
|
|
if (model.payload) {
|
|
await this.setError(model.payload, model.name);
|
|
}
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.ClearError:
|
|
await this.clearError(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsDirty:
|
|
await this.markAsDirty(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsTouched:
|
|
await this.markAsTouched(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsPending:
|
|
await this.markAsPending(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsPristine:
|
|
await this.markAsPending(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.MarkAsUnTouched:
|
|
await this.markAsUnTouched(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.UpdateValueAndValidity:
|
|
await this.updateValueAndValidity(model.name);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.SetValue:
|
|
await this.setValue(model.name, model.payload);
|
|
break;
|
|
|
|
//
|
|
case XFormBaseAction.ClearData:
|
|
await this.clearData();
|
|
break;
|
|
|
|
//
|
|
case XFormControlAction.Focuse:
|
|
if (model.name) {
|
|
this.focusOnControl(model.name);
|
|
}
|
|
break;
|
|
|
|
//
|
|
case XFormControlAction.Blur:
|
|
if (model.name) {
|
|
this.blurOfControl(model.name);
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
//
|
|
private unregisterActionProvider() {
|
|
//
|
|
if (!this.ACTION_PROVIDER_SUBSCRIPTION) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.ACTION_PROVIDER_SUBSCRIPTION.unsubscribe();
|
|
this.ACTION_PROVIDER_SUBSCRIPTION = null;
|
|
}
|
|
|
|
//
|
|
private async handleUiDisabledChanged() {
|
|
//
|
|
if (this.uiDisabled) {
|
|
await this.disable();
|
|
} else {
|
|
await this.enable();
|
|
}
|
|
}
|
|
|
|
//
|
|
//#region Color Appliers ...
|
|
private async applyColors() {
|
|
//
|
|
await this.applyRegularColor();
|
|
await this.applyAccentColor();
|
|
await this.applyHintColor();
|
|
await this.applyPendingColor();
|
|
await this.applyActiveColor();
|
|
await this.applyValidColor();
|
|
await this.applyInvalidColor();
|
|
await this.applyFillColor();
|
|
await this.applyDisabledColor();
|
|
await this.applyDisabledFillColor();
|
|
}
|
|
|
|
private async applyRegularColor() {
|
|
//
|
|
const color = await this.getValueAsync(this.regularColor);
|
|
if (!color) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.RegularColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.RegularColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyAccentColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.accentColor);
|
|
if (!color) {
|
|
color = XColor.Secondary;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.AccentColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.AccentColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyHintColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.hintColor);
|
|
if (!color) {
|
|
color = XColor.Tertiary;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.HintColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.HintColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyPendingColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.pendingColor);
|
|
if (!color) {
|
|
color = XColor.Warning;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.PendingColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.PendingColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyActiveColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.activeColor);
|
|
if (!color) {
|
|
color = XColor.Tertiary;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.ActiveColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.ActiveColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyValidColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.validColor);
|
|
if (!color) {
|
|
color = XColor.Success;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.ValidColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.ValidColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyInvalidColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.invalidColor);
|
|
if (!color) {
|
|
color = XColor.Danger;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.InvalidColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.InvalidColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyFillColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.fillColor);
|
|
if (!color) {
|
|
color = XColorWithBrightness.SecondaryTint;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.FillColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.FillColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyDisabledColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.disabledColor);
|
|
if (!color) {
|
|
color = XColorWithBrightness.LightTint;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.DisableColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.DisableColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
|
|
private async applyDisabledFillColor() {
|
|
//
|
|
let color = await this.getValueAsync(this.disabledFillColor);
|
|
if (!color) {
|
|
color = XColorWithBrightness.LightShade;
|
|
}
|
|
|
|
//
|
|
const colorDescriptor = parseXColor(color);
|
|
if (!colorDescriptor) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
const bgColor = getXColorCssVariableName(
|
|
colorDescriptor.name,
|
|
false,
|
|
colorDescriptor.brightnessLevel
|
|
);
|
|
if (isNullOrEmptyString(bgColor)) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
this.setCssVar(XFormCssVar.DisabledFillColor, `var(${bgColor})`);
|
|
this.setCssVar(
|
|
XFormCssVar.DisabledFillColor,
|
|
`var(${bgColor})`,
|
|
document.documentElement
|
|
);
|
|
|
|
//
|
|
this.detectChanges();
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.module.ts
|
|
|
|
import {
|
|
LocaleFactory,
|
|
XPersianDateAdapter,
|
|
MatDateFormatFactory,
|
|
} from 'x-framework-core';
|
|
import {
|
|
DateAdapter,
|
|
MAT_DATE_LOCALE,
|
|
MAT_DATE_FORMATS,
|
|
} from '@angular/material/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { XMapModule } from '../x-map/x-map.module';
|
|
import { LOCALE_ID, NgModule } from '@angular/core';
|
|
import { XFormComponent } from './x-form.component';
|
|
import { XIconModule } from '../x-icon/x-icon.module';
|
|
import { XCardModule } from '../x-card/x-card.module';
|
|
import { XListModule } from '../x-list/x-list.module';
|
|
import { XColorModule } from '../x-color/x-color.module';
|
|
import { XDialogsModule } from '../dialogs/x-dialog.module';
|
|
import { XSlotterModule } from '../x-slotter/x-slotter.module';
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
import { XMarkdownModule } from '../x-markdown/x-markdown.module';
|
|
import { XDataPagerModule } from '../x-data-pager/x-data-pager.module';
|
|
import { XBaseComponentModule } from '../modules/x-base-component.module';
|
|
import { XFileUploadModule } from '../x-file-upload/x-file-upload.module';
|
|
import { XColorPickerModule } from '../x-color-picker/x-color-picker.module';
|
|
import { XAvatarUploadModule } from '../x-avatar-upload/x-avatar-upload.module';
|
|
import { MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
|
|
|
|
@NgModule({
|
|
entryComponents: [],
|
|
declarations: [XFormComponent],
|
|
imports: [
|
|
XMapModule,
|
|
XCardModule,
|
|
XListModule,
|
|
XIconModule,
|
|
FormsModule,
|
|
CommonModule,
|
|
XColorModule,
|
|
XDialogsModule,
|
|
XSlotterModule,
|
|
XMarkdownModule,
|
|
XDataPagerModule,
|
|
XFileUploadModule,
|
|
XColorPickerModule,
|
|
ReactiveFormsModule,
|
|
XAvatarUploadModule,
|
|
XBaseComponentModule,
|
|
],
|
|
exports: [
|
|
XMapModule,
|
|
XCardModule,
|
|
XListModule,
|
|
XIconModule,
|
|
FormsModule,
|
|
CommonModule,
|
|
XColorModule,
|
|
XDialogsModule,
|
|
XFormComponent,
|
|
XSlotterModule,
|
|
XMarkdownModule,
|
|
XDataPagerModule,
|
|
XFileUploadModule,
|
|
XColorPickerModule,
|
|
ReactiveFormsModule,
|
|
XAvatarUploadModule,
|
|
XBaseComponentModule,
|
|
],
|
|
providers: [
|
|
{
|
|
provide: LOCALE_ID,
|
|
useFactory: LocaleFactory,
|
|
},
|
|
{
|
|
provide: MAT_DATE_LOCALE,
|
|
useFactory: LocaleFactory,
|
|
},
|
|
{
|
|
deps: [MAT_DATE_LOCALE],
|
|
provide: MAT_DATE_FORMATS,
|
|
useFactory: MatDateFormatFactory,
|
|
},
|
|
{
|
|
provide: DateAdapter,
|
|
useClass: XPersianDateAdapter,
|
|
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
|
|
},
|
|
],
|
|
})
|
|
export class XFormModule {}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.tools.ts
|
|
|
|
import { XIconNames } from '../x-icon/x-icon.typings';
|
|
import { XColorWithBrightness } from 'x-framework-core';
|
|
import { XControlIconPosition, XControlIconDescriptor } from './x-form.typings';
|
|
|
|
export const defaultFormControlClearIcon: XControlIconDescriptor = {
|
|
name: XIconNames.clear,
|
|
applyStateColor: false,
|
|
color: XColorWithBrightness.Danger,
|
|
position: XControlIconPosition.Suffix,
|
|
}
|
|
|
|
export const defaultFormControlSelectIcon: XControlIconDescriptor = {
|
|
name: XIconNames.touch,
|
|
applyStateColor: false,
|
|
color: XColorWithBrightness.Success,
|
|
position: XControlIconPosition.Suffix,
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\x-form.typings.ts
|
|
|
|
import {
|
|
Input,
|
|
Inject,
|
|
NgZone,
|
|
Output,
|
|
Renderer2,
|
|
Component,
|
|
ElementRef,
|
|
Injectable,
|
|
TemplateRef,
|
|
EventEmitter,
|
|
ChangeDetectorRef,
|
|
} from '@angular/core';
|
|
import {
|
|
XLocale,
|
|
XBaseDto,
|
|
XStandardType,
|
|
XOneOrManyType,
|
|
XColorIdentifier,
|
|
XResourceIdentifier,
|
|
XExceptionIdentifier,
|
|
XColorWithBrightness,
|
|
XBorderStyleIdentifier,
|
|
} from 'x-framework-core';
|
|
import {
|
|
XManagerService,
|
|
XFormInputFormatterIdentifier,
|
|
XStringInputFormatTypeIdentifier,
|
|
} from 'x-framework-services';
|
|
import {
|
|
XMarkdownActionModel,
|
|
XMarkdownModeIdentifier,
|
|
XMarkdownToolbarConfigProps,
|
|
} from '../x-markdown/x-markdown.typings';
|
|
import {
|
|
XComponentCardContainer,
|
|
IXComponentCardContainer,
|
|
XComponentCardContainerComponent,
|
|
} from '../x-card/x-card.typings';
|
|
import { concatMap, map } from 'rxjs/operators';
|
|
import {
|
|
XAvatarUploadActionModel,
|
|
XAvatarUploadActionButton,
|
|
} from '../x-avatar-upload/x-avatar-upload.typings';
|
|
import { ViewportRuler } from '@angular/cdk/overlay';
|
|
import { forkJoin, Observable, Subject } from 'rxjs';
|
|
import { AbstractControlOptions } from '@angular/forms';
|
|
import { XIconIdentifier } from '../x-icon/x-icon.typings';
|
|
import { XBaseActionModel } from '../classes/x-base-action.model';
|
|
import { IXMapContainer, XMapActionModel } from '../x-map/x-map.typings';
|
|
import { X_FRAMEWORK_COMPONENTS_CONFIG } from '../tokens/x-injectable-tokens';
|
|
import { XMapDialogService } from '../x-map/x-map-dialog/x-map-dialog.service';
|
|
import { XColorPickerActionModel } from '../x-color-picker/x-color-picker.typings';
|
|
import { XFrameworkComponentsConfig } from '../config/x-framework-components.config';
|
|
import { XFileDropAreaActionModel } from '../x-file-drop-area/x-file-drop-area.typings';
|
|
import { XSelectorDialogConfig } from '../dialogs/x-selector-dialog/x-selector-dialog.typings';
|
|
import { XSelectorDialogService } from '../dialogs/x-selector-dialog/x-selector-dialog.service';
|
|
import { XColorPickerDialogConfig } from '../x-color-picker/x-color-picker-dialog/x-color-picker-dialog.typings';
|
|
import { XColorPickerDialogService } from '../x-color-picker/x-color-picker-dialog/x-color-picker-dialog.service';
|
|
|
|
//
|
|
//#region Css Vars ...
|
|
export enum XFormCssVar {
|
|
FillColor = 'fill-color',
|
|
HintColor = 'hint-color',
|
|
ValidColor = 'valid-color',
|
|
ActiveColor = 'active-color',
|
|
AccentColor = 'accent-color',
|
|
RegularColor = 'regular-color',
|
|
PendingColor = 'pending-color',
|
|
InvalidColor = 'invalid-color',
|
|
DisableColor = 'disabled-color',
|
|
DisabledFillColor = 'disabled-fill-color',
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Base Form Control Action Model ...
|
|
export type XFormControlNameIdentifier = string | number | symbol;
|
|
|
|
export interface XBaseFormControlActionModel {
|
|
name?: XFormControlNameIdentifier;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Auto Complete Config ...
|
|
export interface XFormControlAutoCompleteConfig<T extends XBaseDto = any> {
|
|
opened?: XStandardType<boolean>;
|
|
color?: XStandardType<XColorIdentifier>;
|
|
onSelect?: (item: T) => XStandardType<void>;
|
|
items: () => XStandardType<XOneOrManyType<T>>;
|
|
itemTemplate: XStandardType<TemplateRef<any>>;
|
|
cssClass?: XStandardType<XOneOrManyType<string>>;
|
|
onEscape?: () => XStandardType<void>;
|
|
onOutsideClicked?: () => XStandardType<void>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region XForm Validator Model ...
|
|
export type XFormValidatorDescriptor = Partial<
|
|
Pick<AbstractControlOptions, 'validators' | 'asyncValidators'>
|
|
>;
|
|
//#endregion
|
|
|
|
//
|
|
//#region Error Handler Configs ...
|
|
export interface XFormErrorHandler {
|
|
errorName: XStandardType<string>;
|
|
errorMessage: XStandardType<XResourceIdentifier>;
|
|
errorDataProvider?: (errorObject: any) => XStandardType<XResourceIdentifier>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Formatter Config ...
|
|
export interface XFormControlFormatterConfig {
|
|
locale?: XStandardType<XLocale>;
|
|
seperator?: XStandardType<string>;
|
|
type: XStandardType<XFormInputFormatterIdentifier>;
|
|
inputType?: XStandardType<XStringInputFormatTypeIdentifier>;
|
|
currencyLable?: XStandardType<XResourceIdentifier>;
|
|
stringFormatter?: XStandardType<XOneOrManyType<number>>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Control Progressbar Config ...
|
|
export interface XFormControlProgressbarConfig {
|
|
color: XStandardType<XColorIdentifier>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region XForm Control Appearance ...
|
|
export enum XFormControlAppearance {
|
|
None = 'none',
|
|
Legacy = 'legacy',
|
|
Standard = 'standard',
|
|
Fill = 'fill',
|
|
Outline = 'outline',
|
|
}
|
|
|
|
export type XFormControlAppearanceIdentifier = XFormControlAppearance | string;
|
|
|
|
export interface XFormControlAppearanceDescriptor {
|
|
hidden?: XStandardType<boolean>;
|
|
disabled?: XStandardType<boolean>;
|
|
hint?: XStandardType<XResourceIdentifier>;
|
|
label: XStandardType<XResourceIdentifier>;
|
|
tooltip?: XStandardType<XResourceIdentifier>;
|
|
placeholder?: XStandardType<XResourceIdentifier>;
|
|
cssClass?: XStandardType<XOneOrManyType<string>>;
|
|
icons?: XStandardType<XFormControlIconDescriptor>;
|
|
formatter?: XStandardType<XFormControlFormatterConfig>;
|
|
progressBar?: XStandardType<XFormControlProgressbarConfig>;
|
|
autoComplete?: XStandardType<XFormControlAutoCompleteConfig>;
|
|
appearance?: XStandardType<XFormControlAppearanceIdentifier>;
|
|
labelPosition?: XStandardType<XFormControlLabelPositionIdentifier>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Icon Configs ...
|
|
export enum XControlIconPosition {
|
|
Prefix = 'prefix',
|
|
Suffix = 'suffix',
|
|
}
|
|
|
|
export type XControlIconPositionIdentifier = XControlIconPosition | string;
|
|
|
|
export enum XControlIconRole {
|
|
Clear = 'clear',
|
|
Select = 'select',
|
|
}
|
|
|
|
export type XControlIconRoleIdentifier = XControlIconRole | string;
|
|
|
|
export interface XControlIconDescriptor {
|
|
handler?: () => XStandardType<void>;
|
|
name?: XStandardType<XIconIdentifier>;
|
|
color?: XStandardType<XColorIdentifier>;
|
|
applyStateColor?: XStandardType<boolean>;
|
|
tooltip?: XStandardType<XResourceIdentifier>;
|
|
position?: XStandardType<XControlIconPositionIdentifier>;
|
|
}
|
|
|
|
export interface XFormIconDescriptor
|
|
extends Pick<
|
|
Partial<XControlIconDescriptor>,
|
|
'handler' | 'name' | 'color' | 'applyStateColor' | 'tooltip'
|
|
> {}
|
|
|
|
export interface XFormControlIconDescriptor {
|
|
suffix?: XStandardType<XFormIconDescriptor>;
|
|
prefix?: XStandardType<XFormIconDescriptor>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Control Status and Values Changed ...
|
|
export interface XFormControlValueChangeEventModel
|
|
extends XBaseFormControlActionModel {
|
|
value: any;
|
|
}
|
|
|
|
export interface XFormControlStatusChangeEventModel
|
|
extends XBaseFormControlActionModel {
|
|
status: XFormStatusIdentifier;
|
|
}
|
|
|
|
// tslint:disable-next-line:no-empty-interface
|
|
export interface XFormValueChangeEventModel
|
|
extends XFormControlValueChangeEventModel {}
|
|
|
|
// tslint:disable-next-line:no-empty-interface
|
|
export interface XFormStatusChangeEventModel
|
|
extends XFormControlStatusChangeEventModel {}
|
|
|
|
//
|
|
// Form and Form Control Status ...
|
|
export enum XFormStatus {
|
|
UnKnown = 'UNKNOWN',
|
|
Valid = 'VALID',
|
|
Invalid = 'INVALID',
|
|
Pending = 'PENDING',
|
|
Disabled = 'DISABLED',
|
|
}
|
|
|
|
export type XFormStatusIdentifier = XFormStatus | string;
|
|
|
|
export interface XFormControlEventsDescriptor {
|
|
statusChanged?: (
|
|
model: XFormControlStatusChangeEventModel
|
|
) => XStandardType<void>;
|
|
valueChanged?: (
|
|
model: XFormControlValueChangeEventModel
|
|
) => XStandardType<void>;
|
|
onBlured?: (model: XBaseFormControlActionModel) => XStandardType<void>;
|
|
onFocused?: (model: XBaseFormControlActionModel) => XStandardType<void>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Control Label Position ...
|
|
export enum XFormControlLabelPosition {
|
|
After = 'after',
|
|
Before = 'before',
|
|
}
|
|
|
|
export type XFormControlLabelPositionIdentifier =
|
|
| XFormControlLabelPosition
|
|
| string;
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form and Form Control Action Provider ...
|
|
export enum XFormBaseAction {
|
|
//
|
|
MarkAsDirty = 'mark_as_dirty',
|
|
MarkAsTouched = 'mark_as_touched',
|
|
MarkAsPending = 'mark_as_pending',
|
|
MarkAsPristine = 'mark_as_pristine',
|
|
MarkAsUnTouched = 'mark_as_untouched',
|
|
UpdateValueAndValidity = 'update_value_and_validity',
|
|
//
|
|
SetError = 'set_error',
|
|
ClearError = 'clear_error',
|
|
//
|
|
SetValue = 'set_value',
|
|
//
|
|
Enable = 'enable',
|
|
Disable = 'disable',
|
|
//
|
|
Refresh = 'refresh',
|
|
//
|
|
ClearData = 'clear_data',
|
|
}
|
|
|
|
export enum XFormControlAction {
|
|
Focuse = 'focuse',
|
|
Blur = 'blur',
|
|
}
|
|
|
|
export type XFormControlActionIdentifier =
|
|
| XFormBaseAction
|
|
| XFormControlAction
|
|
| string;
|
|
|
|
export interface XFormControlActionProviderModel
|
|
extends XBaseActionModel<XFormControlActionIdentifier>,
|
|
XBaseFormControlActionModel {}
|
|
|
|
export interface XFormActionModel extends XFormControlActionProviderModel {}
|
|
//#endregion
|
|
|
|
//
|
|
//#region XForm and XForm Control Update On ...
|
|
export enum XFormUpdateOn {
|
|
BLUR = 'blur',
|
|
CHANGE = 'change',
|
|
SUBMIT = 'submit',
|
|
}
|
|
|
|
export type XFormUpdateOnIdentifier = XFormUpdateOn | string;
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Control Types ...
|
|
export enum XFormControlType {
|
|
Text = 'text',
|
|
Number = 'number',
|
|
Password = 'password',
|
|
Color = 'color',
|
|
Email = 'email',
|
|
Tel = 'tel',
|
|
Url = 'url',
|
|
Select = 'select',
|
|
Radio = 'radio',
|
|
CheckBox = 'checkbox',
|
|
Hidden = 'hidden',
|
|
Date = 'date',
|
|
Slider = 'slider',
|
|
Toggle = 'toggle',
|
|
MarkDown = 'markdown',
|
|
Map = 'map',
|
|
ColorPicker = 'color_picker',
|
|
AvatarUpload = 'avatar_upload',
|
|
Selector = 'selector',
|
|
}
|
|
|
|
export type XFormControlTypeIdentifier = XFormControlType | string;
|
|
|
|
export type XFormControlTypeConfig =
|
|
| XFormMapControlConfig
|
|
| XFormRadioControlConfig
|
|
| XFormInputControlConfig
|
|
| XFormSelectControlConfig
|
|
| XFormSliderControlConfig
|
|
| XFormSelectorControlConfig
|
|
| XFormMarkdownControlConfig
|
|
| XFormCheckBoxControlConfig
|
|
| XFormDatePickerControlConfig
|
|
| XFormColorPickerControlConfig
|
|
| XFormAvatarUploadControlConfig
|
|
| undefined;
|
|
export interface XFormControlTypeDescriptor {
|
|
type: XStandardType<XFormControlTypeIdentifier>;
|
|
config?: XStandardType<XFormControlTypeConfig>;
|
|
}
|
|
|
|
//
|
|
//#region Type Configs ...
|
|
//
|
|
//#region Input Type ...
|
|
export interface XFormInputControlConfig {
|
|
readonly?: XStandardType<boolean>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Select Type ...
|
|
export interface XFormSelectControlOption<T extends XBaseDto = any> {
|
|
value: XStandardType<T>;
|
|
viewValue: XStandardType<string>;
|
|
}
|
|
|
|
export interface XFormSelectControlConfig<T extends XBaseDto = any> {
|
|
options?: XStandardType<XOneOrManyType<XFormSelectControlOption<T>>>;
|
|
multiple?: XStandardType<boolean>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Radio Type ...
|
|
export interface XFormRadioControlOption<T extends XBaseDto = any> {
|
|
value: XStandardType<T>;
|
|
viewValue: XStandardType<string>;
|
|
}
|
|
|
|
export interface XFormRadioControlConfig<T extends XBaseDto = any> {
|
|
options?: XStandardType<XOneOrManyType<XFormRadioControlOption<T>>>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Date Control Config ...
|
|
export enum XFormDatePickerControlPickerPosition {
|
|
Suffix = 'suffix',
|
|
Prefix = 'prefix',
|
|
}
|
|
|
|
export type XFormDatePickerControlPickerPositionIdentifier =
|
|
| XFormDatePickerControlPickerPosition
|
|
| string;
|
|
|
|
export interface XFormDatePickerControlConfig {
|
|
startAt?: XStandardType<Date>;
|
|
dateFilter?: (d: any) => boolean;
|
|
applyStateColor?: XStandardType<boolean>;
|
|
toggleIcon?: XStandardType<XIconIdentifier>;
|
|
iconColor?: XStandardType<XColorIdentifier>;
|
|
datePickerPosition: XStandardType<XFormDatePickerControlPickerPositionIdentifier>;
|
|
disableInput?: XStandardType<boolean>;
|
|
disablePicker?: XStandardType<boolean>;
|
|
iconTooltip?: XStandardType<XResourceIdentifier>;
|
|
dateInput?: (event: Date) => XStandardType<void>;
|
|
dateChange?: (event: Date) => XStandardType<void>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Slider Control ...
|
|
export interface XFormSliderControlConfig {
|
|
min?: XStandardType<number>;
|
|
max?: XStandardType<number>;
|
|
step?: XStandardType<number>;
|
|
invert?: XStandardType<boolean>;
|
|
vertical?: XStandardType<boolean>;
|
|
thumbLabel?: XStandardType<boolean>;
|
|
formatter?: (value: number) => string;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Markdown Control Config ...
|
|
export interface XFormMarkdownControlConfig {
|
|
//
|
|
isInPage?: XStandardType<boolean>;
|
|
hasToolbar?: XStandardType<boolean>;
|
|
wrapWithCard?: XStandardType<boolean>;
|
|
cardColor?: XStandardType<XColorIdentifier>;
|
|
cardForegroundColor?: XStandardType<boolean>;
|
|
mode?: XStandardType<XMarkdownModeIdentifier>;
|
|
toolbarColor?: XStandardType<XColorIdentifier>;
|
|
cardTitle?: XStandardType<XResourceIdentifier>;
|
|
actionProvider?: Subject<XMarkdownActionModel>;
|
|
toolbarForegroundColor?: XStandardType<boolean>;
|
|
cssClass?: XStandardType<XOneOrManyType<string>>;
|
|
editorBoxColor?: XStandardType<XColorIdentifier>;
|
|
previewBoxColor?: XStandardType<XColorIdentifier>;
|
|
cardSubTitle?: XStandardType<XResourceIdentifier>;
|
|
toolbarCssClass?: XStandardType<XOneOrManyType<string>>;
|
|
contentChanged?: (content: string) => XStandardType<void>;
|
|
toolbarConfig?: XStandardType<XMarkdownToolbarConfigProps>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Check Box Config ...
|
|
export interface XFormCheckBoxControlConfig {
|
|
checkedChanged?: (checked: boolean) => XStandardType<any>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Map Config ...
|
|
export enum XFormMapControlPresentType {
|
|
WithDialog = 'width_dialog',
|
|
WithoutDialog = 'without_dialog',
|
|
}
|
|
|
|
export type XFormMapControlPresentTypeIdentifier =
|
|
| XFormMapControlPresentType
|
|
| string;
|
|
|
|
//
|
|
export interface XFormMapControlConfig
|
|
extends Pick<
|
|
Partial<IXMapContainer>,
|
|
| 'zoom'
|
|
| 'markerStyle'
|
|
| 'cssClass'
|
|
| 'canSelect'
|
|
//
|
|
| 'showProgressBar'
|
|
| 'progressBarColor'
|
|
| 'progressBarPosition'
|
|
//
|
|
| 'showSearchBar'
|
|
| 'searchBarType'
|
|
| 'searchBarValue'
|
|
| 'searchBarDebounce'
|
|
| 'searchBarQueryChange'
|
|
| 'searchBarSpellcheck'
|
|
| 'searchPlaceProvider'
|
|
| 'searchBarColor'
|
|
| 'searchBarForegroundColor'
|
|
| 'searchBarClearButtonIcon'
|
|
| 'searchBarTitle'
|
|
| 'searchBarSearchButtonIcon'
|
|
| 'searchBarSearchInputColor'
|
|
| 'searchBarForegroundSearchInputColor'
|
|
| 'searchResultListColor'
|
|
| 'searchBarActionProvider'
|
|
| 'searchBarClearButtonIconColor'
|
|
| 'searchBarCssClass'
|
|
| 'searchBarSearchButtonIconColor'
|
|
| 'searchBarCancelButtonIcon'
|
|
| 'searchBarPosition'
|
|
| 'searchBarKeyboardType'
|
|
| 'searchBarCancelButtonTitle'
|
|
| 'searchBarEnterKeyHint'
|
|
| 'searchBarShowCancelButton'
|
|
//
|
|
| 'showSelectedLocation'
|
|
| 'selectedLocationPosition'
|
|
//
|
|
| 'showGoMarkedPlace'
|
|
| 'goMarkedPlacePosition'
|
|
//
|
|
| 'showClearMarker'
|
|
| 'clearMarkerPosition'
|
|
//
|
|
| 'showLocator'
|
|
| 'locatorPosition'
|
|
//
|
|
| 'showZoom'
|
|
| 'showRotate'
|
|
| 'showZoomSlider'
|
|
//
|
|
| 'isReady'
|
|
| 'locationSelected'
|
|
//
|
|
| 'isInPage'
|
|
| 'wrapWithCard'
|
|
| 'cardShowFooter'
|
|
| 'cardColor'
|
|
| 'cardForegroundColor'
|
|
| 'cardTitle'
|
|
| 'cardSubTitle'
|
|
> {
|
|
//
|
|
disableIcon?: XStandardType<boolean>;
|
|
disableInput?: XStandardType<boolean>;
|
|
actionProvider?: Subject<XMapActionModel>;
|
|
clearIcon?: XStandardType<XControlIconDescriptor>;
|
|
selectIcon?: XStandardType<XControlIconDescriptor>;
|
|
inputCssClass?: XStandardType<XOneOrManyType<string>>;
|
|
inputValueChanged?: (value?: string) => XStandardType<string>;
|
|
presentType?: XStandardType<XFormMapControlPresentTypeIdentifier>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region ColorPicker Config ...
|
|
export enum XFormColorPickerControlPresentType {
|
|
WithDialog = 'width_dialog',
|
|
WithoutDialog = 'without_dialog',
|
|
// Both = 'both',
|
|
}
|
|
|
|
export type XFormColorPickerControlPresentTypeIdentifier =
|
|
| XFormColorPickerControlPresentType
|
|
| string;
|
|
|
|
//
|
|
export interface XFormColorPickerControlConfig
|
|
extends Pick<
|
|
Partial<XColorPickerDialogConfig>,
|
|
| 'color'
|
|
| 'cssClass'
|
|
| 'cardColor'
|
|
| 'cardTitle'
|
|
| 'cursorColor'
|
|
| 'presetColors'
|
|
| 'outputFormat'
|
|
| 'cardSubTitle'
|
|
| 'colorSelected'
|
|
| 'colorTextColor'
|
|
| 'showColorValue'
|
|
| 'showHueChannel'
|
|
| 'showColorInput'
|
|
| 'foregroundColor'
|
|
| 'showPresetColors'
|
|
| 'showAlphaChannel'
|
|
| 'presetColorsLable'
|
|
| 'showPaletteChannel'
|
|
| 'cardForegroundColor'
|
|
| 'showCopyToClipboard'
|
|
| 'colorInputIconLabel'
|
|
| 'colorInputIconColor'
|
|
| 'clearColorIconColor'
|
|
| 'clearColorIconLabel'
|
|
| 'representColorFormats'
|
|
| 'presetColorsLableColor'
|
|
| 'copyToClipboardIconLabel'
|
|
| 'copyToClipboardIconColor'
|
|
| 'showSelectedColorPreview'
|
|
> {
|
|
//
|
|
isInPage?: XStandardType<boolean>;
|
|
disableIcon?: XStandardType<boolean>;
|
|
disableInput?: XStandardType<boolean>;
|
|
wrapWithCard?: XStandardType<boolean>;
|
|
showCardFooter?: XStandardType<boolean>;
|
|
colorViewBorderWidth?: XStandardType<number>;
|
|
actionProvider?: Subject<XColorPickerActionModel>;
|
|
clearIcon?: XStandardType<XControlIconDescriptor>;
|
|
selectIcon?: XStandardType<XControlIconDescriptor>;
|
|
inputCssClass?: XStandardType<XOneOrManyType<string>>;
|
|
colorViewBorderColor?: XStandardType<XColorIdentifier>;
|
|
colorViewBorderStyle?: XStandardType<XBorderStyleIdentifier>;
|
|
inputValueChanged?: (value?: string) => XStandardType<string>;
|
|
presentType?: XStandardType<XFormColorPickerControlPresentTypeIdentifier>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Avatar Upload Config ...
|
|
export interface XFormAvatarUploadControlConfig {
|
|
fileDropAreaFilesChangeEmiter?: (
|
|
files?: XOneOrManyType<File>
|
|
) => XStandardType<void>;
|
|
canDrop?: XStandardType<boolean>;
|
|
isInPage?: XStandardType<boolean>;
|
|
wrapWithCard?: XStandardType<boolean>;
|
|
color?: XStandardType<XColorIdentifier>;
|
|
showCardFooter?: XStandardType<boolean>;
|
|
foregroundColor?: XStandardType<boolean>;
|
|
placeHolderAvatar?: XStandardType<string>;
|
|
minAllowedFileSize?: XStandardType<number>;
|
|
maxAllowedFileSize?: XStandardType<number>;
|
|
cardColor?: XStandardType<XColorIdentifier>;
|
|
cardForegroundColor?: XStandardType<boolean>;
|
|
fileDropAreaIsInPage?: XStandardType<boolean>;
|
|
cardTitle?: XStandardType<XResourceIdentifier>;
|
|
cssClass?: XStandardType<XOneOrManyType<string>>;
|
|
fileDropAreaWrapWithCard?: XStandardType<boolean>;
|
|
fileDropAreaIcon?: XStandardType<XIconIdentifier>;
|
|
fileDropAreaDragDisabled?: XStandardType<boolean>;
|
|
cardSubTitle?: XStandardType<XResourceIdentifier>;
|
|
actionProvider?: Subject<XAvatarUploadActionModel>;
|
|
fileDropAreaShowCardFooter?: XStandardType<boolean>;
|
|
fileDropAreaColor?: XStandardType<XColorIdentifier>;
|
|
fileDropAreaForegroundColor?: XStandardType<boolean>;
|
|
avatarChange?: (avatar?: File) => XStandardType<void>;
|
|
fileDropAreaDisableFileCheck?: XStandardType<boolean>;
|
|
fileDropAreaCardColor?: XStandardType<XColorIdentifier>;
|
|
fileDropAreaCardForegroundColor?: XStandardType<boolean>;
|
|
emptyFileException?: XStandardType<XExceptionIdentifier>;
|
|
fileDropAreaErrorColor?: XStandardType<XColorIdentifier>;
|
|
fileDropAreaMessage?: XStandardType<XResourceIdentifier>;
|
|
fileDropAreaAccentColor?: XStandardType<XColorIdentifier>;
|
|
allowedExtensions?: XStandardType<XOneOrManyType<string>>;
|
|
fileDropAreaCardTitle?: XStandardType<XResourceIdentifier>;
|
|
fileDropAreaSuccessColor?: XStandardType<XColorIdentifier>;
|
|
fileDropAreaSupportsMultipleFiles?: XStandardType<boolean>;
|
|
fileDropAreaCssClass?: XStandardType<XOneOrManyType<string>>;
|
|
fileDropAreaCardSubTitle?: XStandardType<XResourceIdentifier>;
|
|
notAllowedFileException?: XStandardType<XExceptionIdentifier>;
|
|
fileDropAreaContentTemplate?: XStandardType<TemplateRef<any>>;
|
|
fileDropAreaActionProvider?: Subject<XFileDropAreaActionModel>;
|
|
minAllowedFileSizeException?: XStandardType<XExceptionIdentifier>;
|
|
maxAllowedFileSizeException?: XStandardType<XExceptionIdentifier>;
|
|
actions?: XStandardType<XOneOrManyType<XAvatarUploadActionButton>>;
|
|
fileDropAreaAllowedExtensions?: XStandardType<XOneOrManyType<string>>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Selector Config ...
|
|
export interface XFormSelectorControlConfig
|
|
extends Partial<XSelectorDialogConfig> {
|
|
//
|
|
clearIcon?: XStandardType<XControlIconDescriptor>;
|
|
selectIcon?: XStandardType<XControlIconDescriptor>;
|
|
inputCssClass?: XStandardType<XOneOrManyType<string>>;
|
|
inputValueChanged?: (value?: string) => XStandardType<string>;
|
|
formatSelectedItem?: (item: XOneOrManyType<any>) => XStandardType<string>;
|
|
}
|
|
//#endregion
|
|
//#endregion
|
|
//#endregion
|
|
|
|
//
|
|
//#region Form Control Config ...
|
|
export interface XFormControlConfig<T extends XBaseDto = any> {
|
|
index: number;
|
|
propName: keyof Partial<T>;
|
|
focusHandler?: Subject<any>;
|
|
type: XStandardType<XFormControlTypeDescriptor>;
|
|
updateOn?: XStandardType<XFormUpdateOnIdentifier>;
|
|
validators?: XStandardType<XFormValidatorDescriptor>;
|
|
actionProvider?: Subject<XFormControlActionProviderModel>;
|
|
eventHandlers?: XStandardType<XFormControlEventsDescriptor>;
|
|
appearance: XStandardType<XFormControlAppearanceDescriptor>;
|
|
errorHandlers?: XStandardType<XOneOrManyType<XFormErrorHandler>>;
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
// Form Config ...
|
|
export interface XFormConfig<T extends XBaseDto = any> {
|
|
name: XStandardType<string>;
|
|
model?: XStandardType<Partial<T>>;
|
|
updateOn?: XStandardType<XFormUpdateOnIdentifier>;
|
|
validators?: XStandardType<XFormValidatorDescriptor>;
|
|
controls: XStandardType<XOneOrManyType<XFormControlConfig<T>>>;
|
|
errorHandlers?: XStandardType<XOneOrManyType<XFormErrorHandler>>;
|
|
}
|
|
|
|
//
|
|
//#region Inside Card Container ...
|
|
export interface IXFormContainer extends IXComponentCardContainer {
|
|
//
|
|
actionProvider: Subject<XFormActionModel>;
|
|
cssClass: XStandardType<XOneOrManyType<string>>;
|
|
formConfig: XStandardType<XFormConfig>;
|
|
applyStatusOnControls: XStandardType<boolean>;
|
|
|
|
//
|
|
regularColor: XStandardType<XColorIdentifier>;
|
|
accentColor: XStandardType<XColorIdentifier>;
|
|
hintColor: XStandardType<XColorIdentifier>;
|
|
activeColor: XStandardType<XColorIdentifier>;
|
|
validColor: XStandardType<XColorIdentifier>;
|
|
invalidColor: XStandardType<XColorIdentifier>;
|
|
pendingColor: XStandardType<XColorIdentifier>;
|
|
fillColor: XStandardType<XColorIdentifier>;
|
|
disabledColor: XStandardType<XColorIdentifier>;
|
|
disabledFillColor: XStandardType<XColorIdentifier>;
|
|
|
|
//
|
|
valueChanged: EventEmitter<XFormValueChangeEventModel>;
|
|
statusChanged: EventEmitter<XFormStatusChangeEventModel>;
|
|
controlFocused: EventEmitter<XBaseFormControlActionModel>;
|
|
controlBlured: EventEmitter<XBaseFormControlActionModel>;
|
|
controlValueChanged: EventEmitter<XFormControlValueChangeEventModel>;
|
|
controlStatusChanged: EventEmitter<XFormControlStatusChangeEventModel>;
|
|
}
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class XFormContainer
|
|
extends XComponentCardContainer
|
|
implements Readonly<IXFormContainer>
|
|
{
|
|
//
|
|
//#region Props ...
|
|
//
|
|
readonly actionProvider: Subject<XFormActionModel> =
|
|
new Subject<XFormActionModel>();
|
|
readonly cssClass: XStandardType<XOneOrManyType<string>>;
|
|
readonly formConfig: XStandardType<XFormConfig> = null;
|
|
readonly applyStatusOnControls: XStandardType<boolean> = false;
|
|
|
|
//
|
|
readonly regularColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Dark;
|
|
readonly accentColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Secondary;
|
|
readonly hintColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Tertiary;
|
|
readonly activeColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Tertiary;
|
|
readonly validColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Success;
|
|
readonly invalidColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Danger;
|
|
readonly pendingColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.Warning;
|
|
readonly fillColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.SecondaryTint;
|
|
readonly disabledColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.LightTint;
|
|
readonly disabledFillColor: XStandardType<XColorIdentifier> =
|
|
XColorWithBrightness.LightShade;
|
|
|
|
//
|
|
readonly valueChanged: EventEmitter<XFormValueChangeEventModel> =
|
|
new EventEmitter<XFormValueChangeEventModel>();
|
|
readonly statusChanged: EventEmitter<XFormStatusChangeEventModel> =
|
|
new EventEmitter<XFormStatusChangeEventModel>();
|
|
readonly controlFocused: EventEmitter<XBaseFormControlActionModel> =
|
|
new EventEmitter<XBaseFormControlActionModel>();
|
|
readonly controlBlured: EventEmitter<XBaseFormControlActionModel> =
|
|
new EventEmitter<XBaseFormControlActionModel>();
|
|
readonly controlValueChanged: EventEmitter<XFormControlValueChangeEventModel> =
|
|
new EventEmitter<XFormControlValueChangeEventModel>();
|
|
readonly controlStatusChanged: EventEmitter<XFormControlStatusChangeEventModel> =
|
|
new EventEmitter<XFormControlStatusChangeEventModel>();
|
|
//#endregion
|
|
}
|
|
|
|
@Injectable()
|
|
@Component({
|
|
template: ``,
|
|
})
|
|
export abstract class XFormContainerComponent
|
|
extends XComponentCardContainerComponent
|
|
implements IXFormContainer
|
|
{
|
|
//
|
|
//#region Props ...
|
|
//
|
|
@Input()
|
|
actionProvider: Subject<XFormActionModel> =
|
|
this.propertyProvider.actionProvider;
|
|
|
|
@Input()
|
|
cssClass: XStandardType<XOneOrManyType<string>> =
|
|
this.propertyProvider.cssClass;
|
|
|
|
@Input()
|
|
formConfig: XStandardType<XFormConfig> = this.propertyProvider.formConfig;
|
|
|
|
@Input()
|
|
applyStatusOnControls: XStandardType<boolean> =
|
|
this.propertyProvider.applyStatusOnControls;
|
|
|
|
//
|
|
@Input()
|
|
regularColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.regularColor;
|
|
|
|
@Input()
|
|
accentColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.accentColor;
|
|
|
|
@Input()
|
|
hintColor: XStandardType<XColorIdentifier> = this.propertyProvider.hintColor;
|
|
|
|
@Input()
|
|
activeColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.activeColor;
|
|
|
|
@Input()
|
|
validColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.validColor;
|
|
|
|
@Input()
|
|
invalidColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.invalidColor;
|
|
|
|
@Input()
|
|
pendingColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.pendingColor;
|
|
|
|
@Input()
|
|
fillColor: XStandardType<XColorIdentifier> = this.propertyProvider.fillColor;
|
|
|
|
@Input()
|
|
disabledColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.disabledColor;
|
|
|
|
@Input()
|
|
disabledFillColor: XStandardType<XColorIdentifier> =
|
|
this.propertyProvider.disabledFillColor;
|
|
|
|
//
|
|
@Output()
|
|
valueChanged: EventEmitter<XFormValueChangeEventModel> = new EventEmitter();
|
|
|
|
@Output()
|
|
statusChanged: EventEmitter<XFormStatusChangeEventModel> = new EventEmitter();
|
|
|
|
@Output()
|
|
controlFocused: EventEmitter<XBaseFormControlActionModel> = new EventEmitter();
|
|
|
|
@Output()
|
|
controlBlured: EventEmitter<XBaseFormControlActionModel> = new EventEmitter();
|
|
|
|
@Output()
|
|
controlValueChanged: EventEmitter<XFormControlValueChangeEventModel> = new EventEmitter();
|
|
|
|
@Output()
|
|
controlStatusChanged: EventEmitter<XFormControlStatusChangeEventModel> = new EventEmitter();
|
|
//#endregion
|
|
|
|
//
|
|
//#region Constructor ...
|
|
public constructor(
|
|
@Inject(X_FRAMEWORK_COMPONENTS_CONFIG)
|
|
public config: XFrameworkComponentsConfig,
|
|
public managerService: XManagerService,
|
|
public element: ElementRef,
|
|
public renderer: Renderer2,
|
|
public ruler: ViewportRuler,
|
|
public zone: NgZone,
|
|
public changeDetector: ChangeDetectorRef,
|
|
protected propertyProvider: XFormContainer,
|
|
protected mapDialogService: XMapDialogService,
|
|
protected selectorDialogService: XSelectorDialogService,
|
|
protected colorPickerDialogService: XColorPickerDialogService
|
|
) {
|
|
super(
|
|
config,
|
|
managerService,
|
|
element,
|
|
renderer,
|
|
ruler,
|
|
zone,
|
|
changeDetector,
|
|
propertyProvider
|
|
);
|
|
}
|
|
//#endregion
|
|
|
|
//
|
|
//#region Abstract ...
|
|
public extractProps(
|
|
container?: IXFormContainer
|
|
): Observable<IXFormContainer> {
|
|
return super
|
|
.extractProps(container ? container : this)
|
|
.pipe(
|
|
concatMap((superData) => {
|
|
return forkJoin({
|
|
//
|
|
cssClass: this.getValue(
|
|
container ? container.cssClass : this.cssClass
|
|
),
|
|
formConfig: this.getValue(
|
|
container ? container.formConfig : this.formConfig
|
|
),
|
|
applyStatusOnControls: this.getValue(
|
|
container
|
|
? container.applyStatusOnControls
|
|
: this.applyStatusOnControls
|
|
),
|
|
regularColor: this.getValue(
|
|
container ? container.regularColor : this.regularColor
|
|
),
|
|
accentColor: this.getValue(
|
|
container ? container.accentColor : this.accentColor
|
|
),
|
|
hintColor: this.getValue(
|
|
container ? container.hintColor : this.hintColor
|
|
),
|
|
activeColor: this.getValue(
|
|
container ? container.activeColor : this.activeColor
|
|
),
|
|
validColor: this.getValue(
|
|
container ? container.validColor : this.validColor
|
|
),
|
|
invalidColor: this.getValue(
|
|
container ? container.invalidColor : this.invalidColor
|
|
),
|
|
pendingColor: this.getValue(
|
|
container ? container.pendingColor : this.pendingColor
|
|
),
|
|
fillColor: this.getValue(
|
|
container ? container.fillColor : this.fillColor
|
|
),
|
|
disabledColor: this.getValue(
|
|
container ? container.disabledColor : this.disabledColor
|
|
),
|
|
disabledFillColor: this.getValue(
|
|
container ? container.disabledFillColor : this.disabledFillColor
|
|
),
|
|
}).pipe(
|
|
map((data) => {
|
|
return {
|
|
superData,
|
|
data,
|
|
};
|
|
})
|
|
);
|
|
})
|
|
)
|
|
.pipe(
|
|
map((info) => {
|
|
return {
|
|
//
|
|
...info.superData,
|
|
|
|
//
|
|
...info.data,
|
|
|
|
//
|
|
actionProvider: container
|
|
? container.actionProvider
|
|
: this.actionProvider,
|
|
|
|
//
|
|
valueChanged: this.valueChanged,
|
|
statusChanged: this.statusChanged,
|
|
controlFocused: this.controlFocused,
|
|
controlBlured: this.controlBlured,
|
|
controlValueChanged: this.controlValueChanged,
|
|
controlStatusChanged: this.controlStatusChanged,
|
|
};
|
|
})
|
|
);
|
|
}
|
|
//#endregion
|
|
}
|
|
//#endregion
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xFrameworkComponentsHolder\projects\x-framework-components\src\lib\x-form\validators\x-form-validators.ts
|
|
|
|
import {
|
|
isValidURL,
|
|
XCountryCode,
|
|
isNullOrUndefined,
|
|
isValidPhoneNumber,
|
|
isNullOrEmptyString,
|
|
toNumber,
|
|
toXString,
|
|
} from 'x-framework-core';
|
|
import { ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
|
|
|
|
export class XFormValidators {
|
|
/**
|
|
* check given date in between start and end date ...
|
|
*
|
|
* @param startDate start date for validating
|
|
* @param endDate end date for validating
|
|
*/
|
|
static validateDate(
|
|
startDate: Date | string,
|
|
endDate: Date | string
|
|
): ValidatorFn {
|
|
//
|
|
const errorObject = {
|
|
startDate,
|
|
endDate,
|
|
currentDate: new Date(),
|
|
xValidateDate: true,
|
|
};
|
|
|
|
//
|
|
const validatorFn = (control: AbstractControl): ValidationErrors | null => {
|
|
//
|
|
if (
|
|
isNullOrEmptyString(control.value) ||
|
|
isNullOrUndefined(startDate) ||
|
|
isNullOrUndefined(endDate)
|
|
) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
const mStartDate = new Date(startDate);
|
|
const mEndDate = new Date(endDate);
|
|
const mDate = new Date(control.value);
|
|
|
|
//
|
|
const isValid = mDate >= mStartDate && mDate <= mEndDate;
|
|
if (!isValid) {
|
|
//
|
|
errorObject.currentDate = mDate;
|
|
return errorObject;
|
|
}
|
|
|
|
//
|
|
return null;
|
|
};
|
|
|
|
//
|
|
return validatorFn;
|
|
}
|
|
|
|
/**
|
|
* check given value be a valid phone number ...
|
|
*
|
|
* @param defaultCountryCode an optional value which used for country code if not exists in value
|
|
*/
|
|
static validatePhoneNumber(defaultCountry?: XCountryCode): ValidatorFn {
|
|
//
|
|
const errorObject = {
|
|
xPhoneNumberValidator: true,
|
|
};
|
|
|
|
//
|
|
const validatorFn = (control: AbstractControl): ValidationErrors | null => {
|
|
//
|
|
if (isNullOrEmptyString(control.value)) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
const value = control.value as string;
|
|
const isValid = isValidPhoneNumber(value, defaultCountry);
|
|
|
|
//
|
|
if (!isValid) {
|
|
return errorObject;
|
|
}
|
|
|
|
//
|
|
return null;
|
|
};
|
|
|
|
//
|
|
return validatorFn;
|
|
}
|
|
|
|
/**
|
|
* check given value is Valid URL or not ...
|
|
*/
|
|
static validateUrl(): ValidatorFn {
|
|
//
|
|
const errorObject = {
|
|
xUrlValidator: true,
|
|
};
|
|
|
|
//
|
|
const validatorFn = (control: AbstractControl): ValidationErrors | null => {
|
|
//
|
|
if (isNullOrEmptyString(control.value)) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
const value = control.value as string;
|
|
const isValid = isValidURL(value);
|
|
|
|
//
|
|
if (!isValid) {
|
|
return errorObject;
|
|
}
|
|
|
|
//
|
|
return null;
|
|
};
|
|
|
|
//
|
|
return validatorFn;
|
|
}
|
|
|
|
/**
|
|
* check give value notEquals to Zero ...
|
|
* usually works for id's in Selector Component ...
|
|
*/
|
|
static validateNotZero(): ValidatorFn {
|
|
//
|
|
const errorObject = {
|
|
xNotZeroValidator: true,
|
|
};
|
|
|
|
//
|
|
const validatorFn = (control: AbstractControl): ValidationErrors | null => {
|
|
//
|
|
if (isNullOrEmptyString(control.value)) {
|
|
return null;
|
|
}
|
|
|
|
//
|
|
const value = control.value as string;
|
|
const isValid =
|
|
!isNullOrEmptyString(value) &&
|
|
(toXString(value) !== '0' || toNumber(value) !== 0);
|
|
|
|
//
|
|
if (!isValid) {
|
|
return errorObject;
|
|
}
|
|
|
|
//
|
|
return null;
|
|
};
|
|
|
|
//
|
|
return validatorFn;
|
|
}
|
|
}
|