"""_____________________________________________________________________

:PROJECT: LARAsuite

*lara_django_processes admin *

:details: lara_django_processes admin module admin backend configuration.
         - 
:authors: mark doerr <mark.doerr@uni-greifswald.de>

.. note:: -
.. todo:: - run "lara-django-dev forms_generator -c lara_django_processes > forms.py" to update this file
________________________________________________________________________
"""

# django crispy forms s. https://github.com/django-crispy-forms/django-crispy-forms for []
# generated with django-extensions forms_generator -c  [] > forms.py (LARA-version)

from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Row, Column

from .models import (
    ExtraData,
    ProcMethodClass,
    Method,
    Procedure,
    Process,
    MethodInstance,
    ProcedureInstance,
    ProcessStepClass,
    ProcessInstanceStep,
    # ProcedureInstanceMoveStep,
    ProcessInstance,
)


class ExtraDataCreateForm(forms.ModelForm):
    class Meta:
        model = ExtraData
        fields = (
            "data_type",
            "name",
            "name_full",
            "name_display",
            "namespace",
            "version",
            "hash_sha256",
            "data_json",
            "media_type",
            "iri",
            "url",
            "description",
            "image",
            "file",
        )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            "data_type",
            "name",
            "name_full",
            "name_display",
            "namespace",
            "version",
            "hash_sha256",
            "data_json",
            "media_type",
            "iri",
            "url",
            "description",
            "image",
            "file",
            Submit("submit", "Create"),
        )


class ExtraDataUpdateForm(forms.ModelForm):
    class Meta:
        model = ExtraData
        fields = (
            "data_type",
            "name",
            "name_full",
            "name_display",
            "namespace",
            "version",
            "data_json",
            "media_type",
            "iri",
            "url",
            "description",
            "image",
            "file",
        )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            "data_type",
            "name",
            "name_full",
            "name_display",
            "namespace",
            "version",
            "data_json",
            "media_type",
            "iri",
            "url",
            "description",
            "image",
            "file",
            Submit("submit", "Update"),
        )


class MethodClassCreateForm(forms.ModelForm):
    class Meta:
        model = ProcMethodClass
        fields = ("name", "iri", "description")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout("name", "iri", "description", Submit("submit", "Create"))


class MethodClassUpdateForm(forms.ModelForm):
    class Meta:
        model = ProcMethodClass
        fields = ("name", "iri", "description")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout("name", "iri", "description", Submit("submit", "Update"))


class MethodCreateForm(forms.ModelForm):
    class Meta:
        model = Method
        fields = (
            "name_display",
            "namespace",
            "name",
            "method_class",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "media_type",
            "method_json",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Title", "required": True}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "pid", "required": False}),
            "media_type": forms.TextInput(attrs={"placeholder": "Media type", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("method_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
                Column("version", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-10 mb-0"),
                Column("icon", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("pid", css_class="form-group col-md-6 mb-0"),
                Column("iri", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class MethodUpdateForm(forms.ModelForm):
    class Meta:
        model = Method
        fields = (
            "name_display",
            "namespace",
            "name",
            "method_class",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "media_type",
            "method_json",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Title", "required": True}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "pid", "required": False}),
            "media_type": forms.TextInput(attrs={"placeholder": "Media type", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("method_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
                Column("version", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-10 mb-0"),
                Column("icon", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("pid", css_class="form-group col-md-6 mb-0"),
                Column("iri", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


class ProcedureCreateForm(forms.ModelForm):
    class Meta:
        model = Procedure
        fields = (
            "name_display",
            # "procedure_base",
            "namespace",
            "name",
            "creators",
            "parts",
            "devices",
            "labware",
            "substances",
            "polymers",
            "mixtures",
            "organisms",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "procedure_json",
            "procedure_file",
            "procedure_class",
            "media_type",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "parts": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "devices": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymers": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixtures": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organisms": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "proocdure_JSON": forms.Textarea(attrs={"placeholder": "Procedure File", "required": False}),
            "procedure_file": forms.ClearableFileInput(
                attrs={"placeholder": "Procedure file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            # Row(
            #     Column("process_base", css_class="form-group col-md-12 mb-0"),
            # ),
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("procedure_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("parts", css_class="form-group col-md-4 mb-0"),
                Column("devices", css_class="form-group col-md-4 mb-0"),
                Column("labware", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substances", css_class="form-group col-md-4 mb-0"),
                Column("polymers", css_class="form-group col-md-4 mb-0"),
                Column("mixtures", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organisms", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("procedure_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("procedure_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class ProcedureUpdateForm(forms.ModelForm):
    class Meta:
        model = Procedure
        fields = (
            "name_display",
            # "procedure_base",
            "namespace",
            "name",
            "creators",
            "parts",
            "devices",
            "labware",
            "substances",
            "polymers",
            "mixtures",
            "organisms",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "procedure_json",
            "procedure_file",
            "procedure_class",
            "media_type",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "parts": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "devices": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymers": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixtures": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organisms": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "proocdure_JSON": forms.Textarea(attrs={"placeholder": "Procedure File", "required": False}),
            "procedure_file": forms.ClearableFileInput(
                attrs={"placeholder": "Procedure file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            # Row(
            #     Column("process_base", css_class="form-group col-md-12 mb-0"),
            # ),
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("procedure_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("parts", css_class="form-group col-md-4 mb-0"),
                Column("devices", css_class="form-group col-md-4 mb-0"),
                Column("labware", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substances", css_class="form-group col-md-4 mb-0"),
                Column("polymers", css_class="form-group col-md-4 mb-0"),
                Column("mixtures", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organisms", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("procedure_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("procedure_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


class ProcessCreateForm(forms.ModelForm):
    class Meta:
        model = Process
        fields = (
            "name_display",
            "namespace",
            "name",
            "creators",
            "parts",
            "devices",
            "labware",
            "substances",
            "polymers",
            "mixtures",
            "organisms",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "process_class",
            "process_json",
            "process_file",
            "media_type",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Name", "required": True}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "parts": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "devices": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymers": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixtures": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organisms": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "process_json": forms.Textarea(attrs={"placeholder": "Process", "required": False}),
            "process_file": forms.FileInput(
                attrs={"placeholder": "Process file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("process_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("parts", css_class="form-group col-md-4 mb-0"),
                Column("devices", css_class="form-group col-md-4 mb-0"),
                Column("labware", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substances", css_class="form-group col-md-4 mb-0"),
                Column("polymers", css_class="form-group col-md-4 mb-0"),
                Column("mixtures", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organisms", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("process_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("process_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class ProcessUpdateForm(forms.ModelForm):
    class Meta:
        model = Process
        fields = (
            "name_display",
            "namespace",
            "name",
            "creators",
            "parts",
            "devices",
            "labware",
            "substances",
            "polymers",
            "mixtures",
            "organisms",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "process_class",
            "process_json",
            "process_file",
            "media_type",
        )
        widgets = {
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": True}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "parts": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "devices": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymers": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixtures": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organisms": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "process_json": forms.Textarea(attrs={"placeholder": "Process", "required": False}),
            "process_file": forms.FileInput(
                attrs={"placeholder": "Process file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("process_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("parts", css_class="form-group col-md-4 mb-0"),
                Column("devices", css_class="form-group col-md-4 mb-0"),
                Column("labware", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substances", css_class="form-group col-md-4 mb-0"),
                Column("polymers", css_class="form-group col-md-4 mb-0"),
                Column("mixtures", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organisms", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("process_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("process_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


class MethodInstanceCreateForm(forms.ModelForm):
    class Meta:
        model = MethodInstance
        fields = (
            "name_display",
            "namespace",
            "name",
            "uri",
            "version",
            "parameters",
            "status",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "method_base",
            "media_type",
        )
        widgets = {
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "status": forms.Select(attrs={"placeholder": "State", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "method_base": forms.Select(attrs={"placeholder": "Method", "required": True}),
            "method_json": forms.Textarea(attrs={"placeholder": "Method", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("method_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-6 mb-0"),
                Column("name", css_class="form-group col-md-4 mb-0"),
                Column("status", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("method_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class MethodInstanceUpdateForm(forms.ModelForm):
    class Meta:
        model = MethodInstance
        fields = (
            "namespace",
            "name",
            "uri",
            "version",
            "parameters",
            "status",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "method_base",
            "media_type",
        )
        widgets = {
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": True}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "status": forms.Select(attrs={"placeholder": "State", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "method_base": forms.Select(attrs={"placeholder": "Method", "required": True}),
            "method_json": forms.Textarea(attrs={"placeholder": "Method", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("method_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-6 mb-0"),
                Column("name", css_class="form-group col-md-4 mb-0"),
                Column("status", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
                Column("version", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("method_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


class ProcedureInstanceCreateForm(forms.ModelForm):
    class Meta:
        model = ProcedureInstance
        fields = (
            "name_display",
            "procedure_base",
            "namespace",
            "name",
            "creators",
            "part_instances",
            "device_instances",
            "labware_instances",
            "substance_instances",
            "polymer_instances",
            "mixture_instances",
            "organism_instances",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "procedure_json",
            "procedure_file",
            # "procedure_class",
            "media_type",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "part_instances": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "device_instances": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware_instances": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substance_instances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymer_instances": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixture_instances": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organism_instances": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "proocdure_JSON": forms.Textarea(attrs={"placeholder": "Procedure File", "required": False}),
            "procedure_file": forms.ClearableFileInput(
                attrs={"placeholder": "Procedure file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("procedure_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-8 mb-0"),
                # Column("procedure_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("part_instances", css_class="form-group col-md-4 mb-0"),
                Column("device_instances", css_class="form-group col-md-4 mb-0"),
                Column("labware_instances", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substance_instances", css_class="form-group col-md-4 mb-0"),
                Column("polymer_instances", css_class="form-group col-md-4 mb-0"),
                Column("mixture_instances", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organism_instances", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("procedure_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("procedure_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class ProcedureInstanceUpdateForm(forms.ModelForm):
    class Meta:
        model = ProcedureInstance
        fields = (
            "namespace",
            "name",
            "uri",
            "version",
            "parameters",
            "status",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "procedure_base",
            "procedure_json",
            "media_type",
            "procedure_file",
        )
        widgets = {
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": True}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "status": forms.Select(attrs={"placeholder": "State", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "procedure_base": forms.Select(attrs={"placeholder": "Procedure", "required": True}),
            "procedure_json": forms.Textarea(attrs={"placeholder": "Procedure", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("procedure_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-6 mb-0"),
                Column("name", css_class="form-group col-md-4 mb-0"),
                Column("status", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
                Column("version", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("procedure_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


# class ProcedureInstanceStepClassCreateForm(forms.ModelForm):
#     class Meta:
#         model = ProcessInstanceStepClass
#         fields = ("name", "iri", "description")

#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.helper = FormHelper()
#         self.helper.layout = Layout("name", "iri", "description", Submit("submit", "Create"))


# class ProcedureInstanceStepClassUpdateForm(forms.ModelForm):
#     class Meta:
#         model = ProcessInstanceStepClass
#         fields = ("name", "iri", "description")

#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.helper = FormHelper()
#         self.helper.layout = Layout("name", "iri", "description", Submit("submit", "Update"))


class ProcedureInstanceStepCreateForm(forms.ModelForm):
    class Meta:
        model = ProcessInstanceStep
        fields = (
            
            # "step_class",
            "datetime_start",
            "datetime_end",
            "procedure_instance",
            # "device_instance",
            # "labware_instance",
            "parameters",
            "simulation",
        )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            # "name",
            # "step_class",
            "datetime_start",
            "datetime_end",
            "procedure_instance",
            # "device_instance",
            # "labware_instance",
            "parameters",
            "simulation",
            Submit("submit", "Create"),
        )


class ProcedureInstanceStepUpdateForm(forms.ModelForm):
    class Meta:
        model = ProcessInstanceStep
        fields = (
            # "name",
            # "step_class",
            "datetime_start",
            "datetime_end",
            "procedure_instance",
            # "device_instance",
            # "labware_instance",
            "parameters",
            "simulation",
        )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            # "name",
            # "step_class",
            "datetime_start",
            "datetime_end",
            "procedure_instance",
            # "device_instance",
            # "labware_instance",
            "parameters",
            "simulation",
            Submit("submit", "Update"),
        )





class ProcessInstanceCreateForm(forms.ModelForm):
    class Meta:
        model = ProcessInstance
        fields = (
            "name_display",
            "process_base",
            "namespace",
            "name",
            "creators",
            "part_instances",
            "device_instances",
            "labware_instances",
            "substance_instances",
            "polymer_instances",
            "mixture_instances",
            "organism_instances",
            "samples",
            "sample_sets",
            "tags",
            "uri",
            "version",
            "parameters",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "process_json",
            "process_file",
            "media_type",
        )
        widgets = {
            "name_display": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": False}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "part_instances": forms.SelectMultiple(attrs={"placeholder": "parts", "required": False}),
            "device_instances": forms.SelectMultiple(attrs={"placeholder": "devices", "required": False}),
            "labware_instances": forms.SelectMultiple(attrs={"placeholder": "labware", "required": False}),
            "substance_instances": forms.SelectMultiple(attrs={"placeholder": "substances", "required": False}),
            "polymer_instances": forms.SelectMultiple(attrs={"placeholder": "polymers", "required": False}),
            "mixture_instances": forms.SelectMultiple(attrs={"placeholder": "mixtures", "required": False}),
            "organism_instances": forms.SelectMultiple(attrs={"placeholder": "organisms", "required": False}),
            "samples": forms.SelectMultiple(attrs={"placeholder": "samples", "required": False}),
            "sample_sets": forms.SelectMultiple(attrs={"placeholder": "sample_sets", "required": False}),
            "creators": forms.SelectMultiple(attrs={"placeholder": "creators", "required": False}),
            "tags": forms.SelectMultiple(attrs={"placeholder": "tags", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "process_json": forms.Textarea(attrs={"placeholder": "Process", "required": False}),
            "process_file": forms.FileInput(
                attrs={"placeholder": "Process file", "required": False}
            ),  # ClearableFileInput
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("process_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("name_display", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-4 mb-0"),
                Column("name", css_class="form-group col-md-6 mb-0"),
                Column("process_class", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-10 mb-0"),
                Column("version", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column("creators", css_class="form-group col-md-6 mb-0"),
                Column("uri", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("part_instances", css_class="form-group col-md-4 mb-0"),
                Column("device_instances", css_class="form-group col-md-4 mb-0"),
                Column("labware_instances", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("substance_instances", css_class="form-group col-md-4 mb-0"),
                Column("polymer_instances", css_class="form-group col-md-4 mb-0"),
                Column("mixture_instances", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("organism_instances", css_class="form-group col-md-4 mb-0"),
                Column("samples", css_class="form-group col-md-4 mb-0"),
                Column("sample_sets", css_class="form-group col-md-4 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("process_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-4 mb-0"),
                Column("process_file", css_class="form-group col-md-8 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("tags", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Create"),
        )


class ProcessInstanceUpdateForm(forms.ModelForm):
    class Meta:
        model = ProcessInstance
        fields = (
            "namespace",
            "name",
            "uri",
            "version",
            "parameters",
            "status",
            "resources_external",
            "icon",
            "description",
            "remarks",
            "iri",
            "pid",
            "process_base",
            "process_json",
            "media_type",
            "process_file",
        )
        widgets = {
            "name": forms.TextInput(attrs={"placeholder": "Name", "required": True}),
            "uri": forms.URLInput(attrs={"placeholder": "uri", "required": False}),
            "version": forms.TextInput(attrs={"placeholder": "Version", "required": False}),
            "parameters": forms.Textarea(attrs={"placeholder": "Parameters", "required": False}),
            "status": forms.Select(attrs={"placeholder": "State", "required": False}),
            "resources_external": forms.SelectMultiple(attrs={"placeholder": "resources_external", "required": False}),
            "icon": forms.TextInput(attrs={"placeholder": "Icon", "required": False}),
            "description": forms.Textarea(attrs={"placeholder": "Description", "required": False}),
            "remarks": forms.Textarea(attrs={"placeholder": "Remarks", "required": False}),
            "iri": forms.TextInput(attrs={"placeholder": "IRI", "required": False}),
            "pid": forms.TextInput(attrs={"placeholder": "Persistent Identifier", "required": False}),
            "process_base": forms.Select(attrs={"placeholder": "Process", "required": True}),
            "process_json": forms.Textarea(attrs={"placeholder": "Process", "required": False}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column("process_base", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("namespace", css_class="form-group col-md-6 mb-0"),
                Column("name", css_class="form-group col-md-4 mb-0"),
                Column("status", css_class="form-group col-md-2 mb-0"),
            ),
            Row(
                Column(css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("uri", css_class="form-group col-md-6 mb-0"),
                Column("version", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("parameters", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("description", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("remarks", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("resources_external", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("iri", css_class="form-group col-md-6 mb-0"),
                Column("pid", css_class="form-group col-md-6 mb-0"),
            ),
            Row(
                Column("process_json", css_class="form-group col-md-12 mb-0"),
            ),
            Row(
                Column("media_type", css_class="form-group col-md-6 mb-0"),
                Column("icon", css_class="form-group col-md-6 mb-0"),
            ),
            Submit("submit", "Update"),
        )


# from .forms import ExtraDataCreateForm, ItemCreatorTypeCreateForm, ItemCreatorCreateForm, MethodClassCreateForm, MethodCreateForm, ProcedureCreateForm, ProcessCreateForm, MethodInstanceCreateForm, ProcedureInstanceCreateForm, ProcessInstanceCreateFormExtraDataUpdateForm, ItemCreatorTypeUpdateForm, ItemCreatorUpdateForm, MethodClassUpdateForm, MethodUpdateForm, ProcedureUpdateForm, ProcessUpdateForm, MethodInstanceUpdateForm, ProcedureInstanceUpdateForm, ProcessInstanceUpdateForm
