Add inline machine type creation and employee search results
- Add "+ New" button for machine types when adding models on network device pages (firewall, switch, server, access point, camera) - Machine type dropdown now grouped by category (Equipment, Network, PC) - Add firewall device type to savenetworkdevice.asp - Remove employee autocomplete dropdown from global search bar - Add employee search results to search.asp results page - Update data_cache.asp with null-safe CLng handling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -233,20 +233,55 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
|
||||
<option value="">-- Select Machine Type --</option>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
|
||||
<option value="">-- Select Machine Type --</option>
|
||||
<%
|
||||
Dim rsMachineTypes
|
||||
strSQL3 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC"
|
||||
Dim rsMachineTypes, lastCat
|
||||
strSQL3 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
|
||||
Set rsMachineTypes = objConn.Execute(strSQL3)
|
||||
lastCat = ""
|
||||
While Not rsMachineTypes.EOF
|
||||
If rsMachineTypes("category") <> lastCat Then
|
||||
If lastCat <> "" Then Response.Write("</optgroup>")
|
||||
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
|
||||
lastCat = rsMachineTypes("category")
|
||||
End If
|
||||
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
|
||||
rsMachineTypes.MoveNext
|
||||
Wend
|
||||
If lastCat <> "" Then Response.Write("</optgroup>")
|
||||
rsMachineTypes.Close
|
||||
Set rsMachineTypes = Nothing
|
||||
%>
|
||||
</select>
|
||||
<option value="new">+ Add New Type</option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
|
||||
<i class="zmdi zmdi-plus"></i> New
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden section for adding new machine type -->
|
||||
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
|
||||
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
|
||||
<div class="form-group">
|
||||
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
|
||||
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="newmachinetypecategory">Category</label>
|
||||
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
|
||||
<option value="Equipment">Equipment</option>
|
||||
<option value="Network" selected>Network Device</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
|
||||
<i class="zmdi zmdi-close"></i> Cancel
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -552,6 +587,21 @@ $(document).ready(function() {
|
||||
$('#newvendorname').val('').prop('required', false);
|
||||
});
|
||||
|
||||
// Show/hide new machine type section
|
||||
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
|
||||
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
|
||||
$('#newmodelmachinetypeid').val('new');
|
||||
$('#newMachineTypeSection').slideDown();
|
||||
$('#newmachinetypename').prop('required', true);
|
||||
}
|
||||
});
|
||||
|
||||
$('#cancelNewMachineType').on('click', function() {
|
||||
$('#newMachineTypeSection').slideUp();
|
||||
$('#newmodelmachinetypeid').val('');
|
||||
$('#newmachinetypename').val('').prop('required', false);
|
||||
});
|
||||
|
||||
// Form validation
|
||||
$('form').on('submit', function(e) {
|
||||
// If adding new model, make sure fields are filled
|
||||
@@ -578,6 +628,15 @@ $(document).ready(function() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If machine type is 'new', check machine type name
|
||||
if ($('#newmodelmachinetypeid').val() === 'new') {
|
||||
if ($('#newmachinetypename').val().trim() === '') {
|
||||
e.preventDefault();
|
||||
alert('Please enter a machine type name or select an existing type');
|
||||
$('#newmachinetypename').focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user