Skip to content

Commit

Permalink
Add fields service provider for default fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeSangoi committed Dec 19, 2014
1 parent a52fcdd commit 6fadc84
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions www/base/src/app/common/services/fields/fields.service.coffee
@@ -0,0 +1,32 @@
class fieldsService extends Factory('common')
constructor: ->
return {

checkbox: (name) ->
if localStorage.getItem(name) isnt undefined
initial_value = localStorage.getItem(name) is "true"

ret =
type: 'checkbox'
name: name
value: initial_value

return ret

radio: (name, answers...) ->
default_answers =
"yes": "yes"
"no" : "no"

if localStorage.getItem(name) isnt undefined
initial_value = localStorage.getItem(name)

ret =
name: name
type: 'radio'
value: initial_value
answers: default_answers

return ret
}

0 comments on commit 6fadc84

Please sign in to comment.