Changeset - 2c973af2b13e
[Not reviewed]
default
0 1 0
Drew Perttula - 8 years ago 2017-05-30 08:54:24
drewp@bigasterisk.com
refactor light9-device-settings settings table
Ignore-this: 7685c17a0a1c5f46764aeab8c181698a
1 file changed with 14 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/web/paint/paint-elements.coffee
Show inline comments
 
@@ -156,9 +156,21 @@ Polymer
 
    for s in @graph.objects(U(@subj), U(':setting'))
 
      attr = @graph.uriValue(s, U(':deviceAttr'))
 
      attrLabel = @graph.stringValue(attr, U('rdfs:label'))
 
      @push('attrs', {attr: attrLabel, val: @graph.floatValue(s, U(':value'))})
 
    
 
      @attrs.push({attr: attrLabel, val: @settingValue(s)})
 
    @attrs = _.sortBy(@attrs, 'attr')
 

	
 
  settingValue: (s) ->
 
    U = (x) => @graph.Uri(x)
 
    for pred in [U(':value'), U(':scaledValue')]
 
      try
 
        return @graph.stringValue(s, pred)
 
      catch
 
        null
 
      try
 
        return @graph.floatValue(s, pred)
 
      catch
 
        null
 
    throw new Error("no value for #{s}")
 
    
 
Polymer
 
  is: "light9-paint"
0 comments (0 inline, 0 general)