Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
manxingxing committed Sep 1, 2014
1 parent 14d5010 commit 60cb368
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion app/assets/stylesheets/tags.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
padding: 10px 0px;
.tag {
width: 33%;
margin: 0px;
margin: 0px 0px 5px 0px;
float: left;
white-space: nowrap;
overflow:hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
input[type=checkbox]{margin-bottom:0;vertical-align: text-top;}
}
}
#manage{
Expand Down
6 changes: 6 additions & 0 deletions app/models/bef_param.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# This class is used to parse query params in specified format(eg: a:1,b:x|y):
# 1) a list of key-value pairs separated by commas.
# 2) Key and value are separated by a colon.
# 3) value can be a collection of atom values which are separated by a pipe. collection values can be either
# a) radio-like: different values or conbination of values are exclusive. default
# or b) checkbox-like: different values can be added or removed independently
class BefParam
def initialize(bef_param_str, *config)
@params = BefParam.parse(bef_param_str)
Expand Down
9 changes: 4 additions & 5 deletions app/models/datatype.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
## The Datatype class is the validated data type for the "Sheetcell" accepted_value. Datatypes are initialised at application start up by the "Datatypehelper" class.
##
## See config/initializers/datatype_load.rb ( DatattypeLoad ) for initializing datatypes
## and a list of possible datatypes. A Datagroup contains a datatype attribute that is a suggestion
## for the datatype attribute of a Datacolumn. Datacolumn overrides Datagroup. After validation, a
## and a list of possible datatypes. A Datagroup contains a datatype attribute that is a suggestion
## for the datatype attribute of a Datacolumn. Datacolumn overrides Datagroup. After validation, a
## Datacolumn may have different datatypes, since invalid values are converted to Category objects.
## Validation is performed by PostgreSQL procedures defined in db/non_schema_sql.sql
class Datatype
attr_accessor :id, :name, :format
attr_accessor :id, :name

def initialize(id, name, format)
def initialize(id, name)
@id = id
@name = name
@format = format
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion app/views/tags/manage.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
var li=$("<li/>").attr({id: tag_id});
var hidden_input = $("<input type='hidden' />").attr({name: 'keywords[]', value: tag_id});
var span_name = $("<span/>").text(name);
var remove_link = $("<a/>").attr({class: 'remove_parent'});
var remove_link = $("<a/>").addClass('remove_parent');
li.append(remove_link, hidden_input, span_name).appendTo(selected_area);
}
function remove_from_selected(tag_id){selected_area.find('li#'+tag_id).remove(); }
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# config.action_controller.asset_host = "http://assets.example.com"

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w(site.js site.css ZeroClipboard)
config.assets.precompile += %w(site.js site.css ZeroClipboard.min.js)

# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
Expand Down
18 changes: 10 additions & 8 deletions config/initializers/datatype_load.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
class Datatypehelper

DATATYPE_COLLECTION = [
Datatype.new(1, "text", ""),
Datatype.new(2, "year", ""),
Datatype.new(3, "date", "yyyy-mm-dd"),
Datatype.new(5, "category", ""),
Datatype.new(7, "number", ""),
Datatype.new(8, "unknown", "")
Datatype.new(1, "text"),
Datatype.new(2, "year"),
Datatype.new(3, "date"),
Datatype.new(5, "category"),
Datatype.new(7, "number"),
Datatype.new(8, "unknown")
]
UNKNOWN = DATATYPE_COLLECTION.detect {|dt| dt.name == 'unknown'}

def self.known
DATATYPE_COLLECTION.reject{|dt| dt.name == 'unknown'}
end

def self.find_by_name(name)
DATATYPE_COLLECTION.each{ |dt| return dt if dt.name == name.try(:downcase) }
return UNKNOWN if name.blank?
name = name.downcase.strip
DATATYPE_COLLECTION.each{ |dt| return dt if dt.name == name }
return UNKNOWN
end

Expand Down

0 comments on commit 60cb368

Please sign in to comment.