diff --git a/app/assets/stylesheets/admin/budgets/actions.scss b/app/assets/stylesheets/admin/budgets/actions.scss new file mode 100644 index 000000000..e733807c5 --- /dev/null +++ b/app/assets/stylesheets/admin/budgets/actions.scss @@ -0,0 +1,27 @@ +.admin .budgets-actions { + $gap: $line-height; + @include flex-with-gap($gap); + align-items: baseline; + flex-wrap: wrap; + margin-top: -$gap; + + > * { + margin-bottom: 0; + margin-top: $gap; + } + + + * { + margin-top: $line-height; + } + + .preview-link { + @include has-fa-icon(eye, regular); + @include hollow-button; + margin-left: $gap; + margin-top: $gap; + + &::before { + margin-#{$global-right}: $font-icon-margin; + } + } +} diff --git a/app/assets/stylesheets/admin/budgets/drafting.scss b/app/assets/stylesheets/admin/budgets/drafting.scss index 28819e763..2ab00daf6 100644 --- a/app/assets/stylesheets/admin/budgets/drafting.scss +++ b/app/assets/stylesheets/admin/budgets/drafting.scss @@ -1,41 +1,25 @@ .admin .drafting { - margin-bottom: 2 * $line-height / 3; - margin-left: auto; + $vertical-gap: nth($callout-margin, 3); + @include flex-with-gap($line-height / 2); + align-items: flex-start; + flex-wrap: wrap; + margin-bottom: $line-height * 1.5; + margin-top: -$vertical-gap; - @include breakpoint(large) { - align-items: flex-start; - display: flex; - - .callout { - flex: 1; - margin-bottom: 0; - } + > * { + margin-top: $vertical-gap; } - @include breakpoint(small medium only) { - text-align: right; - - .callout { - text-align: left; - } - } - - .preview-link { - @include has-fa-icon(eye, regular); - @include hollow-button; - - &::before { - margin-right: $font-icon-margin; - } + .callout { + flex-basis: $global-width / 3; + flex-grow: 1; + margin-bottom: 0; } .publish-link { @include regular-button; margin-bottom: 0; - } - - .preview-link, - .publish-link { - margin-left: $line-height / 2; + margin-#{$global-left}: $line-height / 2; + margin-top: $vertical-gap; } } diff --git a/app/components/admin/budgets/actions_component.html.erb b/app/components/admin/budgets/actions_component.html.erb new file mode 100644 index 000000000..e638838f3 --- /dev/null +++ b/app/components/admin/budgets/actions_component.html.erb @@ -0,0 +1,15 @@ +
+ <%= render Admin::Budgets::CalculateWinnersButtonComponent.new(budget) %> + <% if budget.has_winning_investments? %> + <%= link_to t("budgets.show.see_results"), + budget_results_path(budget), + class: "button hollow" %> + <% end %> + + <%= link_to t("admin.budgets.actions.preview"), budget_path(budget), class: "preview-link", target: "_blank" %> + + <%= link_to t("admin.budgets.edit.delete"), + admin_budget_path(budget), + method: :delete, + class: "delete" %> +
diff --git a/app/components/admin/budgets/actions_component.rb b/app/components/admin/budgets/actions_component.rb new file mode 100644 index 000000000..3eb3c64e6 --- /dev/null +++ b/app/components/admin/budgets/actions_component.rb @@ -0,0 +1,7 @@ +class Admin::Budgets::ActionsComponent < ApplicationComponent + attr_reader :budget + + def initialize(budget) + @budget = budget + end +end diff --git a/app/components/admin/budgets/drafting_component.html.erb b/app/components/admin/budgets/drafting_component.html.erb index 6c84a4972..bde73a546 100644 --- a/app/components/admin/budgets/drafting_component.html.erb +++ b/app/components/admin/budgets/drafting_component.html.erb @@ -1,16 +1,10 @@
- <% if can? :publish, budget %> -
- <%= t("admin.budgets.edit.drafting") %> -
- <% end %> +
+ <%= t("admin.budgets.edit.drafting") %> +
- <%= link_to t("admin.budgets.actions.preview"), budget_path(budget), class: "preview-link", target: "_blank" %> - - <% if can? :publish, budget %> - <%= link_to t("admin.budgets.edit.publish"), - publish_admin_budget_path(budget), - method: :patch, class: "publish-link", - data: { confirm: t("admin.actions.confirm") } %> - <% end %> + <%= link_to t("admin.budgets.edit.publish"), + publish_admin_budget_path(budget), + method: :patch, class: "publish-link", + data: { confirm: t("admin.actions.confirm") } %>
diff --git a/app/components/admin/budgets/drafting_component.rb b/app/components/admin/budgets/drafting_component.rb index 18d37b93f..d196b0184 100644 --- a/app/components/admin/budgets/drafting_component.rb +++ b/app/components/admin/budgets/drafting_component.rb @@ -5,4 +5,8 @@ class Admin::Budgets::DraftingComponent < ApplicationComponent def initialize(budget) @budget = budget end + + def render? + can?(:publish, budget) + end end diff --git a/app/components/admin/budgets/form_component.html.erb b/app/components/admin/budgets/form_component.html.erb index 6fa6ecec1..fd2026da0 100644 --- a/app/components/admin/budgets/form_component.html.erb +++ b/app/components/admin/budgets/form_component.html.erb @@ -84,21 +84,5 @@ <%= f.submit nil, class: "button success" %> <% end %> - -
- <%= render Admin::Budgets::CalculateWinnersButtonComponent.new(budget) %> - - <% if budget.has_winning_investments? %> - <%= link_to t("budgets.show.see_results"), - budget_results_path(budget), - class: "button hollow margin-left" %> - <% end %> - <% if budget.persisted? %> - <%= link_to t("admin.budgets.edit.delete"), - admin_budget_path(budget), - method: :delete, - class: "delete float-right margin-left" %> - <% end %> -
<% end %> diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb index ad5d44f76..07247f80d 100644 --- a/app/views/admin/budgets/edit.html.erb +++ b/app/views/admin/budgets/edit.html.erb @@ -5,4 +5,5 @@ <%= render Admin::Budgets::DraftingComponent.new(@budget) %> +<%= render Admin::Budgets::ActionsComponent.new(@budget) %> <%= render Admin::Budgets::FormComponent.new(@budget) %>