mirror of
https://github.com/we-promise/sure.git
synced 2026-05-27 14:34:56 +00:00
* feat(design-system): add :card_inset variant + migrate ibkr_panel and settings/_section Wraps up the disclosure migration cluster from #1715 §6: 1. **New `:card_inset` variant** on `DS::Disclosure`. Same contract as `:card` but uses `bg-surface-inset rounded-xl p-4` (no shadow) for inset sub-panels embedded inside a parent card surface. 2. **Migrate `_ibkr_panel.html.erb`** — the "flex query details" disclosure (`<details class="group bg-surface-inset rounded-xl p-4">`) was the one panel skipped from #1856 because it used the inset surface. Now uses `DS::Disclosure(variant: :card_inset)`. Chevron gets the `motion-safe:transition-transform motion-safe:duration-150` treatment along the way. 3. **Migrate `settings/_section.html.erb`** — the global "collapsible settings card" primitive backing 19 callsites via the `settings_section(...)` helper. The collapsible branch's `<details class="group bg-container shadow-border-xs rounded-xl p-4">` becomes `DS::Disclosure(variant: :card, open: open, data: ...)`. While here: - Update `disclosure.html.erb` to spread `**opts` onto the `<details>` element via `tag.details`. Previously opts were captured but never applied; the `settings/_section` migration needs `data-controller` + `data-auto-open-param-value` to flow through to the rendered `<details>`. - Non-collapsible branch in `settings/_section.html.erb` stays as raw `<section>` — different semantics (not expandable), DS::Disclosure can't replace because it always renders `<details>`. API: DS::Disclosure.new( variant: :card | :card_inset | :default, open: bool, data: { controller: "...", ... } # forwarded to <details> ) * fix(review): merge caller class in DS::Disclosure + i18n plaid deletion - DS::Disclosure: extract caller class: from opts and merge via class_names before forwarding to tag.details. Prevents the latent duplicate keyword arg error when callers pass class: alongside the variant-derived classes. - plaid_items/_plaid_item: localize "(deletion in progress...)" via t('.deletion_in_progress') + add en locale key, matching lunchflow / mercury / sophtron / coinstats convention. * fix(panels): replace text-white and bg-gray-tint-10 with semantic tokens `text-white` → `text-inverse` on the EnableBanking reauthorize button (`bg-warning` background); `bg-gray-tint-10` → `bg-container-inset` on the IndexaCapital item avatar wrapper. Both flagged by sure-design as non-functional palette tokens. Pre-existing on main; surfaced by the re-indentation that this PR applied during the disclosure migration.
153 lines
6.6 KiB
Plaintext
153 lines
6.6 KiB
Plaintext
<div id="ibkr-providers-panel" class="space-y-4">
|
|
<% error_msg = local_assigns[:error_message] || @error_message %>
|
|
<% if error_msg.present? %>
|
|
<%= render DS::Alert.new(message: error_msg, variant: :error) %>
|
|
<% end %>
|
|
|
|
<%= render "settings/providers/setup_steps",
|
|
steps: [
|
|
t(".steps.step_1"),
|
|
t(".steps.step_2"),
|
|
t(".steps.step_3"),
|
|
t(".steps.step_4"),
|
|
t(".steps.step_5")
|
|
] %>
|
|
|
|
<%= render DS::Disclosure.new(variant: :card_inset) do |disclosure| %>
|
|
<% disclosure.with_summary_content do %>
|
|
<div class="flex items-start justify-between gap-3">
|
|
<div>
|
|
<p class="text-xs font-medium uppercase text-subdued tracking-wider mb-2"><%= t(".flex_query_details.eyebrow") %></p>
|
|
<p class="text-sm font-medium text-primary"><%= t(".flex_query_details.title") %></p>
|
|
<p class="text-xs text-secondary mt-1"><%= t(".flex_query_details.summary") %></p>
|
|
</div>
|
|
<%= icon "chevron-down", class: "mt-0.5 text-secondary group-open:rotate-180 motion-safe:transition-transform motion-safe:duration-150" %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="mt-4 space-y-4 text-sm text-secondary">
|
|
<div class="space-y-2">
|
|
<p class="font-medium text-primary"><%= t(".flex_query_details.sections_heading") %></p>
|
|
<ul class="list-disc list-inside space-y-2">
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.account_information") %></span>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.cash_report") %></span>
|
|
<ul class="list-disc list-inside mt-1 ml-4 space-y-1">
|
|
<li><%= t(".sections.cash_report_options") %></li>
|
|
<li><%= t(".sections.cash_report_fields") %></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.cash_transactions") %></span>
|
|
<ul class="list-disc list-inside mt-1 ml-4 space-y-1">
|
|
<li><%= t(".sections.cash_transactions_options") %></li>
|
|
<li><%= t(".sections.cash_transactions_fields") %></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.change_in_position_value_summary") %></span>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.net_asset_value") %></span>
|
|
<ul class="list-disc list-inside mt-1 ml-4 space-y-1">
|
|
<li><%= t(".sections.net_asset_value_options") %></li>
|
|
<li><%= t(".sections.net_asset_value_fields") %></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.open_positions") %></span>
|
|
<ul class="list-disc list-inside mt-1 ml-4 space-y-1">
|
|
<li><%= t(".sections.open_positions_options") %></li>
|
|
<li><%= t(".sections.open_positions_fields") %></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<span class="text-primary"><%= t(".sections.trades") %></span>
|
|
<ul class="list-disc list-inside mt-1 ml-4 space-y-1">
|
|
<li><%= t(".sections.trades_options") %></li>
|
|
<li><%= t(".sections.trades_fields") %></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<p class="font-medium text-primary"><%= t(".flex_query_details.configuration_heading") %></p>
|
|
<ul class="list-disc list-inside space-y-1">
|
|
<li><%= t(".configuration.models") %></li>
|
|
<li><%= t(".configuration.format") %></li>
|
|
<li><%= t(".configuration.period") %></li>
|
|
<li><%= t(".configuration.date_format") %></li>
|
|
<li><%= t(".configuration.time_format") %></li>
|
|
<li><%= t(".configuration.date_time_separator") %></li>
|
|
<li><%= t(".configuration.profit_and_loss") %></li>
|
|
<li><%= t(".configuration.all_other_options") %></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<p class="text-xs text-secondary"><%= t(".report_window_note") %></p>
|
|
</div>
|
|
<% end %>
|
|
|
|
<%
|
|
ibkr_item = Current.family.ibkr_items.first_or_initialize(name: "Interactive Brokers")
|
|
is_new_record = ibkr_item.new_record?
|
|
%>
|
|
|
|
<% if ibkr_item.persisted? %>
|
|
<div class="flex flex-wrap justify-end gap-2">
|
|
<%= button_to sync_ibkr_item_path(ibkr_item),
|
|
method: :post,
|
|
class: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium text-secondary hover:text-primary border border-secondary rounded-lg hover:border-primary",
|
|
disabled: ibkr_item.syncing? do %>
|
|
<%= icon "refresh-cw", size: "sm" %>
|
|
<%= t(".sync") %>
|
|
<% end %>
|
|
|
|
<%= button_to ibkr_item_path(ibkr_item),
|
|
method: :delete,
|
|
class: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium text-destructive hover:bg-destructive/10 rounded-lg",
|
|
data: { turbo_confirm: t(".disconnect_confirm") } do %>
|
|
<%= icon "trash-2", size: "sm" %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<%= styled_form_with model: ibkr_item,
|
|
url: is_new_record ? ibkr_items_path : ibkr_item_path(ibkr_item),
|
|
scope: :ibkr_item,
|
|
method: is_new_record ? :post : :patch,
|
|
data: { turbo: true },
|
|
class: "space-y-3" do |form| %>
|
|
<%= form.text_field :query_id,
|
|
label: t(".query_id_label"),
|
|
placeholder: is_new_record ? t(".query_id_placeholder_new") : t(".query_id_placeholder_existing"),
|
|
type: :password %>
|
|
|
|
<%= form.text_field :token,
|
|
label: t(".token_label"),
|
|
placeholder: is_new_record ? t(".token_placeholder_new") : t(".token_placeholder_existing"),
|
|
type: :password %>
|
|
|
|
<div class="flex flex-wrap justify-end gap-2">
|
|
<%= form.submit(is_new_record ? t(".save_configuration") : t(".update_configuration")) %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="flex items-center gap-2">
|
|
<% if ibkr_item.persisted? && ibkr_item.credentials_configured? %>
|
|
<div class="w-2 h-2 bg-success rounded-full"></div>
|
|
<p class="text-sm text-secondary">
|
|
<%= t(".status_configured_prefix", summary: ibkr_item.sync_status_summary) %>
|
|
<%= link_to t(".accounts_tab"), accounts_path, class: "link" %>
|
|
<%= t(".status_configured_suffix") %>
|
|
</p>
|
|
<% else %>
|
|
<div class="w-2 h-2 bg-gray-400 rounded-full"></div>
|
|
<p class="text-sm text-secondary"><%= t(".not_configured") %></p>
|
|
<% end %>
|
|
</div>
|
|
</div>
|