puerto 0.34.0

Puerto: la CLI de un framework full-stack DDD en Rust. Genera proyectos con Clean Architecture, la inyección de dependencias cableada sola y soporte de SQLx, sin cablear nada a mano. Antes, puerto-framework.
import { Link } from "wouter";
import type { Esquemas } from "../../../api/cliente";
{%- set enums = fields | filter(attribute="is_enum", value=true) %}
{%- if enums %}
import { {% for f in enums %}{{ f.texts_const }}{% if not loop.last %}, {% endif %}{% endfor %} } from "../../../generado/textos";
{%- endif %}
{%- if targets %}
import { EnlaceReferencia } from "../../../compartido/ui/enlace-referencia";
{%- endif %}
{%- if display_helpers %}
import { {{ display_helpers | join(sep=", ") }} } from "../../../compartido/formularios";
{%- endif %}

type {{ pascal }} = Esquemas["Dto{{ pascal }}"];

{% if targets -%}
/** Los `{{ plural_ident }}`, y la etiqueta de cada elemento que referencian, para sus enlaces. */
export function VistaLista{{ pascal }}({
  {{ plural_ident }},
{%- for t in targets %}
  etiquetas{{ t.pascal }},
{%- endfor %}
}: {
  {{ plural_ident }}: {{ pascal }}[];
{%- for t in targets %}
  etiquetas{{ t.pascal }}: Map<string, string>;
{%- endfor %}
}) {
{%- else -%}
export function VistaLista{{ pascal }}({ {{ plural_ident }} }: { {{ plural_ident }}: {{ pascal }}[] }) {
{%- endif %}
  return (
    <div className="overflow-x-auto rounded-box bg-base-100">
      <table className="table">
        <thead>
          <tr>
{%- for f in fields %}
            <th>{{ f.label }}</th>
{%- endfor %}
            <th />
          </tr>
        </thead>
        <tbody>
          {{ "{" }}{{ plural_ident }}.map(({{ ident }}) => (
            <tr key={{ "{" }}{{ ident }}.id}>
{%- for f in fields %}
{%- if f.input == "reference" %}
{%- for r in references %}{% if r.camel == f.camel %}
              <td>
{%- if r.list_link_inline %}
                <EnlaceReferencia {% if r.ref_path %}ruta="{{ r.ref_path }}" {% endif %}id={{ "{" }}{{ ident }}.{{ r.camel }}} etiquetas={etiquetas{{ r.target_pascal }}} />
{%- else %}
                <EnlaceReferencia
{%- if r.ref_path %}
                  ruta="{{ r.ref_path }}"
{%- endif %}
                  id={{ "{" }}{{ ident }}.{{ r.camel }}}
                  etiquetas={etiquetas{{ r.target_pascal }}}
                />
{%- endif %}
              </td>
{%- endif %}{% endfor %}
{%- elif f.input == "references" %}
{%- for r in references %}{% if r.camel == f.camel %}
              <td className="space-x-2">
                {{ "{" }}{{ ident }}.{{ r.camel }}.map((id) =>
{%- if r.set_list_link_inline %} (
                  <EnlaceReferencia key={id} {% if r.ref_path %}ruta="{{ r.ref_path }}" {% endif %}id={id} etiquetas={etiquetas{{ r.target_pascal }}} />
{%- else %} (
                  <EnlaceReferencia
                    key={id}
{%- if r.ref_path %}
                    ruta="{{ r.ref_path }}"
{%- endif %}
                    id={id}
                    etiquetas={etiquetas{{ r.target_pascal }}}
                  />
{%- endif %}
                ))}
              </td>
{%- endif %}{% endfor %}
{%- else %}
              <td>{{ "{" }}{{ f.display }}}</td>
{%- endif %}
{%- endfor %}
              <td className="text-right">
                <Link href={`/{{ plural }}/${{ "{" }}{{ ident }}.id}`} className="link">
                  Ver
                </Link>
              </td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}