DanielCaspers / CA-Portal

1 stars 0 forks source link

Checklist.item.URL variable tag exchange #68

Closed scaspers closed 2 years ago

scaspers commented 2 years ago

Could we exchange\replace a tag (ie. {?webaddr?} ) in the checklistItemURL from DI before it is used in CA or SA?

If the URL from DI is "{?webaddr?}/mv/article/Lower-Ball-Joint" make it be "https://www.protech-automotive.com/mv/article/Lower-Ball-Joint"

The replacement would be the same URL used in the link for the logo which is currently the baseURL for each store.

This will allow us to maintain branding for these informational URL links.

DanielCaspers commented 2 years ago

Here you can see a video demonstrating the change in DI, SA, CA.

Note that the substitution token will work as a prefix only and was corrected to '{?webaddr?}' after the video was recorded.

Here's the relevant logic extracted from the code. Feel free to look through the pull request in more detail if you have questions.

New code only needs to be loaded onto ca2 and sa2 for this change to go into affect. No changes were made to DI to facilitate this.

`

    this.cannedResponseBaseUrl = storeInfo.StoreWebAssets.WebAddress;

private readonly urlVariableSubstitutionToken = '{?webaddr?}';

/**
 * If the URI contains the variable substitution token at the beginning of the URI,
 * replace it to allow per-domain branding of help topic content.
 * @param url returned from Digital Inspection help content management prior to variable substitution
 */
public transformCannedResponseUrl(url: string): string {
    if (!!this.cannedResponseBaseUrl && url.startsWith(this.urlVariableSubstitutionToken)) {
        return url.replace(this.urlVariableSubstitutionToken, this.cannedResponseBaseUrl);
    }

    return url;
}

`