Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Recreate the color autocomplete field, when a new field is added

  • Loading branch information...
commit 8f8ce2b7e113836a527efe4c0df50ef36552b88c 1 parent b889ef3
Bob Van Landuyt authored
View
4 app/views/devices/_form.html.erb
@@ -28,11 +28,11 @@
</div>
<div id="interfaces">
<% unless device.interfaces.size > 1 %>
- <fieldset id="quickadd">
+ <fieldset id="quickadd" class="clearfix">
<legend>Quickly add interfaces</legend>
<p>Ethernet interfaces:<input id="count_ethernet_interfaces" type="text"></input></p>
<p>Power interfaces:<input id="count_power_interfaces" type="text"></input></p>
- <p><a href="#" id="create_interfaces" class="button">Create interfaces</a></p>
+ <a href="#" id="create_interfaces" class="button" style="height:15px;display:block;">Create interfaces</a>
</fieldset>
<% end %>
<fieldset style="float:left">
View
11 features/manage_devices.feature
@@ -10,16 +10,17 @@ Background:
And a server_rack exist with datacenter: the datacenter, name: "devices testrack"
And 42 units exist with server_rack: the server_rack
-Scenario: Create a device without any interfaces
- And I am on the home page
+Scenario: Create a device
+ Given I am on the home page
When I follow "Add device"
When I fill in "device_name" with "Testserver"
- And I fill in "device_comment" with "Some comment for ipthe restserver"
- And I select "1" from "device_unit_ids"
- And I press "Create Device"
+ And I fill in "device_comment" with "Some comment"
+ And I select 1 from "device_unit_ids"
+ And I press "Create device"
Then I should see "Device was successfully created."
And I should see "1: Server: Testserver"
+
Scenario: Delete a device
Given a "42"U device exists inside the server_rack with name: "Device1"
View
27 public/javascripts/application.js
@@ -88,17 +88,7 @@ $(function(){
minHeight:300
});
$('#modal_form > form > div.tabs ').tabs();
- $(".connection_color").autocomplete({
- source: function(request, response){
- $.ajax({
- url: "/search/find_colors",
- data: {term: request.term},
- success: function(data){
- response(data);
- }
- })
- }
- });
+ createColorAutocomplete();
// load the company names autocomplete fields, but only if the element exists
if ($("#device_company_names").length > 0) {
@@ -237,7 +227,7 @@ function newInterfaceRow(){
});
//append the new row
$interface_table.append('<tr class="interface_row">' + $interface_row.html() + '</tr>')
- //append the action for the cbo's
+ createColorAutocomplete();
return false;
}
//get parameters from the querystring
@@ -258,6 +248,19 @@ function split( val ) {
function extractLast( term ) {
return split( term ).pop();
}
+function createColorAutocomplete(){
+ $(".connection_color").autocomplete({
+ source: function(request, response){
+ $.ajax({
+ url: "/search/find_colors",
+ data: {term: request.term},
+ success: function(data){
+ response(data);
+ }
+ })
+ }
+ });
+}
function loadJavascript(filename){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
Please sign in to comment.
Something went wrong with that request. Please try again.