diff --git a/Gemfile b/Gemfile index 9be37ab..86749eb 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,7 @@ gem 'bootstrap-sass' gem 'bootstrap-sass-extras' gem 'bootswatch-rails' gem 'autoprefixer-rails' +gem "font-awesome-rails" group :development do gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index f563267..48e7db1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,6 +104,8 @@ GEM faker (1.4.3) i18n (~> 0.5) ffi (1.9.3) + font-awesome-rails (4.2.0.0) + railties (>= 3.2, < 5.0) formatador (0.2.5) globalize (4.0.2) activemodel (>= 4.0.0, < 5) @@ -283,6 +285,7 @@ DEPENDENCIES devise-i18n factory_girl_rails faker + font-awesome-rails globalize (~> 4.0.2) guard-rspec jquery-rails diff --git a/app/assets/javascripts/management/application.js b/app/assets/javascripts/management/application.js index d9c80b0..bffe770 100644 --- a/app/assets/javascripts/management/application.js +++ b/app/assets/javascripts/management/application.js @@ -1,3 +1,4 @@ //= require jquery //= require jquery_ujs //= require bootstrap-sprockets +//= require_directory . diff --git a/app/assets/stylesheets/management/_user_details.css.scss b/app/assets/stylesheets/management/_user_details.css.scss new file mode 100644 index 0000000..4f62aeb --- /dev/null +++ b/app/assets/stylesheets/management/_user_details.css.scss @@ -0,0 +1,22 @@ +.user-details { + @extend .modal; + @extend .fade; + .center { + text-align: center; + } + + .profile-image { + @extend .img-circle; + max-width: 140px; + max-height: 140px; + } + + .social { + @extend .btn-group; + + a { + @extend .btn; + @extend .btn-default; + } + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/management/application.css.scss b/app/assets/stylesheets/management/application.css.scss index 2f826f8..ce3bd28 100644 --- a/app/assets/stylesheets/management/application.css.scss +++ b/app/assets/stylesheets/management/application.css.scss @@ -2,5 +2,7 @@ @import "bootswatch/simplex/variables"; @import "bootstrap"; @import "bootswatch/simplex/bootswatch"; +@import "font-awesome"; @import "navbar"; -@import "record_table"; \ No newline at end of file +@import "record_table"; +@import "user_details"; \ No newline at end of file diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index f325311..c6871d9 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -1,14 +1,16 @@ module Management class UsersController < ManagementController - before_action :assign_user, only: [:toggle_admin] + before_action :assign_user, only: [:show, :toggle_admin] def index @users = User.all end def toggle_admin - @user.admin = !@user.admin - @user.save + @user.toggle_admin! + end + + def show end private diff --git a/app/models/speaker_profile.rb b/app/models/speaker_profile.rb index 9e0ce34..c026383 100644 --- a/app/models/speaker_profile.rb +++ b/app/models/speaker_profile.rb @@ -17,4 +17,8 @@ class SpeakerProfile < ActiveRecord::Base def twitter=(handle) write_attribute :twitter, handle.gsub(/\A@/,'') if handle end + + def name + "#{first_name} #{last_name}" + end end diff --git a/app/models/user.rb b/app/models/user.rb index 8ae638a..a44047b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,4 +9,8 @@ class User < ActiveRecord::Base has_many :workshops accepts_nested_attributes_for :speaker_profile, update_only: true + + def toggle_admin! + update admin: !admin + end end diff --git a/app/views/management/users/_about_user.html.slim b/app/views/management/users/_about_user.html.slim new file mode 100644 index 0000000..2c4d8eb --- /dev/null +++ b/app/views/management/users/_about_user.html.slim @@ -0,0 +1,32 @@ +.user-details id="about-user-#{@user.id}" tabindex="-1" role="dialog" aria-hidden="true" + .modal-dialog + .modal-content + .modal-header + button type="button" class="close" data-dismiss="modal" aria-hidden="true" + h4.modal-title = t(:more_about_user, user: @user.speaker_profile.name) + .modal-body + .center + = image_tag @user.speaker_profile.picture.url, class: "profile-image" + h3.media-heading + = @user.speaker_profile.name + small< = @user.speaker_profile.organisation + div.social + = link_to "mailto://#{@user.email}" + = fa_icon :envelope + - if @user.speaker_profile.github.present? + = link_to "https://github.com/#{@user.speaker_profile.github}" + = fa_icon :github + - if @user.speaker_profile.twitter.present? + = link_to "https://twitter.com/#{@user.speaker_profile.twitter}" + = fa_icon :twitter + + hr + + h5 = SpeakerProfile.human_attribute_name(:biography) + = simple_format @user.speaker_profile.biography + + p #{glyph(:phone)} #{Phony.format(@user.speaker_profile.mobile_phone, format: :international)} + + .modal-footer + button type="button" class="btn btn-default" data-dismiss="modal" + = t(:close) diff --git a/app/views/management/users/_modal_test.html.erb b/app/views/management/users/_modal_test.html.erb new file mode 100644 index 0000000..0ecac57 --- /dev/null +++ b/app/views/management/users/_modal_test.html.erb @@ -0,0 +1,23 @@ + + + + + diff --git a/app/views/management/users/_user.html.slim b/app/views/management/users/_user.html.slim index 28331da..4724eae 100644 --- a/app/views/management/users/_user.html.slim +++ b/app/views/management/users/_user.html.slim @@ -11,7 +11,7 @@ tr id="user-#{user.id}" = link_to glyph(:unchecked), toggle_admin_management_user_path(user), remote: true, method: :post, data: {confirm: t(:are_you_sure)}, class: 'unchecked' td .actions - = link_to management_user_path(user), title: t(:view) + = link_to management_user_path(user), title: t(:view), remote: true, disabled: user.speaker_profile.blank? = glyph(:share) = link_to edit_management_user_path(user), title: t(:edit) = glyph(:edit) diff --git a/app/views/management/users/show.js.erb b/app/views/management/users/show.js.erb new file mode 100644 index 0000000..36414ae --- /dev/null +++ b/app/views/management/users/show.js.erb @@ -0,0 +1,5 @@ +$('body').append('<%= j render 'about_user' %>'); +$('#about-user-<%= @user.id %>').on('hidden.bs.modal', function () { + $(this).remove(); +}); +$('#about-user-<%= @user.id %>').modal('show'); diff --git a/config/locales/management.bg.yml b/config/locales/management.bg.yml index 47fdc21..74757bc 100644 --- a/config/locales/management.bg.yml +++ b/config/locales/management.bg.yml @@ -1,4 +1,5 @@ bg: are_you_sure: Сигурен ли си? view: Преглед - home: Начало \ No newline at end of file + home: Начало + more_about_user: "Повече информация за %{user}" \ No newline at end of file