# Path: gramps_connect/template_functions.py
# def make_button(text, link):
#     return """<input type="button" value="%s" onclick="location.href='%s';" />""" % (text, link)


import logging
import math
import time
from ..template_functions import make_button
from gramps.gen.display.name import NameDisplay
from gramps.gen.datehandler import displayer, parser
                for item in data:
                    if retval:
                        retval += ", "
                    retval += item
            else:
                ## a list of handles
                retval = """<select multiple="multiple" name="%s" id="id_%s" style="width: 100%%">""" % (field, field)
                count = 1
                for item in data:
                    retval += """<option value="%d" selected="selected">%s</option>""" % (count, item)
                    count += 1
                retval += "</select>"
        else:
            retval = data
            if action in ["edit", "add"]:
                id = js if js else "id_" + field
                dict = {"id": id, "name": field, "value": retval}
                retval = """<input id="%(id)s" type="text" name="%(name)s" value="%(value)s" style="display:table-cell; width:100%%">""" % dict
        if field in self.post_process_functions:
            retval = self.post_process_functions[field](data, {})
        if link:
            retval = '''<a href="''' +  (link % kwargs) + '''">''' + retval + """</a>"""
        return str(retval)

    def get(self, field):
        return self.instance.get_field(field, self.database)

    def save(self, handler):
        # go thorough fields and save values
        for field in self.edit_fields:

# Path: gramps_connect/template_functions.py
# def make_button(text, link):
#     return """<input type="button" value="%s" onclick="location.href='%s';" />""" % (text, link)


# Path: gramps_connect/forms/forms.py
import logging
import math
import time
from ..template_functions import make_button
from gramps.gen.display.name import NameDisplay
from gramps.gen.datehandler import displayer, parser

                for item in data:
                    if retval:
                        retval += ", "
                    retval += item
            else:
                ## a list of handles
                retval = """<select multiple="multiple" name="%s" id="id_%s" style="width: 100%%">""" % (field, field)
                count = 1
                for item in data:
                    retval += """<option value="%d" selected="selected">%s</option>""" % (count, item)
                    count += 1
                retval += "</select>"
        else:
            retval = data
            if action in ["edit", "add"]:
                id = js if js else "id_" + field
                dict = {"id": id, "name": field, "value": retval}
                retval = """<input id="%(id)s" type="text" name="%(name)s" value="%(value)s" style="display:table-cell; width:100%%">""" % dict
        if field in self.post_process_functions:
            retval = self.post_process_functions[field](data, {})
        if link:
            retval = '''<a href="''' +  (link % kwargs) + '''">''' + retval + """</a>"""
        return str(retval)

    def get(self, field):
        return self.instance.get_field(field, self.database)

    def save(self, handler):
        # go thorough fields and save values
        for field in self.edit_fields:

            try: