Skip to content
Snippets Groups Projects
Commit 72babcf3 authored by jojohoch's avatar jojohoch
Browse files

Rename event "navigateTo" to "buttonActionEvent"

parent ba704413
No related branches found
No related tags found
No related merge requests found
......@@ -19,11 +19,10 @@ import { ElementComponent } from '../../directives/element-component.directive';
[style.font-style]="elementModel.styling.italic ? 'italic' : ''"
[style.text-decoration]="elementModel.styling.underline ? 'underline' : ''"
[style.border-radius.px]="elementModel.styling.borderRadius"
(click)="$event.preventDefault(); elementModel.action && elementModel.actionParam !== null ?
navigateTo.emit({
action: elementModel.action,
param: elementModel.actionParam
}) : false">
(click)="$event.preventDefault();
elementModel.action && elementModel.actionParam !== null ?
buttonActionEvent.emit($any({ action: elementModel.action, param: elementModel.actionParam})) :
false">
<!--preventDefault to prevent form submission-->
{{elementModel.label}}
</a>
......@@ -41,25 +40,19 @@ import { ElementComponent } from '../../directives/element-component.directive';
[style.text-decoration]="elementModel.styling.underline ? 'underline' : ''"
[style.border-radius.px]="elementModel.styling.borderRadius"
(click)="elementModel.action && elementModel.actionParam !== null ?
navigateTo.emit({
action: elementModel.action,
param: elementModel.actionParam
}) :
false">
buttonActionEvent.emit($any({ action: elementModel.action, param: elementModel.actionParam })) :
false">
{{elementModel.label}}
</button>
<input
*ngIf="elementModel.imageSrc" type="image"
[src]="elementModel.imageSrc | safeResourceUrl"
[class]="elementModel.position?.dynamicPositioning &&
*ngIf="elementModel.imageSrc" type="image"
[src]="elementModel.imageSrc | safeResourceUrl"
[class]="elementModel.position?.dynamicPositioning &&
!elementModel.position?.fixedSize ? 'dynamic-image' : 'static-image'"
[alt]="'imageNotFound' | translate"
(click)="elementModel.action && elementModel.actionParam !== null?
navigateTo.emit({
action: elementModel.action,
param: elementModel.actionParam
}) :
false">
[alt]="'imageNotFound' | translate"
(click)="elementModel.action !== null && elementModel.actionParam !== null?
buttonActionEvent.emit($any({ action: elementModel.action, param: elementModel.actionParam })) :
false">
`,
styles: [
'.dynamic-image {width: 100%; height: fit-content;}',
......@@ -69,5 +62,5 @@ import { ElementComponent } from '../../directives/element-component.directive';
})
export class ButtonComponent extends ElementComponent {
@Input() elementModel!: ButtonElement;
@Output() navigateTo = new EventEmitter<ButtonEvent>();
@Output() buttonActionEvent = new EventEmitter<ButtonEvent>();
}
......@@ -66,7 +66,7 @@ export class CompoundGroupElementComponent extends ElementFormGroupDirective imp
this.manageOnKeyDown(child as TextFieldSimpleComponent, childModel);
}
if (childModel.type === 'button') {
this.addNavigationEventListener(child as ButtonComponent);
this.addButtonActionEventListener(child as ButtonComponent);
}
});
}
......@@ -129,24 +129,24 @@ export class CompoundGroupElementComponent extends ElementFormGroupDirective imp
}
}
private addNavigationEventListener(button: ButtonComponent) {
button.navigateTo
private addButtonActionEventListener(button: ButtonComponent) {
button.buttonActionEvent
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(navigationEvent => {
switch (navigationEvent.action) {
.subscribe(buttonEvent => {
switch (buttonEvent.action) {
case 'unitNav':
this.veronaPostService.sendVopUnitNavigationRequestedNotification(
(navigationEvent.param as UnitNavParam)
(buttonEvent.param as UnitNavParam)
);
break;
case 'pageNav':
this.navigationService.setPage(navigationEvent.param as number);
this.navigationService.setPage(buttonEvent.param as number);
break;
case 'highlightText':
this.anchorService.toggleAnchor(navigationEvent.param as string);
this.anchorService.toggleAnchor(buttonEvent.param as string);
break;
case 'stateVariableChange':
this.unitStateService.changeElementCodeValue(navigationEvent.param as ValueChangeElement);
this.unitStateService.changeElementCodeValue(buttonEvent.param as ValueChangeElement);
break;
default:
}
......
......@@ -2,7 +2,7 @@
*ngIf="elementModel.type === 'button'"
#elementComponent
[elementModel]="elementModel | cast: ButtonElement"
(navigateTo)="navigateTo($event)">
(buttonActionEvent)="applyButtonAction($event)">
</aspect-button>
<aspect-frame
*ngIf="elementModel.type === 'frame'"
......
......@@ -46,21 +46,21 @@ export class InteractiveGroupElementComponent extends ElementGroupDirective impl
this.pageIndex);
}
navigateTo(navigationEvent: ButtonEvent): void {
switch (navigationEvent.action) {
applyButtonAction(buttonEvent: ButtonEvent): void {
switch (buttonEvent.action) {
case 'unitNav':
this.veronaPostService.sendVopUnitNavigationRequestedNotification(
(navigationEvent.param as UnitNavParam)
(buttonEvent.param as UnitNavParam)
);
break;
case 'pageNav':
this.navigationService.setPage(navigationEvent.param as number);
this.navigationService.setPage(buttonEvent.param as number);
break;
case 'highlightText':
this.anchorService.toggleAnchor(navigationEvent.param as string);
this.anchorService.toggleAnchor(buttonEvent.param as string);
break;
case 'stateVariableChange':
this.unitStateService.changeElementCodeValue(navigationEvent.param as ValueChangeElement);
this.unitStateService.changeElementCodeValue(buttonEvent.param as ValueChangeElement);
break;
default:
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment