parent
0c0cbc0cb3
commit
dfed59ad25
@ -0,0 +1,19 @@ |
||||
.trigger-option, .trigger-value { |
||||
float: left; |
||||
display: inline-block; |
||||
} |
||||
|
||||
.trigger-option { |
||||
width: 30%; |
||||
max-width: 300px; |
||||
padding-right: 4px; |
||||
} |
||||
|
||||
.trigger-value { |
||||
width: 70%; |
||||
|
||||
input { |
||||
display: inline-block !important; |
||||
width: auto !important; |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
<template name="livechatTriggerAction"> |
||||
<div class="input-line each-action"> |
||||
<div class="trigger-option"> |
||||
<select name="action" class="trigger-action"> |
||||
<option value="send-message">{{_ "Send_a_message"}}</option> |
||||
</select> |
||||
</div> |
||||
<div class="trigger-value"> |
||||
<div class="send-message {{hiddenValue 'send-message'}}"> |
||||
<input type="text" name="send-message-name" placeholder="{{_ "Name_of_agent"}}" value="{{params.name}}" size="15"> |
||||
<input type="text" name="send-message-msg" placeholder="{{_ "Message"}}" value="{{params.msg}}"> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
@ -0,0 +1,23 @@ |
||||
Template.livechatTriggerAction.helpers({ |
||||
hiddenValue (current) { |
||||
if (this.name === undefined && Template.instance().firstAction) { |
||||
Template.instance().firstAction = false; |
||||
return ''; |
||||
} else { |
||||
if (this.name !== current) { |
||||
return 'hidden'; |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
|
||||
Template.livechatTriggerAction.events({ |
||||
'change .trigger-action' (e, instance) { |
||||
instance.$('.trigger-action-value ').addClass('hidden'); |
||||
instance.$('.' + e.currentTarget.value).removeClass('hidden'); |
||||
} |
||||
}); |
||||
|
||||
Template.livechatTriggerAction.onCreated(function() { |
||||
this.firstAction = true; |
||||
}); |
||||
@ -0,0 +1,18 @@ |
||||
<template name="livechatTriggerCondition"> |
||||
<div class="input-line each-condition"> |
||||
<div class="trigger-option"> |
||||
<select name="condition" class="trigger-condition"> |
||||
<option value="page-url" selected="{{conditionSelected 'page-url'}}">{{_ "Visitor_page_URL"}}</option> |
||||
<option value="time-on-site" selected="{{conditionSelected 'time-on-site'}}">{{_ "Visitor_time_on_site"}}</option> |
||||
</select> |
||||
</div> |
||||
<div class="trigger-value"> |
||||
<div class="page-url trigger-condition-value {{hiddenValue 'page-url'}}"> |
||||
<input type="text" name="page-url-value" class="page-url-value" placeholder="{{_ "Enter_a_regex"}}" value="{{valueFor 'page-url'}}"> |
||||
</div> |
||||
<div class="time-on-site trigger-condition-value {{hiddenValue 'time-on-site'}}"> |
||||
<input type="number" name="time-on-site-value" class="time-on-site-value" placeholder="{{_ "Time_in_seconds"}}" value="{{valueFor 'time-on-site'}}"> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
@ -0,0 +1,33 @@ |
||||
Template.livechatTriggerCondition.helpers({ |
||||
hiddenValue (current) { |
||||
if (this.name === undefined && Template.instance().firstCondition) { |
||||
Template.instance().firstCondition = false; |
||||
return ''; |
||||
} else { |
||||
if (this.name !== current) { |
||||
return 'hidden'; |
||||
} |
||||
} |
||||
}, |
||||
conditionSelected (current) { |
||||
if (this.name === current) { |
||||
return 'selected'; |
||||
} |
||||
}, |
||||
valueFor (condition) { |
||||
if (this.name === condition) { |
||||
return this.value; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
Template.livechatTriggerCondition.events({ |
||||
'change .trigger-condition' (e, instance) { |
||||
instance.$('.trigger-condition-value ').addClass('hidden'); |
||||
instance.$('.' + e.currentTarget.value).removeClass('hidden'); |
||||
} |
||||
}); |
||||
|
||||
Template.livechatTriggerCondition.onCreated(function() { |
||||
this.firstCondition = true; |
||||
}) |
||||
@ -0,0 +1,11 @@ |
||||
Meteor.methods({ |
||||
'livechat:removeTrigger' (trigger) { |
||||
console.log('[methods] livechat:removeTrigger -> '.green, 'arguments:', arguments); |
||||
|
||||
if (!Meteor.userId() || !RocketChat.authz.hasPermission(Meteor.userId(), 'view-livechat-manager')) { |
||||
throw new Meteor.Error("not-authorized"); |
||||
} |
||||
|
||||
return RocketChat.models.LivechatTrigger.removeAll(); |
||||
} |
||||
}); |
||||
Loading…
Reference in new issue