Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / chat_website.js
1 /**
2  * Chat Website Model
3  */
4
5 module.exports = function(sequelize, DataTypes) {
6
7         var ChatWebsite = sequelize.define('ChatWebsite', {
8                 name: DataTypes.STRING,
9                 address: {
10                         type: DataTypes.STRING,
11                         unique: true
12                 },
13                 description: DataTypes.STRING,
14                 color: {
15                         type: DataTypes.STRING,
16                         defaultValue: '#000080'
17                 },
18                 color_focus: {
19                         type: DataTypes.STRING,
20                         defaultValue: '#000080'
21                 },
22                 color_button: {
23                         type: DataTypes.STRING,
24                         defaultValue: '#000080'
25                 },
26                 remote: DataTypes.STRING,
27                 animation: {
28                         type: DataTypes.BOOLEAN,
29                         defaultValue: true
30                 },
31                 header_shape: {
32                         type: DataTypes.ENUM('rounded', 'squared'),
33                         defaultValue: 'rounded'
34                 },
35                 header_online: {
36                         type: DataTypes.STRING,
37                         defaultValue: 'We are here!'
38                 },
39                 online_message: {
40                         type: DataTypes.STRING,
41                         defaultValue: '<strong>Questions?<\/strong><br \/>Insert your name and email address to start a live-chat with our support team.'
42                 },
43                 username_placeholder: {
44                         type: DataTypes.STRING,
45                         defaultValue: 'Your name'
46                 },
47                 email_placeholder: {
48                         type: DataTypes.STRING,
49                         defaultValue: 'Your e-mail address'
50                 },
51                 start_chat_button: {
52                         type: DataTypes.STRING,
53                         defaultValue: 'Chat'
54                 },
55                 header_offline: {
56                         type: DataTypes.STRING,
57                         defaultValue: 'Contact us'
58                 },
59                 offline_message: {
60                         type: DataTypes.STRING,
61                         defaultValue: '<strong>We\'re not online.<\/strong><br \/>It doesn\'t mean we\'re not there to help - leave your message below and we\'ll be in touch as soon as possible.'
62                 },
63                 enquiry_message_placeholder: {
64                         type: DataTypes.STRING,
65                         defaultValue: 'Your message...'
66                 },
67                 enquiry_button: {
68                         type: DataTypes.STRING,
69                         defaultValue: 'Leave message'
70                 },
71                 download_transcript: {
72                         type: DataTypes.BOOLEAN,
73                         defaultValue: true
74                 },
75                 enquiry_forwarding: {
76                         type: DataTypes.BOOLEAN,
77                         defaultValue: false
78                 },
79                 enquiry_forwarding_address: {
80                         type: DataTypes.STRING
81                 },
82                 enquiry_enable: {
83                         type: DataTypes.BOOLEAN,
84                         defaultValue: true
85                 },
86                 rating_enable: {
87                         type: DataTypes.BOOLEAN,
88                         defaultValue: true
89                 },
90                 rating_message: {
91                         type: DataTypes.STRING,
92                         defaultValue: 'Would you like rate this chat?'
93                 },
94                 rating_send: {
95                         type: DataTypes.STRING,
96                         defaultValue: 'Send'
97                 },
98                 rating_skip: {
99                         type: DataTypes.STRING,
100                         defaultValue: 'Skip'
101                 },
102                 show_service_name: {
103                         type: DataTypes.BOOLEAN,
104                         defaultValue: false
105                 },
106                 service_name: {
107                         type: DataTypes.STRING
108                 },
109                 fidelity: {
110                         type: DataTypes.BOOLEAN,
111                         defaultValue: false
112                 },
113                 timeout: {
114                         type: DataTypes.INTEGER,
115                         defaultValue: 0
116                 },
117                 agents_busy: {
118                         type: DataTypes.STRING,
119                         defaultValue: 'In this moment all agents are busy. Try again!'
120                 },
121                 name_title: {
122                         type: DataTypes.STRING,
123                         defaultValue: 'Name'
124                 },
125                 email_title: {
126                         type: DataTypes.STRING,
127                         defaultValue: 'Email Address'
128                 },
129                 message_title: {
130                         type: DataTypes.STRING,
131                         defaultValue: 'Message'
132                 },
133                 logo: {
134                         type: DataTypes.STRING
135                 },
136                 defaultLogo: {
137                         type: DataTypes.BOOLEAN,
138                         defaultValue: true
139                 },
140                 whiteLabel: {
141                         type: DataTypes.STRING,
142                         defaultValue: 'Powered by xCALLY'
143                 },
144                 defaultWhiteLabel: {
145                         type: DataTypes.BOOLEAN,
146                         defaultValue: true
147                 },
148                 acceptUrl: {
149                         type: DataTypes.STRING
150                 },
151                 rejectUrl: {
152                         type: DataTypes.STRING
153                 },
154                 closeUrl: {
155                         type: DataTypes.STRING
156                 },
157                 closeMethod: {
158                         type: DataTypes.ENUM('GET', 'POST')
159                 },
160                 acceptMethod: {
161                         type: DataTypes.ENUM('GET', 'POST')
162                 },
163                 rejectMethod: {
164                         type: DataTypes.ENUM('GET', 'POST')
165                 },
166                 actions: {
167                         type: DataTypes.STRING,
168                         get: function() {
169                                 return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
170                         },
171                         set: function(val) {
172                                 return this.setDataValue('actions', JSON.stringify(val));
173                         }
174                 }
175         }, {
176                 tableName: 'chat_websites',
177                 associate: function(models) {
178                         // hasMany relations
179                         ChatWebsite.belongsTo(models.Template, {
180                                 as: 'OfflineTemplate'
181                         });
182                         ChatWebsite.hasMany(models.ChatRoom);
183                         ChatWebsite.hasMany(models.ChatApplication);
184                         ChatWebsite.belongsTo(models.List);
185                         ChatWebsite.hasMany(models.ChatWebsitesField, {
186                                 as: 'Online',
187                                 foreignKey: 'OnlineId'
188                         });
189                         ChatWebsite.hasMany(models.ChatWebsitesField, {
190                                 as: 'Offline',
191                                 foreignKey: 'OfflineId'
192                         });
193                         ChatWebsite.hasMany(models.ChatProactiveAction);
194                         ChatWebsite.hasMany(models.ChatDisposition);
195                 }
196         });
197
198         return ChatWebsite;
199 };