Skip to content

Commit

Permalink
Refactored schema to input types code
Browse files Browse the repository at this point in the history
  - removed unused function
  - created constant dictionary
  • Loading branch information
zurawiki committed Aug 5, 2014
1 parent 75213c9 commit 566208c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
22 changes: 2 additions & 20 deletions client/collection_view.coffee
@@ -1,13 +1,3 @@
schemaToInputType = (type) ->
dict = {
number: 'number'
string: 'text'
boolean: 'checkbox'
}
if type of dict
dict[type]
else 'text'

get_sort_by = ->
sort_by = {}
sort_by[Houston._session('sort_key')] = Houston._session('sort_order')
Expand Down Expand Up @@ -190,13 +180,5 @@ Template._houston_collection_view.events
Template._houston_new_document_field.helpers
field_is_id: -> @name is '_id'
document_id: -> Houston._session('document_id')
has_type: ->
@type is 'string' ||
@type is 'number' ||
@type is 'checkbox'
input_type: ->
{
number: 'number'
string: 'text'
boolean: 'checkbox'
}[@type]
has_type: -> Houston._INPUT_TYPES[@type]?
input_type: -> Houston._INPUT_TYPES[@type]
12 changes: 2 additions & 10 deletions client/document_view.coffee
Expand Up @@ -19,16 +19,8 @@ Template._houston_document_view.helpers
Template._houston_document_field.helpers
field_is_id: -> @name is '_id'
document_id: -> Houston._session('document_id')
has_type: ->
@type is 'string' ||
@type is 'number' ||
@type is 'checkbox'
input_type: ->
{
number: 'number'
string: 'text'
boolean: 'checkbox'
}[@type]
has_type: -> Houston._INPUT_TYPES[@type]?
input_type: -> Houston._INPUT_TYPES[@type]

get_collection = -> Houston._get_collection(Houston._session('collection_name'))

Expand Down
6 changes: 6 additions & 0 deletions lib/shared.coffee
Expand Up @@ -37,3 +37,9 @@ Houston._get_fields = (documents) ->

Houston._get_field_names = (documents) ->
_.pluck(Houston._get_fields(documents), 'name')

Houston._INPUT_TYPES = {
number: 'number'
string: 'text'
boolean: 'checkbox'
}

0 comments on commit 566208c

Please sign in to comment.