Skip to content

Fix missing getWiresLocation() helper method - #219

Merged
grantcopley merged 6 commits into
nextfrom
copilot/add-customize-progress-bar
Oct 30, 2025
Merged

Fix missing getWiresLocation() helper method#219
grantcopley merged 6 commits into
nextfrom
copilot/add-customize-progress-bar

Conversation

Copilot AI commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

Fix missing getWiresLocation() helper method

Overview

This PR fixes a bug where getWiresLocation() was being called in CBWIREController.cfc but the method didn't exist, which would cause errors when using module component paths.

Changes

Bug Fix (CBWIREController.cfc)

  1. ✅ Added missing getWiresLocation() private helper method
  2. ✅ Refactored getComponentDSL() to use getWiresLocation() instead of duplicating the logic

Implementation

The getWiresLocation() helper method centralizes the logic for determining the wires location:

private function getWiresLocation(){
    return moduleSettings.keyExists( "wiresLocation" ) ? moduleSettings.wiresLocation : "wires";
}

Now used consistently in:

  • getModuleComponentPath() - For module component path resolution
  • getComponentDSL() - For standard component path resolution

This eliminates code duplication and ensures consistent behavior across both methods.

Note on Progress Bar Settings

The original issue requested adding configuration for wire:navigate progress bar customization. However, these settings already exist and are working correctly:

  • showProgressBar - Enable/disable the progress bar (default: true)
  • progressBarColor - Customize the progress bar color (default: ##2299dd)

These settings are properly implemented in:

  • ModuleConfig.cfc: Configuration defaults
  • models/scripts.cfm: Adds data-no-progress-bar attribute when disabled
  • models/styles.cfm: Sets CSS variable --livewire-progress-bar-color

Usage (Already Available)

// config/ColdBox.cfc
component {
    function configure() {
        moduleSettings = {
            "cbwire" = {
                // Enable or disable the progress bar (default: true)
                "showProgressBar" = false,
                
                // Customize the color (default: ##2299dd)
                "progressBarColor" = "##cc0000"
            }
        };
    }
}

Fixes #170

Original prompt

This section details on the original issue you should resolve

<issue_title>Add ability to customize or disable Livewire progress bar on wire:navigate</issue_title>
<issue_description>We need to add the ability to customize the progress bar that is displayed by default when using wire:navigate and the page takes longer than 200ms to load.

Here's how Livewire allows their users to configure the progress bar.
https://livewire.laravel.com/docs/navigate#customizing-the-progress-bar

We need to add configuration settings for like to other configurations
https://cbwire.ortusbooks.com/v5/configuration

Here's an example with the defaults set.

// config/ColdBox.cfc
component {
    function configure() {
        moduleSettings = {
            "cbwire" = {
                // Navigation
               "navigateShowProgressBar" = true,
               "navigateProgressBarColor" = "##2299dd"
            }
        };
    }
}
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

Fixes #170


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits October 13, 2025 15:20
Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to customize Livewire progress bar Add ability to customize or disable wire:navigate progress bar Oct 13, 2025
Copilot AI requested a review from grantcopley October 13, 2025 15:28

@grantcopley grantcopley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I forgot we already have "showProgressBar" and "progressBarColor" configuration settings and I don't want to change them. But check to the code to make sure these settings actually affect the progress bar because I don't believe they are working currently.

…or are already working

Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>

Copilot AI commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

@copilot I forgot we already have "showProgressBar" and "progressBarColor" configuration settings and I don't want to change them. But check to the code to make sure these settings actually affect the...

You're absolutely right! The settings showProgressBar and progressBarColor already exist and ARE working correctly. I've reverted my changes that renamed them.

The existing settings properly control the wire:navigate progress bar:

  • showProgressBar adds/removes the data-no-progress-bar attribute in scripts.cfm
  • progressBarColor sets the CSS variable --livewire-progress-bar-color in styles.cfm

The only change I kept was adding the missing getWiresLocation() helper method which was being called but didn't exist (bug fix).

Commit: Revert to original setting names - showProgressBar and progressBarColor are already working

Copilot AI changed the title Add ability to customize or disable wire:navigate progress bar Fix missing getWiresLocation() helper method Oct 13, 2025
Copilot AI requested a review from grantcopley October 13, 2025 15:48
@grantcopley

Copy link
Copy Markdown
Collaborator

@copilot Should we not also call getWiresLocation() here? Double check.

        if ( !local.componentDSL contains "wires." ) {
            // Get the default wires location from our setttings
            if ( moduleSettings.keyExists( "wiresLocation" ) ) {
                local.componentDSL = moduleSettings.wiresLocation & "." & local.componentDSL;
            } else {
                // Fallback
            local.componentDSL = "wires." & local.componentDSL;
            }
        }

… logic

Co-authored-by: grantcopley <1197835+grantcopley@users.noreply.github.com>

Copilot AI commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Should we not also call getWiresLocation() here? Double check.

...

Good catch! Yes, we should use getWiresLocation() there to avoid duplicating the logic. I've updated getComponentDSL() to call the helper method instead of repeating the same conditional logic.

This ensures both getComponentDSL() and getModuleComponentPath() use the same centralized logic for determining the wires location.

Commit: Use getWiresLocation() helper in getComponentDSL() to avoid duplicate logic

@grantcopley grantcopley added this to the v5.0 milestone Oct 30, 2025
@grantcopley
grantcopley marked this pull request as ready for review October 30, 2025 15:19
@grantcopley
grantcopley merged commit b22516f into next Oct 30, 2025
1 check passed
@grantcopley
grantcopley deleted the copilot/add-customize-progress-bar branch October 30, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants