How to use the basis.data.index.count function in basis

To help you get started, we’ve selected a few basis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basisjs / basisjs / demo / apps / todomvc / basis / js / module / list / index.js View on Github external
destroy: function(){
      this.target.destroy();
    }
  }
});


//
// Main view
//

module.exports = new Node({
  template: resource('./template/list.tmpl'),
  binding: {
    hidden: count(Todo.all).as(basis.bool.invert),
    noActive: count(Todo.active).as(basis.bool.invert)
  },
  action: {
    toggleCompletedForAll: function(event){
      var dataset = event.sender.checked ? Todo.active : Todo.completed;

      // invert completed flag for dataset members
      dataset.forEach(function(item){
        item.update({
          completed: !item.data.completed
        });
      });
    }
  },

  sorting: 'data.id',  // shortcut for function(child){ return child.data.id }
  sortingDesc: true,
github basisjs / basisjs / demo / apps / todomvc / basis / js / module / stat / index.js View on Github external
title: 'Completed'
    }
  ]
});


//
// panel
//

module.exports = new Node({
  template: resource('./template/footer.tmpl'),
  binding: {
    filters: filters,
    hidden: count(Todo.all).as(basis.bool.invert),
    completed: count(Todo.completed),
    active: count(Todo.active)
  },
  action: {
    clearCompleted: function(){
      Todo.completed.forEach(function(item){
        item.destroy();
      });
    }
  }
});
github basisjs / basisjs / src / devpanel / view / warnings / tab.js View on Github external
var count = require('basis.data.index').count;
var Warning = require('type').Warning;

module.exports = {
  caption: 'Warnings',
  view: resource('./view/index.js'),

  template: resource('./tab.tmpl'),
  binding: {
    count: count(Warning.all)
  }
};
github basisjs / basisjs / src / devpanel / view / file-graph / view / file-stat / index.js View on Github external
count: function(node){
      return count(node.dataset || node.delegate);
    }
  },
github basisjs / basisjs / src / devpanel / view / warnings / view / index.js View on Github external
hasWarnings: count(Warning.all)
  },
  dataSource: warningsByType,
  childClass: StatItem,
  sorting: 'data.title',
  selection: true,
  satellite: {
    total: {
      delegate: basis.fn.$self,
      instance: new StatItem({
        dataset: Warning.all,
        caption: 'Total'
      })
    },
    fatal: {
      existsIf: count(fatalWarnings),
      delegate: basis.fn.$self,
      instance: new StatItem({
        dataset: fatalWarnings,
        caption: 'Fatal',
        fatal: true
      })
    }
  }
});
StatItem.prototype.contextSelection = stat.selection;
Value.query(stat, 'selection.pick()').link(stat.selection, function(selected){
  if (!selected)
      this.set([stat.satellite.total]);
});

function processMessage(node){
github basisjs / basisjs / src / devpanel / view / ui / view / index.js View on Github external
}
});
var templates = require('basis.template').define('devpanel.ui', {
  view: resource('./template/view.tmpl')
});
require('basis.template').theme('standalone').define('devpanel.ui', {
  view: resource('./template/standalone.tmpl')
});

module.exports = Node.subclass({
  disabled: api.connected.as(basis.bool.invert),

  template: templates.view,
  binding: {
    connected: api.connected,
    instanceCount: count(instances),
    withLoc: count(instances, 'data.loc')
  },

  dataSource: splitByParent.getSubset(null, true),
  childClass: ViewNode,
  childFactory: function(config){
    return map.resolve(config.delegate);
  },
  sorting: 'data.id',

  init: function(){
    Node.prototype.init.call(this);

    uiApi.channel.link(this, processData);
    api.connected.link(this, function(connected){
      if (connected)
github basisjs / basisjs / src / devpanel / module / ui / index.js View on Github external
nestedViewCount: function(node){
      return count(node.subset);
    }
  },
github basisjs / basisjs / src / devpanel / module / ui / index.js View on Github external
delegate: instanceMap[this.data.grouping]
      });
  },
  destroy: function(){
    this.subset = null;
    Node.prototype.destroy.call(this);
  }
});

new Node({
  container: document.body,

  template: resource('./template/view.tmpl'),
  binding: {
    instanceCount: count(uiInfo.instances),
    withLoc: count(uiInfo.instances, 'data.loc')
  },

  childClass: ViewNode,
  dataSource: splitByParent.getSubset(null, true),
  sorting: 'data.id'
});
github basisjs / basisjs / src / devpanel / view / warnings / view / index.js View on Github external
},
    count: {
      events: 'delegateChanged',
      getter: function(node){
        return count(node.dataset || node.delegate);
      }
    }
  }
});

var stat = new Node({
  template: resource('./template/stat.tmpl'),
  binding: {
    total: 'satellite:',
    fatal: 'satellite:',
    hasWarnings: count(Warning.all)
  },
  dataSource: warningsByType,
  childClass: StatItem,
  sorting: 'data.title',
  selection: true,
  satellite: {
    total: {
      delegate: basis.fn.$self,
      instance: new StatItem({
        dataset: Warning.all,
        caption: 'Total'
      })
    },
    fatal: {
      existsIf: count(fatalWarnings),
      delegate: basis.fn.$self,
github basisjs / basisjs / tour / src / slide / viewer / fileList / index.js View on Github external
var Value = require('basis.data').Value;
var count = require('basis.data.index').count;
var TabControl = require('basis.ui.tabs').TabControl;

module.exports = TabControl.subclass({
  autoDelegate: true,
  dataSource: Value.query('data.files'),

  template: resource('./template/list.tmpl'),
  binding: {
    hasChanges: count(Value.query('data.files'), 'rollbackUpdate', 'modified')
  },
  action: {
    resetSlides: function(){
      this.data.files.forEach(function(file){
        file.rollback();
      });
    }
  },

  childClass: {
    active: true,
    template: resource('./template/item.tmpl'),
    binding: {
      name: Value.query('data.filename').as(basis.path.basename),
      modified: Value.query('target.modified').as(Boolean)
    }