Exemple #1
0
export function files(state=initialState, action) {
  switch (action.type) {
  case Actions.SAVE_FILE:
    return _.assign({}, state, {
      [action.path]: action.text
    });

  case Actions.DELETE_FILE:
    return _.omit(state, action.path)

  case Actions.CREATE_FILE:
    return _.assign({}, state, {
      [action.path]: action.text
    });

  case Actions.RENAME_FILE:
    return _.assign(
      {},
      _.omit(state, action.path),
      {[action.newPath]: state[action.path]}
    );

  default:
    return state;
  }
};
Exemple #2
0
    initialize: function(models, options) {
        Collection.prototype.initialize.apply(this, arguments);
        _.assign(this, {
            columnModel: options.columnModel,
            domState: options.domState,
            gridId: options.gridId,
            lastRowKey: -1,
            originalRows: [],
            originalRowMap: {},
            startIndex: options.startIndex || 1,
            sortOptions: {
                columnName: 'rowKey',
                ascending: true,
                useClient: (_.isBoolean(options.useClientSort) ? options.useClientSort : true)
            },

            /**
             * Whether the all rows are disabled.
             * This state is not related to individual state of each rows.
             * @type {Boolean}
             */
            disabled: false,
            publicObject: options.publicObject
        });

        if (!this.sortOptions.useClient) {
            this.comparator = null;
        }

        if (options.domEventBus) {
            this.listenTo(options.domEventBus, 'click:headerCheck', this._onClickHeaderCheck);
            this.listenTo(options.domEventBus, 'click:headerSort', this._onClickHeaderSort);
        }
    },
Exemple #3
0
    initialize: function(attrs, options) {
        var editEventName = options.editingEvent + ':cell';
        var domEventBus;

        Model.prototype.initialize.apply(this, arguments);

        _.assign(this, {
            dataModel: options.dataModel,
            columnModel: options.columnModel,
            coordRowModel: options.coordRowModel,
            domEventBus: options.domEventBus,
            domState: options.domState
        });

        this.listenTo(this.dataModel, 'reset', this._onResetData);
        this.listenTo(this.dataModel, 'add', this._onAddDataModel);

        if (this.domEventBus) {
            domEventBus = this.domEventBus;
            this.listenTo(domEventBus, editEventName, this._onMouseClickEdit);
            this.listenTo(domEventBus, 'mousedown:focus', this._onMouseDownFocus);
            this.listenTo(domEventBus, 'key:move', this._onKeyMove);
            this.listenTo(domEventBus, 'key:edit', this._onKeyEdit);
        }
    },
Exemple #4
0
  const behavior = function (view, account) {
    const navigateOptions = _.assign({}, options, { account });
    view.navigate(endpoint, navigateOptions);

    // halt the flow after navigating.
    return new Promise(() => {});
  };
Exemple #5
0
 initialize: function(rawData, options) {
     _.assign(this, {
         dataModel: options.dataModel,
         columnModel: options.columnModel,
         focusModel: options.focusModel
     });
 },
Exemple #6
0
    initialize: function() {
        Frame.prototype.initialize.apply(this, arguments);
        _.assign(this, {
            whichSide: frameConst.L
        });

        this.listenTo(this.dimensionModel, 'change:lsideWidth', this._onFrameWidthChanged);
    },
Exemple #7
0
 onGetCharacterSuccess(data) {
   assign(this, data);
   $(document.body).attr('class', 'profile ' + this.race.toLowerCase());
   let localData = localStorage.getItem('NEF') ? JSON.parse(localStorage.getItem('NEF')) : {};
   let reports = localData.reports || [];
   this.isReported = contains(reports, this.characterId);
   // If is NaN (from division by zero) then set it to "0"
   this.winLossRatio = ((this.wins / (this.wins + this.losses) * 100) || 0).toFixed(1);
 }
  _request (config) {
    const url = this._baseUrl + config.url;

    return this._xhr.oauthAjax(assign({}, config, {
      timeout: this._xhrTimeout,
      url,
    })).catch(function (xhr) {
      throw MarketingEmailErrors.normalizeXHRError(xhr);
    });
  }
Exemple #9
0
 init: function(options) {
     _.assign(this, {
         type: options.type,
         domEventBus: options.domEventBus,
         onDragMove: options.onDragMove,
         onDragEnd: options.onDragEnd,
         cursor: options.cursor,
         startData: null
     });
 },
Exemple #10
0
    initialize: function() {
        Frame.prototype.initialize.apply(this, arguments);

        _.assign(this, {
            whichSide: frameConst.R,
            $scrollBorder: null
        });
        this.listenTo(this.dimensionModel, 'change:lsideWidth change:rsideWidth', this._onFrameWidthChanged);
        this.listenTo(this.dimensionModel, 'change:bodyHeight change:headerHeight',
            this._resetScrollBorderHeight);
    },
exports.search = function search(req, res) {
  var searchParams = _.assign(defaultSearch, req.query);

  yelpController.search(searchParams)
  .then(function returnResults(results) {
    res.status(200).json(results);
  })
  .catch(function catchError(error) {
    res.status(404).json(error);
  });
};
Exemple #12
0
export function preferences(state = initialState, action) {
  switch (action.type) {
    case Actions.SET_PREFERENCE:
      return _.assign({}, state, {
        [action.key]: action.value
      });

    default:
      return state;
  }
}
Exemple #13
0
export function terminal(state = initialState, action) {
  switch (action.type) {
  case Actions.WRITE_TERMINAL:
  case Actions.BREAK_TERMINAL:
    return _.assign({}, state, {
      lines: lines(state.lines, action)
    });

  case Actions.ERROR_TERMINAL:
    return _.assign({}, state, {
      error: action.line
    });

  case Actions.FLUSH_TERMINAL:
    return initialState;

  default:
    return state;
  }
};
Exemple #14
0
		async.parallel(tasks, function(err) {
			if (err) {
				return res.status(500).json({
					err: 'database error',
					detail: err
				});
			}
			res.json(_.assign(req.list.getData(item, fields), {
				drilldown: drilldown,
				relationships: relationships
			}));
		});
Exemple #15
0
    initialize: function(options) {
        View.prototype.initialize.call(this);

        _.assign(this, {
            viewFactory: options.viewFactory,
            renderModel: options.renderModel,
            dimensionModel: options.dimensionModel,
            whichSide: options.whichSide || frameConst.R
        });

        this.listenTo(this.renderModel, 'columnModelChanged', this.render);
    },
 get: function () {
     var textStyle = _.assign({
         text: faIconMap["map-marker"],
         font: 'normal ' + this.size +'px FontAwesome',
         textBaseline: 'Bottom',
         rotation: this.rotation,
         fill: new ol.style.Fill({
             color: this.color
         })
     }, faIconMap[this.icon]);
     return new ol.style.Style({
         text: new ol.style.Text(textStyle)
     });
 }
Exemple #17
0
    setRowSpanData: function(columnName, data) {
        var rowSpanData = _.assign({}, this.data.rowSpanData);

        if (!columnName) {
            return;
        }
        if (!data) {
            if (rowSpanData[columnName]) {
                delete rowSpanData[columnName];
            }
        } else {
            rowSpanData[columnName] = data;
        }
        this.data.rowSpanData = rowSpanData;
    },
  constructor (attrs = {}, config = {}) {
    const attrsWithDefaults = assign({
      email: '',
      hasUserTakenAction: false,
      isVisible: false,
      // The null default is so a `change:password` event fires if
      // the user submits the form with an empty password.
      password: null,
    }, attrs);
    super(attrsWithDefaults, config);

    this.on('change:password', () => this.set('hasUserTakenAction', true));
    // Force a validity check every time the password is updated.
    this.on('change:password', () => this.isValid());
  }
Exemple #19
0
/**
 * Create and return a custom error class
 * 
 * @param {String} name
 * @param {Function} parent constructor
 * @return {Function}
 */
function createError(name, props) {
  // constructor
  var Ctor = _.has(props, 'constructor') 
    ? props.constructor 
    : function Ctor(message) {
    this.name = name
    this.message = message || this.message
    
    Error.captureStackTrace(this, Ctor)
  }
  
  // prototype inheritance
  Ctor.prototype = Object.create(Error.prototype)
  _.assign(Ctor.prototype, { constructor: Ctor }, props)
  
  return Ctor
}
Exemple #20
0
        initialize: function(options) {
            AutocompleteComponent.__super__.initialize.apply(this, arguments);

            // add debounce to search method
            this._searchForResults = _.debounce(this._searchForResults.bind(this), this.debounceWait);

            var thisOptions = {
                selection_template: _.bind(this.renderSelection, this),
                config: {
                    source: _.bind(this.source, this),
                    matcher: _.bind(this.matcher, this),
                    updater: _.bind(this.updater, this),
                    sorter: _.bind(this.sorter, this),
                    show: this.show,
                    hide: this.hide
                }
            };

            this.options = $.extend(true, thisOptions, this.options, options || {});
            this.$el = options._sourceElement;

            this.$el.attr('autocomplete', 'off');

            var dropClasses = this.$el.data('dropdown-classes');
            if (dropClasses) {
                this.options.config = _.assign(this.options.config, {
                    holder: '<div class="' + dropClasses.holder + '"></div>',
                    menu: '<ul class="' + dropClasses.menu + '"></ul>',
                    item: '<li class="' + dropClasses.item + '"><a class="' + dropClasses.link + '" href="#"></a></li>'
                });
            }

            if (this.options.route_name) {
                this.url = routing.generate(
                    this.options.route_name,
                    this.options.route_parameters
                );
            }

            if (!_.isFunction(this.options.selection_template) && !_.isEmpty(this.options.selection_template)) {
                this.options.selection_template = _.template(this.options.selection_template);
            }

            this.$el.typeahead(this.options.config);
        },
Exemple #21
0
const NavigationBehavior = function (endpoint, options = {}) {
  const behavior = function (view, account) {
    const navigateOptions = _.assign({}, options, { account });
    view.navigate(endpoint, navigateOptions);

    // halt the flow after navigating.
    return new Promise(() => {});
  };

  // used for testing
  _.assign(behavior, options, {
    endpoint: endpoint,
    halt: true,
    type: 'navigate',
  });

  return behavior;
};
Exemple #22
0
module.exports = function user(state, action) {
	if (typeof state === 'undefined') {
		return {
			can_approve: false,
			can_bypass_approval: false,
			can_abort_deployment: false
		};
	}

	switch (action.type) {
		case actions.SET_USER:
			return _.assign({}, state, {
				can_approve: action.data.can_approve,
				can_bypass_approval: action.data.can_bypass_approval,
				can_abort_deployment: action.data.can_abort_deployment
			});
		default:
			return state;
	}
};
Exemple #23
0
  constructor(options) {
    super(_.assign({}, options, {objectMode: true}));
    this.deferred = null;
    this.obj = null;
    this.ended = false;
    this.errored = false;

    this.on('end', () => {
      this.ended = true;
      if(this.deferred) {
        this.deferred.resolve(null);
        this.deferred = null;
      }
    });
    this.on('error', err => {
      this.errored = true;
      this.obj = err;
      if(this.deferred) {
        this.deferred.reject(err);
        this.deferred = null;
      }
    });
  }
Exemple #24
0
    initialize: function(options) {
        View.prototype.initialize.call(this);

        _.assign(this, {
            renderModel: options.renderModel,
            coordColumnModel: options.coordColumnModel,
            selectionModel: options.selectionModel,
            focusModel: options.focusModel,
            columnModel: options.columnModel,
            dataModel: options.dataModel,
            coordRowModel: options.coordRowModel,

            viewFactory: options.viewFactory,
            domEventBus: options.domEventBus,

            headerHeight: options.headerHeight,
            whichSide: options.whichSide || frameConst.R
        });

        this.dragEmitter = new DragEventEmitter({
            type: 'header',
            domEventBus: this.domEventBus,
            onDragMove: _.bind(this._onDragMove, this)
        });

        this.listenTo(this.renderModel, 'change:scrollLeft', this._onScrollLeftChange)
            .listenTo(this.coordColumnModel, 'columnWidthChanged', this._onColumnWidthChanged)
            .listenTo(this.selectionModel, 'change:range', this._refreshSelectedHeaders)
            .listenTo(this.focusModel, 'change:columnName', this._refreshSelectedHeaders)
            .listenTo(this.dataModel, 'sortChanged', this._updateBtnSortState);

        if (this.whichSide === frameConst.L && this.columnModel.get('selectType') === 'checkbox') {
            this.listenTo(this.dataModel,
                'change:_button disabledChanged extraDataChanged add remove reset',
                _.debounce(_.bind(this._syncCheckedState, this), DELAY_SYNC_CHECK));
        }
    },
Exemple #25
0
 cb(null, _.map(res, function(rec) {return _.assign(rec, {source: id})}));
 }).done((data) => {
     assign(payload, data);
     this.actions.findCharacterSuccess(payload);
 }).fail(() => {
function _post(options, data) {
    return _httpRequest(_.assign(options, {method: 'POST'}), data);
}
const Mixin = assign({}, ModalPanelMixin, {
  initialize (options = {}) {
    this.parentView = options.parentView;
    this.on('modal-cancel', () => this.onModalCancel());
  },

  events: {
    'click .cancel': preventDefaultThen('_returnToSettings'),
    'click .modal-panel #back': preventDefaultThen('_returnToAvatarChange')
  },

  _returnToAvatarChange () {
    this.navigate('settings/avatar/change');
  },

  _returnToClients () {
    this.navigate('settings/clients');
  },

  _returnToTwoFactorAuthentication () {
    this.navigate('settings/two_step_authentication');
  },

  _returnToAccountRecovery (hasRecoveryKey) {
    this.navigate('settings/account_recovery', { hasRecoveryKey });
  },

  _showAccountRecoveryKey () {
    this.navigate('settings/account_recovery/recovery_key', {
      hasRecoveryKey: true
    });
  },

  _returnToSettings () {
    this.navigate('settings');
  },

  onModalCancel() {
    // modal-cancel is called whenever the modal is closed because the
    // page has navigated, causing two navigate's to occur. If a navigate
    // has already happened, do not try to navigate again when the
    // modal-cancel event occurs.
    if (this.hasNavigated()) {
      return;
    }

    switch (this.currentPage) {
    case 'settings/clients/disconnect':
      this._returnToClients();
      break;
    case 'settings/two_step_authentication/recovery_codes':
      if (this.model.get('previousViewName') === 'sign_in_recovery_code') {
        const account = this.getSignedInAccount();
        return this.invokeBrokerMethod('afterCompleteSignInWithCode', account);
      }
      this._returnToTwoFactorAuthentication();
      break;
    case 'settings/account_recovery/recovery_key' :
      this._returnToAccountRecovery(true);
      break;
    case 'settings/account_recovery/confirm_revoke' :
      this._returnToAccountRecovery(false);
      break;
    case 'settings/account_recovery/confirm_password' :
      if (this.showRecoveryKeyView) {
        this._showAccountRecoveryKey();
      } else {
        this._returnToAccountRecovery(false);
      }
      break;
    default:
      this._returnToSettings();
    }
  },

  displaySuccess (msg) {
    this.parentView.displaySuccess(msg);
  }
});
Exemple #29
0
 constructor(fileInfo,stream){
     this[_stream] = stream;
     _.assign(this,fileInfo);
 }
 .done((data) => {
     assign(payload, data); // payload + data
     this.actions.findPokemonSuccess(payload); // on fera dans le Store :  payload._id : récupere l'id de l'objet pokemon
 })