File

src/app/components/feedback-selection/feedback-selection.component.ts

Description

Drop-down input for selecting the feedback-level of a ModelChecking request. Persists the selection throughout refreshed.

Metadata

Index

Properties
Methods
Accessors

Constructor

Public constructor(store: Store<State>)
Parameters :
Name Type Optional
store Store<State> No

Methods

Public onSelectionChange
onSelectionChange(change: MatSelectChange)
Parameters :
Name Type Optional
change MatSelectChange No
Returns : void

Properties

Public Readonly feedbackOptions
Default value : feedbackOptions
Public Readonly selectedFeedback$
Default value : this.store.select('settings').pipe(map((settings) => settings.selectedFeedback))
Private Readonly selectionInput
Type : MatSelect
Decorators :
@ViewChild('selectionInput')

Accessors

selectedFeedback
getselectedFeedback()
import { Component, ViewChild } from '@angular/core';
import { MatLegacySelect as MatSelect, MatLegacySelectChange as MatSelectChange } from '@angular/material/legacy-select';
import { Store } from '@ngrx/store';
import { map } from 'rxjs/operators';

import { Feedback } from 'src/app/model/api/model-checker-request';
import { setSelectedFeedback } from 'src/app/store/actions';
import { State } from 'src/app/store/state';

interface FeedbackOption {
  feedback: Feedback;
  name: string; // Translation key for button text.
  description: string; // Translation key for info-tooltip.
}

const feedbackOptions: FeedbackOption[] = [
  {
    feedback: 'full',
    name: 'feedback.full.name',
    description: 'feedback.full.description',
  },
  {
    feedback: 'relevant',
    name: 'feedback.relevant.name',
    description: 'feedback.relevant.description',
  },
  {
    feedback: 'minimal',
    name: 'feedback.minimal.name',
    description: 'feedback.minimal.description',
  },
];

/**
 * Drop-down input for selecting the feedback-level of a ModelChecking request.
 * Persists the selection throughout refreshed.
 */
@Component({
  selector: 'apollo-feedback-selection',
  templateUrl: './feedback-selection.component.html',
  styleUrls: ['./feedback-selection.component.scss'],
})
export class FeedbackSelectionComponent {
  @ViewChild('selectionInput') private readonly selectionInput!: MatSelect;

  public readonly feedbackOptions = feedbackOptions;

  public readonly selectedFeedback$ = this.store.select('settings').pipe(map((settings) => settings.selectedFeedback));

  public constructor(private readonly store: Store<State>) {}

  public get selectedFeedback(): Feedback {
    return this.selectionInput.value;
  }

  public onSelectionChange(change: MatSelectChange): void {
    this.store.dispatch(setSelectedFeedback({ feedback: change.value }));
  }
}
<mat-form-field>
  <mat-label>{{ "feedback.title" | translate }}</mat-label>
  <mat-select #selectionInput (selectionChange)="onSelectionChange($event)" [value]="selectedFeedback$ | async">
    <mat-option
      *ngFor="let feedbackOption of feedbackOptions"
      [value]="feedbackOption.feedback"
      [matTooltip]="feedbackOption.description | translate"
      matTooltipPosition="left"
      matTooltipShowDelay="250"
      matTooltipHideDelay="250"
    >
      {{ feedbackOption.name | translate }}
    </mat-option>
  </mat-select>
</mat-form-field>

./feedback-selection.component.scss

:host {
  display: block;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""