File

lib/components/reset-plot-setting/reset-plot-setting.component.ts

Description

Button to reset the plot settings back to default.

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor()

Inputs

defaultPlotSetting
resetDisabled
Default value : true

Whether the reset button is disabled

Outputs

resetClick

Event emitter on button click

Methods

reset
reset()
Returns : void

Properties

Readonly defaultPlotSetting
Readonly plotSettings
Default value : input<FormGroup<NshmpPlotSettingFormGroup>>()

Plot settings form state

Readonly resetButtonSize
Default value : input('grid-col-3')

SCSS class of reset button size

Readonly resetClick

Event emitter on button click

Readonly resetDisabled
Default value : true

Whether the reset button is disabled

Readonly resetLabel
Default value : input('Reset')

The reset button label

import {Component, input, output} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {MatButton} from '@angular/material/button';

import {NshmpPlotSettingFormGroup, NshmpPlotSettings} from '../../models';

/**
 * Button to reset the plot settings back to default.
 */
@Component({
  imports: [MatButton],
  selector: 'nshmp-plot-reset-plot-setting',
  styleUrl: './reset-plot-setting.component.scss',
  templateUrl: './reset-plot-setting.component.html',
})
export class NshmpPlotResetPlotSettingComponent {
  /** SCSS class of reset button size */
  readonly resetButtonSize = input('grid-col-3');

  /** Whether the reset button is disabled */
  readonly resetDisabled = input(true);

  /** The reset button label */
  readonly resetLabel = input('Reset');

  /** Plot settings form state */
  readonly plotSettings = input<FormGroup<NshmpPlotSettingFormGroup>>();

  readonly defaultPlotSetting = input<NshmpPlotSettings>();

  /** Event emitter on button click */
  readonly resetClick = output();

  constructor() {}

  reset(): void {
    this.resetClick.emit();

    const plotSettings = this.plotSettings();
    const defaultPlotSetting = this.defaultPlotSetting();
    if (plotSettings && defaultPlotSetting) {
      plotSettings.setValue({
        config: {
          toImageButtonOptions: {
            ...defaultPlotSetting.config.toImageButtonOptions,
          },
        },
        layout: defaultPlotSetting.layout,
      });
    }
  }
}
<!-- Reset Plot Settings Button -->
<div class="grid-row">
  <div class="{{ resetButtonSize() }} reset-button">
    <button
      class="grid-col-12 margin-left-2 error"
      [disabled]="resetDisabled()"
      mat-raised-button
      (click)="reset()"
      type="button"
    >
      {{ resetLabel() }}
    </button>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""