From a14caf29fa98352913a90c42276ad91295dccd70 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:46:04 +0200 Subject: [PATCH 1/9] Fix button placement on subscription form --- .../spree/admin/subscriptions/_form.html.erb | 112 +++++++++--------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/app/views/spree/admin/subscriptions/_form.html.erb b/app/views/spree/admin/subscriptions/_form.html.erb index 80c1681d..056318a4 100644 --- a/app/views/spree/admin/subscriptions/_form.html.erb +++ b/app/views/spree/admin/subscriptions/_form.html.erb @@ -1,81 +1,83 @@ -
- <%= t('.subscription') %> +
+
+ <%= t('.subscription') %> + +
+ <% if f.object.new_record? %> +
+ <%= f.label :user_id, I18n.t('spree.user'), class: "required" %> + <%= f.collection_select :user_id, Spree::User.all, :id, :email, {}, class: "select2 fullwidth" %> +
+ <% end %> -
- <% if f.object.new_record? %>
- <%= f.label :user_id, I18n.t('spree.user'), class: "required" %> - <%= f.collection_select :user_id, Spree::User.all, :id, :email, {}, class: "select2 fullwidth" %> + <%= f.label :actionable_date %> + <%= f.text_field :actionable_date, class: "form-control fullwidth datepicker" %>
- <% end %> - -
- <%= f.label :actionable_date %> - <%= f.text_field :actionable_date, class: "form-control fullwidth datepicker" %> -
-
-
-
- <%= f.label :interval_length %> - <%= f.number_field :interval_length, class: "form-control fullwidth" %> +
+
+
+ <%= f.label :interval_length %> + <%= f.number_field :interval_length, class: "form-control fullwidth" %> +
-
-
-
- <% - unit_values = SolidusSubscriptions::LineItem.interval_units.keys - units = unit_values.map do |unit| - [ - SolidusSubscriptions::LineItem.human_attribute_name("interval_units.#{unit}"), - unit, - ] - end - %> +
+
+ <% + unit_values = SolidusSubscriptions::LineItem.interval_units.keys + units = unit_values.map do |unit| + [ + SolidusSubscriptions::LineItem.human_attribute_name("interval_units.#{unit}"), + unit, + ] + end + %> - <%= f.label :interval_units %> - <%= f.select(:interval_units, units, {}, class: 'fullwidth select2') %> + <%= f.label :interval_units %> + <%= f.select(:interval_units, units, {}, class: 'fullwidth select2') %> +
-
-
- <%= f.label :end_date %> - <%= f.text_field :end_date, class: "fullwidth datepicker" %> -
+
+ <%= f.label :end_date %> + <%= f.text_field :end_date, class: "fullwidth datepicker" %> +
-
- <%= f.label :store_id %> - <%= f.collection_select :store_id, Spree::Store.all, :id, :name, {}, class: 'fullwidth select2' %> +
+ <%= f.label :store_id %> + <%= f.collection_select :store_id, Spree::Store.all, :id, :name, {}, class: 'fullwidth select2' %> +
-
+
-
-
- Shipping Address +
+ Shipping Address +
<%= f.fields_for :shipping_address do |sa_form| %> <%= render partial: 'spree/admin/shared/address_form', locals: { f: sa_form, type: "shipping" } %> <% end %>
-
-
+
+
-
+
<%= t('.subscription_line_items') %> <%= f.fields_for :line_items do |lf| %>
-
+
<%= lf.label :subscribable_id %> <%= lf.collection_select :subscribable_id, Spree::Variant.where(subscribable: true), :id, :pretty_name, {}, { class: "fullwidth select2" } %>
-
+
<%= lf.label :quantity %> <%= lf.number_field :quantity, min: 1, class: "form-control fullwidth" %> @@ -90,11 +92,11 @@
<% end %> -
- <% if f.object.new_record? %> - <%= render partial: 'spree/admin/shared/new_resource_links' %> - <% else %> - <%= render partial: 'spree/admin/shared/edit_resource_links' %> - <% end %> -
+ <% if f.object.new_record? %> + <%= render partial: 'spree/admin/shared/new_resource_links' %> + <% else %> + <%= render partial: 'spree/admin/shared/edit_resource_links' %> + <% end %> + + From 69e5c34caa0d2a18cec80524cf2ac9bbbfdf6267 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:46:30 +0200 Subject: [PATCH 2/9] Extract subscription state and processing state pills into partials --- .../subscriptions/_processing_state_pill.html.erb | 9 +++++++++ .../spree/admin/subscriptions/_state_pill.html.erb | 10 ++++++++++ app/views/spree/admin/subscriptions/index.html.erb | 8 ++------ 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 app/views/spree/admin/subscriptions/_processing_state_pill.html.erb create mode 100644 app/views/spree/admin/subscriptions/_state_pill.html.erb diff --git a/app/views/spree/admin/subscriptions/_processing_state_pill.html.erb b/app/views/spree/admin/subscriptions/_processing_state_pill.html.erb new file mode 100644 index 00000000..4260446f --- /dev/null +++ b/app/views/spree/admin/subscriptions/_processing_state_pill.html.erb @@ -0,0 +1,9 @@ +<% state_class = { + success: 'active', + failed: 'error', + pending: 'inactive', +}[subscription.processing_state.to_sym] %> + + + <%= subscription.class.human_attribute_name("processing_state.#{subscription.processing_state}") %> + diff --git a/app/views/spree/admin/subscriptions/_state_pill.html.erb b/app/views/spree/admin/subscriptions/_state_pill.html.erb new file mode 100644 index 00000000..1d79bdac --- /dev/null +++ b/app/views/spree/admin/subscriptions/_state_pill.html.erb @@ -0,0 +1,10 @@ +<% state_class = { + active: 'active', + canceled: 'error', + pending_cancellation: 'warning', + inactive: 'inactive', +}[subscription.state.to_sym] %> + + + <%= subscription.human_state_name %> + diff --git a/app/views/spree/admin/subscriptions/index.html.erb b/app/views/spree/admin/subscriptions/index.html.erb index a15f3d5d..aadecfbd 100644 --- a/app/views/spree/admin/subscriptions/index.html.erb +++ b/app/views/spree/admin/subscriptions/index.html.erb @@ -121,12 +121,8 @@ <%= link_to subscription.user.email, admin_user_path(subscription.user) %> <%= subscription.actionable_date ? l(subscription.actionable_date.to_date) : '-' %> <%= subscription.interval.inspect %> - <%= content_tag :span, subscription.human_state_name, class: "state #{ subscription.state }" %> - - - <%= subscription.class.human_attribute_name("processing_state.#{subscription.processing_state}") %> - - + <%= render 'state_pill', subscription: subscription %> + <%= render 'processing_state_pill', subscription: subscription %> <% if subscription.state_events.include?(:cancel) %> <%= From 74578e8ef3624a5cdbec996657b036e939872b1a Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:48:06 +0200 Subject: [PATCH 3/9] Add sidebar to subscription edit page --- .../shared/_subscription_sidebar.html.erb | 18 ++++++++++++++++++ .../spree/admin/subscriptions/edit.html.erb | 4 +--- config/locales/en.yml | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 app/views/spree/admin/shared/_subscription_sidebar.html.erb diff --git a/app/views/spree/admin/shared/_subscription_sidebar.html.erb b/app/views/spree/admin/shared/_subscription_sidebar.html.erb new file mode 100644 index 00000000..423e7e5b --- /dev/null +++ b/app/views/spree/admin/shared/_subscription_sidebar.html.erb @@ -0,0 +1,18 @@ +<% content_for :sidebar_title do %> + <%= t("spree.admin.subscriptions.edit.sidebar") %> +<% end %> + +<% content_for :sidebar do %> + +<% end %> diff --git a/app/views/spree/admin/subscriptions/edit.html.erb b/app/views/spree/admin/subscriptions/edit.html.erb index 274bbad7..c2826ae0 100644 --- a/app/views/spree/admin/subscriptions/edit.html.erb +++ b/app/views/spree/admin/subscriptions/edit.html.erb @@ -1,8 +1,6 @@ <% content_for(:page_title) { t('.title') } %> -<% content_for :sidebar_title do %> - Details -<% end %> +<%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> <%= form_for @subscription, url: spree.admin_subscription_path(@subscription) do |f| %> <%= render "form", f: f %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 1d151048..f5bde478 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -36,6 +36,7 @@ en: fulfillment_status: Fulfillment Status revenue: Revenue interval: Interval + sidebar: Status new: back: Back to Subscriptions List title: Create a Susbcription From 3dc8fcda04d1a3e4c981d1c4d6cb217164673341 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:49:06 +0200 Subject: [PATCH 4/9] Add breadcrumbs to subscription edit page --- .../spree/admin/shared/_subscription_breadcrumbs.html.erb | 4 ++++ app/views/spree/admin/subscriptions/edit.html.erb | 1 + config/locales/en.yml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/views/spree/admin/shared/_subscription_breadcrumbs.html.erb diff --git a/app/views/spree/admin/shared/_subscription_breadcrumbs.html.erb b/app/views/spree/admin/shared/_subscription_breadcrumbs.html.erb new file mode 100644 index 00000000..6fb5f694 --- /dev/null +++ b/app/views/spree/admin/shared/_subscription_breadcrumbs.html.erb @@ -0,0 +1,4 @@ +<% admin_breadcrumb( + link_to(plural_resource_name(SolidusSubscriptions::Subscription), admin_subscriptions_path), + link_to("#{subscription.id}", edit_admin_subscription_path(subscription)) + ) %> diff --git a/app/views/spree/admin/subscriptions/edit.html.erb b/app/views/spree/admin/subscriptions/edit.html.erb index c2826ae0..995e1b9e 100644 --- a/app/views/spree/admin/subscriptions/edit.html.erb +++ b/app/views/spree/admin/subscriptions/edit.html.erb @@ -1,5 +1,6 @@ <% content_for(:page_title) { t('.title') } %> +<%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> <%= form_for @subscription, url: spree.admin_subscription_path(@subscription) do |f| %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f5bde478..0afd879b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,7 +30,7 @@ en: skip: Skip One new_subscription: New Subscription edit: - title: Edit a Subscription + title: Details customer: Customer status: Status fulfillment_status: Fulfillment Status From 0343c6114f0e99ed8347a5894ebf0ac457596c52 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:50:10 +0200 Subject: [PATCH 5/9] Add tabs to subscription edit page --- app/views/spree/admin/shared/_subscription_tabs.html.erb | 9 +++++++++ app/views/spree/admin/subscriptions/edit.html.erb | 1 + config/locales/en.yml | 1 + 3 files changed, 11 insertions(+) create mode 100644 app/views/spree/admin/shared/_subscription_tabs.html.erb diff --git a/app/views/spree/admin/shared/_subscription_tabs.html.erb b/app/views/spree/admin/shared/_subscription_tabs.html.erb new file mode 100644 index 00000000..ce6676f6 --- /dev/null +++ b/app/views/spree/admin/shared/_subscription_tabs.html.erb @@ -0,0 +1,9 @@ +<% content_for :tabs do %> + +<% end %> diff --git a/app/views/spree/admin/subscriptions/edit.html.erb b/app/views/spree/admin/subscriptions/edit.html.erb index 995e1b9e..4043fb7d 100644 --- a/app/views/spree/admin/subscriptions/edit.html.erb +++ b/app/views/spree/admin/subscriptions/edit.html.erb @@ -2,6 +2,7 @@ <%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> +<%= render 'spree/admin/shared/subscription_tabs', current: :details %> <%= form_for @subscription, url: spree.admin_subscription_path(@subscription) do |f| %> <%= render "form", f: f %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0afd879b..fe65faca 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -37,6 +37,7 @@ en: revenue: Revenue interval: Interval sidebar: Status + details: Details new: back: Back to Subscriptions List title: Create a Susbcription From 461f5c034e2585c315bc4ce9a03d8d6cef654ef8 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 15:50:26 +0200 Subject: [PATCH 6/9] Add installments list to subscription edit page --- .../spree/admin/installments_controller.rb | 23 ++++++++++++ .../solidus_subscriptions/installment.rb | 7 ++++ .../admin/installments/_state_pill.html.erb | 8 +++++ .../spree/admin/installments/index.html.erb | 35 +++++++++++++++++++ .../admin/shared/_subscription_tabs.html.erb | 3 ++ config/locales/en.yml | 15 +++++++- config/routes.rb | 2 ++ 7 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 app/controllers/spree/admin/installments_controller.rb create mode 100644 app/views/spree/admin/installments/_state_pill.html.erb create mode 100644 app/views/spree/admin/installments/index.html.erb diff --git a/app/controllers/spree/admin/installments_controller.rb b/app/controllers/spree/admin/installments_controller.rb new file mode 100644 index 00000000..f499147a --- /dev/null +++ b/app/controllers/spree/admin/installments_controller.rb @@ -0,0 +1,23 @@ +module Spree + module Admin + class InstallmentsController < ResourceController + belongs_to 'subscription', model_class: SolidusSubscriptions::Subscription + + skip_before_action :load_resource, only: :index + + def index + @search = collection.ransack(params[:q]) + + @installments = @search.result(distinct: true). + page(params[:page]). + per(params[:per_page] || Spree::Config[:orders_per_page]) + end + + private + + def model_class + ::SolidusSubscriptions::Installment + end + end + end +end diff --git a/app/models/solidus_subscriptions/installment.rb b/app/models/solidus_subscriptions/installment.rb index a899ceee..1cad63ee 100644 --- a/app/models/solidus_subscriptions/installment.rb +++ b/app/models/solidus_subscriptions/installment.rb @@ -95,6 +95,13 @@ def fulfilled? details.where(success: true).exists? end + # Returns the state of this fulfillment + # + # @return [Symbol] :fulfilled/:unfulfilled + def state + fulfilled? ? :fulfilled : :unfulfilled + end + # Mark this installment as having a failed payment # # @param order [Spree::Order] The order generated for this processing diff --git a/app/views/spree/admin/installments/_state_pill.html.erb b/app/views/spree/admin/installments/_state_pill.html.erb new file mode 100644 index 00000000..08a86a38 --- /dev/null +++ b/app/views/spree/admin/installments/_state_pill.html.erb @@ -0,0 +1,8 @@ +<% state_class = { + fulfilled: 'active', + unfulfilled: 'error', +}[installment.state.to_sym] %> + + + <%= SolidusSubscriptions::Installment.human_attribute_name("state.#{installment.state}") %> + diff --git a/app/views/spree/admin/installments/index.html.erb b/app/views/spree/admin/installments/index.html.erb new file mode 100644 index 00000000..ed584b0e --- /dev/null +++ b/app/views/spree/admin/installments/index.html.erb @@ -0,0 +1,35 @@ +<% content_for(:page_title, t('.title')) %> + +<%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> +<%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> +<%= render 'spree/admin/shared/subscription_tabs', current: :installments %> + +
+ <%= t('spree.admin.installments.index.title') %> + + <%= paginate @installments, theme: 'solidus_admin' %> + + + + + + + + + + + + + <% @installments.each do |installment| %> + + + + + + + <% end %> + +
<%= sort_link(@search, :actionable_date, SolidusSubscriptions::Installment.human_attribute_name(:actionable_date)) %><%= sort_link(@search, :created_at, SolidusSubscriptions::Installment.human_attribute_name(:created_at)) %><%= SolidusSubscriptions::Installment.human_attribute_name(:fulfilled) %>
<%= l(installment.actionable_date.to_date) if installment.actionable_date %><%= l(installment.created_at.to_date) %><%= render 'state_pill', installment: installment %>
+ + <%= paginate @installments, theme: 'solidus_admin' %> +
diff --git a/app/views/spree/admin/shared/_subscription_tabs.html.erb b/app/views/spree/admin/shared/_subscription_tabs.html.erb index ce6676f6..ea64e62d 100644 --- a/app/views/spree/admin/shared/_subscription_tabs.html.erb +++ b/app/views/spree/admin/shared/_subscription_tabs.html.erb @@ -4,6 +4,9 @@ > <%= link_to t("spree.admin.subscriptions.edit.details"), spree.edit_admin_subscription_path(@subscription) %> + > + <%= link_to t("spree.admin.subscriptions.edit.installments"), spree.admin_subscription_installments_path(@subscription) %> + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index fe65faca..b34c1add 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -38,6 +38,7 @@ en: interval: Interval sidebar: Status details: Details + installments: Installments new: back: Back to Subscriptions List title: Create a Susbcription @@ -46,6 +47,9 @@ en: subscription_line_items: Line Items tab: subscriptions: Subscriptions + installments: + index: + title: Installments promotion_rule_types: subscription_promotion_rule: name: Subscription @@ -74,11 +78,20 @@ en: failed: failure solidus_subscriptions/line_item: _destroy: Remove? - + solidus_subscriptions/installment: + created_at: Creation date + actionable_date: Actionable date + state: State + solidus_subscriptions/installment/state: + fulfilled: Fulfilled + unfulfilled: Unfulfilled models: solidus_subscriptions/subscription: one: Subscription other: Subscriptions + solidus_subscriptions/installment: + one: Installment + other: Installments errors: models: diff --git a/config/routes.rb b/config/routes.rb index e8542956..cf5045c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,8 @@ delete :cancel, on: :member post :activate, on: :member post :skip, on: :member + + resources :installments, only: [:index, :show] end end end From fabde7f1751cddb74ce9e9e51a946fbfe318a272 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 16:04:51 +0200 Subject: [PATCH 7/9] Add actions to subscription detail page --- .../spree/admin/subscriptions_controller.rb | 6 ++-- .../spree/admin/installments/index.html.erb | 1 + .../shared/_subscription_actions.html.erb | 35 +++++++++++++++++++ .../spree/admin/subscriptions/edit.html.erb | 1 + .../spree/admin/subscriptions/index.html.erb | 8 ++--- config/locales/en.yml | 3 +- 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 app/views/spree/admin/shared/_subscription_actions.html.erb diff --git a/app/controllers/spree/admin/subscriptions_controller.rb b/app/controllers/spree/admin/subscriptions_controller.rb index 8462ba19..fae79aa8 100644 --- a/app/controllers/spree/admin/subscriptions_controller.rb +++ b/app/controllers/spree/admin/subscriptions_controller.rb @@ -36,7 +36,7 @@ def cancel notice = @subscription.errors.full_messages.to_sentence end - redirect_to spree.admin_subscriptions_path, notice: notice + redirect_back(fallback_location: spree.admin_subscriptions_path, notice: notice) end def activate @@ -48,7 +48,7 @@ def activate notice = @subscription.errors.full_messages.to_sentence end - redirect_to spree.admin_subscriptions_path, notice: notice + redirect_back(fallback_location: spree.admin_subscriptions_path, notice: notice) end def skip @@ -59,7 +59,7 @@ def skip date: @subscription.actionable_date ) - redirect_to spree.admin_subscriptions_path, notice: notice + redirect_back(fallback_location: spree.admin_subscriptions_path, notice: notice) end private diff --git a/app/views/spree/admin/installments/index.html.erb b/app/views/spree/admin/installments/index.html.erb index ed584b0e..1e8849bc 100644 --- a/app/views/spree/admin/installments/index.html.erb +++ b/app/views/spree/admin/installments/index.html.erb @@ -3,6 +3,7 @@ <%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_tabs', current: :installments %> +<%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %>
<%= t('spree.admin.installments.index.title') %> diff --git a/app/views/spree/admin/shared/_subscription_actions.html.erb b/app/views/spree/admin/shared/_subscription_actions.html.erb new file mode 100644 index 00000000..9c79258d --- /dev/null +++ b/app/views/spree/admin/shared/_subscription_actions.html.erb @@ -0,0 +1,35 @@ +<% content_for :page_actions do %> + <% if subscription.state_events.include?(:cancel) %> + <%= + link_to( + t('spree.admin.subscriptions.actions.cancel'), + spree.cancel_admin_subscription_path(subscription), + method: :delete, + data: { confirm: t('spree.admin.subscriptions.actions.cancel_alert') }, + class: 'btn btn-primary' + ) + %> + <% end %> + + <% if subscription.state_events.include?(:activate) %> + <%= + link_to( + t('spree.admin.subscriptions.actions.activate'), + spree.activate_admin_subscription_path(subscription), + method: :post, + class: 'btn btn-primary', + ) + %> + <% end %> + + <% if subscription.active? %> + <%= + link_to( + t('spree.admin.subscriptions.actions.skip'), + spree.skip_admin_subscription_path(subscription), + method: :post, + class: 'btn btn-default', + ) + %> + <% end %> +<% end %> diff --git a/app/views/spree/admin/subscriptions/edit.html.erb b/app/views/spree/admin/subscriptions/edit.html.erb index 4043fb7d..c4d57721 100644 --- a/app/views/spree/admin/subscriptions/edit.html.erb +++ b/app/views/spree/admin/subscriptions/edit.html.erb @@ -3,6 +3,7 @@ <%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_tabs', current: :details %> +<%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %> <%= form_for @subscription, url: spree.admin_subscription_path(@subscription) do |f| %> <%= render "form", f: f %> diff --git a/app/views/spree/admin/subscriptions/index.html.erb b/app/views/spree/admin/subscriptions/index.html.erb index aadecfbd..7389a10a 100644 --- a/app/views/spree/admin/subscriptions/index.html.erb +++ b/app/views/spree/admin/subscriptions/index.html.erb @@ -128,11 +128,11 @@ <%= link_to_with_icon( :stop, - t('.cancel'), + t('spree.admin.subscriptions.actions.cancel'), spree.cancel_admin_subscription_path(subscription), no_text: true, method: :delete, - data: { confirm: t('.cancel_alert') } + data: { confirm: t('spree.admin.subscriptions.actions.cancel_alert') } ) %> <% end %> @@ -141,7 +141,7 @@ <%= link_to_with_icon( :play, - t('.activate'), + t('spree.admin.subscriptions.actions.activate'), spree.activate_admin_subscription_path(subscription), no_text: true, method: :post @@ -153,7 +153,7 @@ <%= link_to_with_icon( :'fast-forward', - t('.skip'), + t('spree.admin.subscriptions.actions.skip'), spree.skip_admin_subscription_path(subscription), no_text: true, method: :post diff --git a/config/locales/en.yml b/config/locales/en.yml index b34c1add..30e78cfe 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -23,11 +23,12 @@ en: successfully_canceled: Subsciption Canceled! successfully_activated: Subsciption Activated! successfully_skipped: Subsciption delayed until %{date} - index: + actions: cancel: Cancel cancel_alert: "Are you sure you want to cancel this subscription?" activate: Activate skip: Skip One + index: new_subscription: New Subscription edit: title: Details From b5125e83d535adebbe353a9216ed0c0f0b496d92 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 16:04:57 +0200 Subject: [PATCH 8/9] Use a local variable in `_subscription_tabs` partial --- app/views/spree/admin/installments/index.html.erb | 2 +- app/views/spree/admin/shared/_subscription_tabs.html.erb | 4 ++-- app/views/spree/admin/subscriptions/edit.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/spree/admin/installments/index.html.erb b/app/views/spree/admin/installments/index.html.erb index 1e8849bc..483cf4d6 100644 --- a/app/views/spree/admin/installments/index.html.erb +++ b/app/views/spree/admin/installments/index.html.erb @@ -2,7 +2,7 @@ <%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> -<%= render 'spree/admin/shared/subscription_tabs', current: :installments %> +<%= render 'spree/admin/shared/subscription_tabs', current: :installments, subscription: @subscription %> <%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %>
diff --git a/app/views/spree/admin/shared/_subscription_tabs.html.erb b/app/views/spree/admin/shared/_subscription_tabs.html.erb index ea64e62d..7c00486f 100644 --- a/app/views/spree/admin/shared/_subscription_tabs.html.erb +++ b/app/views/spree/admin/shared/_subscription_tabs.html.erb @@ -2,10 +2,10 @@ diff --git a/app/views/spree/admin/subscriptions/edit.html.erb b/app/views/spree/admin/subscriptions/edit.html.erb index c4d57721..e42995c5 100644 --- a/app/views/spree/admin/subscriptions/edit.html.erb +++ b/app/views/spree/admin/subscriptions/edit.html.erb @@ -2,7 +2,7 @@ <%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %> <%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %> -<%= render 'spree/admin/shared/subscription_tabs', current: :details %> +<%= render 'spree/admin/shared/subscription_tabs', current: :details, subscription: @subscription %> <%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %> <%= form_for @subscription, url: spree.admin_subscription_path(@subscription) do |f| %> From d8954026c19c1615a96b557a48017e2db01cdeeb Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Tue, 16 Jun 2020 16:08:34 +0200 Subject: [PATCH 9/9] Fix column sizes in line items form --- app/views/spree/admin/subscriptions/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/subscriptions/_form.html.erb b/app/views/spree/admin/subscriptions/_form.html.erb index 056318a4..ee67d2b5 100644 --- a/app/views/spree/admin/subscriptions/_form.html.erb +++ b/app/views/spree/admin/subscriptions/_form.html.erb @@ -70,7 +70,7 @@ <%= f.fields_for :line_items do |lf| %>
-
+
<%= lf.label :subscribable_id %> <%= lf.collection_select :subscribable_id, Spree::Variant.where(subscribable: true), :id, :pretty_name, {}, { class: "fullwidth select2" } %> @@ -84,7 +84,7 @@
-
+
<%= lf.label :_destroy %> <%= lf.check_box :_destroy, class: "form-control", disabled: lf.object.new_record? %>