Exemplo n.º 1
0
    render: function () {
        var SortIcon = this.props.sortOrder !== null ? Icon({
            style: {marginLeft: 5},
            name: this.props.sortOrder === 'asc' ? 'sort-by-alphabet' : 'sort-by-alphabet-alt'
        }) : null;

        var Label = this.props.attr.description ? span(null, Popover({
            value: this.props.attr.label,
            popoverValue: this.props.attr.description
        })) : this.props.attr.label;

        return (
            th({className: this.props.className},
                this.props.canSort ? span({style: {cursor: 'pointer'}, onClick: this._handleSort},
                    Label,
                    SortIcon
                ) : Label
            )
        );
    },
Exemplo n.º 2
0
    _createValue: function (value) {
        var CellContent, attr = this.props.attr;

        if (value === undefined || value === null) {
            CellContent = span(null, String.fromCharCode(160)); //  
        } else {
            switch (attr.fieldType) {
                case 'BOOL':
                    CellContent = span(null, value.toString());
                    break;
                case 'CATEGORICAL':
                case 'XREF':
                    if (attr.expression) {
                        // computed refs refer to entities that only exist within the context of entity that refers to them
                        CellContent = span(null, value[attr.refEntity.labelAttribute]);
                    } else {
                        CellContent = a({
                            href: '#',
                            onClick: this._toggleModal.bind(null, true)
                        }, span(null, value[attr.refEntity.labelAttribute]));
                    }
                    break;
                case 'FILE':
                    CellContent = (
                        div(null,
                            a({
                                href: '#',
                                onClick: this._toggleModal.bind(null, true)
                            }, span(null, value[attr.refEntity.labelAttribute])),
                            ' ',
                            a({href: value['url']},
                                Icon({
                                    name: 'download',
                                    style: {cursor: 'pointer'}
                                })
                            )
                        )
                    );
                    break;
                case 'CATEGORICAL_MREF':
                case 'MREF':
                case 'ONE_TO_MANY':
                    if (attr.name === "PubMedID") {
                        CellContent = (
                            span(null,
                                _.flatten(_.map(value, function (item, i) {
                                    var Element;
                                    if (value != "Unpublished") {
                                        Element = a({
                                            href: "http://www.ncbi.nlm.nih.gov/pubmed/" + item[attr.refEntity.labelAttribute],
                                            target: '_blank'
                                        }, item[attr.refEntity.labelAttribute]);
                                    } else {
                                        Element = span(null, item[attr.refEntity.labelAttribute]);
                                    }
                                    var Seperator = i < value.length - 1 ? span({key: 's' + i}, ',') : null;
                                    return [Element, Seperator];
                                }.bind(this)))
                            )
                        );
                    }
                    else {
                        CellContent = (
                            span(null,
                                _.flatten(_.map(value, function (item, i) {
                                    var Element;
                                    if (attr.expression) {
                                        // computed refs refer to entities that only exist within the context of entity that refers to them
                                        Element = span(null, item[attr.refEntity.labelAttribute]);
                                    } else {
                                        Element = a({
                                            href: '#',
                                            onClick: this._toggleModal.bind(null, true),
                                            key: 'a' + i
                                        }, span(null, item[attr.refEntity.labelAttribute]));
                                    }
                                    var Seperator = i < value.length - 1 ? span({key: 's' + i}, ',') : null;
                                    return [Element, Seperator];
                                }.bind(this)))
                            )
                        );
                    }
                    break;
                case 'EMAIL':
                    CellContent = a({href: 'mailto:' + value}, value);
                    break;
                case 'HYPERLINK':
                    CellContent = a({href: value, target: '_blank'}, value);
                    break;
                case 'HTML':
                case 'SCRIPT':
                case 'TEXT':
                    var maxLength = 50;
                    if (value.length > maxLength) {
                        CellContent = span(null, Popover({
                            value: value.substring(0, maxLength - 3) + '...',
                            popoverValue: value
                        }));
                    } else {
                        CellContent = span(null, value);
                    }
                    break;
                default:
                    if (attr.name === mutationAttr.name) {
                        CellContent = a({
                            href: '#',
                            onClick: function () {
                                this.props.onRowInspect({
                                    name: "col7a1_Mutations",
                                    id: value["cdnanotation"]
                                });
                            }.bind(this),
                        }, span(null, value["cdnanotation"]));
                    } else {
                        CellContent = span(null, value);
                    }
                    break;
            }
        }

        return CellContent;
    },