from flask_table import Table, Col, LinkCol


class JobInputTable(Table):
    """
    Declares the table describing colum by column.
    """
    classes = ['highlight', 'responsive-table']
    filename = Col('Filename', column_html_attrs={'class': 'filename'},
                   th_html_attrs={'class': 'sort',
                                  'data-sort': 'filename'})
    url = LinkCol('Download', 'jobs.download_job_input',
                  url_kwargs=dict(job_id='job.id',
                                  job_input_id='input_id'),
                  anchor_attrs={'class': 'waves-effect waves-light btn-floating',
                                'download': ''},
                  text_fallback='<i class="material-icons">file_download</i>')


class JobInputItem(object):
    """
    Describes one item like one row per table.
    """

    def __init__(self, filename, job, input_id):
        self.filename = filename
        self.job = job
        self.input_id = input_id