from plone.app.textfield import RichText as RichTextField
from plone.app.textfield.value import RichTextValue
from plone.app.z3cform.widget import RichTextFieldWidget
from plone.autoform import directives as form
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import model
from ploneintranet.core import _
from zope.interface import provider
from zope.schema import TextLine
from zope.schema import Tuple


@provider(IFormFieldProvider)
class IMail(model.Schema):

    mail_from = TextLine(title=_("from", "From"), description="", default="")

    mail_to = Tuple(
        title=_("to", "To"),
        description="",
        value_type=TextLine(),
        defaultFactory=tuple,
        required=False,
    )

    mail_cc = Tuple(
        title=_("cc", "CC"),
        description="",
        value_type=TextLine(),
        defaultFactory=tuple,
        required=False,
    )

    mail_bcc = Tuple(
        title=_("bcc", "BCC"),
        description="",
        value_type=TextLine(),
        missing_value=(),
        required=False,
    )

    mail_body = RichTextField(
        title=_("body", "Body"),
        description="",
        required=False,
        default=RichTextValue(""),
    )
    form.widget("mail_body", RichTextFieldWidget)
    model.primary("mail_body")
