Example #1
0
 transform(items:List<StoreModel>, ...args:any[]):any {
     if (_.isNull(args))
         return items;
     var field =  args[0];
     var desc = args[1] == undefined ? false : args[1];
     if (items && field) {
         return items.sort((a:StoreModel, b:StoreModel)=> {
             if (a.getKey(field) < b.getKey(field))
                 return desc ? 1 : -1;
             if (a.getKey(field) > b.getKey(field))
                 return desc ? -1 : 1;
             return 0;
         })
         // return Array.from(input).sort((a: Object, b: Object) => {
         //     if (_.get(a, field) < _.get(b, field)) {
         //         return desc ? 1 : -1;
         //     }
         //     if (_.get(a, field) > _.get(b, field)) {
         //         return desc ? -1 : 1;
         //     }
         //     return 0;
         // });
     }
     return items;
 }
Example #2
0
 recomputeIncomes(): Project {
   return this
     .set(
       'incomes',
       this
         .incomes
         .sort(compareIncomes)
         .map(income => income.refresh()))
     .recomputeExpenses();
 }
Example #3
0
 transform(items:List<StoreModel>, config:any = '+'):any {
     if (Array.isArray(items))
         return items;
     return items.sort((a:StoreModel, b:StoreModel)=> {
         if (a.getKey('order') < b.getKey('order'))
             return -1;
         if (a.getKey('order') > b.getKey('order'))
             return 1;
         return 0;
     })
 }
Example #4
0
const sortAnnotations = (annotations: List<Record<AnnotationColorMap>>) => {
  const path = ['annotation', 'utc_timestamp']

  return annotations.sort((a1, a2) => {
    const a1Start = a1.getIn(path)
    const a2Start = a2.getIn(path)
    if(a1Start < a2Start) {
      return -1
    } else if(a1Start > a2Start) {
      return 1
    } elseĀ {
      return 0
    }
  })
}
Example #5
0
  constructor(
    plugins: List<TablePlugin>,
    columns: List<ColumnDef>,
    dataTable: DataTable,
    initData: TableData
  ) {
    this.dataTable = dataTable
    this.columns = columns

    // Sort plugins by priority DESC
    this.plugins = plugins.sort(
      (a, b) => b.priority - a.priority
    ).toList()

    // Register root element to each plugin
    this.plugins
      .filter(p => !!p.register)
      .forEach(p => p.register(this, initData))
  }