Skip to content

Commit

Permalink
added admin section
Browse files Browse the repository at this point in the history
  • Loading branch information
joshnuss committed Nov 22, 2010
1 parent 11c3f91 commit d0cd691
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/admin/contact_topics_controller.rb
@@ -0,0 +1,11 @@
class Admin::ContactTopicsController < Admin::BaseController
resource_controller

create.wants.html { redirect_to collection_path }
update.wants.html { redirect_to collection_path }

new_action.response do |wants|
wants.html {render :action => :new, :layout => !request.xhr?}
end

end
2 changes: 2 additions & 0 deletions app/helpers/admin/contact_topics_helper.rb
@@ -0,0 +1,2 @@
module Admin::ContactTopicsHelper
end
19 changes: 19 additions & 0 deletions app/views/admin/contact_topics/_form.html.erb
@@ -0,0 +1,19 @@
<%- locals = {:f => f} %>
<%= render "shared/error_messages", :target => f.object %>
<%= hook :admin_contact_topic_form, locals do %>
<%= f.field_container :name do %>
<%= f.label :name, t("name") %> <span class="required">*</span><br />
<%= f.text_field :name, :class => 'fullwidth title' %>
<%= f.error_message_on :name %>
<% end %>
<%= f.field_container :emails do %>
<%= f.label :emails, t("emails") %> (<%= t('comma_delimited') %>) <span class="required">*</span><br />
<%= f.text_field :emails, :class => 'fullwidth title' %>
<%= f.error_message_on :emails %>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions app/views/admin/contact_topics/edit.html.erb
@@ -0,0 +1,4 @@
<%= form_for(@contact_topic, :url => object_url, :html => { :method => :put }) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= render :partial => 'admin/shared/edit_resource_links' %>
<% end %>
42 changes: 42 additions & 0 deletions app/views/admin/contact_topics/index.html.erb
@@ -0,0 +1,42 @@
<div class='toolbar'>
<ul class='actions'>
<li id="new_contact_topic_link">
<%= button_link_to t("new_contact_topic"), new_object_url, {:remote => true, :icon => 'add'} %>
</li>
</ul>
<br class='clear' />
</div>

<h1><%= t("contact_topics")%></h1>

<div id="new_contact_topic"></div>

<table class="index">
<tr>
<%= hook :admin_contact_topic_index_headers do %>
<th><%= t("name") %></th>
<th><%= t("emails") %></th>
<% end %>
<th>
<%= hook :admin_contact_topic_index_header_actions %>
</th>
</tr>
<% @contact_topics.each do |topic| %>
<tr id="<%= dom_id topic %>">
<%- locals = {:topic => topic} %>
<%= hook :admin_contact_topics_index_rows, locals do %>
<td><%= topic.name %></td>
<td><%= topic.emails %></td>
<% end %>
<td class="actions">
<%= hook :admin_contact_topics_index_row_actions, locals do %>
<%= link_to_edit topic %>
&nbsp;
<%= link_to_delete topic %>
<% end %>
</td>
</tr>
<% end %>
</table>


4 changes: 4 additions & 0 deletions app/views/admin/contact_topics/new.html.erb
@@ -0,0 +1,4 @@
<%= form_for(@contact_topic, :url => collection_url) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= render :partial => 'admin/shared/new_resource_links' %>
<% end %>
5 changes: 5 additions & 0 deletions config/locales/en.yml
Expand Up @@ -7,3 +7,8 @@ en:
topic: Topic
invalid_order_number: "should start with letter 'R' followed by 9 numbers (e.g. R123123213)"
contact_thank_you: "Thank you! Your message has been sent successfully, we will be contacting you shortly"
contact_topics: Contact Topics
contact_topics_description: Setup topics for the contact form, choose which email address topics should be routed to
emails: Emails
new_contact_topic: New Contact Topic
comma_delimited: comma delimited
4 changes: 4 additions & 0 deletions config/routes.rb
@@ -1,3 +1,7 @@
Rails.application.routes.draw do
resource :contact, :controller => 'contact'

namespace :admin do
resources :contact_topics
end
end
3 changes: 3 additions & 0 deletions lib/spree_contact_form_hooks.rb
@@ -1,4 +1,7 @@
class SpreeContactFormHooks < Spree::ThemeSupport::HookListener
insert_after :admin_configurations_menu do
"<%= configurations_menu_item(I18n.t('contact_topics'), admin_contact_topics_path, I18n.t('contact_topics_description')) %>"
end

end

5 changes: 5 additions & 0 deletions spec/controllers/admin/contact_topics_controller_spec.rb
@@ -0,0 +1,5 @@
require 'spec_helper'

describe Admin::ContactTopicsController do

end
4 changes: 4 additions & 0 deletions spec/helpers/admin/contact_topics_helper_spec.rb
@@ -0,0 +1,4 @@
require 'spec_helper'

describe Admin::ContactTopicsHelper do
end

0 comments on commit d0cd691

Please sign in to comment.