|
|
@ -47,6 +47,8 @@ interface MultipleInputWidgetSettings { |
|
|
widgetTitle: string; |
|
|
widgetTitle: string; |
|
|
showActionButtons: boolean; |
|
|
showActionButtons: boolean; |
|
|
updateAllValues: boolean; |
|
|
updateAllValues: boolean; |
|
|
|
|
|
saveButtonLabel: string; |
|
|
|
|
|
resetButtonLabel: string; |
|
|
showResultMessage: boolean; |
|
|
showResultMessage: boolean; |
|
|
showGroupTitle: boolean; |
|
|
showGroupTitle: boolean; |
|
|
groupTitle: string; |
|
|
groupTitle: string; |
|
|
@ -67,27 +69,19 @@ interface MultipleInputWidgetDataKeySettings { |
|
|
maxValue?: number; |
|
|
maxValue?: number; |
|
|
requiredErrorMessage?: string; |
|
|
requiredErrorMessage?: string; |
|
|
invalidDateErrorMessage?: string; |
|
|
invalidDateErrorMessage?: string; |
|
|
minErrorMessage?: string; |
|
|
minValueErrorMessage?: string; |
|
|
maxErrorMessage?: string; |
|
|
maxValueErrorMessage?: string; |
|
|
icon: string; |
|
|
icon: string; |
|
|
inputTypeNumber?: boolean; |
|
|
inputTypeNumber?: boolean; |
|
|
readOnly?: boolean; |
|
|
readOnly?: boolean; |
|
|
disabledOnCondition?: boolean; |
|
|
disabledOnCondition?: boolean; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
interface MultipleInputWidgetDataKeyErrorMessages { |
|
|
|
|
|
requiredErrorMessage?: string; |
|
|
|
|
|
invalidDateErrorMessage?: string; |
|
|
|
|
|
minErrorMessage?: string; |
|
|
|
|
|
maxErrorMessage?: string; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface MultipleInputWidgetDataKey extends DataKey { |
|
|
interface MultipleInputWidgetDataKey extends DataKey { |
|
|
formId?: string; |
|
|
formId?: string; |
|
|
settings: MultipleInputWidgetDataKeySettings; |
|
|
settings: MultipleInputWidgetDataKeySettings; |
|
|
isFocused: boolean; |
|
|
isFocused: boolean; |
|
|
value?: any; |
|
|
value?: any; |
|
|
errorMessages?: MultipleInputWidgetDataKeyErrorMessages; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
interface MultipleInputWidgetSource { |
|
|
interface MultipleInputWidgetSource { |
|
|
@ -170,6 +164,17 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
|
|
|
|
|
|
|
|
this.settings.groupTitle = this.settings.groupTitle || '${entityName}'; |
|
|
this.settings.groupTitle = this.settings.groupTitle || '${entityName}'; |
|
|
|
|
|
|
|
|
|
|
|
if (this.settings.saveButtonLabel && this.settings.saveButtonLabel.length) { |
|
|
|
|
|
this.settings.saveButtonLabel = this.utils.customTranslation(this.settings.saveButtonLabel, this.settings.saveButtonLabel); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.settings.saveButtonLabel = this.translate.instant('action.save'); |
|
|
|
|
|
} |
|
|
|
|
|
if (this.settings.resetButtonLabel && this.settings.resetButtonLabel.length) { |
|
|
|
|
|
this.settings.resetButtonLabel = this.utils.customTranslation(this.settings.resetButtonLabel, this.settings.resetButtonLabel); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.settings.resetButtonLabel = this.translate.instant('action.undo'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// For backward compatibility
|
|
|
// For backward compatibility
|
|
|
if (isUndefined(this.settings.showActionButtons)) { |
|
|
if (isUndefined(this.settings.showActionButtons)) { |
|
|
this.settings.showActionButtons = true; |
|
|
this.settings.showActionButtons = true; |
|
|
@ -338,25 +343,40 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
|
|
|
|
|
|
|
|
private updateWidgetDisplaying() { |
|
|
private updateWidgetDisplaying() { |
|
|
this.changeAlignment = (this.ctx.$container && this.ctx.$container[0].offsetWidth < 620); |
|
|
this.changeAlignment = (this.ctx.$container && this.ctx.$container[0].offsetWidth < 620); |
|
|
this.smallWidthContainer = (this.ctx.$container && this.ctx.$container[0].offsetWidth < 420); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onDataUpdated() { |
|
|
public onDataUpdated() { |
|
|
this.ngZone.run(() => { |
|
|
// this.ngZone.run(() => {
|
|
|
this.updateWidgetData(this.subscription.data); |
|
|
this.updateWidgetData(this.subscription.data); |
|
|
this.ctx.detectChanges(); |
|
|
this.ctx.detectChanges(); |
|
|
}); |
|
|
// });
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private resize() { |
|
|
private resize() { |
|
|
this.ngZone.run(() => { |
|
|
// this.ngZone.run(() => {
|
|
|
this.updateWidgetDisplaying(); |
|
|
this.updateWidgetDisplaying(); |
|
|
this.ctx.detectChanges(); |
|
|
this.ctx.detectChanges(); |
|
|
}); |
|
|
// });
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public getGroupTitle(datasource: Datasource): string { |
|
|
public getGroupTitle(datasource: Datasource): string { |
|
|
return createLabelFromDatasource(datasource, this.settings.groupTitle); |
|
|
const groupTitle = createLabelFromDatasource(datasource, this.settings.groupTitle); |
|
|
|
|
|
return this.utils.customTranslation(groupTitle, groupTitle); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public getErrorMessageText(errorMessage, defaultMessage, messageValues?): string { |
|
|
|
|
|
let messageText; |
|
|
|
|
|
if (errorMessage && errorMessage.length) { |
|
|
|
|
|
messageText = this.utils.customTranslation(errorMessage, errorMessage); |
|
|
|
|
|
} else if (defaultMessage && defaultMessage.length) { |
|
|
|
|
|
if (!messageValues) { |
|
|
|
|
|
messageValues = {}; |
|
|
|
|
|
} |
|
|
|
|
|
messageText = this.translate.instant(defaultMessage, messageValues); |
|
|
|
|
|
} else { |
|
|
|
|
|
messageText = ''; |
|
|
|
|
|
} |
|
|
|
|
|
return messageText; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public visibleKeys(source: MultipleInputWidgetSource): MultipleInputWidgetDataKey[] { |
|
|
public visibleKeys(source: MultipleInputWidgetSource): MultipleInputWidgetDataKey[] { |
|
|
@ -480,8 +500,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
|
|
if (tasks.length) { |
|
|
if (tasks.length) { |
|
|
forkJoin(tasks).subscribe( |
|
|
forkJoin(tasks).subscribe( |
|
|
() => { |
|
|
() => { |
|
|
// this.multipleInputFormGroup.reset(undefined, {emitEvent: false});
|
|
|
|
|
|
this.multipleInputFormGroup.markAsPristine(); |
|
|
this.multipleInputFormGroup.markAsPristine(); |
|
|
|
|
|
this.ctx.detectChanges(); |
|
|
if (this.settings.showResultMessage) { |
|
|
if (this.settings.showResultMessage) { |
|
|
this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'), |
|
|
this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'), |
|
|
1000, 'bottom', 'left', this.toastTargetId); |
|
|
1000, 'bottom', 'left', this.toastTargetId); |
|
|
@ -494,8 +514,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
// this.multipleInputFormGroup.reset(undefined, {emitEvent: false});
|
|
|
|
|
|
this.multipleInputFormGroup.markAsPristine(); |
|
|
this.multipleInputFormGroup.markAsPristine(); |
|
|
|
|
|
this.ctx.detectChanges(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|