Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close #2249 Add section tab in taxon edit screen #2250

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/controllers/spree/admin/view_events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Spree
module Admin
class ViewEventsController < Spree::Admin::ResourceController
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not decorating the existing TaxonController? Naming a new controller can be challenging, and if the new controller is minimal, the additional effort might not be justified.

before_action :load_taxonomy_taxon
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicitly add which action to apply:

before_action :load_taxonomy_taxon, only: [:index]


def index
# Fetch the specific taxon associated with the taxonomy
@taxon = @taxonomy.taxons.find(params[:taxon_id])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need this because the load_taxonomy_taxon already does just this.

end

private

def model_class
Spree::Taxon
end

def load_taxonomy_taxon
@taxonomy = Spree::Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:taxon_id])
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/spree_cm_commissioner/view_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module SpreeCmCommissioner
class ViewEvent < ApplicationRecord
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this, the model is linked to a table in the DB.

end
end
2 changes: 1 addition & 1 deletion app/views/spree/admin/guest_card_classes/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for :page_title do %>
<%= link_to Spree.t(:taxonomies), spree.admin_taxonomies_url %> /

<%= link_to @taxonomy.root.name, spree.edit_admin_taxonomy_url(@taxonomy) %>
<% unless @taxon.root? %>
/ <%= link_to @taxon.name %>
Expand Down
17 changes: 16 additions & 1 deletion app/views/spree/admin/shared/_taxon_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
admin_taxonomy_taxon_taxon_vendors_url(@taxonomy.id, @taxon.id),
class: "nav-link #{'active' if current == :vendors}" %>
<% end if can?(:admin,SpreeCmCommissioner::TaxonVendor)%>
<% if @taxon.depth != 1 %>

<%= content_tag :li, class: 'nav-item' do %>
<%= link_to_with_icon 'inbox.svg',
Spree.t(:products),
admin_taxonomy_taxon_classifications_url(@taxonomy.id, @taxon.id),
class: "nav-link #{'active' if current == :products}" %>
<% end if can?(:admin, Spree::Classification)%>
<%else%>
<%= content_tag :li, class: 'nav-item' do %>
<%= link_to_with_icon 'store.svg',
Spree.t(:sections),
admin_taxonomy_taxon_view_events_url(@taxonomy.id, @taxon.id),
class: "nav-link #{'active' if current == :view_events}" %>
<% end if can?(:admin,Spree::Taxon)%>
<%end%>

<%= content_tag :li, class: 'nav-item' do %>
<%= link_to_with_icon 'user.svg',
Expand All @@ -33,5 +42,11 @@
Spree.t(:guest_card_classes),
admin_taxonomy_taxon_guest_card_classes_url(@taxonomy.id, @taxon.id),
class: "nav-link #{'active' if current == :guest_card_classes}" %>
<% end if can?(:admin,SpreeCmCommissioner::GuestCardClasses)%>
<% end if can?(:admin,SpreeCmCommissioner::GuestCardClasses)%>
<% end %>

<%if(@taxon.depth != 1) && current == :details %>
<%content_for(:page_actions) do%>
<%= button_link_to Spree.t(:back_to_parent_taxon), edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.parent.id), class: "btn-success"%>
<%end%>
<%end%>
36 changes: 36 additions & 0 deletions app/views/spree/admin/view_events/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<% content_for :page_title do %>
<%= link_to Spree.t(:taxonomies), spree.admin_taxonomies_url %>/

<%= link_to @taxonomy.root.name, spree.edit_admin_taxonomy_url(@taxonomy) %>/
<% unless @taxon.root? %>
<%= @taxon.name %>
<% end %>
<% end %>

<%= render partial: 'spree/admin/shared/taxon_tabs', locals: { current: :view_events } %>


<div id="sortableTreeArea">
<div class="row">
<div class="col-12">
<% if @taxonomy.root.present? %>
<div class="card-body p-0 bg-light" data-controller="sortable-tree" data-sortable-tree-handle-value=".move-handle">
<div data-sortable-tree-parent-id-value="<%= @taxonomy.root.id %>">

<% if @taxonomy.root.children.present? %>

<%= build_sortable_tree(@taxonomy, @taxon) %>
<% else %>
<div class="text-center no-objects-found m-5 m-5">
<%= Spree.t('admin.taxonomies.no_taxons') %>
</div>
<% end %>

</div>
</div>
<% end %>
</div>

</div>
</div>
</div>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
resources :taxonomies do
resources :taxons do
resources :taxon_vendors
resources :view_events
resources :guest_card_classes do
member do
delete :remove_background_image
Expand Down
Loading