Sha256: 84bcb038c6d4a93da1bae2da0aa1db3fbfb7eb601f7aa6ab9aa0922ca500617f

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

import { filter, reduce, find } from 'lodash';
import { computed } from 'mobx';

export default class Info {
    constructor(query) {
        this.query = query;
    }

    @computed get syncUrl() {
        return this.query.customSyncUrl || this.query.src.syncUrl;
    }

    @computed get minWidth() {
        return reduce(this.visibleFields, (sum, f) => sum + f.width, 0);
    }

    // the index of fields marked as visible
    @computed get visibleIndexes() {
        const indexes = [];
        this.query.fields.forEach((f, i) => { if (f.visible) { indexes.push(i); } });
        return indexes;
    }

    @computed get visibleFields() {
        return filter(this.query.fields, f => f.visible);
    }

    @computed get queryableFields() {
        return filter(this.query.fields, f => f.queryable);
    }

    @computed get loadableFields() {
        return filter(this.query.fields, f => f.loadable);
    }

    @computed get identifierField() {
        const property = this.query.src.identifierFieldName;
        return find(this.query.fields, { id: property });
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hippo-fw-0.9.5 client/hippo/models/query/info.js