mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
* Singularize "transaction" in transaction-nested paths * Refactor category badge partial * Let modal content define its width * Add contectual menu to transactions index * Add null_category helper * Implement category edits * Fix inline transaction category badges * Fix typos in system test paths * Add missing translations * Add decoration to color select controller * Wire up transaction category creation * Fix indent in color-select-controller * Add button for clearing category from transaction * Implement category deletions * Fix existing modal sizes * Use null_category in a single place * Remove anemic method in category deletion controller * reassign_and_destroy -> reassign_transactions_then_destroy * Fix i18n * Remove destroy action from CategoriesController callbacks * transactions_merchant -> transaction_merchant * reassign_transactions_then_destroy -> replace_and_destroy * Add transaction category CRUD tests * Add presence check for transaction_id * Check replacement_category_id presence * Test Transaction::Category#replace_and_destroy!
28 lines
1.7 KiB
Plaintext
28 lines
1.7 KiB
Plaintext
<% is_editing = @merchant.id.present? %>
|
|
<div data-controller="merchant-avatar">
|
|
<%= form_with model: @merchant, url: is_editing ? transaction_merchant_path(@merchant) : transaction_merchants_path, method: is_editing ? :patch : :post, scope: :transaction_merchant, data: { turbo: false } do |f| %>
|
|
<section class="space-y-4">
|
|
<div class="w-fit m-auto">
|
|
<%= render partial: "transactions/merchants/avatar", locals: { merchant: } %>
|
|
</div>
|
|
<div data-controller="select" data-select-active-class="bg-gray-200" data-select-selected-value="<%= @merchant&.color || Transaction::Merchant::COLORS[0] %>">
|
|
<%= f.hidden_field :color, data: { select_target: "input", merchant_avatar_target: "color" } %>
|
|
<ul data-select-target="list" class="flex gap-2 items-center">
|
|
<% Transaction::Merchant::COLORS.each do |color| %>
|
|
<li tabindex="0" data-select-target="option" data-action="click->select#selectOption" data-value="<%= color %>" class="flex shrink-0 justify-center items-center w-6 h-6 cursor-pointer hover:bg-gray-200 rounded-full">
|
|
<div style="background-color: <%= color %>" class="shrink-0 w-4 h-4 rounded-full"></div>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
<div class="relative flex items-center border border-gray-200 rounded-lg">
|
|
<%= f.text_field :name, placeholder: t(".name_placeholder"), class: "text-sm font-normal placeholder:text-gray-500 h-10 relative pl-3 w-full border-none rounded-lg", required: true, data: { merchant_avatar_target: "name" } %>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<%= f.submit(is_editing ? t(".submit_edit") : t(".submit_create")) %>
|
|
</section>
|
|
<% end %>
|
|
</div>
|