PermissionManagePolicies

new PermissionManagePolicies()

INTERNAL CODE DOCUMENTATION COMPLETE

Permission Manage Policies Controller

A sophisticated Stimulus controller that provides an interactive permission matrix for managing CakePHP authorization policies. Features hierarchical checkbox management with indeterminate states, batch processing for performance, and asynchronous AJAX updates with queue management.

Key Features:

  • Hierarchical checkbox management (class-level controls method-level checkboxes)
  • Indeterminate state indicators for partial selections
  • Batch processing with loading overlay for performance optimization
  • Asynchronous AJAX queue management for reliable server updates
  • Dynamic event listener management with cleanup

Extends

  • Controller

Members

changeQueue :Array

Queue for managing sequential AJAX requests to prevent race conditions

Type:
  • Array

Methods

changeMethod(method, isChecked)

Queue permission change for server update Adds change to queue and processes if not already processing

Parameters:
NameTypeDescription
methodHTMLElement

The method checkbox element

isCheckedBoolean

Whether the checkbox is checked

checkClass(className, permissionId)

Update class-level checkbox state based on method selections Implements three-state logic: checked, unchecked, and indeterminate

Parameters:
NameTypeDescription
classNameString

The class name to check state for

permissionIdString

The permission ID to check state for

classClicked(event)

Handle class-level checkbox clicks Updates all method-level checkboxes and manages indeterminate state

Parameters:
NameTypeDescription
eventEvent

The click event from class checkbox

connect()

Controller initialization and setup Implements batch processing for performance optimization when dealing with large permission matrices. Shows loading overlay during processing.

disconnect()

Clean up event listeners on controller disconnect Removes all dynamically added event listeners to prevent memory leaks

hideLoadingOverlay()

Remove loading overlay after processing completion Cleans up spinner overlay from permissions matrix

methodClicked(event)

Handle method-level checkbox clicks Updates parent class checkbox state and queues server update

Parameters:
NameTypeDescription
eventEvent

The click event from method checkbox

policyClassTargetConnected(element)

Event handler for policy class target connection Sets up click event listeners for class-level checkboxes

Parameters:
NameTypeDescription
elementHTMLElement

The connected policy class checkbox element

policyMethodTargetConnected(element)

Event handler for policy method target connection Sets up click event listeners for method-level checkboxes

Parameters:
NameTypeDescription
elementHTMLElement

The connected policy method checkbox element

processQueue()

Process queued permission changes sequentially Handles AJAX communication with server for policy updates Maintains queue integrity and prevents race conditions

showLoadingOverlay()

Display loading overlay during batch processing Creates a Bootstrap spinner overlay for performance indication