forked from lucianocosta/node-red-contrib-rocketchat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocketchat-custom-field.html
80 lines (77 loc) · 2.88 KB
/
rocketchat-custom-field.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script type="text/x-red" data-template-name="rocketchat-custom-field">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-tasks"></i> <span data-i18n="rocketchat-custom-field.label.server"></span></label>
<input type="text" id="node-input-server" data-i18n="[placeholder]rocketchat-custom-field.label.server">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-liveChatTokenConfig">
<i class="fa fa-tag"></i>
<span data-i18n="rocketchat-custom-field.label.liveChatTokenConfig"></span>
</label>
<input type="text" id="node-input-liveChatTokenConfig" style="width: 70%" data-i18n="[placeholder]rocketchat-custom-field.label.liveChatTokenConfig">
</div>
<div class="form-row">
<label for="node-input-customFields">
<i class="fa fa-tag"></i>
<span data-i18n="rocketchat-custom-field.label.customFields"></span>
</label>
<input type="text" id="node-input-customFields" data-i18n="[placeholder]rocketchat-custom-field.label.customFields">
<input type="hidden" id="node-input-customFields-type">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('rocketchat-custom-field', {
category: 'Rocket․Chat',
color: '#F98F9D',
paletteLabel: 'Set custom field',
defaults: {
name: { value: '' },
server: { value: '', type: 'rocketchat-server', required: true },
liveChatTokenConfig: {
value: '',
required: true,
validate: RED.validators.typedInput('liveChatTokenConfigType'),
},
liveChatTokenConfigType: { value: 'msg' },
customFields: {
value: '',
required: true,
validate: RED.validators.typedInput('customFieldsType'),
},
customFieldsType: { value: 'msg' },
},
inputs: 1,
outputs: 1,
icon: 'rocketchat.png',
label: function () {
return this.name || 'Rocket.Chat set custom field';
},
oneditprepare: function () {
const node = this;
$('#node-input-liveChatTokenConfig').typedInput({
default: node.liveChatTokenConfigType || 'str',
types: ['msg', 'flow', 'global', 'env', 'str'],
});
if (node.liveChatTokenConfig != null) {
$('#node-input-liveChatTokenConfig').typedInput('value', node.liveChatTokenConfig);
}
$('#node-input-customFields').typedInput({
type: 'msg',
types: ['msg', 'flow', 'global', 'json'],
typeField: '#node-input-customFields-type',
});
if (node.customFields != null) {
$('#node-input-customFields').typedInput('value', node.customFields);
}
},
oneditsave: function () {
const node = this;
node.liveChatTokenConfigType = $('#node-input-liveChatTokenConfig').typedInput('type');
node.customFieldsType = $('#node-input-customFields').typedInput('type');
},
});
</script>