Ejemplo n.º 1
0
var hbs = require('handlebars');
var LayoutView = require('lib/config/layout-view');
var POS = require('lib/utilities/global');

var Layout = LayoutView.extend({

  template: hbs.compile('' +
    '<div class="list-actions"></div>' +
    '<div class="list-tabs tabs infinite-tabs"></div>' +
    '<div class="list"></div>' +
    '<div class="list-footer"></div>'
  ),

  tagName: 'section',

  regions: {
    actions   : '.list-actions',
    tabs      : '.list-tabs',
    list      : '.list',
    footer    : '.list-footer'
  },

  attributes: {
    'class'         : 'module products-module'
  }

});

module.exports = Layout;
POS.attach('POSApp.Products.Layout', Layout);
Ejemplo n.º 2
0
    return {
      showing : this.collection.length,
      local   : this.collection.superset().length,
      queue   : queue,
      hasQueue: queue > 0
    };
  }

  //onRender: function() {
  //  this.$('.current').text(this.collection.getPage() + 1);
  //  this.$('.total').text(this.collection.getNumPages());
  //  this.$('.prev').prop('disabled', !this.collection.hasPrevPage());
  //  this.$('.next').prop('disabled', !this.collection.hasNextPage());
  //},

  //onPrev: function() {
  //  if (this.collection.hasPrevPage()) {
  //    this.collection.prevPage();
  //  }
  //},
  //
  //onNext: function() {
  //  if (this.collection.hasNextPage()) {
  //    this.collection.nextPage();
  //  }
  //}
});

module.exports = View;
POS.attach('Components.Pagination.View', View);
Ejemplo n.º 3
0
  initialize: function() {
    var id = this.model.id;
    this.template = function(){
      return $('script[data-id="' + id + '"]').html();
    };
  },

  behaviors: {
    Tooltip: {
      behaviorClass: Tooltip
    }
  },

  onRender: function(){
    var self = this;

    // bind ordinary elements
    this.$('input, select, textarea').each(function(){
      var name = $(this).attr('name');
      if(name){
        self.addBinding(null, '*[name="' + name + '"]', name);
      }
    });

  }

});

module.exports = View;
POS.attach('SettingsApp.HotKeys.View');
Ejemplo n.º 4
0
var ReceiptView = require('lib/config/receipt-view');
var POS = require('lib/utilities/global');
var hbs = require('handlebars');
var $ = require('jquery');

var View = ReceiptView.extend({
  tagName: 'ul',
  template: hbs.compile( $('#tmpl-receipt-totals').html() )
});

module.exports = View;
POS.attach('POSApp.Receipt.Views.Totals', View);
Ejemplo n.º 5
0
  template: hbs.compile(Tmpl),

  className: function(){
    return this.model.get('payment_details.paid') ? 'paid' : 'unpaid';
  },

  initialize: function(){
    var status = this.model.get('payment_details.paid') ? 'paid' : 'unpaid';
    this.status = polyglot.t('titles.' + status);

    var message = this.model.get('payment_details.message');
    if( _.isArray(message) ){
      this.message = _.last(message);
    } else {
      this.message = message;
    }
  },

  templateHelpers: function(){
    return {
      status: this.status,
      message: this.message
    };
  }

});

module.exports = View;
POS.attach('POSApp.Receipt.Views.Status', View);
Ejemplo n.º 6
0
    view.render();

    // update model on customer select
    this.listenTo(view, 'customer:select', function(customer) {
      this.model.set({
        default_customer: customer.id,
        customer: customer
      });
    });

    // disable customer select if logged_in_user checked
    if(this.model.get('logged_in_user')){
      view.triggerMethod('select:disable', true);
    }

    this.model.on('change:logged_in_user', function(model, toggle){
      view.triggerMethod('select:disable', toggle);
    });

    // clean up
    // TODO: abstract clean up
    this.on('destroy', function(){
      view.destroy();
    });
  }

});

module.exports = View;
POS.attach('SettingsApp.General.View');
Ejemplo n.º 7
0
  },

  behaviors: {
    HotKeys: {
      behaviorClass: HotKeys
    },
    Dropdown: {
      behaviorClass: Dropdown
    }
  },

  update: function(str){
    var title = str ? str : this.title;
    this.$('h1').text(title);
  },

  openMenu: function(e){
    e.preventDefault();
    Radio.command('header', 'open:menu');
  },

  showHelpModal: function() {
    var view = new HelpModal();
    Radio.request('modal', 'open', view);
  }

});

module.exports = View;
POS.attach('HeaderApp.Views.TitleBar', View);
Ejemplo n.º 8
0
    function onSuccess(resp){
      if(resp.result === 'success'){
        btn.trigger('state', [ 'success', resp.message ]);
      } else {
        btn.trigger('state', [ 'error', resp.message ]);
      }
    }

    function onError(jqxhr){
      var message = null;
      if(jqxhr.responseJSON && jqxhr.responseJSON.errors){
        message = jqxhr.responseJSON.errors[0].message;
      }
      btn.trigger('state', ['error', message]);
    }

    $.getJSON( ajaxurl, {
      action: 'wc_pos_email_receipt',
      order_id: order_id,
      email : email
    })
    .done(onSuccess)
    .fail(onError);
  }

});

module.exports = ReceiptRoute;
POS.attach('POSApp.Receipt.Route', ReceiptRoute);
Ejemplo n.º 9
0
var hbs = require('handlebars');

var Layout = LayoutView.extend({

  initialize: function(){
    this.template = hbs.compile('' +
      '<div class="list-header"></div>' +
      '<div class="list"></div>' +
      '<div class="list-actions"></div>' +
      '<div class="list-footer"></div>'
    );
  },

  tagName: 'section',

  regions: {
    header  : '.list-header',
    list    : '.list',
    actions : '.list-actions',
    footer  : '.list-footer'
  },

  attributes: {
    'class'         : 'module checkout-module'
  }

});

module.exports = Layout;
POS.attach('POSApp.Checkout.Views.Layout', Layout);
Ejemplo n.º 10
0
      buttons: [{
        action: 'return-to-sale',
        className: 'btn pull-left'
      },{
        action: 'process-payment',
        className: 'btn btn-success',
        icon: 'prepend'
      }]
    });

    this.listenTo(view, {
      'action:return-to-sale': function(){
        this.navigate('cart/' + this.order.id, { trigger: true });
      },
      'action:process-payment': function(btn){
        btn.trigger('state', 'loading');
        this.order.process()
          .always(function(){
            btn.trigger('state', 'reset');
          });
      }
    });

    this.layout.getRegion('actions').show(view);
  }

});

module.exports = CheckoutRoute;
POS.attach('POSApp.Checkout.Route', CheckoutRoute);
Ejemplo n.º 11
0
        options.model.save([], {
          success: function(model, resp){
            btn.trigger('state', 'success');
            if(resp.success){
              view.triggerMethod('message', resp.success, 'success');
            } else {
              view.triggerMethod('message', 'success');
            }
          },
          error: function(jqxhr){
            btn.trigger('state', 'error');
            if(jqxhr.responseJSON && jqxhr.responseJSON.errors){
              view.triggerMethod(
                'message', jqxhr.responseJSON.errors[0].message, 'error'
              );
            } else {
              view.triggerMethod('message', 'error');
            }
          }
        });
      }
    });

    this.layout.getRegion('footer').show(view);
  }

});

module.exports = SettingsRouter;
POS.attach('SettingsApp.Router', SettingsRouter);
Ejemplo n.º 12
0
    }, this);
  },

  fetchDB: function(db){
    this[db] = Radio.request('entities', 'get', {
      type: 'collection',
      name: db
    });

    if(this[db].isNew()){
      return this[db].fetch();
    }
  },

  clearDB: function(db){
    var collection = this[db],
        self = this;

    collection.db.clear()
      .then(function(){
        collection.reset();
        collection.queue = [];
        self.render();
      });
  }

});

module.exports = StatusRoute;
POS.attach('SupportApp.Status.Route', StatusRoute);
Ejemplo n.º 13
0
var ItemView = require('lib/config/item-view');
var InfiniteListView = require('lib/config/infinite-list-view');
var Item = require('./item/layout');
var POS = require('lib/utilities/global');

var Empty = ItemView.extend({
  tagName: 'li',
  className: 'empty',
  template: '#tmpl-products-empty'
});

var List = InfiniteListView.extend({
  childView: Item,
  emptyView: Empty,
  childViewContainer: 'ul'
});

module.exports = List;
POS.attach('POSApp.Products.List', List);
Ejemplo n.º 14
0
  },

  initialize: function() {
    this.template = function(){
      return $('script[data-id="tools"]').html();
    };
  },

  //behaviors: {
  //  Tooltip: {
  //    behaviorClass: Tooltip
  //  }
  //},

  ui: {
    translation: '*[data-action="translation"]'
  },

  onRender: function(){

  },

  triggers: {
    'click @ui.translation': 'translation:update'
  }

});

module.exports = View;
POS.attach('SettingsApp.Tools.View');
Ejemplo n.º 15
0
  events: {
    'input @ui.input' : 'autoGrow'
  },

  autoGrowEach: function() {
    _.each( this.ui.input, function( input ) {
      this.autoGrow( $(input) );
    }, this);
  },

  autoGrow: function( e ) {
    var input = e.target ? $(e.target) : e ;
    var value = input.val();

    value = value.replace(/&/g, '&amp;')
      .replace(/\s/g,'&nbsp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;');

    this.tester.html(value);
    var width = this.tester.width() + this.options.padding;
    input.css({ width: width });

  }

});

module.exports = AutoGrow;
POS.attach('Behaviors.AutoGrow', AutoGrow);
Ejemplo n.º 16
0
  },

  ui: {
    sortable: '.sortable'
  },

  onRender: function() {
    if( this.ui.sortable.length > 0 ) {

      // Custom sorting for checkout settings table
      // TODO: move this to view callback
      var table = this.ui.sortable;
      var rows = table.find('tbody tr').get();

      // sort according to input
      table.append(rows.sort(function(a, b) {
        return parseInt($(a).find('input.gateway_order').val(), 10) -
          parseInt($(b).find('input.gateway_order').val(), 10);
      }));

      table.sortable( this.options );
    }

  }

});

module.exports = Sortable;
POS.attach('Behaviors.Sortable', Sortable);
Ejemplo n.º 17
0
  updateInput: function(btn, state){
    btn.removeClass('loading success error');
    if(state !== 'reset'){
      btn.addClass(state);
    }
  },

  onMessage: function(message, state){
    if(!state){
      state = message;
      message = polyglot.t('messages.' + message);
    }
    this.ui.message.removeClass('loading success error');
    if(state === 'reset'){
      this.ui.message.html('');
    } else {
      this.ui.message.addClass(state);
      this.ui.message.html(message);
    }
  },

  onDisableButtons: function(){
    this.disable();
  }

});

module.exports = Buttons;
POS.attach('Behaviors.Buttons', Buttons);
Ejemplo n.º 18
0
var ReceiptView = require('lib/config/receipt-view');
var POS = require('lib/utilities/global');
var hbs = require('handlebars');
var $ = require('jquery');

var View = ReceiptView.extend({
  tagName: 'ul',
  template: hbs.compile( $('#tmpl-receipt-items').html() )
});

module.exports = View;
POS.attach('POSApp.Receipt.Views.Items', View);
Ejemplo n.º 19
0
var General = Route.extend({

  initialize: function( options ) {
    options = options || {};
    this.container = options.container;
    this.model = options.model;
  },

  fetch: function() {
    if(this.model.isNew()){
      return this.model.fetch();
    }
  },

  render: function() {
    var view = new View({
      model: this.model
    });
    this.listenTo(view, 'action:save', this.saveModel);
    this.container.show(view);
  },

  saveModel: function(){
    this.model.save();
  }

});

module.exports = General;
POS.attach('SettingsApp.General.Route', General);
Ejemplo n.º 20
0
        ajaxurl = Radio.request('entities', 'get', {
          type: 'option',
          name: 'ajaxurl'
        });

    btn.trigger('state', 'loading');
    view.triggerMethod('message', 'reset');

    var onError = function(message){
      btn.trigger('state', 'error');
      view.triggerMethod('message', message, 'error');
    };

    var onSuccess = function(data){
      if(!_.isObject(data) || data.result !== 'success'){
        return onError(data.message);
      }
      btn.trigger('state', 'success');
      view.triggerMethod('message', data.message, 'success');
    };

    $.post( ajaxurl, data )
    .done(onSuccess)
    .fail(onError);
  }

});

module.exports = FormRoute;
POS.attach('SupportApp.Form.Route', FormRoute);
Ejemplo n.º 21
0
    }

  },
  /* jshint +W074 */

  discountKeys: function(e){
    e.preventDefault();
    var key = $(e.currentTarget).data('key');
    this.model.set('active', 'percentage');
    this.model._set('percentage', key.replace('%', ''));
    this.ui.toggle.addClass('toggle');
  },

  cashKeys: function(e){
    e.preventDefault();
    var key = $(e.currentTarget).data('key');
    key = Utils.unformat(key);
    this.model.clearInput().key(key);
  },

  // on keypress, check if input selected
  keyPress: function(){
    var sel = window.getSelection();
    this._hasSelection = sel.toString() === this.ui.input.val();
  }

});

module.exports = View;
POS.attach('Components.Numpad.View', View);
Ejemplo n.º 22
0
    // bind ordinary elements
    this.$('input, select, textarea').each(function(){
      var name = $(this).attr('name');
      if(name){
        self.addBinding(null, '*[name="' + name + '"]', name);
      }
    });

    // init the first tab
    this.ui.tabs.first().addClass('active');
    this.ui.options.first().addClass('active');
  },

  onTabClick: function(e){
    this.ui.tabs.each(function(){
      $(this).removeClass('active');
    });
    this.ui.options.each(function(){
      $(this).removeClass('active');
    });
    $(e.currentTarget).addClass('active');
    var option = $(e.currentTarget).data('id');
    $('#' + option).addClass('active');
  }

});

module.exports = View;
POS.attach('SettingsApp.Access.View');
Ejemplo n.º 23
0
    });

    var self = this;
    Radio.request('modal', 'open', modal)
      .then(function(args){
        var buttons = args.view.getButtons();
        self.listenTo(buttons, 'action:save', function(btn){
          model.save([], { buttons: btn });
        });
      });

  },

  initModalData: function(model, view){
    function element(attr){
      return '#' + model.id + ' .gateway-' + attr;
    }
    var data = {
      title: view.$(element('name')).html(),
      description: view.$(element('description')).html(),
      icon: view.$(element('icon')).data('show') ? true : false
    };
    data.hasIcon = view.$(element('icon')).data('icon');
    model.set(data);
  }

});

module.exports = SettingsRoute;
POS.attach('SettingsApp.Route', SettingsRoute);
Ejemplo n.º 24
0
  },

  /**
   *
   */
  hasNoNames: function(customer){
    return _.chain(customer)
      .pick('first_name', 'last_name')
      .values()
      .compact()
      .isEmpty()
      .value();
  },

  /**
   *
   */
  onSelect: function(e) {
    this.trigger( 'customer:select', e.added );
  },

  /**
   *
   */
  onSelectOpen: function() {}

});

module.exports = View;
POS.attach('Components.CustomerSelect.View', View);
Ejemplo n.º 25
0
  },

  ui: {
    settings: '.gateway-settings'
  },

  events: {
    'click @ui.settings': 'openGatewaySettingsModal'
  },

  behaviors: {
    Tooltip: {
      behaviorClass: Tooltip
    },
    Sortable: {
      behaviorClass: Sortable
    }
  },

  openGatewaySettingsModal: function(e){
    e.preventDefault();
    var gateway = $(e.target).data('gateway');
    var template = this.$('#tmpl-gateway-settings-modal').html();
    this.trigger('gateway:settings', gateway, template);
  }

});

module.exports = View;
POS.attach('SettingsApp.View');
Ejemplo n.º 26
0
  },

  showMenu: function(){
    var view = new Menu();

    this.channel.comply({
      'open:menu'   : view.open,
      'close:menu'  : view.close
    }, view);

    this.menu.show(view);
  },

  browserCheck: function(){
    var props = ['flexbox', 'indexeddb', 'localstorage'],
        pass = _.every(props, function(prop){ return Modernizr[prop]; });

    if(!pass){
      var view = new BrowserModal();
      Radio.request('modal', 'open', view);
    }
  },

  onStop: function(){
    this.channel.reset();
  }
});

module.exports = Service;
POS.attach('HeaderApp.Service', Service);