diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index ee4ed421a..35ccfeb2b 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -28,7 +28,6 @@
//= require jquery.caret.js
//= require jquery.form.js
//= require jquery.qrcode.min.js
-//= require jquery-ui/sortable
//= require titlebar.js.coffee
//= require bootstrap
//= require jstz/jstz-1.0.4.min.js
diff --git a/app/assets/javascripts/projects/edit_fields.js.coffee b/app/assets/javascripts/projects/edit_fields.js.coffee
index 6a309bf87..bf79b7cb1 100644
--- a/app/assets/javascripts/projects/edit_fields.js.coffee
+++ b/app/assets/javascripts/projects/edit_fields.js.coffee
@@ -28,8 +28,7 @@ $ ->
$('#number').click ->
numCount = numCount + 1
displayNumCount = displayNumCount + 1
- addRow(["""""",
- """""", "Number",
"""""", "", """
$('#text').click ->
textCount = textCount + 1
displayTextCount = displayTextCount + 1
- addRow(["""""",
- """""", "Text", "",
- """""", """"""])
$('#timestamp').click ->
timestampCount = timestampCount + 1
- addRow(["""""",
- """""", "Timestamp", "", "", """"""])
document.getElementById('timestamp').disabled = true
$('#location').click ->
locationCount = locationCount + 1
- addRow(["""""",
- """""", "Longitude", "deg", "", """"""])
- addRow(["""""",
- """""", "Latitude", "deg", "", """"""])
document.getElementById('location').disabled = true
- # Make table sortable
- $( "tbody" ).sortable();
-
# Delete field, enable timestamp/location buttons (NOTE: fid is 0 when the field
# hasn't yet been added to project in database)
$('#fields_table').on 'click', '.field_delete', ->
@@ -75,7 +67,7 @@ $ ->
fid = $(@).closest('a').attr('fid')
# Row index of row being deleted
- rowIndex = $(@).closest('tr').index() + 1
+ rowIndex = $(@).closest('tr').index()
# Row name of row being deleted
rowName = $(@).closest('tr').attr('name')
@@ -110,32 +102,15 @@ $ ->
for i in [0...4]
setValue(inputBoxes[i], values[i])
- # add hidden input for each field with it's position
- t = document.getElementById('fields_table')
- for i in [1...t.rows.length]
- field_id = t.rows[i].cells[5].getElementsByTagName('a')[0].getAttribute('fid')
- # This is for new fields that do not have an id yet
- if field_id == '0'
- field_id = t.rows[1].cells[1].getElementsByTagName('input')[0].getAttribute('name')
- input = document.createElement('input')
- input.setAttribute('type', 'text')
- input.setAttribute('text', 'form-control')
- input.setAttribute('style', 'visibility:collapse;')
- input.setAttribute('name', "#{field_id}_index")
- input.setAttribute('id', "#{field_id}_index")
- input.setAttribute('value', i - 1)
- document.getElementById('hidden_index_inputs').appendChild(input)
-
-
# Adds row to table, highlight new row
addRow = (content) ->
- row = document.getElementById('sortable').insertRow(0)
- $(row).attr('name', content[2].toLowerCase())
+ row = document.getElementById('fields_table').insertRow(1)
+ $(row).attr('name', content[1].toLowerCase())
- cells = for i in [1...7]
+ cells = for i in [1...6]
row.insertCell(i - 1)
- for i in [0...6]
+ for i in [0...5]
cells[i].innerHTML = content[i]
$(row).highlight(500)
@@ -144,21 +119,12 @@ addRow = (content) ->
callDeleteRow = (rowIndex, rowName, fid) ->
if rowName == 'timestamp'
deleteRow(rowIndex, true, 'timestamp')
-
else if rowName == 'latitude'
- t = document.getElementById('fields_table')
deleteRow(rowIndex, true, 'location')
- for i in [1...t.rows.length]
- if t.rows[i].cells[2].innerHTML == 'Longitude'
- deleteRow(i, true, 'location')
-
+ deleteRow(rowIndex, true, 'location')
else if rowName == 'longitude'
- t = document.getElementById('fields_table')
deleteRow(rowIndex, true, 'location')
- for i in [1...t.rows.length]
- if t.rows[i].cells[2].innerHTML == 'Latitude'
- deleteRow(i, true, 'location')
-
+ deleteRow(rowIndex - 1, true, 'location')
else
deleteRow(rowIndex, false, '')
diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss
index 2cc747dd6..0b989a660 100644
--- a/app/assets/stylesheets/projects.css.scss
+++ b/app/assets/stylesheets/projects.css.scss
@@ -48,10 +48,4 @@
.wide-input {
width: 100% !important;
}
-
- .sort-hamburger {
- padding-top:8px;
- padding-left: 12px;
- }
-
-}
+}
\ No newline at end of file
diff --git a/app/controllers/fields_controller.rb b/app/controllers/fields_controller.rb
index 96039f4e8..26d5a15f6 100644
--- a/app/controllers/fields_controller.rb
+++ b/app/controllers/fields_controller.rb
@@ -95,6 +95,6 @@ def destroy
private
def field_params
- params[:field].permit(:project_id, :field_type, :name, :unit, :restrictions, :index)
+ params[:field].permit(:project_id, :field_type, :name, :unit, :restrictions)
end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 56a69048d..36c5ea262 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -268,7 +268,6 @@ def save_fields
unless field.update_attributes(name: params["#{field.id}_name"],
unit: params["#{field.id}_unit"],
- index: params["#{field.id}_index"],
restrictions: restrictions)
respond_to do |format|
flash[:error] = 'Field names must be unique.'
@@ -279,19 +278,19 @@ def save_fields
# Add fields based on type
if params[:hidden_location_count] == '1'
- if addField('Latitude', 'Latitude', 'deg', [], params['latitude_index']) == -1 and return
+ if addField('Latitude', 'Latitude', 'deg', []) == -1 and return
end
- if addField('Longitude', 'Longitude', 'deg', [], params['longitude_index']) == -1 and return
+ if addField('Longitude', 'Longitude', 'deg', []) == -1 and return
end
end
if params[:hidden_timestamp_count] == '1'
- if addField('Timestamp', 'Timestamp', '', [], params['timestamp_index']) == -1 and return
+ if addField('Timestamp', 'Timestamp', '', []) == -1 and return
end
end
(params[:hidden_num_count].to_i).times do |i|
- if addField('Number', params[('number_' + (i + 1).to_s).to_sym], params[('units_' + (i + 1).to_s).to_sym], [], params['number_' + i.to_s + '_index']) == -1 and return
+ if addField('Number', params[('number_' + (i + 1).to_s).to_sym], params[('units_' + (i + 1).to_s).to_sym], []) == -1 and return
end
end
@@ -299,7 +298,7 @@ def save_fields
# Need to explicitly check if restrictions are nil because empty restrictions should be []
restrictions = params[('restrictions_' + (i + 1).to_s).to_sym].nil? ? [] : params[('restrictions_' + (i + 1).to_s).to_sym].split(',')
- if addField('Text', params[('text_' + (i + 1).to_s).to_sym], '', restrictions, params['text_' + i.to_s + '_index']) == -1 and return
+ if addField('Text', params[('text_' + (i + 1).to_s).to_sym], '', restrictions) == -1 and return
end
end
@@ -307,19 +306,15 @@ def save_fields
end
# Helper function to add field to database
- def addField(fieldType, fieldName, unit, restrictions, index)
+ def addField(fieldType, fieldName, unit, restrictions)
if fieldName.nil?
return
else
- if index.nil?
- index = @project.fields.size
- end
field = Field.new(project_id: @project.id,
field_type: get_field_type(fieldType),
name: fieldName,
unit: unit,
- restrictions: restrictions,
- index: index)
+ restrictions: restrictions)
end
unless field.save
@@ -359,9 +354,7 @@ def finishTemplateUpload
@project = Project.find(params[:id])
@matches.each do |header|
field = Field.new(project_id: @project.id,
- field_type: header[1].to_i,
- name: header[0],
- index: @project.fields.size)
+ field_type: header[1].to_i, name: header[0])
unless field.save
respond_to do |format|
diff --git a/app/controllers/visualizations_controller.rb b/app/controllers/visualizations_controller.rb
index b2d388a11..9890be2da 100644
--- a/app/controllers/visualizations_controller.rb
+++ b/app/controllers/visualizations_controller.rb
@@ -241,7 +241,7 @@ def displayVis
data_fields.push(typeID: TEXT_TYPE, unitName: 'String', fieldID: -1, fieldName: 'Combined Data Sets')
# push real fields to temp variable
- @project.fields.sort_by(&:index).each do |field|
+ @project.fields.each do |field|
data_fields.push(typeID: field.field_type, unitName: field.unit, fieldID: field.id, fieldName: field.name)
end
diff --git a/app/helpers/data_sets_helper.rb b/app/helpers/data_sets_helper.rb
index 3c7887376..919c443f5 100644
--- a/app/helpers/data_sets_helper.rb
+++ b/app/helpers/data_sets_helper.rb
@@ -5,7 +5,8 @@ def data_set_edit_helper(field, can_edit = false, make_link = true, url = '#')
end
def format_slickgrid(fields, data_set)
- cols, data = [fields.sort_by(&:index), data_set]
+ cols = fields
+ data = data_set
cols, data = format_slickgrid_merge cols, data
cols, data = format_slickgrid_units cols, data
cols, data = format_slickgrid_populate cols, data
diff --git a/app/views/projects/_field_edit.html.erb b/app/views/projects/_field_edit.html.erb
index cf2462515..3e445bf6a 100644
--- a/app/views/projects/_field_edit.html.erb
+++ b/app/views/projects/_field_edit.html.erb
@@ -1,4 +1,4 @@
-<% @project.fields.sort_by(&:index).each do |field| %>
+<% @project.fields.each do |field| %>
diff --git a/app/views/projects/_print.html.erb b/app/views/projects/_print.html.erb
index 9f8cb3f6a..42901cae6 100644
--- a/app/views/projects/_print.html.erb
+++ b/app/views/projects/_print.html.erb
@@ -33,7 +33,7 @@
- <% @project.fields.sort_by(&:index).each do |field|%>
+ <% @project.fields.each do |field|%>
<%=field.name%> |
<% end %>
diff --git a/app/views/projects/edit_fields.html.erb b/app/views/projects/edit_fields.html.erb
index b508702fa..9c94e0260 100644
--- a/app/views/projects/edit_fields.html.erb
+++ b/app/views/projects/edit_fields.html.erb
@@ -25,48 +25,40 @@
<% end %>
-
<%= form_tag "/projects/#{@project.id}/save_fields", name: "fields_form" do %>
diff --git a/db/migrate/20150805145056_add_index_to_fields.rb b/db/migrate/20150805145056_add_index_to_fields.rb
deleted file mode 100644
index 6a90386da..000000000
--- a/db/migrate/20150805145056_add_index_to_fields.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class AddIndexToFields < ActiveRecord::Migration
- def up
- add_column :fields, :index, :integer
- Project.find_each do |p|
- p.fields.each_with_index do |f, index|
- f.update_attribute(:index, index)
- end
- end
- end
-
- def down
- remove_column :fields, :index
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index f294924ed..4320f992a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150805145056) do
+ActiveRecord::Schema.define(version: 20150519161334) do
create_table "contrib_keys", force: true do |t|
t.string "name", null: false
@@ -41,7 +41,6 @@
t.datetime "created_at"
t.datetime "updated_at"
t.text "restrictions", default: "[]"
- t.integer "index"
end
create_table "likes", force: true do |t|
@@ -65,7 +64,6 @@
t.integer "news_id"
t.string "store_key"
t.string "file"
- t.string "md5"
end
create_table "news", force: true do |t|
@@ -138,6 +136,14 @@
t.datetime "updated_at"
end
+ create_table "vislogs", force: true do |t|
+ t.text "data"
+ t.integer "visualization_id"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "visualizations", force: true do |t|
t.string "title"
t.integer "user_id"
@@ -152,6 +158,7 @@
t.datetime "featured_at"
t.text "summary"
t.integer "thumb_id"
+ t.boolean "should_log", default: false
end
end
\ No newline at end of file
|