Added chat tabs based on database. Added chat.preferences store.
This commit is contained in:
parent
fe572ae54b
commit
d94399ec7f
3 changed files with 26 additions and 14 deletions
|
@ -7,21 +7,27 @@ class App.ChannelChat extends App.ControllerTabs
|
|||
|
||||
@title @header, true
|
||||
|
||||
@tabs = [
|
||||
{
|
||||
name: 'company.com/sales',
|
||||
target: 'company-com-sales',
|
||||
controller: App.ChannelChatDesigner,
|
||||
},
|
||||
{
|
||||
name: 'company.com',
|
||||
target: 'company-com',
|
||||
controller: App.ChannelChatDesigner,
|
||||
}
|
||||
]
|
||||
@load()
|
||||
|
||||
load: =>
|
||||
@tabs = []
|
||||
@ajax(
|
||||
id: 'chat_index'
|
||||
type: 'GET'
|
||||
url: @apiPath + '/chats'
|
||||
processData: true
|
||||
success: (data, status, xhr) =>
|
||||
App.Collection.loadAssets(data.assets)
|
||||
for chat in App.Chat.all()
|
||||
tab =
|
||||
name: chat.name
|
||||
target: "chat-#{chat.id}"
|
||||
controller: App.ChannelChatDesigner
|
||||
params:
|
||||
model: chat
|
||||
@tabs.push tab
|
||||
@render()
|
||||
|
||||
)
|
||||
|
||||
class App.ChannelChatDesigner extends App.Controller
|
||||
events:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class Chat < ApplicationModel
|
||||
validates :name, presence: true
|
||||
store :preferences
|
||||
|
||||
def customer_state(session_id = nil)
|
||||
return { state: 'chat_disabled' } if !Setting.get('chat')
|
||||
|
|
5
db/migrate/20151117000001_update3_chat.rb
Normal file
5
db/migrate/20151117000001_update3_chat.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Update3Chat < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :chats, :preferences, :string, limit: 5000, null: true
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue