Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Open source new admin settings (part 1) (#12230)
Damian Legawiec7d4b9fef6889
diff --git a/admin/app/controllers/spree/admin/properties_controller.rb b/admin/app/controllers/spree/admin/properties_controller.rbnew file mode 100644index 0000000000..2c37ea7f1d--- /dev/null+++ b/admin/app/controllers/spree/admin/properties_controller.rb@@ -0,0 +1,27 @@+module Spree+ module Admin+ class PropertiesController < ResourceController+ def index+ respond_with(@collection)+ end++ protected++ def update_turbo_stream_enabled?+ true+ end++ def collection+ return @collection if @collection.present?++ # params[:q] can be blank upon pagination+ params[:q] = {} if params[:q].blank?++ @collection = super+ @search = @collection.ransack(params[:q])+ @collection = @search.result.+ page(params[:page])+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/refund_reasons_controller.rb b/admin/app/controllers/spree/admin/refund_reasons_controller.rbnew file mode 100644index 0000000000..e08a6a69ce--- /dev/null+++ b/admin/app/controllers/spree/admin/refund_reasons_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class RefundReasonsController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rb b/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rbnew file mode 100644index 0000000000..fd7a7b135d--- /dev/null+++ b/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class ReturnAuthorizationReasonsController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/store_credit_categories_controller.rb b/admin/app/controllers/spree/admin/store_credit_categories_controller.rbnew file mode 100644index 0000000000..cb40f19e62--- /dev/null+++ b/admin/app/controllers/spree/admin/store_credit_categories_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class StoreCreditCategoriesController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/tax_categories_controller.rb b/admin/app/controllers/spree/admin/tax_categories_controller.rbnew file mode 100644index 0000000000..34a050d586--- /dev/null+++ b/admin/app/controllers/spree/admin/tax_categories_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class TaxCategoriesController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/zones_controller.rb b/admin/app/controllers/spree/admin/zones_controller.rbnew file mode 100644index 0000000000..62f7be47e6--- /dev/null+++ b/admin/app/controllers/spree/admin/zones_controller.rb@@ -0,0 +1,26 @@+module Spree+ module Admin+ class ZonesController < ResourceController+ before_action :load_data, except: :index++ def new+ @zone.zone_members.build+ end++ protected++ def collection+ params[:q] ||= {}+ params[:q][:s] ||= 'name asc'+ @search = super.ransack(params[:q])+ @zones = @search.result.page(params[:page]).per(params[:per_page])+ end++ def load_data+ @countries = Country.order(:name)+ @states = State.order(:name)+ @zones = Zone.order(:name)+ end+ end+ end+enddiff --git a/admin/app/views/spree/admin/properties/_form.html.erb b/admin/app/views/spree/admin/properties/_form.html.erbnew file mode 100644index 0000000000..6a547e3f4b--- /dev/null+++ b/admin/app/views/spree/admin/properties/_form.html.erb@@ -0,0 +1,22 @@+<div data-controller="slug-form">+ <div class="form-group">+ <%= f.label :presentation, raw(Spree.t(:presentation) + required_span_tag) %>+ <%= f.text_field :presentation, class: 'form-control', data: { slug_form_target: :name, action: 'input->slug-form#updateUrlFromName' } %>+ <%= f.error_message_on :presentation %>+ </div>+ <div class="form-group">+ <%= f.label :name, Spree.t(:internal_name) %>+ <%= f.text_field :name, class: 'form-control', data: { slug_form_target: :url } %>+ <%= f.error_message_on :name %>+ </div>+ <div class="form-group">+ <%= f.label :kind, Spree.t(:kind) %>+ <%= f.select :kind, options_for_select(Spree::Property.kinds.map{ |k| [k.first.humanize, k.first.to_sym] }, @object.kind), {}, { class: 'custom-select' } %>+ <%= f.error_message_on :kind %>+ </div>+ <div class="form-group">+ <%= f.label :display_on, Spree.t(:display_on) %>+ <%= f.select :display_on, display_on_options, {}, { class: 'custom-select' } %>+ <%= f.error_message_on :display_on %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/properties/_property.html.erb b/admin/app/views/spree/admin/properties/_property.html.erbnew file mode 100644index 0000000000..bacd51f9a3--- /dev/null+++ b/admin/app/views/spree/admin/properties/_property.html.erb@@ -0,0 +1,25 @@+<tr id="<%= spree_dom_id property %>" data-controller="row-link" data-sortable-update-url="<%= spree.admin_property_path(property) %>">+ <td class="w-5 move-handle text-center">+ <%= icon('grip-vertical', class: 'rounded hover-gray p-2') %>+ </td>+ <td class="w-20 cursor-pointer py-0" data-action="click->row-link#openLink">+ <code><%= property.name %></vode>+ </td>+ <td class="w-20 cursor-pointer" data-action="click->row-link#openLink">+ <%= link_to property.presentation, spree.edit_admin_property_path(property), class: 'text-decoration-none d-flex align-items-center font-weight-bold text-dark', data: { row_link_target: :link } %>+ </td>+ <td class="w-20 cursor-pointer" data-action="click->row-link#openLink">+ <%= property.kind.humanize %>+ </td>+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">+ <%= property.products.count %>+ </td>+ <td>+ <%= form_with model: property, url: admin_property_path(property), method: :patch, data: { controller: 'auto-submit' } do |f| %>+ <%= f.select :display_on, display_on_options, {}, { class: 'custom-select custom-select-sm w-auto', data: { action: 'auto-submit#submit' } } %>+ <% end %>+ </td>+ <td class="w-10 actions">+ <%= link_to_edit(property, class: 'btn btn-light btn-sm') if can?(:edit, property) %>+ </td>+</tr>\ No newline at end of filediff --git a/admin/app/views/spree/admin/properties/edit.html.erb b/admin/app/views/spree/admin/properties/edit.html.erbnew file mode 100644index 0000000000..76ca1c0ee3--- /dev/null+++ b/admin/app/views/spree/admin/properties/edit.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button admin_properties_url %>+ <%= @property.name %>+<% end %>+++<%= form_for [:admin, @property] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @property } %>+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/properties/index.html.erb b/admin/app/views/spree/admin/properties/index.html.erbnew file mode 100644index 0000000000..6dc881b532--- /dev/null+++ b/admin/app/views/spree/admin/properties/index.html.erb@@ -0,0 +1,60 @@+<% content_for(:page_title) do %>+ <%= Spree.t(:properties) %>+<% end %>++<% content_for(:page_alerts) do %>+ <div class="alert alert-info">+ Properties allow you to enrich your Product information.+ </div>+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_property), new_object_url, { class: "btn-primary", icon: 'plus', } %>+<% end if can?(:create, Spree::Property) %>++<% content_for :table_filter do %>+ <div data-hook="admin_property_sidebar">+ <%= search_form_for [:admin, @search] do |f| %>++ <%- locals = {f: f} %>++ <div class="row">+ <div class="col-12 col-lg-6">+ <div data-hook="admin_property_index_search" class="form-group">+ <%= f.label :name_or_presentation_cont, Spree.t(:name) %>+ <%= f.text_field :name_or_presentation_cont, class: "form-control js-quick-search-target js-filterable" %>+ </div>+ </div>+ </div>++ <div class="form-actions">+ <%= button Spree.t(:search), 'search' %>+ </div>++ <% end %>+ </div>+<% end if Spree::Property.any? %>++<% if @properties.present? %>+ <div class="table-responsive">+ <table class="table" id='listing_properties'>+ <thead class="text-muted">+ <tr data-hook="listing_properties_header">+ <th class="no-border handel-head"></th>+ <th><%= Spree.t(:internal_name) %></th>+ <th><%= Spree.t(:presentation) %></th>+ <th><%= Spree.t(:kind) %></th>+ <th><%= Spree.t(:products) %></th>+ <th><%= Spree.t(:visibility) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody data-controller="sortable" data-sortable-handle-value=".move-handle" data-sortable-resource-name-value="property" data-sortable-response-kind-value="turbo-stream">+ <%= render partial: 'spree/admin/properties/property', collection: @collection, cached: spree_base_cache_scope %>+ </tbody>+ </table>+ <%= render 'spree/admin/shared/index_table_options', collection: @collection, simple: true %>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/properties/new.html.erb b/admin/app/views/spree/admin/properties/new.html.erbnew file mode 100644index 0000000000..27a43a7958--- /dev/null+++ b/admin/app/views/spree/admin/properties/new.html.erb@@ -0,0 +1,14 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_properties_path %>+ <%= Spree.t(:new_property) %>+<% end %>++<%= form_for [:admin, @property] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @property } %>+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/app/views/spree/admin/properties/update.turbo_stream.erb b/admin/app/views/spree/admin/properties/update.turbo_stream.erbnew file mode 100644index 0000000000..d9fb79328e--- /dev/null+++ b/admin/app/views/spree/admin/properties/update.turbo_stream.erb@@ -0,0 +1 @@+<%= turbo_render_alerts %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/refund_reasons/edit.html.erb b/admin/app/views/spree/admin/refund_reasons/edit.html.erbnew file mode 100755index 0000000000..6253c207e2--- /dev/null+++ b/admin/app/views/spree/admin/refund_reasons/edit.html.erb@@ -0,0 +1,3 @@+<%= render partial: 'spree/admin/shared/named_types/edit', locals: {+ collection_url_label: Spree.t(:refund_reasons)+} %>diff --git a/admin/app/views/spree/admin/refund_reasons/index.html.erb b/admin/app/views/spree/admin/refund_reasons/index.html.erbnew file mode 100644index 0000000000..0b1366453c--- /dev/null+++ b/admin/app/views/spree/admin/refund_reasons/index.html.erb@@ -0,0 +1,38 @@+<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_refund_reason), new_object_url, { icon: 'plus', id: 'admin_new_named_type', class: "btn-primary" } %>+<% end if can? :create, Spree::RefundReason %>++<%= render partial: 'spree/admin/shared/returns_and_refunds_nav' %>++<% if @collection.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table" id='listing_named_types' data-hook>+ <thead class="text-muted">+ <tr data-hook="named_types_header">+ <th><%= Spree.t(:name) %></th>+ <th><%= Spree.t(:status) %></th>+ <th></th>+ </tr>+ </thead>+ <tbody id="<%= plural_resource_name(Spree::RefundReason).to_s.parameterize.underscore %>">+ <% @collection.each do |refund_reason| %>+ <tr id="<%= spree_dom_id refund_reason %>" data-hook="named_type_row">+ <td class="align-center">+ <%= refund_reason.name %>+ </td>+ <td class="align-center">+ <%= active_badge(refund_reason.active, label: Spree.t(refund_reason.active? ? :active : :inactive)) %>+ </td>+ <td class="actions">+ <% if refund_reason.mutable? %>+ <%= link_to_edit(refund_reason, no_text: true) if can? :edit, refund_reason %>+ <% end %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/refund_reasons/new.html.erb b/admin/app/views/spree/admin/refund_reasons/new.html.erbnew file mode 100755index 0000000000..6ec309047a--- /dev/null+++ b/admin/app/views/spree/admin/refund_reasons/new.html.erb@@ -0,0 +1,4 @@+<%= render partial: 'spree/admin/shared/named_types/new', locals: {+ collection_url_label: Spree.t(:refund_reasons),+ page_title: Spree.t(:new_refund_reason)+} %>diff --git a/admin/app/views/spree/admin/reimbursement_types/_form.html.erb b/admin/app/views/spree/admin/reimbursement_types/_form.html.erbnew file mode 100644index 0000000000..23a57fdfa1--- /dev/null+++ b/admin/app/views/spree/admin/reimbursement_types/_form.html.erb@@ -0,0 +1,30 @@+<div class="card mb-4">+ <div class="card-body pb-0">+ <div class="form-group">+ <%= f.label :name, Spree.t(:name) %>+ <%= f.text_field :name, class:'form-control' %>+ <%= f.error_message_on :name %>+ </div>+ <%- if @reimbursement_type.new_record? %>+ <div class="form-group">+ <%= f.label :type, Spree.t(:type) %>+ <%= f.select :type, options_for_select(Spree::ReimbursementType::KINDS.map { |kind| [kind.demodulize.humanize, kind] }), { include_blank: false}, { class: 'custom-select' } %>+ <%= f.error_message_on :type %>+ </div>+ <% end %>+ <div class="form-group">+ <div class="custom-control custom-checkbox">+ <%= f.check_box :active, class: 'custom-control-input' %>+ <%= f.label :active, Spree.t(:active), class: 'custom-control-label' %>+ </div>+ <%= f.error_message_on :active %>+ </div>+ <div class="form-group">+ <div class="custom-control custom-checkbox">+ <%= f.check_box :mutable, class: 'custom-control-input' %>+ <%= f.label :mutable, Spree.t(:mutable), class: 'custom-control-label' %>+ </div>+ <%= f.error_message_on :mutable %>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/reimbursement_types/edit.html.erb b/admin/app/views/spree/admin/reimbursement_types/edit.html.erbnew file mode 100644index 0000000000..5357d5f7c8--- /dev/null+++ b/admin/app/views/spree/admin/reimbursement_types/edit.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_reimbursement_types_url %>+ <%= @reimbursement_type.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @reimbursement_type } %>++<div class="row">+ <div class="col-lg-6">+ <%= form_for @reimbursement_type, :url => object_url, :method => :put do |reimbursement_form| %>+ <%= render partial: 'form', locals: { f: reimbursement_form } %>+ <%= render 'spree/admin/shared/edit_resource_links', f: reimbursement_form %>+ <% end %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/reimbursement_types/index.html.erb b/admin/app/views/spree/admin/reimbursement_types/index.html.erbnew file mode 100644index 0000000000..78804c72c9--- /dev/null+++ b/admin/app/views/spree/admin/reimbursement_types/index.html.erb@@ -0,0 +1,36 @@+<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_reimbursement_type), new_object_url, { :class => "btn-primary", :icon => 'plus', :id => 'admin_new_reimbursement_type' } %>+<% end if can?(:create, Spree::ReimbursementType) %>++<%= render partial: 'spree/admin/shared/returns_and_refunds_nav' %>++<% if @reimbursement_types.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table" id='listing_reimbursement_types' data-hook>+ <thead class="text-muted">+ <tr>+ <th><%= Spree.t(:name) %></th>+ <th><%= Spree.t(:type) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @reimbursement_types.each do |reimbursement_type| %>+ <tr id="<%= spree_dom_id reimbursement_type %>">+ <td class="align-center">+ <%= reimbursement_type.name.humanize %>+ </td>+ <td>+ <code><%= reimbursement_type.type.demodulize %></code>+ </td>+ <td class="actions">+ <%= link_to_edit reimbursement_type, no_text: true if can?(:edit, reimbursement_type) %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/reimbursement_types/new.html.erb b/admin/app/views/spree/admin/reimbursement_types/new.html.erbnew file mode 100644index 0000000000..83dff57613--- /dev/null+++ b/admin/app/views/spree/admin/reimbursement_types/new.html.erb@@ -0,0 +1,16 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_reimbursement_types_url %>+ <%= Spree.t(:new_reimbursement_type) %>+<% end %>+++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @reimbursement_type } %>++<div class="row">+ <div class="col-lg-6">+ <%= form_for [:admin, @reimbursement_type] do |reimbursement_form| %>+ <%= render partial: 'form', locals: { f: reimbursement_form } %>+ <%= render 'spree/admin/shared/new_resource_links' %>+ <% end %>+ </div>+</div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/return_authorization_reasons/edit.html.erb b/admin/app/views/spree/admin/return_authorization_reasons/edit.html.erbnew file mode 100644index 0000000000..1368b27fe4--- /dev/null+++ b/admin/app/views/spree/admin/return_authorization_reasons/edit.html.erb@@ -0,0 +1,3 @@+<%= render partial: 'spree/admin/shared/named_types/edit', locals: {+ collection_url_label: Spree.t(:return_authorization_reasons)+} %>diff --git a/admin/app/views/spree/admin/return_authorization_reasons/index.html.erb b/admin/app/views/spree/admin/return_authorization_reasons/index.html.erbnew file mode 100644index 0000000000..18f0a4e182--- /dev/null+++ b/admin/app/views/spree/admin/return_authorization_reasons/index.html.erb@@ -0,0 +1,38 @@+<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_rma_reason), new_object_url, { icon: 'plus', id: 'admin_new_named_type', class: "btn-primary" } %>+<% end if can? :create, Spree::RefundReason %>++<%= render partial: 'spree/admin/shared/returns_and_refunds_nav' %>++<% if @collection.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table" id='listing_named_types' data-hook>+ <thead class="text-muted">+ <tr data-hook="named_types_header">+ <th><%= Spree.t(:name) %></th>+ <th><%= Spree.t(:status) %></th>+ <th></th>+ </tr>+ </thead>+ <tbody id="<%= plural_resource_name(Spree::ReturnAuthorizationReason).to_s.parameterize.underscore %>">+ <% @collection.each do |return_authorization_reason| %>+ <tr id="<%= spree_dom_id return_authorization_reason %>" data-hook="named_type_row">+ <td class="align-center">+ <%= return_authorization_reason.name %>+ </td>+ <td class="align-center">+ <%= active_badge(return_authorization_reason.active, label: Spree.t(return_authorization_reason.active? ? :active : :inactive)) %>+ </td>+ <td class="actions">+ <% if return_authorization_reason.mutable? %>+ <%= link_to_edit(return_authorization_reason, no_text: true) if can? :edit, return_authorization_reason %>+ <% end %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/return_authorization_reasons/new.html.erb b/admin/app/views/spree/admin/return_authorization_reasons/new.html.erbnew file mode 100644index 0000000000..7d22ecd390--- /dev/null+++ b/admin/app/views/spree/admin/return_authorization_reasons/new.html.erb@@ -0,0 +1,4 @@+<%= render partial: 'spree/admin/shared/named_types/new', locals: {+ collection_url_label: Spree.t(:return_authorization_reasons),+ page_title: Spree.t(:new_rma_reason)+} %>diff --git a/admin/app/views/spree/admin/shared/_no_resource_found.html.erb b/admin/app/views/spree/admin/shared/_no_resource_found.html.erbnew file mode 100644index 0000000000..b7abe7b167--- /dev/null+++ b/admin/app/views/spree/admin/shared/_no_resource_found.html.erb@@ -0,0 +1,4 @@+<div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(model_class)) %>+ <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link ml-3' if can?(:create, model_class) %>+</div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_returns_and_refunds_nav.html.erb b/admin/app/views/spree/admin/shared/_returns_and_refunds_nav.html.erbnew file mode 100644index 0000000000..978f271c3b--- /dev/null+++ b/admin/app/views/spree/admin/shared/_returns_and_refunds_nav.html.erb@@ -0,0 +1,9 @@+<% content_for(:page_title) do %>+ Returns & Refunds+<% end %>++<% content_for(:page_tabs) do %>+ <%= nav_pill_list_item(:return_authorization_reasons, url: spree.admin_return_authorization_reasons_path) if can?(:manage, Spree::ReturnAuthorizationReason) %>+ <%= nav_pill_list_item(:refund_reasons, url: spree.admin_refund_reasons_path) if can?(:manage, Spree::RefundReason) %>+ <%= nav_pill_list_item(:reimbursement_types, url: spree.admin_reimbursement_types_path) if can?(:manage, Spree::ReimbursementType) %>+<% end %>diff --git a/admin/app/views/spree/admin/shared/named_types/_edit.html.erb b/admin/app/views/spree/admin/shared/named_types/_edit.html.erbnew file mode 100644index 0000000000..c0814bb37b--- /dev/null+++ b/admin/app/views/spree/admin/shared/named_types/_edit.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button collection_url %>+ <%= @object.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %>++<div class="row">+ <div class="col-lg-6">+ <%= form_for [:admin, @object] do |f| %>+ <%= render partial: 'spree/admin/shared/named_types/form', locals: { f: f } %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+ <% end %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/shared/named_types/_form.html.erb b/admin/app/views/spree/admin/shared/named_types/_form.html.erbnew file mode 100644index 0000000000..7b4702c3ab--- /dev/null+++ b/admin/app/views/spree/admin/shared/named_types/_form.html.erb@@ -0,0 +1,15 @@+<div class="card mb-4">+ <div class="card-body">+ <div class="form-group">+ <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>+ <%= f.text_field :name, class: 'form-control' %>+ <%= f.error_message_on :name %>+ </div>+ <div class="custom-control custom-checkbox">+ <%= f.check_box :active, class: 'custom-control-input' %>+ <%= f.label :active, class: 'custom-control-label' do %>+ <%= Spree.t(:active) %>+ <% end %>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/shared/named_types/_new.html.erb b/admin/app/views/spree/admin/shared/named_types/_new.html.erbnew file mode 100644index 0000000000..a072762a21--- /dev/null+++ b/admin/app/views/spree/admin/shared/named_types/_new.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button collection_url %>+ <%= page_title %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %>++<div class="row">+ <div class="col-lg-6">+ <%= form_for [:admin, @object] do |f| %>+ <%= render partial: 'spree/admin/shared/named_types/form', locals: { f: f } %>+ <%= render 'spree/admin/shared/new_resource_links' %>+ <% end %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/shipping_categories/_form.html.erb b/admin/app/views/spree/admin/shipping_categories/_form.html.erbnew file mode 100644index 0000000000..5d6297bd0b--- /dev/null+++ b/admin/app/views/spree/admin/shipping_categories/_form.html.erb@@ -0,0 +1,9 @@+<div class="card mb-4">+ <div class="card-body pb-0">+ <div class="form-group">+ <%= f.label :name, Spree.t(:name) %>+ <%= f.text_field :name, class: 'form-control' %>+ <%= f.error_message_on :name %>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/shipping_categories/edit.html.erb b/admin/app/views/spree/admin/shipping_categories/edit.html.erbnew file mode 100644index 0000000000..64a6c23708--- /dev/null+++ b/admin/app/views/spree/admin/shipping_categories/edit.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_shipping_categories_url %>+ <%= @shipping_category.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @shipping_category } %>++<%= form_for [:admin, @shipping_category] do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/shipping_categories/index.html.erb b/admin/app/views/spree/admin/shipping_categories/index.html.erbnew file mode 100644index 0000000000..f92212831c--- /dev/null+++ b/admin/app/views/spree/admin/shipping_categories/index.html.erb@@ -0,0 +1,36 @@+<% content_for :page_title do %>+ <%= Spree.t(:shipping) %>+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_shipping_category), new_object_url, class: "btn-primary", icon: 'plus.svg' %>+<% end if can? :create, Spree::ShippingCategory %>++<%= render partial: 'spree/admin/shared/shipping_nav' %>++<% if @shipping_categories.any? %>+ <div class="table-responsive border rounded bg-white shadow-xs">+ <table class="table">+ <thead class="text-muted">+ <tr>+ <th><%= Spree.t(:name) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @shipping_categories.each do |shipping_category| %>+ <tr id="<%= spree_dom_id shipping_category %>" class="cursor-pointer" data-controller="row-link">+ <td data-action="click->row-link#openLink"><%= shipping_category.name %></td>+ <td class="actions">+ <span class="d-flex justify-content-end">+ <%= link_to_edit(shipping_category, data: { row_link_target: :link }) if can? :edit, shipping_category %>+ </span>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/shipping_categories/new.html.erb b/admin/app/views/spree/admin/shipping_categories/new.html.erbnew file mode 100644index 0000000000..bdc76b9173--- /dev/null+++ b/admin/app/views/spree/admin/shipping_categories/new.html.erb@@ -0,0 +1,13 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_shipping_categories_url %>+ <%= Spree.t(:new_shipping_category) %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @shipping_category } %>++<%= form_for [:admin, @shipping_category] do |f| %>+ <fieldset>+ <%= render partial: 'form', locals: { f: f } %>+ <%= render partial: 'spree/admin/shared/new_resource_links' %>+ </fieldset>+<% end %>diff --git a/admin/app/views/spree/admin/stock_locations/index.html.erb b/admin/app/views/spree/admin/stock_locations/index.html.erbindex f6c31988b1..68716f8f2e 100644--- a/admin/app/views/spree/admin/stock_locations/index.html.erb+++ b/admin/app/views/spree/admin/stock_locations/index.html.erb@@ -22,8 +22,5 @@</table></div><% else %>- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">- <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::StockLocation)) %>- <%= link_to_with_icon('plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link') if can? :create, Spree::StockLocation %>- </div>+ <%= render 'spree/admin/shared/no_resource_found' %><% end %>diff --git a/admin/app/views/spree/admin/store_credit_categories/_form.html.erb b/admin/app/views/spree/admin/store_credit_categories/_form.html.erbnew file mode 100644index 0000000000..6b2d53f843--- /dev/null+++ b/admin/app/views/spree/admin/store_credit_categories/_form.html.erb@@ -0,0 +1,5 @@+<div class="form-group">+ <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>+ <%= f.text_field :name, class: 'form-control' %>+ <%= f.error_message_on :name %>+<% end %>diff --git a/admin/app/views/spree/admin/store_credit_categories/edit.html.erb b/admin/app/views/spree/admin/store_credit_categories/edit.html.erbnew file mode 100644index 0000000000..53e76d4a87--- /dev/null+++ b/admin/app/views/spree/admin/store_credit_categories/edit.html.erb@@ -0,0 +1,13 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_store_credit_categories_url %>+ <%= @store_credit_category.name %>+<% end %>++<%= render 'spree/admin/shared/error_messages', target: @store_credit_category %>++<%= form_for [:admin, @store_credit_category] do |f| %>+ <fieldset>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+ </fieldset>+<% end %>diff --git a/admin/app/views/spree/admin/store_credit_categories/index.html.erb b/admin/app/views/spree/admin/store_credit_categories/index.html.erbnew file mode 100644index 0000000000..490878f6b9--- /dev/null+++ b/admin/app/views/spree/admin/store_credit_categories/index.html.erb@@ -0,0 +1,32 @@+<% content_for :page_title do %>+ <%= plural_resource_name(Spree::StoreCreditCategory) %>+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_store_credit_category), new_object_url, class: "btn-primary", icon: 'plus', id: 'admin_new_store_credit_category_link' %>+<% end if can? :create, Spree::StoreCreditCategory %>++<% if @store_credit_categories.any? %>+<div class="table-responsive card-lg p-0">+ <table class="table">+ <thead class="text-muted">+ <tr data-hook="admin_store_credit_categories_index_headers">+ <th><%= Spree.t(:name) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @store_credit_categories.each do |store_credit_category| %>+ <tr id="<%= spree_dom_id store_credit_category %>" data-hook="admin_store_credit_categories_index_rows">+ <td><%= store_credit_category.name %></td>+ <td class="actions">+ <%= link_to_edit(store_credit_category, no_text: true) if can? :edit, store_credit_category %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+</div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/store_credit_categories/new.html.erb b/admin/app/views/spree/admin/store_credit_categories/new.html.erbnew file mode 100644index 0000000000..bd04d8a4fe--- /dev/null+++ b/admin/app/views/spree/admin/store_credit_categories/new.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_store_credit_categories_url %>+ <%= Spree.t(:new_store_credit_category) %>+<% end %>++<%= render 'spree/admin/shared/error_messages', target: @store_credit_category %>++<%= form_for [:admin, @store_credit_category] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/app/views/spree/admin/tax_categories/_form.html.erb b/admin/app/views/spree/admin/tax_categories/_form.html.erbnew file mode 100644index 0000000000..736bf99820--- /dev/null+++ b/admin/app/views/spree/admin/tax_categories/_form.html.erb@@ -0,0 +1,25 @@+<div class="card mb-4">+ <div class="card-body">++ <div class="form-group">+ <%= f.label :name, Spree.t(:name) %>+ <%= f.text_field :name, class: 'form-control' %>+ <%= f.error_message_on :name %>+ </div>++ <div class="form-group">+ <%= f.label :tax_code, Spree.t(:tax_code) %>+ <%= f.text_field :tax_code, class: 'form-control' %>+ </div>++ <div class="form-group">+ <%= f.label :description, Spree.t(:description) %><br>+ <%= f.text_field :description, class: 'form-control' %>+ </div>++ <div class="custom-control custom-checkbox">+ <%= f.check_box :is_default, class: 'custom-control-input' %>+ <%= f.label :is_default, class: 'custom-control-label' %>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/tax_categories/_tax_category.html.erb b/admin/app/views/spree/admin/tax_categories/_tax_category.html.erbnew file mode 100644index 0000000000..5d84919c8f--- /dev/null+++ b/admin/app/views/spree/admin/tax_categories/_tax_category.html.erb@@ -0,0 +1,9 @@+<tr id="<%= spree_dom_id tax_category %>" data-controller="row-link" class="cursor-pointer">+ <td data-action="click->row-link#openLink"><%= tax_category.name %></td>+ <td data-action="click->row-link#openLink"><%= tax_category.tax_code %></td>+ <td data-action="click->row-link#openLink"><%= tax_category.description %></td>+ <td data-action="click->row-link#openLink"><%= active_badge(tax_category.is_default?) %></td>+ <td class="actions">+ <%= link_to_edit(tax_category, data: { row_link_target: :link }) if can? :edit, tax_category %>+ </td>+</tr>diff --git a/admin/app/views/spree/admin/tax_categories/edit.html.erb b/admin/app/views/spree/admin/tax_categories/edit.html.erbnew file mode 100644index 0000000000..a1a9f8d821--- /dev/null+++ b/admin/app/views/spree/admin/tax_categories/edit.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_tax_categories_url %>+ <%= @tax_category.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @tax_category } %>++<%= form_for [:admin, @tax_category] do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/tax_categories/index.html.erb b/admin/app/views/spree/admin/tax_categories/index.html.erbnew file mode 100644index 0000000000..5046301055--- /dev/null+++ b/admin/app/views/spree/admin/tax_categories/index.html.erb@@ -0,0 +1,30 @@+<% content_for :page_title do %>+ <%= Spree.t(:taxes) %>+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_tax_category), new_object_url, class: "btn-primary", icon: 'plus', id: 'admin_new_tax_categories_link' %>+<% end if can? :create, Spree::TaxCategory %>++<%= render partial: 'spree/admin/shared/tax_nav' %>++<% if @tax_categories.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table" id='listing_tax_categories' data-hook>+ <thead class="text-muted">+ <tr data-hook="tax_header">+ <th><%= Spree.t(:name) %></th>+ <th><%= Spree.t(:tax_code) %></th>+ <th><%= Spree.t(:description) %></th>+ <th><%= Spree.t(:default) %></th>+ <th></th>+ </tr>+ </thead>+ <tbody>+ <%= render collection: @tax_categories, partial: 'spree/admin/tax_categories/tax_category', cached: spree_base_cache_scope %>+ </tbody>+ </table>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/tax_categories/new.html.erb b/admin/app/views/spree/admin/tax_categories/new.html.erbnew file mode 100644index 0000000000..09dfcc2eb8--- /dev/null+++ b/admin/app/views/spree/admin/tax_categories/new.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_tax_categories_url %>+ <%= Spree.t(:new_tax_category) %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @tax_category } %>++<%= form_for [:admin, @tax_category] do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/app/views/spree/admin/zones/_country_members.html.erb b/admin/app/views/spree/admin/zones/_country_members.html.erbnew file mode 100644index 0000000000..00cc3da0a1--- /dev/null+++ b/admin/app/views/spree/admin/zones/_country_members.html.erb@@ -0,0 +1,16 @@+<div id="country_members" data-hook="member">+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title">+ <%= Spree.t(:countries) %>+ </h5>+ </div>++ <div class="card-body">+ <div class="form-group">+ <%= zone_form.label :country_ids, Spree.t(:countries) %>+ <%= tom_select_tag 'zone[country_ids]', multiple: true, class: 'w-100', options: Spree::Country.all.to_tom_select_json, active_option: @zone.country_ids %>+ </div>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/zones/_form.html.erb b/admin/app/views/spree/admin/zones/_form.html.erbnew file mode 100644index 0000000000..dde0ffd09c--- /dev/null+++ b/admin/app/views/spree/admin/zones/_form.html.erb@@ -0,0 +1,49 @@+<div class="row">+ <div class="col-12 col-lg-6" data-hook="admin_zone_form_fields">+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title"><%= Spree.t(:general_settings) %></h5>+ </div>++ <div class="card-body">+ <div class="form-group">+ <%= zone_form.label :name, Spree.t(:name) %>+ <%= zone_form.text_field :name, class: 'form-control' %>+ <%= zone_form.error_message_on :name %>+ </div>++ <div class="form-group">+ <%= zone_form.label :description, Spree.t(:description) %>+ <%= zone_form.text_field :description, class: 'form-control' %>+ </div>++ <div class="form-group checkbox">+ <%= label_tag "zone[#{:default_tax}" do %>+ <%= zone_form.check_box :default_tax %>+ <%= Spree.t(:default_tax_zone) %>+ <% end %>+ </div>++ <div class="form-group">+ <strong><%= Spree.t(:type) %></strong>+ <div class="radio my-2">+ <%= label_tag :country_based do %>+ <%= zone_form.radio_button('kind', 'country', { id: 'country_based' }) %>+ <%= Spree.t(:country_based) %>+ <% end %>+ </div>+ <div class="radio my-2">+ <%= label_tag :state_based do %>+ <%= zone_form.radio_button('kind', 'state', { id: 'state_based' }) %>+ <%= Spree.t(:state_based) %>+ <% end %>+ </div>+ </div>+ </div>+ </div>+ </div>+ <div class="col-12 col-lg-6">+ <%= render partial: 'state_members', locals: { zone_form: zone_form } %>+ <%= render partial: 'country_members', locals: { zone_form: zone_form } %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/zones/_state_members.html.erb b/admin/app/views/spree/admin/zones/_state_members.html.erbnew file mode 100644index 0000000000..80ca2e7d66--- /dev/null+++ b/admin/app/views/spree/admin/zones/_state_members.html.erb@@ -0,0 +1,16 @@+<div id="state_members" data-hook="member">+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title">+ <%= Spree.t(:states) %>+ </h5>+ </div>++ <div class="card-body">+ <div class="form-group">+ <%= zone_form.label :state_ids, Spree.t(:states) %>+ <%= tom_select_tag 'zone[state_ids]', multiple: true, class: 'w-100', options: @states.to_tom_select_json, active_option: @zone.state_ids %>+ </div>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/zones/edit.html.erb b/admin/app/views/spree/admin/zones/edit.html.erbnew file mode 100644index 0000000000..5c1fa1f0f3--- /dev/null+++ b/admin/app/views/spree/admin/zones/edit.html.erb@@ -0,0 +1,12 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_zones_url %>+ <%= @zone.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @zone } %>++<%= form_for [:admin, @zone] do |f| %>+ <%= render 'form', zone_form: f %>++ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/zones/index.html.erb b/admin/app/views/spree/admin/zones/index.html.erbnew file mode 100644index 0000000000..e98569d581--- /dev/null+++ b/admin/app/views/spree/admin/zones/index.html.erb@@ -0,0 +1,50 @@+<%= content_for(:title) do %>+ Markets+<% end %>+++<%= content_for(:page_title) do %>+ Markets+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_market), new_object_url, class: "btn-primary", icon: 'plus', id: 'admin_new_zone_link' %>+<% end if can? :create, Spree::Zone %>++<% content_for :page_alerts do %>+ <div class="alert alert-info">+ Markets are geographical groupings, they represent collections of either states or countries.+ </div>+<% end %>++<% if @zones.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table" id='listing_zones' data-hook>+ <thead class="text-muted">+ <tr data-hook="zones_header">+ <th><%= sort_link @search,:name, Spree.t(:name), title: 'zones_order_by_name_title' %></th>+ <th>+ <%= sort_link @search,:description, Spree.t(:description), {}, {title: 'zones_order_by_description_title'} %>+ </th>+ <th><%= Spree.t(:default_tax_zone) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @zones.each do |zone| %>+ <tr id="<%= spree_dom_id zone %>" class="cursor-pointer" data-controller="row-link">+ <td data-action="click->row-link#openLink"><%= zone.name %></td>+ <td data-action="click->row-link#openLink"><%= zone.description %></td>+ <td data-action="click->row-link#openLink"><%= active_badge(zone.default_tax?) %></td>+ <td class="actions">+ <%= link_to_edit(zone, data: { row_link_target: :link }) if can? :edit, zone %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ <%= render 'spree/admin/shared/index_table_options', collection: @zones, simple: true %>+ </div>+<% else %>+ <%= render 'spree/admin/shared/no_resource_found' %>+<% end %>diff --git a/admin/app/views/spree/admin/zones/new.html.erb b/admin/app/views/spree/admin/zones/new.html.erbnew file mode 100644index 0000000000..937fc311f3--- /dev/null+++ b/admin/app/views/spree/admin/zones/new.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_zones_url %>+ <%= Spree.t(:new_market) %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @zone } %>++<%= form_for [:admin, @zone] do |zone_form| %>+ <%= render partial: 'form', locals: { zone_form: zone_form } %>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/config/routes.rb b/admin/config/routes.rbindex 707c532292..12592ae907 100644--- a/admin/config/routes.rb+++ b/admin/config/routes.rb@@ -1,5 +1,8 @@Spree::Core::Engine.add_routes donamespace :admin, path: Spree.admin_path do+ # product catalog+ resources :properties+# media libraryresources :assets, only: [:create, :edit, :update, :destroy] docollection do@@ -14,7 +17,15 @@ Spree::Core::Engine.add_routes doresource :profile, controller: 'profile', only: %i[edit update]# store settings- resources :stock_locations, except: [:show] do+ resources :shipping_categories, except: :show+ resources :store_credit_categories+ resources :tax_rates, except: :show+ resources :tax_categories, except: :show+ resources :reimbursement_types+ resources :refund_reasons, except: :show+ resources :return_authorization_reasons, except: :show+ resources :zones+ resources :stock_locations, except: :show domember doput :mark_as_defaultenddiff --git a/admin/spec/controllers/spree/admin/properties_controller_spec.rb b/admin/spec/controllers/spree/admin/properties_controller_spec.rbnew file mode 100644index 0000000000..f70c873ec1--- /dev/null+++ b/admin/spec/controllers/spree/admin/properties_controller_spec.rb@@ -0,0 +1,19 @@+require 'spec_helper'++describe Spree::Admin::PropertiesController, type: :controller do+ stub_authorization!++ let(:store) { Spree::Store.default }++ describe '#index' do+ let!(:property) { create(:property, name: 'Ingredients', presentation: 'Product Ingredients') }++ it 'renders index' do+ get :index+ expect(response).to have_http_status(:ok)++ expect(assigns(:collection).to_a.count).to eq(1)+ expect(assigns(:collection).to_a).to eq([property])+ end+ end+end