summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-01-17 17:35:39 +0100
committerAzul <azul@leap.se>2013-01-18 07:50:40 +0100
commitb348f9dbf3b8298e0e76bda6a9da973da25ed9bd (patch)
treed4481ebc868bb1169ba40f7bf9f21d984e3e0560
parent168c36b578d675c99aad62a350aa68cc1b6d1316 (diff)
more flexible email partial
-rw-r--r--users/app/helpers/users_helper.rb7
-rw-r--r--users/app/models/email.rb5
-rw-r--r--users/app/models/local_email.rb4
-rw-r--r--users/app/views/emails/_email.html.haml6
-rw-r--r--users/app/views/users/_email_aliases.html.haml2
-rw-r--r--users/app/views/users/edit.html.haml2
6 files changed, 19 insertions, 7 deletions
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index 5f68085..9feae62 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -36,4 +36,11 @@ module UsersHelper
value || 'not set'
end
+ def wrapped(item, options = {})
+ options[:as] ||= :div
+ content_tag options[:as], :class => dom_class(item), :id => dom_id(item) do
+ yield
+ end
+ end
+
end
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 904acb9..6d82f2a 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -22,7 +22,12 @@ module Email
other.is_a?(Email) ? self.email == other.email : self.email == other
end
+ def to_partial_path
+ "emails/email"
+ end
+
def to_param
email
end
+
end
diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb
index bd9dea3..69cba01 100644
--- a/users/app/models/local_email.rb
+++ b/users/app/models/local_email.rb
@@ -27,8 +27,8 @@ class LocalEmail
strip_domain_if_needed
end
- def to_partial_path
- "emails/email"
+ def to_key
+ [username]
end
protected
diff --git a/users/app/views/emails/_email.html.haml b/users/app/views/emails/_email.html.haml
index e96385d..c81b396 100644
--- a/users/app/views/emails/_email.html.haml
+++ b/users/app/views/emails/_email.html.haml
@@ -1,6 +1,6 @@
-%li.pull-right
- %code= email
- - if params[:action] == 'edit'
+= wrapped(email, local_assigns) do
+ = email
+ - if local_assigns[:with].try(:include?, :delete)
= link_to(user_email_alias_path(@user, email), :method => :delete) do
%i.icon-remove
.clearfix
diff --git a/users/app/views/users/_email_aliases.html.haml b/users/app/views/users/_email_aliases.html.haml
index faac2bc..6e32700 100644
--- a/users/app/views/users/_email_aliases.html.haml
+++ b/users/app/views/users/_email_aliases.html.haml
@@ -1,6 +1,6 @@
.span6
%ul.unstyled
- =render @user.email_aliases
+ = render @user.email_aliases, :as => :li, :with => [:delete]
.clearfix
= f.simple_fields_for :email_aliases, @email_alias do |e|
= e.input :username, :placeholder => "alias"
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 69864e5..03088d8 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -7,7 +7,7 @@
- content_for :email do
%legend=t :email_address
Your email address is
- = render user.email_address
+ = render user.email_address, :as => :span
= user_form_with 'email_forward_field', :legend => :forward_email
= user_form_with 'email_aliases', :legend => :add_email_alias
= render 'tabs/tabs', :tabs => [:account, :email]