Changeset - b697752b35f9
[Not reviewed]
default
0 1 0
Drew Perttula - 6 years ago 2019-05-30 08:31:29
drewp@bigasterisk.com
note about a bug
Ignore-this: 6cc4dbd36a5cdc32496f114d5649b8e0
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/web/live/live.coffee
Show inline comments
 
@@ -323,48 +323,51 @@ class GraphToControls
 
    for settingStr in Array.from(toClear)
 
      @activeSettings.deleteSetting(U(settingStr))
 

	
 
  clearSettings: ->
 
    @activeSettings.clear()
 

	
 
  register: (device, deviceAttr, graphValueChanged) ->
 
    @activeSettings.registerWidget(device, deviceAttr, graphValueChanged)
 

	
 
  shouldBeStored: (deviceAttr, value) ->
 
    # this is a bug for zoom=0, since collector will default it to
 
    # stick at the last setting if we don't explicitly send the
 
    # 0. rx/ry similar though not the exact same deal because of
 
    # their remap.
 
    return value? and value != 0 and value != '#000000'
 

	
 
  emptyEffect: ->
 
    @activeSettings.forAll(@_removeEffectSetting.bind(@))
 

	
 
  controlChanged: (device, deviceAttr, value) ->
 
    # value is float or #color or (Uri or null)
 
    if (value == undefined or (typeof value == "number" and isNaN(value)) or (typeof value == "object" and value != null and not value.id))
 
      throw new Error("controlChanged sent bad value " + value)
 
    effectSetting = @activeSettings.effectSettingLookup(device, deviceAttr)
 

	
 
    # sometimes this misses an existing setting, which leads to a mess
 
    
 
    if @shouldBeStored(deviceAttr, value)
 
      if not effectSetting?
 
        @_addEffectSetting(device, deviceAttr, value)
 
      else
 
        @_patchExistingEffectSetting(effectSetting, deviceAttr, value)
 
    else
 
      @_removeEffectSetting(effectSetting)
 

	
 
  _nodeForValue: (value) ->
 
    if value.id?
 
      return value
 
    return @graph.prettyLiteral(value)
 

	
 
  _addEffectSetting: (device, deviceAttr, value) ->
 
    log('change: _addEffectSetting', deviceAttr.value, value)
 
    U = (x) => @graph.Uri(x)
 
    quad = (s, p, o) => @graph.Quad(s, p, o, @ctx)
 
    effectSetting = @graph.nextNumberedResource(@effect.value + '_set')
 
    @activeSettings.addSettingsRow(device, deviceAttr, effectSetting, value)
 
    addQuads = [
 
      quad(@effect, U(':setting'), effectSetting),
 
      quad(effectSetting, U(':device'),  device),
 
      quad(effectSetting, U(':deviceAttr'), deviceAttr),
 
      quad(effectSetting, valuePred(@graph, deviceAttr), @_nodeForValue(value))
0 comments (0 inline, 0 general)