chatty 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccddaa579727156b1a72b0b4aba0808818d578e2
4
- data.tar.gz: a957fdc99aa2cf4fd9de6759e0afd4e23596e49b
3
+ metadata.gz: 961dbbbebb41c20141c66e14f11dff3b969de2b0
4
+ data.tar.gz: 09c3da27eae898dccde5c8c87c135c5b4ee89b9e
5
5
  SHA512:
6
- metadata.gz: 22ca590ace0f3f6e3c8e66d785a8d6958455682d720aed0d8937f92d2c490afc9be4da025c512568a7f163c92c0c90358db607589f03d99964a4f96118bcb696
7
- data.tar.gz: 9ca27aef9394703ae5cf9bf62c0d916ef1905b756f9aed185a27f15497c86ccb90dae5f21df81c325643dd586fa611e1ee44453cb884e9b68162f34b6aeff396
6
+ metadata.gz: 27bb73080bfda31d93d21616a087867ec67bc0808d45645be5524a3beba987f00763e678fead71d1c2f73cfce3c504bcf8f25a1a45976331934b2bf265a54de4
7
+ data.tar.gz: 2f8956daa6857786fde400f5ab30410993e2d195a2fdba270cd5418e713d75272df44ac1132be3c037c1f352e704d46273aa193b5f07bd389708b8e686bcafb2
@@ -1,25 +1,24 @@
1
1
  class Chatty::AdminChatsController < Chatty::ApplicationController
2
- before_filter :set_chat, :only => [:handle, :show]
3
-
2
+ before_filter :set_chat, only: [:handle, :show]
3
+
4
4
  def index
5
5
  @ransack_params = params[:q] || {}
6
6
  @ransack = Chatty::Chat.ransack(@ransack_params)
7
7
  @chats = @ransack.result.order(:id).reverse_order
8
8
  end
9
-
9
+
10
10
  def show
11
11
  end
12
-
12
+
13
13
  def handle
14
- @chat.handled = true
15
- @chat.save!
16
- @chat.create_activity :key => "chatty/chat.handled", :owner => current_user
17
-
14
+ @chat.handle!
15
+ @chat.create_activity key: "chatty/chat.handled", owner: current_user
16
+
18
17
  redirect_to admin_chat_path(@chat)
19
18
  end
20
-
19
+
21
20
  private
22
-
21
+
23
22
  def set_chat
24
23
  @chat = Chatty::Chat.find(params[:id])
25
24
  end
@@ -2,27 +2,27 @@ require_dependency "chatty/application_controller"
2
2
 
3
3
  class Chatty::ChatsController < Chatty::ApplicationController
4
4
  before_action :set_chat, only: [:show, :edit, :update, :destroy, :messages, :handle, :close]
5
-
5
+
6
6
  def index
7
7
  @ransack_params = params[:q] || {}
8
8
  @ransack = Chatty::Chat.ransack(@ransack_params.clone)
9
9
  @chats = @ransack.result.order(:id).reverse_order
10
10
  end
11
-
11
+
12
12
  def show
13
13
  respond_to do |format|
14
- format.json { render(:json => {:chat => @chat.json}) }
14
+ format.json { render(json: {chat: @chat.json}) }
15
15
  format.html { render :show }
16
16
  end
17
17
  end
18
-
18
+
19
19
  def new
20
20
  @chat = Chatty::Chat.new
21
21
  end
22
-
22
+
23
23
  def edit
24
24
  end
25
-
25
+
26
26
  def create
27
27
  @chat = Chatty::Chat.new(chat_params)
28
28
 
@@ -32,7 +32,7 @@ class Chatty::ChatsController < Chatty::ApplicationController
32
32
  render action: 'new'
33
33
  end
34
34
  end
35
-
35
+
36
36
  def update
37
37
  if @chat.update(chat_params)
38
38
  redirect_to @chat, notice: 'Chat was successfully updated.'
@@ -40,36 +40,36 @@ class Chatty::ChatsController < Chatty::ApplicationController
40
40
  render action: 'edit'
41
41
  end
42
42
  end
43
-
43
+
44
44
  def destroy
45
45
  @chat.destroy
46
46
  redirect_to chats_url, notice: 'Chat was successfully destroyed.'
47
47
  end
48
-
48
+
49
49
  def messages
50
50
  @messages = @chat.messages
51
- render :partial => "messages", :layout => false
51
+ render partial: "messages", layout: false
52
52
  end
53
-
53
+
54
54
  def handle
55
55
  @chat.handle!
56
- @chat.create_activity :key => "chatty/chat.handled", :owner => current_user
56
+ @chat.create_activity key: "chatty/chat.handled", owner: current_user
57
57
  redirect_to chat_path(@chat)
58
58
  end
59
-
59
+
60
60
  def close
61
61
  @chat.close
62
- @chat.create_activity :key => "chatty/chat.closed", :owner => current_user
62
+ @chat.create_activity key: "chatty/chat.closed", owner: current_user
63
63
  redirect_to chat_path(@chat)
64
64
  end
65
-
65
+
66
66
  private
67
-
67
+
68
68
  def set_chat
69
69
  @chat = Chatty::Chat.find(params[:id])
70
70
  authorize! action_name.to_sym, @chat
71
71
  end
72
-
72
+
73
73
  def chat_params
74
74
  params.require(:chat).permit(:user_type, :user_id, :resource_type, :resource_id)
75
75
  end
@@ -1,9 +1,15 @@
1
1
  Chatty::Engine.routes.draw do
2
+ namespace :admin do
3
+ resources :chats
4
+ end
5
+
2
6
  resources :chats do
3
- get :messages, :on => :member
4
- post :handle, :on => :member
5
- post :close, :on => :member
7
+ member do
8
+ get :messages
9
+ post :handle
10
+ post :close
11
+ end
6
12
  end
7
-
13
+
8
14
  resources :messages
9
15
  end
@@ -2,4 +2,5 @@ require "chatty/engine"
2
2
  require "simple_form_ransack"
3
3
 
4
4
  module Chatty
5
+ autoload :ActiveAdminIntegrator, "#{File.dirname(__FILE__)}/chatty/active_admin_integrator"
5
6
  end
@@ -0,0 +1,51 @@
1
+ class Chatty::ActiveAdminIntegrator
2
+ def self.integrate!
3
+ ActiveAdmin.register Chatty::Chat do
4
+ index do
5
+ selectable_column
6
+ id_column
7
+ column :user
8
+ column :resource
9
+ column :state
10
+ column :created_at
11
+ actions
12
+ end
13
+
14
+ show do
15
+ attributes_table do
16
+ row :id
17
+ row :user
18
+ row :resource
19
+ row :state
20
+ row :created_at
21
+ row :updated_at
22
+ end
23
+
24
+ panel Chatty::Message.model_name.human(count: 2) do
25
+ table do
26
+ thead do
27
+ tr do
28
+ th Chatty::Message.human_attribute_name(:id)
29
+ th Chatty::Message.human_attribute_name(:user)
30
+ th Chatty::Message.human_attribute_name(:message)
31
+ th Chatty::Message.human_attribute_name(:created_at)
32
+ end
33
+ end
34
+ tbody do
35
+ resource.messages.each do |message|
36
+ tr do
37
+ td message.id
38
+ td message.user.name
39
+ td message.message
40
+ td message.created_at
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ active_admin_comments
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module Chatty
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -277,10 +277,11 @@ files:
277
277
  - app/views/chatty/messages/_form.html.haml
278
278
  - app/views/chatty/messages/new.html.haml
279
279
  - config/routes.rb
280
- - db/plugin_migrate/20140520083027_create_chatty_messages.rb
281
- - db/plugin_migrate/20140520083510_create_chatty_chats.rb
282
- - db/plugin_migrate/20140521072854_create_activities.rb
280
+ - db/migrate/20140520083027_create_chatty_messages.rb
281
+ - db/migrate/20140520083510_create_chatty_chats.rb
282
+ - db/migrate/20140521072854_create_activities.rb
283
283
  - lib/chatty.rb
284
+ - lib/chatty/active_admin_integrator.rb
284
285
  - lib/chatty/engine.rb
285
286
  - lib/chatty/version.rb
286
287
  - lib/tasks/chatty_tasks.rake