Ejemplo n.º 1
0
import { Template } from 'meteor/templating';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

Template.orders.onCreated(function() {

	this.autorun(() => {
		this.subscribe('ordersData');
	});

	this.status = new ReactiveVar(0);

});

Template.orders.onRendered(function() {

	$('section.orders li').click(function() {

		$('li.current').removeClass('current');
		$(this).addClass('current');

	});

});

Template.orders.helpers({

	orders:function() {

		if (Orders.find().count() > 0) {
Ejemplo n.º 2
0
Template.orders.onCreated(function () {
  this.state = new ReactiveDict();
  this.orderLimits = new ReactiveDict();
  this.state.setDefault({
    orders: []
  });
  this.orderLimits.setDefault({
    new: 10,
    processing: 10,
    completed: 10
  });
  this.state.set("count", 0);

  const filterName = this.data && this.data.filter && this.data.filter.name || "new";
  Reaction.setUserPreferences(PACKAGE_NAME, ORDER_LIST_FILTERS_PREFERENCE_NAME, filterName);

  this.autorun(() => {
    const filter = Reaction.getUserPreferences(PACKAGE_NAME, ORDER_LIST_FILTERS_PREFERENCE_NAME, DEFAULT_FILTER_NAME);
    const limit = this.orderLimits.get(filter);
    const query = OrderHelper.makeQuery(filter);
    this.subscription = this.subscribe("PaginatedOrders", filter, limit);

    if (this.subscription.ready()) {
      const orders = Orders.find(query, { limit: limit }).fetch();
      this.state.set("orders", orders);
    }
  });

  // Watch for updates to shop collection
  this.autorun(() => {
    const shop = Shops.findOne({});

    // Update currency information, this is passed to child components containing
    // Numeric inputs
    this.state.set("currency", shop.currencies[shop.currency]);
  });
});
Ejemplo n.º 3
0
Template.orders.onCreated(function () {
  this.state = new ReactiveDict();
  this.state.setDefault({
    orders: []
  });

  // Watch for updates to the subscription and query params
  // fetch available orders
  this.autorun(() => {
    this.subscribe("Orders");
    const filter = Reaction.Router.getQueryParam("filter");
    const query = OrderHelper.makeQuery(filter);
    const orders = Orders.find(query).fetch();

    this.state.set("orders", orders);
  });

  // Watch for updates to shop collection
  this.autorun(() => {
    const shop = Shops.findOne({});

    // Update currency information, this is passed to child components containing
    // Numeric inputs
    this.state.set("currency", shop.currencies[shop.currency]);
  });

  // Open the action view when necessary
  this.autorun(() => {
    const isActionViewOpen = Reaction.isActionViewOpen();
    const queryParams = Reaction.Router.current().queryParams;

    if (isActionViewOpen === false) {
      Reaction.Router.go("orders", {}, queryParams);
    }
  });
});
Ejemplo n.º 4
0
import './orderrow.js';

Template.orders.helpers({
  /* eslint-disable no-underscore-dangle */
  /* replaced by scrolling orders
  moreBtn: function showMoreBtn() {
    const type = Template.instance().data.type;
    if (type && type === 'lastTrades') {
      const totalOrders = Blaze._globalHelpers.countLastTrades();
      return (this.orders.count() < totalOrders);
    }
    const totalOffers = Blaze._globalHelpers.countOffers(type);
    return (this.orders.count() < totalOffers);
  },
  */
  ordersCount: function ordersCount() {
    return Template.instance().data.orders.count();
  },
  section: function section() {
    return Template.instance().data.type;
  },
  orderCount: function countOffersOrders() {
    const type = Template.instance().data.type;
    if (type && type === 'lastTrades') {
      return parseInt(Blaze._globalHelpers.countLastTrades(), 10);
    }
    return parseInt(Blaze._globalHelpers.countOffers(this.priceClass), 10);
  },
  /* eslint-enable no-underscore-dangle */
});