ccnq-ko-rule-entry
CCNQ Knockout Widget for rule entry
$ cnpm install ccnq-ko-rule-entry 
SYNC missed versions from official npm registry.

A Knockout Widget for CCNQ(4) rule entry

This Knockout component manages a single rule entry as stored in a CCNQ4 ruleset database. The layout of the record is adapted to the tough-rate LCR routing engine.

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

Data

  @data class RuleEntry
    constructor: (@doc) ->
      assert @doc?, 'doc is required'
      assert @doc?.prefix?, 'doc.prefix is required'
      assert @doc?.attrs?.cdr?, 'doc.attrs.cdr is required'

      @prefix = @doc.prefix
      @cdr = ko.observable @doc.attrs.cdr
      @gwlist = new RuleGwlist @doc.gwlist
      return

We also provide the original document so that any other (extra) field is kept.

    update_doc: ->
      @doc._id = "rule:#{@prefix}"
      @doc.type = 'rule'
      @doc.prefix = @prefix
      @doc.gwlist = @gwlist.toJS()
      @doc.attrs ?= {}
      @doc.attrs.cdr = @cdr()
      @doc

Model

  @view ({value,$root,ko}) ->
    # assert value instanceof RuleEntry, 'value should be an instance of RuleEntry'
    assert value?, 'value is required'
    {ruleset_db} = $root
    assert ruleset_db?, 'ruleset_db is required'

    @notify = ko.observable ''

    @save = =>
      doc = value.update_doc()

      @notify "Saving... (#{doc._rev})"

Save the record.

      ruleset_db.put doc
      .then ({rev}) =>
        doc._rev = rev
        @notify 'Saved...'
      .catch (error) =>
        @notify "Not saved: #{error} on #{JSON.stringify doc}"

    return

Layout

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

    div ->
      p "Add a new prefix (routing)"
      label 'Prefix: '
      input
        type:'tel'
        bind:
          value: 'prefix'
        readonly:true
        required:true
      label 'Billing: '
      input
        bind:
          value: 'cdr'
        readonly:true
        required:true
    div ->
      text 'Targets: '
      rule_gwlist 'gwlist'
      button bind: click: 'save', 'Save'
    div '.log', bind: text: 'notify', '(log)'

Extend Knockout witht the rule-gwlist component/tag.

  {RuleGwlist,rule_gwlist} = (require 'ccnq-ko-rule-gwlist') ko

assert = require 'assert'

Current Tags

  • 5.0.0                                ...           latest (5 years ago)

36 Versions

  • 5.0.0                                ...           5 years ago
  • 4.4.1                                ...           5 years ago
  • 4.4.0                                ...           5 years ago
  • 4.3.1                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.5                                ...           5 years ago
  • 4.2.4                                ...           5 years ago
  • 4.2.3                                ...           5 years ago
  • 4.2.2                                ...           5 years ago
  • 4.1.5                                ...           5 years ago
  • 4.1.4                                ...           5 years ago
  • 4.1.3                                ...           5 years ago
  • 4.1.2                                ...           5 years ago
  • 4.1.1                                ...           5 years ago
  • 4.0.2                                ...           5 years ago
  • 4.0.1                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.2.3                                ...           5 years ago
  • 2.2.2                                ...           5 years ago
  • 2.2.1                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.1.4                                ...           5 years ago
  • 2.1.3                                ...           5 years ago
  • 2.1.2                                ...           5 years ago
  • 2.1.1                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.2                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |