From 155c766a29e6aa69f55746cd3a66aa28eb261df5 Mon Sep 17 00:00:00 2001 From: Eugene Korbut Date: Mon, 9 Feb 2009 01:00:26 +1000 Subject: [PATCH] contacts page refactoring --- ...t_controller.rb => contacts_controller.rb} | 6 +-- app/helpers/application_helper.rb | 2 +- app/helpers/contact_helper.rb | 40 ------------------- app/helpers/contacts_helper.rb | 3 ++ app/helpers/navigation_helper.rb | 38 ++++++++++++++++++ app/views/{contact => contacts}/add.rhtml | 0 .../{contact => contacts}/add_multiple.rhtml | 0 app/views/{contact => contacts}/choose.rhtml | 0 .../import_preview.rhtml | 0 .../list.rhtml => contacts/index.html.erb} | 2 +- config/routes.rb | 1 + 11 files changed, 45 insertions(+), 47 deletions(-) rename app/controllers/{contact_controller.rb => contacts_controller.rb} (95%) delete mode 100644 app/helpers/contact_helper.rb create mode 100644 app/helpers/contacts_helper.rb rename app/views/{contact => contacts}/add.rhtml (100%) rename app/views/{contact => contacts}/add_multiple.rhtml (100%) rename app/views/{contact => contacts}/choose.rhtml (100%) rename app/views/{contact => contacts}/import_preview.rhtml (100%) rename app/views/{contact/list.rhtml => contacts/index.html.erb} (94%) diff --git a/app/controllers/contact_controller.rb b/app/controllers/contacts_controller.rb similarity index 95% rename from app/controllers/contact_controller.rb rename to app/controllers/contacts_controller.rb index 0e38c73..caa4bd3 100644 --- a/app/controllers/contact_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -1,11 +1,7 @@ -class ContactController < ApplicationController +class ContactsController < ApplicationController layout :select_layout def index - redirect_to(:action =>"list") - end - - def list @contact_pages = Paginator.new(self, Contact.count("customer_id = #{logged_user}"), CDF::CONFIG[:contacts_per_page], params['page']) @contacts = Contact.find(:all, :conditions=>["customer_id = #{logged_user}"], :order=>['fname'], :limit=>CDF::CONFIG[:contacts_per_page], :offset=>@contact_pages.current.offset) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c38095d..70cfff2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -118,7 +118,7 @@ module ApplicationHelper end def link_main - link_to(_('Contacts'), :controller => '/contact', :action => 'list') + link_to(_('Contacts'), contacts_path) end def alternator diff --git a/app/helpers/contact_helper.rb b/app/helpers/contact_helper.rb deleted file mode 100644 index c8bef05..0000000 --- a/app/helpers/contact_helper.rb +++ /dev/null @@ -1,40 +0,0 @@ -module ContactHelper - def link_import_preview() "/contacts/contact/import_preview" end - def link_main_index() "/webmail/folders" end - def link_contact_save() "/contacts/contact/save" end - def link_contact_import() "/contacts/contact/import" end - def link_contact_choose() "/contacts/contact/choose" end - - def link_contact_list - link_to(_('List'), :controller => "/contacts/contact", :action => "list") - end - - def link_contact_add_one - link_to(_('Add one contact'), :controller => "/contacts/contact", :action => "add") - end - - def link_contact_add_multiple - link_to(_('Add multiple'), :controller => "/contacts/contact", :action => "add_multiple") - end - - def link_contact_group_list - link_to(_('Groups'), :controller => "/contacts/contact_group", :action => "list") - end - - def link_folders - link_to(_('Folders'), :controller=>"/webmail", :action=>"messages") - end - - def link_send_mail - link_to(_('Compose'), :controller=>"/webmail", :action=>"compose") - end - - def link_mail_prefs - link_to(_('Preferences'), :controller=>"/webmail", :action=>"prefs") - end - - def link_mail_filters - link_to(_('Filters'), :controller=>"/webmail", :action=>"filters") - end - -end diff --git a/app/helpers/contacts_helper.rb b/app/helpers/contacts_helper.rb new file mode 100644 index 0000000..6eb7d9a --- /dev/null +++ b/app/helpers/contacts_helper.rb @@ -0,0 +1,3 @@ +module ContactsHelper + +end diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 0fc88cd..f27aa9c 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -23,6 +23,44 @@ module NavigationHelper end end + def link_import_preview() "/contacts/import_preview" end + def link_main_index() "/" end + def link_contact_save() "/contacts/save" end + def link_contact_import() "/contacts/import" end + def link_contact_choose() "/contacts/contact/choose" end + + def link_contact_list + link_to(_('List'), :controller => "/contacts/contact", :action => "list") + end + + def link_contact_add_one + link_to(_('Add one contact'), :controller => "/contacts/contact", :action => "add") + end + + def link_contact_add_multiple + link_to(_('Add multiple'), :controller => "/contacts/contact", :action => "add_multiple") + end + + def link_contact_group_list + link_to(_('Groups'), :controller => "/contacts/contact_group", :action => "list") + end + + def link_folders + link_to(_('Folders'), :controller=>"/webmail", :action=>"messages") + end + + def link_send_mail + link_to(_('Compose'), :controller=>"/webmail", :action=>"compose") + end + + def link_mail_prefs + link_to(_('Preferences'), :controller=>"/webmail", :action=>"prefs") + end + + def link_mail_filters + link_to(_('Filters'), :controller=>"/webmail", :action=>"filters") + end + private def short_fn(folder) diff --git a/app/views/contact/add.rhtml b/app/views/contacts/add.rhtml similarity index 100% rename from app/views/contact/add.rhtml rename to app/views/contacts/add.rhtml diff --git a/app/views/contact/add_multiple.rhtml b/app/views/contacts/add_multiple.rhtml similarity index 100% rename from app/views/contact/add_multiple.rhtml rename to app/views/contacts/add_multiple.rhtml diff --git a/app/views/contact/choose.rhtml b/app/views/contacts/choose.rhtml similarity index 100% rename from app/views/contact/choose.rhtml rename to app/views/contacts/choose.rhtml diff --git a/app/views/contact/import_preview.rhtml b/app/views/contacts/import_preview.rhtml similarity index 100% rename from app/views/contact/import_preview.rhtml rename to app/views/contacts/import_preview.rhtml diff --git a/app/views/contact/list.rhtml b/app/views/contacts/index.html.erb similarity index 94% rename from app/views/contact/list.rhtml rename to app/views/contacts/index.html.erb index eff9b10..588081f 100644 --- a/app/views/contact/list.rhtml +++ b/app/views/contacts/index.html.erb @@ -33,7 +33,7 @@ letters = CDF::CONFIG[:contact_letters] for letterIndex in 0...letters.size letter = letters[letterIndex] %> - <%= link_to(letter, :controller=>"contact", :action=>"listLetter", :id=>letterIndex, :params=>{"mode"=>@mode, "group_id"=>(@group_id ? @group_id : nil)}) %> + <%= link_to(letter, :controller=>"contacts", :action=>"listLetter", :id=>letterIndex, :params=>{"mode"=>@mode, "group_id"=>(@group_id ? @group_id : nil)}) %> <% end %>      <%= link_to(_('Show all'), :controller=>"contact", :action=>"list", :id=>(@group_id ? @group_id : nil), :params=>{"mode"=>@mode})%> diff --git a/config/routes.rb b/config/routes.rb index 9166414..1b1ad03 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ ActionController::Routing::Routes.draw do |map| map.resources :folders, :requirements => {:id => /[^\/]+/} + map.resources :contacts # Add your own custom routes here. # The priority is based upon order of creation: first created -> highest priority.