Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

3.6 KB
Raw Blame
<%# locals: (prompt_persona:) -%>
<% input_class = "w-full px-4 py-2 border border-black rounded text-sm focus:outline-none focus:-translate-x-0.5 focus:-translate-y-0.5 focus:shadow-[2px_2px_0_0_#000000] focus:ring-0 transition-all" %>
<% submit_label = prompt_persona.persisted? ? t('views.admin.prompt_personas.form.submit_save') : t('views.admin.prompt_personas.form.submit_create') %>

<%= form_with model: [:admin, prompt_persona], local: true, class: "space-y-6" do |form| %>
  <% if prompt_persona.errors.any? %>
    <div class="border-2 border-red-500 bg-red-50 rounded-lg p-4 shadow-[2px_2px_0_0_#ef4444]">
      <h3 class="text-sm font-bold text-red-800 mb-2">
        <%= t('views.admin.prompt_personas.form.errors_title', count: prompt_persona.errors.count) %>
      </h3>
      <ul class="list-disc pl-5 text-sm text-red-700 space-y-1">
        <% prompt_persona.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <!-- Key / Position -->
  <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
    <div>
      <%= form.label :key, t('views.admin.prompt_personas.form.label_key'), class: "block text-sm font-bold text-gray-900 mb-1" %>
      <% if prompt_persona.system? %>
        <%# A system persona's key is a contract (e.g. DEFAULT_KEY); locked here and
            additionally dropped server-side on update. %>
        <%= form.text_field :key, readonly: true,
              class: "#{input_class} bg-gray-100 text-gray-500 cursor-not-allowed" %>
        <p class="mt-1 text-sm text-gray-500"><%= t('views.admin.prompt_personas.form.key_locked_hint') %></p>
      <% else %>
        <%= form.text_field :key, class: input_class %>
        <p class="mt-1 text-sm text-gray-500"><%= t('views.admin.prompt_personas.form.key_hint') %></p>
      <% end %>
    </div>

    <div>
      <%= form.label :position, t('views.admin.prompt_personas.form.label_position'), class: "block text-sm font-bold text-gray-900 mb-1" %>
      <%= form.number_field :position, class: input_class %>
      <p class="mt-1 text-sm text-gray-500"><%= t('views.admin.prompt_personas.form.position_hint') %></p>
    </div>
  </div>

  <!-- Active -->
  <div class="flex items-center">
    <%= form.check_box :active, class: "w-4 h-4 border-2 border-black rounded focus:ring-2 focus:ring-black accent-lime-500" %>
    <%= form.label :active, t('views.admin.prompt_personas.form.label_active'), class: "ml-2 text-sm font-medium text-gray-700" %>
  </div>

  <!-- Per-language content -->
  <div class="border-t-2 border-black pt-6">
    <h3 class="text-lg font-medium text-gray-900 mb-4">
      <i class="bi bi-translate text-gray-400 mr-2"></i>
      <%= t('views.admin.prompt_personas.form.section_content') %>
    </h3>
    <%= render 'prompt_personas/locale_fields',
               persona: prompt_persona,
               input_class: input_class,
               label_class: "block text-sm font-bold text-gray-900 mb-1",
               hint_class: "mt-1 text-sm text-gray-500" %>
  </div>

  <!-- Actions -->
  <div class="flex justify-end space-x-3 pt-6 border-t-2 border-black">
    <%= link_to t('views.admin.prompt_personas.form.cancel'), admin_prompt_personas_path,
          class: "py-2 px-4 border border-black rounded text-sm font-medium bg-gray-200 hover:bg-gray-300 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:shadow-[2px_2px_0_0_#000000] transition-all" %>
    <%= form.submit submit_label,
          class: "inline-flex justify-center py-2 px-4 border border-black rounded text-sm font-medium bg-lime-200 hover:bg-lime-300 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:shadow-[2px_2px_0_0_#000000] transition-all" %>
  </div>
<% end %>