message_train 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/.ruby-gemset +1 -1
  4. data/.scss-lint.yml +7 -0
  5. data/.simplecov +1 -1
  6. data/.travis.yml +1 -1
  7. data/Gemfile +6 -2
  8. data/LICENSE.txt +2 -2
  9. data/README.rdoc +5 -5
  10. data/Rakefile +22 -21
  11. data/VERSION +1 -1
  12. data/app/assets/javascripts/message_train.js +1 -1
  13. data/app/assets/stylesheets/message_train.scss +29 -19
  14. data/app/controllers/concerns/message_train_support.rb +41 -37
  15. data/app/controllers/message_train/application_controller.rb +1 -0
  16. data/app/controllers/message_train/boxes_controller.rb +5 -4
  17. data/app/controllers/message_train/conversations_controller.rb +8 -7
  18. data/app/controllers/message_train/messages_controller.rb +25 -22
  19. data/app/controllers/message_train/participants_controller.rb +27 -23
  20. data/app/controllers/message_train/unsubscribes_controller.rb +37 -23
  21. data/app/helpers/message_train/application_helper.rb +6 -8
  22. data/app/helpers/message_train/attachments_helper.rb +12 -4
  23. data/app/helpers/message_train/boxes_helper.rb +38 -11
  24. data/app/helpers/message_train/collectives_helper.rb +38 -12
  25. data/app/helpers/message_train/conversations_helper.rb +43 -35
  26. data/app/helpers/message_train/messages_helper.rb +32 -25
  27. data/app/mailers/message_train/application_mailer.rb +7 -4
  28. data/app/mailers/message_train/previews/receipt_mailer_preview.rb +2 -3
  29. data/app/mailers/message_train/receipt_mailer.rb +14 -4
  30. data/app/models/message_train/attachment.rb +41 -25
  31. data/app/models/message_train/box.rb +159 -122
  32. data/app/models/message_train/conversation.rb +84 -41
  33. data/app/models/message_train/ignore.rb +8 -2
  34. data/app/models/message_train/message.rb +72 -42
  35. data/app/models/message_train/receipt.rb +30 -17
  36. data/app/models/message_train/unsubscribe.rb +1 -0
  37. data/app/views/application/404.html.haml +1 -1
  38. data/app/views/layouts/mailer.html.haml +2 -2
  39. data/app/views/layouts/mailer.text.haml +1 -1
  40. data/app/views/message_train/application/_attachment_fields.html.haml +1 -1
  41. data/app/views/message_train/application/_widget.html.haml +1 -1
  42. data/app/views/message_train/application/results.json.jbuilder +1 -1
  43. data/app/views/message_train/boxes/_dropdown_list.html.haml +1 -1
  44. data/app/views/message_train/boxes/_list_item.html.haml +1 -1
  45. data/app/views/message_train/boxes/show.html.haml +1 -1
  46. data/app/views/message_train/collectives/_dropdown_list.html.haml +1 -1
  47. data/app/views/message_train/collectives/_list_item.html.haml +1 -1
  48. data/app/views/message_train/conversations/_deleted_toggle.html.haml +1 -1
  49. data/app/views/message_train/conversations/_ignored_toggle.html.haml +2 -2
  50. data/app/views/message_train/conversations/_read_toggle.html.haml +1 -1
  51. data/app/views/message_train/conversations/_toggle.html.haml +1 -1
  52. data/app/views/message_train/conversations/_trashed_toggle.html.haml +1 -1
  53. data/app/views/message_train/conversations/show.html.haml +2 -2
  54. data/app/views/message_train/conversations/show.json.jbuilder +5 -1
  55. data/app/views/message_train/messages/_form.html.haml +1 -1
  56. data/app/views/message_train/messages/_message.html.haml +6 -6
  57. data/app/views/message_train/messages/_toggle.html.haml +1 -1
  58. data/app/views/message_train/messages/show.json.jbuilder +5 -1
  59. data/app/views/message_train/participants/_participant.json.jbuilder +1 -1
  60. data/app/views/message_train/participants/index.json.jbuilder +1 -1
  61. data/app/views/message_train/participants/show.json.jbuilder +1 -1
  62. data/app/views/message_train/receipt_mailer/notification_email.html.haml +1 -1
  63. data/app/views/message_train/receipt_mailer/notification_email.text.haml +1 -1
  64. data/app/views/message_train/unsubscribes/index.html.haml +1 -1
  65. data/config/environment.rb +1 -1
  66. data/config/initializers/date_time.rb +2 -2
  67. data/config/locales/en.yml +1 -1
  68. data/config/routes.rb +37 -15
  69. data/lib/generators/message_train/install/install_generator.rb +26 -11
  70. data/lib/generators/message_train/install/templates/initializer.rb +0 -2
  71. data/lib/generators/message_train/utils.rb +11 -4
  72. data/lib/message_train/configuration.rb +4 -5
  73. data/lib/message_train/engine.rb +1 -7
  74. data/lib/message_train/localization.rb +14 -18
  75. data/lib/message_train/mixin.rb +211 -150
  76. data/lib/message_train/version.rb +1 -0
  77. data/lib/message_train.rb +7 -6
  78. data/message_train.gemspec +24 -11
  79. data/spec/controllers/message_train/boxes_controller_spec.rb +63 -15
  80. data/spec/controllers/message_train/concerns_spec.rb +17 -13
  81. data/spec/controllers/message_train/conversations_controller_spec.rb +44 -12
  82. data/spec/controllers/message_train/messages_controller_spec.rb +87 -40
  83. data/spec/controllers/message_train/participants_controller_spec.rb +10 -4
  84. data/spec/controllers/message_train/unsubscribes_controller_spec.rb +43 -13
  85. data/spec/dummy/Rakefile +2 -1
  86. data/spec/dummy/app/assets/stylesheets/application.css.scss +7 -23
  87. data/spec/dummy/app/controllers/application_controller.rb +7 -7
  88. data/spec/dummy/app/models/group.rb +1 -1
  89. data/spec/dummy/app/models/role.rb +11 -7
  90. data/spec/dummy/app/models/user.rb +6 -5
  91. data/spec/dummy/app/views/layouts/_top_navigation.html.haml +1 -1
  92. data/spec/dummy/app/views/layouts/application.html.haml +1 -1
  93. data/spec/dummy/app/views/pages/index.html.haml +1 -1
  94. data/spec/dummy/config/application.rb +23 -17
  95. data/spec/dummy/config/environments/development.rb +5 -4
  96. data/spec/dummy/config/environments/production.rb +10 -6
  97. data/spec/dummy/config/environments/test.rb +4 -3
  98. data/spec/dummy/config/initializers/assets.rb +2 -1
  99. data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -2
  100. data/spec/dummy/config/initializers/bootstrap_leather.rb +1 -1
  101. data/spec/dummy/config/initializers/devise.rb +63 -44
  102. data/spec/dummy/config/initializers/high_voltage.rb +1 -1
  103. data/spec/dummy/config/initializers/message_train.rb +5 -2
  104. data/spec/dummy/config/initializers/mime_types.rb +1 -1
  105. data/spec/dummy/config/initializers/paperclip.rb +5 -2
  106. data/spec/dummy/config/initializers/rolify.rb +3 -2
  107. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
  108. data/spec/dummy/config/routes.rb +1 -3
  109. data/spec/dummy/config/settings.yml +1 -1
  110. data/spec/dummy/db/schema.rb +98 -98
  111. data/spec/dummy/db/seeds/conversations.seeds.rb +160 -160
  112. data/spec/dummy/db/seeds/development/conversations.seeds.rb +6 -2
  113. data/spec/dummy/db/seeds/groups.seeds.rb +11 -12
  114. data/spec/dummy/db/seeds/test/attachments.seeds.rb +13 -3
  115. data/spec/dummy/db/seeds/test/conversations.seeds.rb +6 -2
  116. data/spec/dummy/db/seeds/unsubscribes.seeds.rb +1 -1
  117. data/spec/dummy/db/seeds/users.seeds.rb +47 -42
  118. data/spec/dummy/db/test.sqlite3 +0 -0
  119. data/spec/factories/attachment.rb +6 -2
  120. data/spec/factories/group.rb +1 -4
  121. data/spec/factories/message.rb +29 -23
  122. data/spec/factories/user.rb +6 -4
  123. data/spec/features/boxes_spec.rb +76 -24
  124. data/spec/features/conversations_spec.rb +19 -7
  125. data/spec/features/messages_spec.rb +24 -5
  126. data/spec/features/unsubscribes_spec.rb +36 -9
  127. data/spec/helpers/message_train/application_helper_spec.rb +1 -1
  128. data/spec/helpers/message_train/attachment_helper_spec.rb +27 -12
  129. data/spec/helpers/message_train/boxes_helper_spec.rb +1 -1
  130. data/spec/helpers/message_train/collectives_helper_spec.rb +25 -9
  131. data/spec/helpers/message_train/conversations_helper_spec.rb +239 -120
  132. data/spec/helpers/message_train/messages_helper_spec.rb +137 -81
  133. data/spec/message_train_spec.rb +3 -2
  134. data/spec/models/group_spec.rb +12 -9
  135. data/spec/models/message_train/attachment_spec.rb +33 -30
  136. data/spec/models/message_train/box_spec.rb +243 -60
  137. data/spec/models/message_train/conversation_spec.rb +16 -12
  138. data/spec/models/message_train/ignore_spec.rb +3 -1
  139. data/spec/models/message_train/message_spec.rb +22 -7
  140. data/spec/models/message_train/receipt_spec.rb +14 -4
  141. data/spec/models/role_spec.rb +10 -6
  142. data/spec/models/user_spec.rb +74 -22
  143. data/spec/rails_helper.rb +9 -4
  144. data/spec/spec_helper.rb +6 -54
  145. data/spec/support/controller_behaviors.rb +8 -5
  146. data/spec/support/controller_macros.rb +2 -2
  147. data/spec/support/factory_girl.rb +1 -1
  148. data/spec/support/feature_behaviors.rb +42 -13
  149. data/spec/support/loaded_site/attachments.rb +8 -0
  150. data/spec/support/loaded_site/conversations.rb +73 -0
  151. data/spec/support/{groups.rb → loaded_site/groups.rb} +1 -1
  152. data/spec/support/{loaded_site.rb → loaded_site/loaded_site.rb} +1 -1
  153. data/spec/support/{messages.rb → loaded_site/messages.rb} +13 -5
  154. data/spec/support/{roles.rb → loaded_site/roles.rb} +1 -1
  155. data/spec/support/{users.rb → loaded_site/users.rb} +1 -1
  156. data/spec/support/shared_connection.rb +8 -6
  157. data/spec/support/utilities.rb +10 -10
  158. metadata +67 -10
  159. data/spec/dummy/config/unused/temporary_i18n_debugging.rb +0 -12
  160. data/spec/support/attachments.rb +0 -4
  161. data/spec/support/conversations.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32aa42123688961b79c63b6f69518b5b02bdb3ce
4
- data.tar.gz: 373cd78a85d7659dd200644c5b5c69395e6b3f38
3
+ metadata.gz: 279f6b86182280de36d875bc58b839cffefbb5bd
4
+ data.tar.gz: 24ad6a58c91cf45ddc80f645c642a12e480ef106
5
5
  SHA512:
6
- metadata.gz: 84e2ed92d284aa5c83202fc669397bdd35a668915abb5143fed67e084eac219fd534cffc8ee16fbdae85db8042f2feb0569e83c02715738a245734ea33dd8575
7
- data.tar.gz: 8bb83b97014008b1e35f03da47f0fceecc17fd2db283356ec16135b32699c3229119cac878fe19ba2a555176a47c88df1680450bf296c505276ad51588469b87
6
+ metadata.gz: 20e06ae5d8f27c9760a5bc05ee3b46a59df822824ef8929b92eb93905006b5d6a670ce6a7c34c8cf9fdc94eecbad77f987b6ccdb4df75bc0f8b8b4a3d1fe35c0
7
+ data.tar.gz: 396db8fa546546fa128a7bdeea851bc377e8340bbffbe16f7f4d0db302ecef3d6cb72d10445ecefaf6b69119cd398dc447197b6b9e09f5022e33984c5dc3b2c2
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ Exclude:
3
+ - message_train.gemspec
4
+ - db/migrate/*
5
+ - spec/dummy/db/schema.rb
6
+ - spec/dummy/db/migrate/*
7
+ Style/ClassVars:
8
+ Enabled: false
9
+ Metrics/AbcSize:
10
+ Enabled: false
11
+ Metrics/ClassLength:
12
+ Enabled: false
13
+ Metrics/CyclomaticComplexity:
14
+ Enabled: false
15
+ Metrics/MethodLength:
16
+ Enabled: false
17
+ Metrics/ModuleLength:
18
+ Enabled: false
19
+ Metrics/PerceivedComplexity:
20
+ Enabled: false
data/.ruby-gemset CHANGED
@@ -1 +1 @@
1
- message_train
1
+ message_train
data/.scss-lint.yml ADDED
@@ -0,0 +1,7 @@
1
+ linters:
2
+ PlaceholderInExtend:
3
+ enabled: false
4
+ QualifyingElement:
5
+ enabled: false
6
+ VendorPrefix:
7
+ enabled: false
data/.simplecov CHANGED
@@ -5,4 +5,4 @@ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
5
  SimpleCov.start do
6
6
  add_filter 'lib/message_train/localization.rb'
7
7
  add_filter 'spec'
8
- end
8
+ end
data/.travis.yml CHANGED
@@ -9,4 +9,4 @@ before_script:
9
9
  - sh -e /etc/init.d/xvfb start
10
10
  script: bundle exec rspec
11
11
  notifications:
12
- email: false
12
+ email: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem 'activesupport', '>= 2.3.5'
@@ -32,6 +32,10 @@ group :development do
32
32
  gem 'sdoc', '~> 0.4.1'
33
33
  gem 'bundler', '~> 1.0'
34
34
  gem 'jeweler', '~> 2.0'
35
+ gem 'pre-commit', '~> 0.27'
36
+ gem 'rubocop', '~> 0.37'
37
+ gem 'coffeelint', '~> 1.14'
38
+ gem 'scss_lint', '~> 0.47.0', require: false
35
39
  end
36
40
 
37
41
  group :development, :test do
@@ -57,4 +61,4 @@ group :test do
57
61
  gem 'coveralls', '~> 0.8', require: false
58
62
  gem 'rspec-html-matchers', '~> 0.7'
59
63
  gem 'selenium-webdriver', '~> 2'
60
- end
64
+ end
data/LICENSE.txt CHANGED
@@ -2,7 +2,7 @@ Copyright (c) 2015 Gem Vein
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
5
+ 'Software'), to deal in the Software without restriction, including
6
6
  without limitation the rights to use, copy, modify, merge, publish,
7
7
  distribute, sublicense, and/or sell copies of the Software, and to
8
8
  permit persons to whom the Software is furnished to do so, subject to
@@ -11,7 +11,7 @@ the following conditions:
11
11
  The above copyright notice and this permission notice shall be
12
12
  included in all copies or substantial portions of the Software.
13
13
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
15
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
data/README.rdoc CHANGED
@@ -1,12 +1,12 @@
1
1
  = MessageTrain
2
- {<img src="https://travis-ci.org/gemvein/message_train.svg" alt="Build Status" />}[https://travis-ci.org/gemvein/message_train]
3
- {<img src="https://coveralls.io/repos/gemvein/message_train/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/gemvein/message_train?branch=master]
4
- {<img src="https://badge.fury.io/rb/message_train.svg" alt="Gem Version" />}[http://badge.fury.io/rb/message_train]
2
+ {<img src='https://travis-ci.org/gemvein/message_train.svg' alt='Build Status' />}[https://travis-ci.org/gemvein/message_train]
3
+ {<img src='https://coveralls.io/repos/gemvein/message_train/badge.svg?branch=master&service=github' alt='Coverage Status' />}[https://coveralls.io/github/gemvein/message_train?branch=master]
4
+ {<img src='https://badge.fury.io/rb/message_train.svg' alt='Gem Version' />}[http://badge.fury.io/rb/message_train]
5
5
 
6
6
 
7
7
  MessageTrain is a Rails 4 Private Messaging Gem that uses bootstrap to send and display private messages from one user to another. It can also be configured to send messages to a user collective (such as a certain Role or Group of users).
8
8
 
9
- Messages can be saved as drafts instead of sending. Message composition features type-ahead completion for recipients, wysiwyg html bodies, and an arbitrary number of attachments. Messages are grouped together into conversations, and allow valid senders to reply to a given message. Any given conversation can be ignored if it is no longer of interest to the user, at which point no further messages will be received in that conversation. The "read" or "unread" status of messages is tracked automatically, and can also be changed manually by the user.
9
+ Messages can be saved as drafts instead of sending. Message composition features type-ahead completion for recipients, wysiwyg html bodies, and an arbitrary number of attachments. Messages are grouped together into conversations, and allow valid senders to reply to a given message. Any given conversation can be ignored if it is no longer of interest to the user, at which point no further messages will be received in that conversation. The 'read' or 'unread' status of messages is tracked automatically, and can also be changed manually by the user.
10
10
 
11
11
  Conversations are grouped into various boxes, depending on their status for that user: in, sent, all, drafts, trash, ignored. Any message can be trashed by the user, at which point the user has the option to permanently delete it.
12
12
 
@@ -39,7 +39,7 @@ To include Message Train variables and helpers in your controllers, add this con
39
39
 
40
40
  Add to your application.css.scss:
41
41
 
42
- @import "message_train";
42
+ @import 'message_train';
43
43
 
44
44
  And in your application.js:
45
45
 
data/Rakefile CHANGED
@@ -1,26 +1,27 @@
1
1
  # encoding: utf-8
2
-
3
2
  require 'rubygems'
4
3
  require 'bundler'
5
4
  begin
6
5
  Bundler.setup(:default, :development)
7
6
  rescue Bundler::BundlerError => e
8
7
  $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
8
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
9
  exit e.status_code
11
10
  end
12
11
  require 'rake'
13
12
 
14
13
  require 'jeweler'
15
14
  Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
- gem.name = "message_train"
18
- gem.homepage = "http://www.gemvein.com/museum/cases/message_train"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Rails 4 Engine providing messaging for any object}
21
- gem.description = %Q{Rails 4 Engine providing private/public messaging for any object, such as Users or Groups}
22
- gem.email = "karen.e.lundgren@gmail.com"
23
- gem.authors = ["Karen Lundgren"]
15
+ # gem is a Gem::Specification...
16
+ # see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = 'message_train'
18
+ gem.homepage = 'http://www.gemvein.com/museum/cases/message_train'
19
+ gem.license = 'MIT'
20
+ gem.summary = 'Rails 4 Engine providing messaging for any object'
21
+ gem.description = 'Rails 4 Engine providing private/public messaging for '\
22
+ 'any object, such as Users or Groups'
23
+ gem.email = 'karen.e.lundgren@gmail.com'
24
+ gem.authors = ['Karen Lundgren']
24
25
  # dependencies defined in Gemfile
25
26
  end
26
27
  Jeweler::RubygemsDotOrgTasks.new
@@ -31,17 +32,17 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
31
32
  spec.pattern = FileList['spec/**/*_spec.rb']
32
33
  end
33
34
 
34
- desc "Code coverage detail"
35
+ desc 'Code coverage detail'
35
36
  task :simplecov do
36
- ENV['COVERAGE'] = "true"
37
+ ENV['COVERAGE'] = 'true'
37
38
  Rake::Task['spec'].execute
38
39
  end
39
40
 
40
- task :default => :spec
41
+ task default: :spec
41
42
 
42
43
  require 'rdoc/task'
43
44
  Rake::RDocTask.new do |rdoc|
44
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
45
46
 
46
47
  rdoc.rdoc_dir = 'rdoc'
47
48
  rdoc.title = "message_train #{version}"
@@ -49,22 +50,22 @@ Rake::RDocTask.new do |rdoc|
49
50
  rdoc.rdoc_files.include('lib/**/*.rb')
50
51
  end
51
52
 
52
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
53
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
53
54
  load 'rails/tasks/engine.rake'
54
55
 
55
-
56
56
  # load 'rails/tasks/statistics.rake'
57
57
 
58
58
  namespace :message_train do
59
- desc "Clean out development system files"
59
+ desc 'Clean out development system files'
60
60
  task files: :environment do
61
61
  FileUtils.rm_rf(Dir["#{Rails.root}/public/system/development/*/*"])
62
62
  end
63
- desc "Recreate database from seeds and clean out all system files"
63
+ desc 'Recreate database from seeds and clean out all system files'
64
64
  task clean: :environment do
65
65
  import 'spec/dummy/Rakefile'
66
- Rake::Task["message_train:files"].invoke
66
+ Rake::Task['message_train:files'].invoke
67
67
  dummy_app_path = MessageTrain::Engine.root.join('spec', 'dummy')
68
- system "bundle exec rake -f #{dummy_app_path.join('Rakefile')} db:drop db:create db:migrate db:seed db:test:prepare"
68
+ system "bundle exec rake -f #{dummy_app_path.join('Rakefile')} db:drop "\
69
+ 'db:create db:migrate db:seed db:test:prepare'
69
70
  end
70
- end
71
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -8,7 +8,7 @@ function create_alert(level, message) {
8
8
  }
9
9
 
10
10
  function set_and_change(selector, value) {
11
- $(selector).prop('checked', value).trigger("change");
11
+ $(selector).prop('checked', value).trigger('change');
12
12
  }
13
13
 
14
14
  function flicker(selector, count) {
@@ -14,7 +14,9 @@ img {
14
14
  }
15
15
 
16
16
  .message-train-conversations {
17
- a, a:link, a:visited {
17
+ a,
18
+ a:link,
19
+ a:visited {
18
20
  color: $text-color;
19
21
  }
20
22
 
@@ -25,57 +27,65 @@ img {
25
27
  input[type='checkbox'] {
26
28
  margin-right: 1em;
27
29
  }
30
+
28
31
  .unread {
29
32
  font-weight: bold;
30
33
  }
31
34
 
32
35
  .read {
33
- background-color: rgba($list-group-disabled-bg, 0.75);
36
+ background-color: rgba($list-group-disabled-bg, .75);
37
+
38
+ .flicker.flicker-out {
39
+ background-color: $list-group-disabled-bg;
40
+ transition: background-color 1s ease-out;
41
+ }
34
42
  }
35
43
 
36
44
  .draft {
37
45
  font-style: italic;
38
46
  }
39
47
 
40
- .selected, .read.selected {
48
+ .selected,
49
+ .read.selected {
50
+ background-color: $state-warning-bg;
51
+
41
52
  a {
42
53
  color: $state-warning-text;
43
54
  }
44
- background-color: $state-warning-bg;
45
55
  }
46
56
 
47
- .flicker, .read.flicker, .selected.flicker {
57
+ .flicker,
58
+ .read.flicker,
59
+ .selected.flicker {
48
60
  background-color: $state-info-bg;
49
- transition: background-color 0.1s ease-in;
61
+ transition: background-color .1s ease-in;
50
62
  }
51
63
 
52
- .flicker.flicker-out, .unread.flicker.flicker-out {
64
+ .flicker.flicker-out,
65
+ .unread.flicker.flicker-out {
53
66
  background-color: $list-group-bg;
54
67
  transition: background-color 1s ease-out;
55
68
  }
56
-
57
- .read.flicker.flicker-out {
58
- background-color: $list-group-disabled-bg;
59
- transition: background-color 1s ease-out;
60
- }
61
69
  }
62
70
 
63
71
  .box-actions {
64
- margin: 2em 0 1em 0;
72
+ margin: 2em 0 1em;
73
+
65
74
  .check-all button {
66
75
  min-height: 2.5em;
67
76
  }
68
77
  }
69
78
 
70
79
  div.conversation-actions {
71
- margin: 1em 0 1em 0;
80
+ margin: 1em 0;
72
81
  }
73
82
 
74
83
  td.conversation-actions {
84
+ white-space: nowrap;
85
+
75
86
  a {
76
87
  visibility: hidden;
77
88
  }
78
- white-space: nowrap;
79
89
  }
80
90
 
81
91
  .date-column {
@@ -91,8 +101,8 @@ tr:hover .conversation-actions a {
91
101
  }
92
102
 
93
103
  .glyphicon.spinning {
94
- animation: spin 1s infinite linear;
95
104
  -webkit-animation: spin2 1s infinite linear;
105
+ animation: spin 1s infinite linear;
96
106
  }
97
107
 
98
108
  @keyframes spin {
@@ -118,9 +128,9 @@ tr:hover .conversation-actions a {
118
128
  }
119
129
 
120
130
  .btn-compose {
121
- margin: 0 auto 10px auto;
122
- width: 100%;
131
+ margin: 0 auto 10px;
123
132
  white-space: inherit;
133
+ width: 100%;
124
134
  }
125
135
 
126
136
  .tt-menu {
@@ -131,4 +141,4 @@ tr:hover .conversation-actions a {
131
141
 
132
142
  .dropdown-menu {
133
143
  width: 240px;
134
- }
144
+ }
@@ -1,8 +1,7 @@
1
+ # MessageTrain support
1
2
  module MessageTrainSupport
2
3
  extend ActiveSupport::Concern
3
-
4
4
  included do
5
-
6
5
  # Last in first out
7
6
  prepend_before_filter :load_collective_boxes,
8
7
  :load_box,
@@ -23,14 +22,9 @@ module MessageTrainSupport
23
22
  rescue_from ActiveRecord::RecordNotFound do
24
23
  render '404', status: :not_found
25
24
  end
26
-
27
25
  end
28
26
 
29
- protected
30
-
31
- # def require_authentication
32
- # redirect_to url_for(MessageTrain.configuration.user_sign_in_path), flash: { error: :you_must_sign_in_or_sign_up_to_continue.l }
33
- # end
27
+ protected
34
28
 
35
29
  def anonymous
36
30
  @anonymous = true
@@ -42,9 +36,9 @@ protected
42
36
  end
43
37
 
44
38
  def load_box_user
45
- # # What we used to do
46
- # @box_user = send(MessageTrain.configuration.current_user_method) || require_authentication
47
- @box_user = send(MessageTrain.configuration.current_user_method) || anonymous
39
+ @box_user = send(
40
+ MessageTrain.configuration.current_user_method
41
+ ) || anonymous
48
42
  end
49
43
 
50
44
  def load_division
@@ -54,40 +48,51 @@ protected
54
48
  def load_collective
55
49
  if params[:collective_id].present?
56
50
  collective_table, collective_id = params[:collective_id].split(':')
57
- collective_class_name = MessageTrain.configuration.recipient_tables[collective_table.to_sym]
51
+ collective_class_name = MessageTrain.configuration.recipient_tables[
52
+ collective_table.to_sym
53
+ ]
58
54
  collective_model = collective_class_name.constantize
59
- slug_column = MessageTrain.configuration.slug_columns[collective_table.to_sym] || :slug
55
+ slug_column = MessageTrain.configuration
56
+ .slug_columns[collective_table.to_sym] || :slug
60
57
  @collective = collective_model.find_by!(slug_column => collective_id)
61
58
 
62
- unless @collective.allows_receiving_by?(@box_user) || @collective.allows_sending_by?(@box_user)
59
+ unless @collective.allows_receiving_by?(
60
+ @box_user
61
+ ) || @collective.allows_sending_by?(
62
+ @box_user
63
+ )
63
64
  flash[:error] = :access_to_that_box_denied.l
64
65
  redirect_to main_app.root_url
65
66
  return
66
67
  end
67
68
 
68
69
  case @division
69
- when :in, :ignored
70
- unless @collective.allows_receiving_by? @box_user
71
- flash[:error] = :access_to_that_box_denied.l
72
- redirect_to message_train.collective_box_url(@collective.path_part, :sent)
73
- end
74
- when :sent, :drafts
75
- unless @collective.allows_sending_by? @box_user
76
- flash[:error] = :access_to_that_box_denied.l
77
- redirect_to message_train.collective_box_url(@collective.path_part, :in)
78
- end
79
- else
80
- # do nothing
70
+ when :in, :ignored
71
+ unless @collective.allows_receiving_by? @box_user
72
+ flash[:error] = :access_to_that_box_denied.l
73
+ redirect_to message_train.collective_box_url(
74
+ @collective.path_part,
75
+ :sent
76
+ )
77
+ end
78
+ when :sent, :drafts
79
+ unless @collective.allows_sending_by? @box_user
80
+ flash[:error] = :access_to_that_box_denied.l
81
+ redirect_to message_train.collective_box_url(
82
+ @collective.path_part,
83
+ :in
84
+ )
85
+ end
81
86
  end
82
87
  end
83
88
  end
84
89
 
85
90
  def load_box
86
- if !@collective.nil?
87
- @box = @collective.box(@division, @box_user)
88
- else
89
- @box = @box_user.box(@division)
90
- end
91
+ @box = if !@collective.nil?
92
+ @collective.box(@division, @box_user)
93
+ else
94
+ @box_user.box(@division)
95
+ end
91
96
  end
92
97
 
93
98
  def load_collective_boxes
@@ -110,25 +115,24 @@ protected
110
115
  def respond_to_marking
111
116
  if !@box.errors.all.empty?
112
117
  respond_to do |format|
113
- format.html {
118
+ format.html do
114
119
  flash[:error] = @box.message
115
120
  show
116
- }
121
+ end
117
122
  format.json { render :results, status: :unprocessable_entity }
118
123
  end
119
124
  else
120
125
  respond_to do |format|
121
- format.html {
126
+ format.html do
122
127
  if @box.results.all.empty?
123
128
  flash[:alert] = @box.message
124
129
  else
125
130
  flash[:notice] = @box.message
126
131
  end
127
132
  show
128
- }
133
+ end
129
134
  format.json { render :results, status: :accepted }
130
135
  end
131
136
  end
132
137
  end
133
-
134
- end
138
+ end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Application controller
2
3
  class ApplicationController < ::ApplicationController
3
4
  include MessageTrainSupport
4
5
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Boxes controller
2
3
  class BoxesController < MessageTrain::ApplicationController
3
4
  before_filter :load_conversations
4
5
 
@@ -18,7 +19,7 @@ module MessageTrain
18
19
 
19
20
  # DELETE /box/:division
20
21
  def destroy
21
- if ['ignore', 'unignore'].include? params[:mark_to_set]
22
+ if %w( ignore unignore ).include? params[:mark_to_set]
22
23
  @box.send(params[:mark_to_set], @objects)
23
24
  end
24
25
  respond_to_marking
@@ -26,8 +27,8 @@ module MessageTrain
26
27
 
27
28
  private
28
29
 
29
- def load_conversations
30
- @conversations = @box.conversations
31
- end
30
+ def load_conversations
31
+ @conversations = @box.conversations
32
+ end
32
33
  end
33
34
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Conversations controller
2
3
  class ConversationsController < MessageTrain::ApplicationController
3
4
  before_filter :load_conversation
4
5
  after_filter :mark_as_read
@@ -20,7 +21,7 @@ module MessageTrain
20
21
 
21
22
  # DELETE /box/:division/conversations/:id
22
23
  def destroy
23
- if ['ignore', 'unignore'].include? params[:mark_to_set]
24
+ if %w( ignore unignore ).include? params[:mark_to_set]
24
25
  @box.send(params[:mark_to_set], @conversation)
25
26
  end
26
27
  respond_to_marking
@@ -28,12 +29,12 @@ module MessageTrain
28
29
 
29
30
  private
30
31
 
31
- def load_conversation
32
- @conversation = @box.find_conversation(params[:id])
33
- end
32
+ def load_conversation
33
+ @conversation = @box.find_conversation(params[:id])
34
+ end
34
35
 
35
- def mark_as_read
36
- @box.mark :read, conversations: @conversation
37
- end
36
+ def mark_as_read
37
+ @box.mark :read, conversations: @conversation
38
+ end
38
39
  end
39
40
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Messages controller
2
3
  class MessagesController < MessageTrain::ApplicationController
3
4
  before_filter :load_message, only: [:show, :edit, :update]
4
5
 
@@ -11,14 +12,14 @@ module MessageTrain
11
12
 
12
13
  # GET /box/:division/messages/new
13
14
  def new
14
- @message = @box.new_message(message_train_conversation_id: params[:conversation_id])
15
+ @message = @box.new_message(
16
+ message_train_conversation_id: params[:conversation_id]
17
+ )
15
18
  end
16
19
 
17
20
  # GET /box/:division/messages/:id/edit
18
21
  def edit
19
- unless @message.draft
20
- raise ActiveRecord::RecordNotFound
21
- end
22
+ !@message.draft && raise(ActiveRecord::RecordNotFound)
22
23
  end
23
24
 
24
25
  # POST /box/:division/messages
@@ -38,15 +39,19 @@ module MessageTrain
38
39
 
39
40
  # PATCH/PUT /box/:division/messages/:id
40
41
  def update
41
- unless @message.draft
42
- raise ActiveRecord::RecordNotFound
43
- end
42
+ !@message.draft && raise(ActiveRecord::RecordNotFound)
44
43
  @box.update_message(@message, message_params)
45
44
  if @box.errors.all.empty?
46
45
  if @message.draft
47
- redirect_to message_train.box_conversation_url(@box, @message.conversation), alert: @box.message
46
+ redirect_to(
47
+ message_train.box_conversation_url(@box, @message.conversation),
48
+ alert: @box.message
49
+ )
48
50
  else
49
- redirect_to message_train.box_path(:sent), notice: @box.message
51
+ redirect_to(
52
+ message_train.box_path(:sent),
53
+ notice: @box.message
54
+ )
50
55
  end
51
56
  else
52
57
  flash[:error] = @box.message
@@ -54,26 +59,24 @@ module MessageTrain
54
59
  end
55
60
  end
56
61
 
57
- private
62
+ private
63
+
58
64
  def load_message
59
65
  @message = @box.find_message(params[:id])
60
66
  end
61
67
 
62
- # Never trust parameters from the scary internet, only allow the white list through.
68
+ # Never trust parameters from the scary internet, only allow the white list
69
+ # through.
63
70
  def message_params
64
71
  permitted = params.require(:message).permit(
65
- :conversation_id,
66
- :subject,
67
- :body,
68
- :draft,
69
- attachments_attributes: [:id, :attachment, :_destroy],
70
- recipients_to_save: MessageTrain.configuration.recipient_tables.keys
72
+ :conversation_id,
73
+ :subject,
74
+ :body,
75
+ :draft,
76
+ attachments_attributes: [:id, :attachment, :_destroy],
77
+ recipients_to_save: MessageTrain.configuration.recipient_tables.keys
71
78
  )
72
- if permitted['draft'] == :save_as_draft.l
73
- permitted['draft'] = true
74
- else
75
- permitted['draft'] = false
76
- end
79
+ permitted['draft'] = (permitted['draft'] == :save_as_draft.l)
77
80
  permitted
78
81
  end
79
82
  end