🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

ccnq-ko-rule-gwlist

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccnq-ko-rule-gwlist

CCNQ Knockout Widget for gwlist management

latest
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

A Knockout Widget for CCNQ4 gwlist

module.exports = (require 'kow') 'rule-gwlist', (ko) ->

Data

  @data class RuleGwlist
    constructor: (gwlist) ->
      gwlist ?= []

      @gwlist = ko.observableArray gwlist.map (data) ->
        new RuleTarget data
      return

    toJS: ->
      @gwlist.remove (x) -> !x._validated()
      ko.toJS @gwlist

Model

  @view ({value,ko}) ->
    # assert value instanceof RuleGwlist, 'value should be an instance of RuleGwlist'
    assert value?, 'value is required'

    @notify = ko.observable ''

Add a new (empty) target. FIXME: should select a default type based on existing targets (e.g. only one source_registrant makes sense).

    @add_gw = =>
      @gwlist.push new RuleTarget {}

Remove an existing target.

    @remove_gw = (target) =>
      @gwlist.remove target

    return

Layout

  @html ({p,div,text,label,input,datalist,option,ul,li,button,tag}) ->

    datalist '#gateway', bind: foreach: '$root.gateways', ->
      option bind: value: '$data'
    datalist '#carrier', bind: foreach: '$root.carriers', ->
      option bind: value: '$data'

    div bind: foreach: 'gwlist', ->
      div ->
        rule_target '$data'
        button bind: click: '$parent.remove_gw', 'Remove'
    button bind: click: 'add_gw', 'Add'

Extend Knockout witht the rule-target component/tag.

  {RuleTarget,rule_target} = (require 'ccnq-ko-rule-target') ko

assert = require 'assert'

Keywords

Knockout

FAQs

Package last updated on 15 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts