Skip to content

ComponentCanDeactivate

reference
1 min readUpdated

Kind: Class

Source: Pams/Web/Pams.Web/Client/app/pipes/CanDeactivateGuard.ts (line 5)

Part of: Pams

ComponentCanDeactivate defines a canDeactivate() check for components that participate in deactivation decisions. Callers use the boolean result to determine whether the current component can be left.

Methods

MethodSignatureReturns
canDeactivatecanDeactivate()boolean

Diagram

mermaid
graph LR
  Component[ComponentCanDeactivate] --> Check[canDeactivate()]
  Check --> Result{boolean result}
  Result -->|true| Allow[Allow deactivation]
  Result -->|false| Block[Block deactivation]

Usage

ts
import { ComponentCanDeactivate } from "./CanDeactivateGuard";

class EditorComponent extends ComponentCanDeactivate {
  private hasUnsavedChanges = true;

  canDeactivate(): boolean {
    return !this.hasUnsavedChanges;
  }
}

const editor = new EditorComponent();

if (editor.canDeactivate()) {
  console.log("Component can be deactivated.");
} else {
  console.log("Stay on the current component.");
}

AI Coding Instructions

  • Keep canDeactivate() synchronous and return a boolean.
  • Override canDeactivate() in components that need to prevent leaving when state is incomplete or unsaved.
  • Return true only when the component may be deactivated; return false to block the action.
  • Keep deactivation checks focused on component state rather than navigation side effects.

Used by

20 references from 20 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (20)

  • NewBranchComponentPams/Web/Pams.Web/Client/app/components/configuration/company/main-branch/new.branch.component.ts:1
  • DashboardSettingsDetailsComponentPams/Web/Pams.Web/Client/app/components/configuration/dashboard-settings/dashboard-settings-details/dashboard-settings-details.component.ts:1
  • ReportsSettingsDetailsComponentPams/Web/Pams.Web/Client/app/components/configuration/reports-settings/reports-settings-details/reports-settings-details.component.ts:1
  • ProductSerialCombinationComponentPams/Web/Pams.Web/Client/app/components/configuration/serials-compinations/product-serial-combination/product-serial-combination.component.ts:1
  • SerialCombinationFormComponentPams/Web/Pams.Web/Client/app/components/configuration/serials-compinations/serial-combination/serial-combination-form/serial-combination-form.component.ts:1
  • NewActivityComponentPams/Web/Pams.Web/Client/app/components/dashboard/my-desk/activities/new-activity/new-activity.component.ts:1
  • NewTasksComponentPams/Web/Pams.Web/Client/app/components/dashboard/my-desk/tasks/new-tasks/new-tasks.component.ts:1
  • InvoiceDetailsComponentPams/Web/Pams.Web/Client/app/components/invoices/invoice-details/invoice-details.component.ts:1

…and 12 more.

Was this page helpful?

Download as PDF