From fd4b63d1e6d6111ff7656f57b802c9b7c468c041 Mon Sep 17 00:00:00 2001 From: phamt Date: Tue, 25 Oct 2011 14:53:59 +0000 Subject: [PATCH] Add default user entry option git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10884 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvmUtils.js | 65 +++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 256d8113e..57c619d9c 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -2246,7 +2246,68 @@ function createZProvisionNew(inst) { provNew.append(os); // Create user entry input - var userEntry = $('
'); + var defaultChkbox = $('').click(function() { + // Remove any warning messages + $(this).parents('.form').find('.ui-state-error').remove(); + + // Get tab ID + var thisTabId = $(this).parents('.ui-tabs-panel').attr('id'); + + // Get objects for HCP, user ID, and group + var hcp = $('#' + thisTabId + ' input[name=hcp]'); + var userId = $('#' + thisTabId + ' input[name=userId]'); + var group = $('#' + thisTabId + ' input[name=group]'); + + // Get default user entry when clicked + if ($(this).attr('checked')) { + if (!hcp.val() || !group.val() || !userId.val()) { + // Show warning message + var warn = createWarnBar('Please specify the hardware control point, group, and user ID before checking this box'); + warn.prependTo($(this).parents('.form')); + + // Highlight empty fields + jQuery.each([hcp, group, userId], function() { + if (!$(this).val()) { + $(this).css('border', 'solid #FF0000 1px'); + } + }); + } else { + // Un-highlight empty fields + jQuery.each([hcp, group, userId], function() { + $(this).css('border', 'solid #BDBDBD 1px'); + }); + + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : 'getdefaultuserentry;' + hcp.val() + ';' + group.val(), + msg : thisTabId + }, + + success:function(data) { + // Populate user entry + var tabId = data.msg; + var entry = new String(data.rsp); + var userId = $('#' + tabId + ' input[name=userId]').val(); + entry = entry.replace(new RegExp('LXUSR', 'g'), userId); + $('#' + tabId + ' textarea:visible').val(entry); + } + }); + } + } else { + $('#' + thisTabId + ' textarea:visible').val(''); + + // Un-highlight empty fields + jQuery.each([hcp, group, userId], function() { + $(this).css('border', 'solid #BDBDBD 1px'); + }); + } + }); + var userEntry = $('
'); + userEntry.append($('').append(defaultChkbox, 'Use default')); provNew.append(userEntry); // Create disk table @@ -2388,7 +2449,7 @@ function createZProvisionNew(inst) { var errMsg = ''; // Get tab ID - var thisTabId = $(this).parent().parent().parent().attr('id'); + var thisTabId = $(this).parents('.ui-tabs-panel').attr('id'); // Get provision tab instance var inst = thisTabId.replace('zvmProvisionTab', '');