function getStageNameList(stageList: List<StageConfig | RawStageConfig>) {
  if (stageList.isEmpty()) {
    return 'empty'
  } else {
    return stageList.map(s => s.name).join(',')
  }
}
function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
        console.log(`todosReducer: Action(${JSON.stringify(action)})`);
        switch(action.type) {
                case Keys.AddTodo:
                    var todos: List<ITask> = List<ITask>(state.concat([action.payload]));
                    console.log(`todosReducer: todos(${JSON.stringify(todos)})`);
                    return todos;
                case Keys.CompleteTodo:
                        return List<ITask>(state.map((task:ITask) => {
                                if (task.Id === action.payload.Id) {
                                        return new Task(
                                                task.Id,
                                                task.Title,
                                                task.Description,
                                                action.payload.Complete
                                        );
                                } else {
                                        return task;
                                }
                        }));
                case Keys.RemoveTodo:
                        return List<ITask>(state.filter((task:ITask) => {
                                return task.Id !== action.payload.Id;
                        }))
        }                                 
        return state || initialState.todos;
}
Example #3
0
 totalIncomeForeignAmount(): BigNumber {
   return this.incomes
       .map((i: Income) => i.foreignAmount)
       .reduce(
           (a: BigNumber, b: BigNumber) => a.plus(b),
           new BigNumber(0));
 }
Example #4
0
 recomputeRemaining(): Project {
   let remaining: BigNumber = this.incomes
       .map(
           (i: Income) => i.remainingLocalAmount())
       .reduce(
           (a: BigNumber, b: BigNumber) => a.plus(b),
           new BigNumber(0));
   return this.set('remainingLocalAmount', remaining);
 }
Example #5
0
function todosReducer(state: List<Todo> = List([]), action) {
  switch (action.type) {
    case LOAD_TODOS:
      return List(action.todos);
    case ADD_TODO:
      return state.push(action.newTodo);
    case TOGGLE_TODO:
      return toggleTodo(state, action);
    case TOGGLE_ALL_TODO:
      return toggleAllTodo(state, action.completed);
    case DELETE_TODO:
      let index = state.findIndex((todo) => todo.id === action.todo.id);
      return state.delete(index);
    case SET_CURRENT_FILTER:
      return state.map(todo => todo);
    case '@@redux-pouchdb-plus/SET_REDUCER':
      return state.map(todo => new Todo(todo.toJS()));
    default:
      return state;
  }
}
Example #6
0
 private calcMinMoves() {
   this.consoleLogMsg('score.service', 'calcMinMoves');
   let moves: number = 0;
   if (this._data.size > 0) {
     this._data.map((score: Score) => {
       if (moves === 0 || score.moves < moves) {
         moves = score.moves;
       }
     });
   }
   this._minMoves = moves;
 }
Example #7
0
 private calcNextRow() {
   this.consoleLogMsg('score.service', 'calcNextRow');
   let row: number = 1;
   if (this._data.size > 0) {
     this._data.map((score: Score) => {
       if (score.row > row) {
         row = score.row;
       }
     });
     row++;
   }
   this.nextRow = row;
   this.consoleLogMsg('score.service', 'nextRow = ' + this.nextRow);
 }
Example #8
0
 private calcNextId() {
   this.consoleLogMsg('score.service', 'calcNextId');
   let id: number = 1;
   if (this._data.size > 0) {
     this._data.map((score: Score) => {
       if (score.id > id) {
         id = score.id;
       }
     });
     id++;
   }
   this._nextId = id;
   this.consoleLogMsg('score.service', 'nextId = ' + this.nextId);
 }
Example #9
0
const fetchMapIssues = (reposIds: List<string>, state: any, page: number) =>
  forkJoin(
    ...reposIds
      .map(id =>
        get({
          endpoint: `repos/${state.repository.getIn([id, "full_name"])}/issues`,
          params: { page }
        })
      )
      .toArray()
  ).pipe(
    map(issues => {
      return List(issues)
        .map((issueArr: any, index) => {
          return issueArr.map(issue =>
            issue.set("repositoryId", reposIds.get(index))
          );
        })
        .flatten(1);
    })
  );
function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
        switch(action.key) {
                case Keys.AddTodo:
                        return List<ITask>(state.concat([action.payload]))
                case Keys.CompleteTodo:
                        return List<ITask>(state.map((task:ITask) => {
                                if (task.Id === action.payload.Id) {
                                        return new Task(
                                                task.Id,
                                                task.Title,
                                                task.Description,
                                                action.payload.Complete
                                        );
                                } else {
                                        return task;
                                }
                        }));
                case Keys.RemoveTodo:
                        return List<ITask>(state.filter((task:ITask) => {
                                return task.Id !== action.payload.Id;
                        }))
        }                                 
        return state;
}