80 lines
3.6 KiB
HTML
80 lines
3.6 KiB
HTML
|
|
<script type="text/javascript">
|
|||
|
|
RED.nodes.registerType("zammad-ticket", {
|
|||
|
|
category: "Zammad",
|
|||
|
|
color: "#3e8e41",
|
|||
|
|
defaults: {
|
|||
|
|
name: { value: "" },
|
|||
|
|
config: { type: "zammad-config", required: true },
|
|||
|
|
operation: { value: "list" },
|
|||
|
|
topic: { value: "" }
|
|||
|
|
},
|
|||
|
|
inputs: 1,
|
|||
|
|
outputs: 1,
|
|||
|
|
icon: "font-awesome/fa-ticket",
|
|||
|
|
label: function () {
|
|||
|
|
return this.name || ("Zammad " + this.operation);
|
|||
|
|
},
|
|||
|
|
labelStyle: function () {
|
|||
|
|
return this.name ? "node_label_italic" : "";
|
|||
|
|
},
|
|||
|
|
oneditprepare: function () {
|
|||
|
|
$("#node-input-config").val(this.config ? this.config.id : "");
|
|||
|
|
var op = this.operation || "list";
|
|||
|
|
$("#node-select-operation").val(op);
|
|||
|
|
$("#node-input-topic").parent().toggle(op === "subscribe" || op === "publish");
|
|||
|
|
},
|
|||
|
|
oneditsave: function () {
|
|||
|
|
this.operation = $("#node-select-operation").val();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<script type="text/x-red" data-template-name="zammad-ticket">
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|||
|
|
<input type="text" id="node-input-name" placeholder="Zammad Ticket">
|
|||
|
|
</div>
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label for="node-input-config"><i class="fa fa-server"></i> Config</label>
|
|||
|
|
<input type="text" id="node-input-config">
|
|||
|
|
</div>
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label for="node-select-operation"><i class="fa fa-wrench"></i> Operation</label>
|
|||
|
|
<select id="node-select-operation">
|
|||
|
|
<option value="list">List Tickets</option>
|
|||
|
|
<option value="search">Search Tickets</option>
|
|||
|
|
<option value="get">Get Ticket</option>
|
|||
|
|
<option value="create">Create Ticket</option>
|
|||
|
|
<option value="update">Update Ticket</option>
|
|||
|
|
<option value="articles">List Articles</option>
|
|||
|
|
<option value="addArticle">Add Article</option>
|
|||
|
|
<option value="tags">List Tags</option>
|
|||
|
|
<option value="addTag">Add Tag</option>
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-tips" style="color:#888; font-size:11px; margin-top:10px;">
|
|||
|
|
<b>Create</b>: Set msg.title, msg.customer, msg.body, msg.group, msg.state, msg.priority —
|
|||
|
|
or send a full JSON payload object with those fields.<br>
|
|||
|
|
<b>Search</b>: Zammad query syntax e.g. <code>state.name:open</code>,
|
|||
|
|
<code>customer.email:foo@example.com</code>, <code>title:order</code><br>
|
|||
|
|
<b>addArticle</b>: msg.articleBody, msg.sender ("Agent"/"Customer"), msg.from (email for customer articles)<br>
|
|||
|
|
<b>addTag</b>: msg.tag — e.g. "woocommerce-order"
|
|||
|
|
</div>
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<script type="text/x-red" data-help-name="zammad-ticket">
|
|||
|
|
<p>Zammad ticket operations: list, search, get, create, update, articles, tags.</p>
|
|||
|
|
<h3>Operations</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li><b>list</b> – List all tickets (optional msg.query, msg.limit, msg.page)</li>
|
|||
|
|
<li><b>search</b</b> – Search via Zammad query syntax (msg.query)</li>
|
|||
|
|
<li><b>get</b> – Get single ticket by msg.ticketId</li>
|
|||
|
|
<li><b>create</b> – Create from individual properties or full JSON payload</li>
|
|||
|
|
<li><b>update</b> – Update existing ticket (msg.ticketId)</li>
|
|||
|
|
<li><b>articles</b> – List ticket articles (msg.ticketId)</li>
|
|||
|
|
<li><b>addArticle</b> – Add article to ticket (msg.ticketId, msg.articleBody, msg.sender)</li>
|
|||
|
|
<li><b>tags</b> – List ticket tags (msg.ticketId)</li>
|
|||
|
|
<li><b>addTag</b> – Add tag to ticket (msg.ticketId, msg.tag)</li>
|
|||
|
|
</ul>
|
|||
|
|
</script>
|