Change lable on buttons in audit workspace g_modal.confirm popup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 09:47 AM
Hello All,
I'm trying to change the button labels on this popup from Cancel and OK to Yes and No. Tried switching to g_modal.showFrame and then the functionality was not working properly. Is there a way to change the label in g_modal.confirm? Both client scripts are currently working, just need to change the labels on the buttons for the workspace. Any help is appreciated. Thanks.
Note: UI page is being used for different client script with same functionality on desktop view. Desktop version works fine.
Client Script: Desktop
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if ((oldValue != '3' || oldValue != '4' || oldValue != '7') && (newValue == '3' || newValue == '4' || newValue == '7')) {
var myActionCallbackOK = function() {
submitRemediationNow();
};
var myActionCallbackCancel = function() {
cancelRemediationNow(oldValue);
};
var dlgBody = 'Are you sure you want to continue?';
var dlgClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
var dlg = new dlgClass('glide_confirm_remediation');
dlg.setTitle('Proceed?');
dlg.setPreference('warning', true);
dlg.setPreference('title', dlgBody);
dlg.setPreference('onPromptComplete', myActionCallbackOK.bind(this));
dlg.setPreference('onPromptCancel', myActionCallbackCancel.bind(this));
dlg.render();
}
}
function submitRemediationNow() {
//g_form.save();
}
function cancelRemediationNow(previewState) {
g_form.setValue('state', previewState);
}
Client Script: Audit Workspace (when either closed states is selected, the popup needs to appear with yes and no buttons, when no is clicked, state reverts back to previous value, when yes is clicked, need to save the record with newValue state)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if ((oldValue != '3' || oldValue != '4' || oldValue != '7') && (newValue == '3' || newValue == '4' || newValue == '7')) {
return confirm();
}
function confirm() {
g_modal.confirm("Have you received a notification from the tester?").then(function() {
g_form.save();
return;
}).catch(function() {
g_form.setValue("state", oldValue);
});
}
}
UI Page: glide_confirm_remediation (Desktop)
<style>
/* dialog styles */
.dialog_content {
width: 100%;
vertical-align: top;
min-width: 300px;
padding: 0 0 20px 20px;
}
.dialog_buttons {
display: inline;
text-align: right;
vertical-align:bottom;
white-space: nowrap;
}
.dialog_buttons_row {
text-align: right;
}
.dialog_left_icon {
font-size: 300%;
vertical-align: top;
}
.dialog_left_icon_warn {
color: #81878E;
}
.dialog_left_icon_confirm {
color: #6CE474;
}
</style>
<g:ui_form onsubmit="return invokePromptCallBack('ok');">
<g2:evaluate>
var title = "${RP.getWindowProperties().get('title')}";
title = new GlideStringUtil().unEscapeHTML(title);
var warning = "${RP.getWindowProperties().get('warning')}";
warning = new GlideStringUtil().unEscapeHTML(warning);
</g2:evaluate>
<table border="0" width="100%">
<tr>
<td nowrap="true" style="vertical-align:top;">
<j2:switch on="$[warning]">
<j2:case value="true">
<i id="image_dialog" class="dialog_left_icon dialog_left_icon_warn icon-alert-triangle"/>
</j2:case>
<j2:default>
<i id="image_dialog" class="dialog_left_icon dialog_left_icon_confirm icon-check-circle"/>
</j2:default>
</j2:switch>
</td>
<td>
<table border="0" width="100%">
<tr>
<td class="dialog_content">$[title]</td>
</tr>
<tr >
<td >
<div class="modal-footer"><span class="pull-right"><button class="btn btn-default" id="cancel_button" onclick="invokePromptCallBack('cancel')" style="min-width: 5em;" title="" type="submit">No
</button><button class="btn btn-primary" id="ok_button" onclick="invokePromptCallBack('ok')" style="min-width: 5em;" title="" type="submit">Yes
</button></span></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</g:ui_form>
Client Script on UI page:
function invokePromptCallBack(type) {
var gdw = GlideDialogWindow.get();
if (type == 'ok')
var f = gdw.getPreference('onPromptComplete');
else
var f = gdw.getPreference('onPromptCancel');
if (typeof(f) == 'function') {
try {
f.call(gdw, gdw.getPreference('oldValue'));
} catch(e) {
}
}
gdw.destroy();
return false;
}
var gdw = GlideDialogWindow.get();
var focusButton = gdw.getPreference('defaultButton');
if (focusButton == null)
focusButton = 'cancel_button';
gel(focusButton).focus();