Hi to all,
My gift of the day.
I spend too much time finding what is the view ID's of those I have on my screen, either by going to the builder or the Inspect element in my browser.
So I coded this little utility that adds the label either to the title or the control. Now, I'm able to see it in bright bold and red directly in the app.
But I only want to see this when I'm in "developer" mode, i.e. usually for me and no one else. So I add the new Developer role in my app and apply it to my account.
Then add this code to the Javascript pane and that's it!
Enjoy,
Norm
ctrnd.com

/////////////////////////////////////////////////////////////////////////////////////////
const SHOW_VIEW_ID = true;
// This must match your App.
var g_accountRoles = {
'Administrator': 'object_12',
'Supervisor': 'object_3',
'Employee': 'object_4',
'Safety Personnel': 'object_8',
'Executive': 'object_13',
'Human Resources': 'object_14',
'Apprentice': 'object_15',
'Accounting': 'object_29',
'SuperAdmin': 'object_32',
'Developer': 'object_35',
}
/////////////////////////////////////////////////////////////////////////////
$(document).on('knack-view-render.any', function (event, view, data) {
if (SHOW_VIEW_ID && Knack.getUserRoles().includes(g_accountRoles['Developer'])) {
var label = document.createElement('label');
label.setAttribute('id', view.key + '-label-id');
label.appendChild(document.createTextNode(' (' + view.key + ')'));
label.setAttribute('style', 'margin-left: 10px; margin-top: 5px; color: red; font-weight: bold;');
if ($('#' + view.key + ' .view-header').length > 0) {
$('#' + view.key + ' .view-header').css({ 'display': 'inline-flex' }).append(label);
} else if ($('#' + view.key + ' .control').length > 0) {
$('#' + view.key + ' .control').css({ 'display': 'inline-flex' }).append(label);
} else {
label.setAttribute('style', 'margin-top: 5px; color: red; font-weight: bold;');
$('#' + view.key).prepend(label);
}
}
})