# -*- coding: utf-8 -*-
import decimal

from flask_wtf import FlaskForm
from wtforms import (BooleanField, DecimalField, Field, TextField, SelectMultipleField,
                     IntegerField, SubmitField)
from wtforms.widgets import TextInput

# make a base class or other utility with this instead..
class TagListField(Field):
    widget = TextInput()

    def _value(self):
        if self.data:
            return ', '.join(self.data)
        else:
            return ''

    def process_formdata(self, valuelist):
        if valuelist:
            self.data = [x.strip() for x in valuelist[0].split(',') if x.strip()]
        else:
            self.data = []

class GeneVariantFiltersForm(FlaskForm):
    """Base FiltersForm for SNVs"""
    variant_type = SelectMultipleField(choices=[('clinical','clinical'),('research','research')])
    hgnc_symbols = TagListField('HGNC Symbols/Ids (case sensitive)')
    filter_variants = SubmitField(label='Filter variants')
    rank_score = IntegerField()
    phenotype_terms = TagListField('HPO terms')
    phenotype_groups = TagListField('Phenotype groups')
    similar_case = TagListField('Phenotypically similar case')
    cohorts = TagListField('Cohorts')
