{{define "choose_map"}}
    <script>
        $("select.{{.Field}}").on("select2:select", function (e) {
            {{range $val, $object := .Data}}

            {{if $object.Hide}}

            if (e.params.data.text === "{{$val}}" || e.params.data.id === "{{$val}}") {
                $("label[for='{{$object.Field}}']").parent().hide()
            } else {
                $("label[for='{{$object.Field}}']").parent().show()
            }

            {{else if $object.Disable}}

            if (e.params.data.text === "{{$val}}" || e.params.data.id === "{{$val}}") {
                $("label[for='{{$object.Field}}']").prop('disabled', true);
            } else {
                $("label[for='{{$object.Field}}']").prop('disabled', false);
            }

            {{else}}

            if (e.params.data.text === "{{$val}}" || e.params.data.id === "{{$val}}") {
                if ($("select.{{$object.Field}}").length > 0) {
                    $("select.{{$object.Field}}").val("{{$object.Value}}").select2()
                } else {
                    $("#{{$object.Field}}").val("{{$object.Value}}")
                }
            }

            {{end}}

            {{end}}
        })
    </script>
{{end}}