From 1e49a00150075dc2cc2287717c3fe2018f674bb4 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 16 Oct 2011 01:58:16 -0400 Subject: [PATCH] fixes to dmail ui --- .../stylesheets/specific/wiki_pages.css.scss | 4 +--- app/controllers/dmails_controller.rb | 5 +++++ app/models/dmail.rb | 2 +- app/views/dmails/_form.html.erb | 4 ++-- app/views/dmails/_received.html.erb | 1 + app/views/dmails/_search.html.erb | 10 ---------- app/views/dmails/_secondary_links.html.erb | 1 + app/views/dmails/_sent.html.erb | 3 ++- app/views/dmails/edit.html.erb | 1 + app/views/dmails/index.html.erb | 14 +++++++++++--- app/views/dmails/new.html.erb | 1 + app/views/dmails/show.html.erb | 5 ++++- app/views/users/_secondary_links.html.erb | 7 +++++-- config/routes.rb | 6 +++++- 14 files changed, 40 insertions(+), 24 deletions(-) delete mode 100644 app/views/dmails/_search.html.erb diff --git a/app/assets/stylesheets/specific/wiki_pages.css.scss b/app/assets/stylesheets/specific/wiki_pages.css.scss index 556342cc7..2caf69e51 100644 --- a/app/assets/stylesheets/specific/wiki_pages.css.scss +++ b/app/assets/stylesheets/specific/wiki_pages.css.scss @@ -20,8 +20,6 @@ div#c-wiki-pages { } } - div#a-edit, div#a-new { - div#preview { - } + div#preview { } } \ No newline at end of file diff --git a/app/controllers/dmails_controller.rb b/app/controllers/dmails_controller.rb index 585952abe..0a21da4cc 100644 --- a/app/controllers/dmails_controller.rb +++ b/app/controllers/dmails_controller.rb @@ -20,6 +20,11 @@ class DmailsController < ApplicationController respond_with(@dmails) end + def search + @search = Dmail.search(params[:search]) + respond_with(@dmails) + end + def show @dmail = Dmail.find(params[:id]) check_privilege(@dmail) diff --git a/app/models/dmail.rb b/app/models/dmail.rb index 503721a58..b0799519a 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -9,7 +9,7 @@ class Dmail < ActiveRecord::Base belongs_to :from, :class_name => "User" after_create :update_recipient after_create :send_dmail - attr_accessible :title, :body, :is_deleted, :to_id, :to + attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name scope :for, lambda {|user| where(["owner_id = ?", user])} scope :inbox, where("to_id = owner_id") scope :sent, where("from_id = owner_id") diff --git a/app/views/dmails/_form.html.erb b/app/views/dmails/_form.html.erb index 87640fafc..1c9ab82e3 100644 --- a/app/views/dmails/_form.html.erb +++ b/app/views/dmails/_form.html.erb @@ -5,6 +5,6 @@ <%= f.input :to_name, :label => "To" %> <%= f.input :title %> <%= f.input :body, :html_options => {:size => "50x25"} %> - <%= f.button :submit %> - <%= submit_tag "Preview" %> + <%= f.button :submit, "Send" %> + <%= submit_tag "Preview", :id => "preview-button" %> <% end %> diff --git a/app/views/dmails/_received.html.erb b/app/views/dmails/_received.html.erb index 8d0d97c42..4d43a899f 100644 --- a/app/views/dmails/_received.html.erb +++ b/app/views/dmails/_received.html.erb @@ -1,4 +1,5 @@ + <%= link_to dmail.to_name, user_path(dmail.to) %> <%= link_to dmail.from_name, user_path(dmail.from) %> <%= link_to dmail.title, dmail_path(dmail) %> <%= compact_time(dmail.created_at) %> diff --git a/app/views/dmails/_search.html.erb b/app/views/dmails/_search.html.erb deleted file mode 100644 index ed6cf1589..000000000 --- a/app/views/dmails/_search.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
- <%= simple_form_for @search do |f| %> - <%= hidden_field_tag :folder, params[:folder] %> - <%= f.input :title_contains, :required => false %> - <%= f.input :body_contains, :required => false %> - <%= f.input :to_name_equals, :required => false %> - <%= f.input :from_name_equals, :required => false %> - <%= f.button :submit %> - <% end %> -
diff --git a/app/views/dmails/_secondary_links.html.erb b/app/views/dmails/_secondary_links.html.erb index d19d5fe18..b8d59e209 100644 --- a/app/views/dmails/_secondary_links.html.erb +++ b/app/views/dmails/_secondary_links.html.erb @@ -3,5 +3,6 @@
  • <%= link_to "Received", dmails_path(:folder => "received") %>
  • <%= link_to "Sent", dmails_path(:folder => "sent") %>
  • <%= link_to "New", new_dmail_path %>
  • +
  • <%= link_to "Search", search_dmails_path %>
  • <% end %> diff --git a/app/views/dmails/_sent.html.erb b/app/views/dmails/_sent.html.erb index d897bba9a..4d43a899f 100644 --- a/app/views/dmails/_sent.html.erb +++ b/app/views/dmails/_sent.html.erb @@ -1,5 +1,6 @@ - <%= link_to dmail.to_name, user_path(dmail.from) %> + <%= link_to dmail.to_name, user_path(dmail.to) %> + <%= link_to dmail.from_name, user_path(dmail.from) %> <%= link_to dmail.title, dmail_path(dmail) %> <%= compact_time(dmail.created_at) %> diff --git a/app/views/dmails/edit.html.erb b/app/views/dmails/edit.html.erb index ecb810365..a13f6f761 100644 --- a/app/views/dmails/edit.html.erb +++ b/app/views/dmails/edit.html.erb @@ -5,3 +5,4 @@ +<%= render "secondary_links" %> \ No newline at end of file diff --git a/app/views/dmails/index.html.erb b/app/views/dmails/index.html.erb index 084a8e3a6..e90e8218b 100644 --- a/app/views/dmails/index.html.erb +++ b/app/views/dmails/index.html.erb @@ -2,9 +2,15 @@

    Messages

    - <%= render "search" %> - - +
    + + + + + + + + <% @dmails.each do |dmail| %> <% if params[:folder] == "sent" %> @@ -17,3 +23,5 @@
    ToFromSubjectDate
    + +<%= render "secondary_links" %> \ No newline at end of file diff --git a/app/views/dmails/new.html.erb b/app/views/dmails/new.html.erb index 2105c426e..e89966ae6 100644 --- a/app/views/dmails/new.html.erb +++ b/app/views/dmails/new.html.erb @@ -5,3 +5,4 @@ +<%= render "secondary_links" %> \ No newline at end of file diff --git a/app/views/dmails/show.html.erb b/app/views/dmails/show.html.erb index 7fcf4306b..f7f2a3e63 100644 --- a/app/views/dmails/show.html.erb +++ b/app/views/dmails/show.html.erb @@ -1,7 +1,8 @@
    -

    <%= @dmail.title %>

    +

    Show Message

    +

    <%= @dmail.title %>

    <%= format_text(@dmail.body) %>

    @@ -11,3 +12,5 @@

    + +<%= render "secondary_links" %> \ No newline at end of file diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb index d5cb4a8b0..da6a714c7 100644 --- a/app/views/users/_secondary_links.html.erb +++ b/app/views/users/_secondary_links.html.erb @@ -2,9 +2,12 @@
  • <%= link_to "Listing", users_path %>
  • <% unless CurrentUser.is_anonymous? %> + <% if @user %> +
  • <%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %>
  • + <% end %>
  • |
  • -
  • <%= link_to "Settings", edit_user_path(CurrentUser.user) %>
  • -
  • <%= link_to "Profile", user_path(CurrentUser.user) %>
  • +
  • <%= link_to "My settings", edit_user_path(CurrentUser.user) %>
  • +
  • <%= link_to "My profile", user_path(CurrentUser.user) %>
  • |
  • <%= link_to "Sign out", session_path, :method => :delete %>
  • <% end %> diff --git a/config/routes.rb b/config/routes.rb index 13b9892c3..4b4fc8ca4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,7 +52,11 @@ Danbooru::Application.routes.draw do get :search end end - resources :dmails + resources :dmails do + collection do + get :search + end + end resource :dtext_preview, :only => [:create] resources :favorites resources :forum_topics