DIVDialog.Title=Digital Identity Verification
DIVDialog.Description=Please review the client information and select an email address to initiate digital identity verification.
DIVDialog.FirstName=Legal First Name
DIVDialog.LastName=Legal Last Name
DIVDialog.DateOfBirth=Date of Birth
DIVDialog.PreferredLanguage=Preferred Language
DIVDialog.IACode=Investment Advisor Code
DIVDialog.EmailAddress=Email Address
DIVDialog.Initiate=Initiate Verification
DIVDialog.Cancel=Cancel
DIVDialog.Cancel.Confirmation=Are you sure you want to cancel?
msg.DIV.EmailAddress.required=Please select an email address.
———-
Okay, let's structure this revised implementation cleanly. It incorporates the Tool/View pattern, improvements to email handling, use of IDs for buttons, and placeholder logic for the API call.
Revised Implementation Files
Here are the three core files with the integrated logic and fixes:
1. DigitalIdentityVerificationView.js
(Handles content/logic inside the dialog)
/**
* Copyright (c) 2024 Canadian Imperial Bank of Commerce. All rights reserved.
*
* View component responsible for rendering the content and handling interactions
* within the Digital Identity Verification dialog.
*
* @constructor
* @param {!Object} settings
*/
com.cibc.go.myclient.view.DigitalIdentityVerification = (function($, utilities, global) {
'use strict'; // Enable strict mode
utilities.assertArrayElementsNotNull(arguments); // Check dependencies on load
/**
* Constructor for the View.
* @param {Object} settings Configuration options passed during instantiation.
*/
var DigitalIdentityVerificationView = function(settings) {
var self = this;
// Store settings if needed, e.g., reference to dialog container
self.settings = $.extend(true, {}, settings);
// Initialize error messages array for this instance
self.errorMessages = [];
// Store reference to the compiled Soy template function
self.soyTemplate = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.main;
self.errorPanelTemplate = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.errorPanel;
};
/**
* Displays error messages within the dialog's designated error panel area.
* @param {Array} errorMessages List of error strings to display.
* @param {jQuery} $container The jQuery object representing the dialog content area.
* @private
*/
function _displayMessages(errorMessages, $container) {
// Ensure container context for selector
$container.find('.error-Panel').remove(); // Clear previous errors
if (errorMessages && errorMessages.length > 0) {
var errorPanelHtml = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.errorPanel({
errorMessages: errorMessages
});
// Prepend error panel within the main content area (adjust selector if needed)
$container.find('.input-panel').prepend(errorPanelHtml);
}
}
// --- Prototype Methods ---
DigitalIdentityVerificationView.prototype = /**
* @lends {com.cibc.go.myclient.view.DigitalIdentityVerification.prototype}
*/ ({
/**
* Renders the Digital Identity Verification view content into the provided container.
* @param {jQuery} $container The jQuery object representing the dialog's content area.
*/
renderIn: function($container) {
var self = this;
self.errorMessages = []; // Reset errors for this render pass
var client = global.CurrentPage.client; // Get client model reference
if (!client) {
self.errorMessages.push(global.Messages.get('DIV.Error.NoClientData') || 'Client data is unavailable.');
_displayMessages(self.errorMessages, $container); // Show error immediately
// Optionally render a minimal template showing only the error
$container.html(self.errorPanelTemplate({ errorMessages: self.errorMessages }));
return self; // Stop rendering
}
// Prepare data structure for Soy template
// ** CRITICAL: Verify these FieldConstants and the structure of 'contactMethods' and 'email' **
var clientData = {
firstName: client.get(com.cibc.go.myclient.model.FieldConstants.Client.firstName.id),
lastName: client.get(com.cibc.go.myclient.model.FieldConstants.Client.lastName.id),
dateOfBirth: client.get(com.cibc.go.myclient.model.FieldConstants.Client.dateOfBirth.id), // Ensure format is display-ready
preferredLanguage: client.get(com.cibc.go.myclient.model.FieldConstants.Client.preferredLanguage.id),
iaCode: client.get(com.cibc.go.myclient.model.FieldConstants.Client.iaCode.id),
emails: [] // Initialize empty email array
};
Apr 12, 2025 - 17:36
0
DIVDialog.Title=Digital Identity Verification
DIVDialog.Description=Please review the client information and select an email address to initiate digital identity verification.
DIVDialog.FirstName=Legal First Name
DIVDialog.LastName=Legal Last Name
DIVDialog.DateOfBirth=Date of Birth
DIVDialog.PreferredLanguage=Preferred Language
DIVDialog.IACode=Investment Advisor Code
DIVDialog.EmailAddress=Email Address
DIVDialog.Initiate=Initiate Verification
DIVDialog.Cancel=Cancel
DIVDialog.Cancel.Confirmation=Are you sure you want to cancel?
msg.DIV.EmailAddress.required=Please select an email address.
———-
Okay, let's structure this revised implementation cleanly. It incorporates the Tool/View pattern, improvements to email handling, use of IDs for buttons, and placeholder logic for the API call.
Revised Implementation Files
Here are the three core files with the integrated logic and fixes:
1. DigitalIdentityVerificationView.js
(Handles content/logic inside the dialog)
/**
* Copyright (c) 2024 Canadian Imperial Bank of Commerce. All rights reserved.
*
* View component responsible for rendering the content and handling interactions
* within the Digital Identity Verification dialog.
*
* @constructor
* @param {!Object} settings
*/
com.cibc.go.myclient.view.DigitalIdentityVerification = (function($, utilities, global) {
'use strict'; // Enable strict mode
utilities.assertArrayElementsNotNull(arguments); // Check dependencies on load
/**
* Constructor for the View.
* @param {Object} settings Configuration options passed during instantiation.
*/
var DigitalIdentityVerificationView = function(settings) {
var self = this;
// Store settings if needed, e.g., reference to dialog container
self.settings = $.extend(true, {}, settings);
// Initialize error messages array for this instance
self.errorMessages = [];
// Store reference to the compiled Soy template function
self.soyTemplate = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.main;
self.errorPanelTemplate = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.errorPanel;
};
/**
* Displays error messages within the dialog's designated error panel area.
* @param {Array} errorMessages List of error strings to display.
* @param {jQuery} $container The jQuery object representing the dialog content area.
* @private
*/
function _displayMessages(errorMessages, $container) {
// Ensure container context for selector
$container.find('.error-Panel').remove(); // Clear previous errors
if (errorMessages && errorMessages.length > 0) {
var errorPanelHtml = com.cibc.go.myclient.soy.view.DigitalIdentityVerification.errorPanel({
errorMessages: errorMessages
});
// Prepend error panel within the main content area (adjust selector if needed)
$container.find('.input-panel').prepend(errorPanelHtml);
}
}
// --- Prototype Methods ---
DigitalIdentityVerificationView.prototype = /**
* @lends {com.cibc.go.myclient.view.DigitalIdentityVerification.prototype}
*/ ({
/**
* Renders the Digital Identity Verification view content into the provided container.
* @param {jQuery} $container The jQuery object representing the dialog's content area.
*/
renderIn: function($container) {
var self = this;
self.errorMessages = []; // Reset errors for this render pass
var client = global.CurrentPage.client; // Get client model reference
if (!client) {
self.errorMessages.push(global.Messages.get('DIV.Error.NoClientData') || 'Client data is unavailable.');
_displayMessages(self.errorMessages, $container); // Show error immediately
// Optionally render a minimal template showing only the error
$container.html(self.errorPanelTemplate({ errorMessages: self.errorMessages }));
return self; // Stop rendering
}
// Prepare data structure for Soy template
// ** CRITICAL: Verify these FieldConstants and the structure of 'contactMethods' and 'email' **
var clientData = {
firstName: client.get(com.cibc.go.myclient.model.FieldConstants.Client.firstName.id),
lastName: client.get(com.cibc.go.myclient.model.FieldConstants.Client.lastName.id),
dateOfBirth: client.get(com.cibc.go.myclient.model.FieldConstants.Client.dateOfBirth.id), // Ensure format is display-ready
preferredLanguage: client.get(com.cibc.go.myclient.model.FieldConstants.Client.preferredLanguage.id),
iaCode: client.get(com.cibc.go.myclient.model.FieldConstants.Client.iaCode.id),
emails: [] // Initialize empty email array
};
// Populate the emails array using the helper function
self._getClientEmails(client, clientData.emails); // Pass client model and target array
// Check if any valid emails were actually found AFTER trying to fetch them
var hasValidEmail = clientData.emails.some(function(email){ return email && email.emailId; });
if (!hasValidEmail) {
self.errorMessages.push(global.Messages.get('DIV.No.Email.Available') || 'No valid email address available for this client.');
}
// Generate HTML using Soy template
var html = self.soyTemplate({
messages: global.Messages.getRaw(), // Pass all messages
client: clientData,
// Pass initial errors (e.g., "No Email") to Soy template if needed,
// otherwise _displayMessages handles it later.
// errorMessages: self.errorMessages
});
// Inject HTML into the dialog container
$container.html(html);
// Display any errors collected so far (like "No Email")
_displayMessages(self.errorMessages, $container);
// Set up event handlers for buttons, email select, etc.
self._setupDIVDetails($container, clientData); // Pass clientData for use in handlers
return self;
},
/**
* Fetches and processes client email addresses.
* ** NOTE: This logic requires verification against the actual client data model structure. **
* @param {Object} client The client model object.
* @param {Array