Commit 4905b543 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Allow user close tickets by himself

parent ad5c62c2
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_close_ticket.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (doc) {
return gadget.jio_post(doc)
.push(function () {
return gadget.getSetting("hateoas_url");
})
.push(function (url) {
return gadget.jio_putAttachment(doc.follow_up,
url + doc.follow_up + "/SupportRequest_close", {});
});
})
.push(function () {
return gadget.redirect({"command": "change",
"options": {"jio_key": gadget.state.jio_key,
"page": "slap_controller"}});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this;
gadget.state.jio_key = options.jio_key;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.getSetting('me'),
gadget.jio_get(gadget.state.jio_key)
]);
})
.push(function (result) {
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "The name of a document in ERP5",
"title": "Title",
"default": "Close: " + result[2].title,
"css_class": "",
"required": 1,
"editable": 1,
"key": "title",
"hidden": 1,
"type": "StringField"
},
"my_text_content": {
"description": "Include your close message",
"title": "Your Close Message",
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": "TextAreaField"
},
"my_source": {
"description": "",
"title": "Source",
"default": result[1],
"css_class": "",
"required": 1,
"editable": 1,
"key": "source",
"hidden": 1,
"type": "StringField"
},
"my_follow_up": {
"description": "",
"title": "Follow up",
"default": gadget.state.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "follow_up",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": "The name of a document in ERP5",
"title": "Portal Type",
"default": "Web Message",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": "Parent Relative Url",
"default": "event_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"center",
[["my_title"], ["my_text_content"], ["my_follow_up"],
["my_portal_type"], ["my_parent_relative_url"],
["my_follow_up"], ["my_source"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: "Close Ticket",
selection_url: url_list[0],
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -217,6 +217,7 @@
return RSVP.all([
gadget.getUrlFor({command: "change", options: {editable: true}}),
gadget.getUrlFor({command: "change", options: {page: "slap_add_related_event", editable: true}}),
gadget.getUrlFor({command: "change", options: {page: "slap_close_ticket", editable: true}}),
gadget.getUrlFor({command: 'history_previous'})
]);
})
......@@ -224,8 +225,11 @@
var header_dict = {
page_title: "Support Request : " + gadget.state.doc.title,
add_url: url_list[1],
selection_url: url_list[2]
selection_url: url_list[3]
};
if (gadget.state.doc.simulation_state_title != "Closed") {
header_dict.close_url = url_list[2];
}
return gadget.updateHeader(header_dict);
});
});
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.37320.56229.50244</string> </value>
<value> <string>974.62049.17150.785</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1545844794.6</float>
<float>1558489188.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -360,6 +360,8 @@ gadget_erp5_page_slap_support_request_view.html\n
gadget_erp5_page_slap_ticket_list.html\n
gadget_erp5_page_slap_ticket_list.js\n
gadget_erp5_page_slap_ticket_view.js\n
gadget_erp5_page_slap_close_ticket.js\n
gadget_erp5_page_slap_close_ticket.html\n
gadget_erp5_page_slap_transfer_computer.html\n
gadget_erp5_page_slap_transfer_computer.js\n
gadget_erp5_page_slap_trial_request_message.html\n
......@@ -547,7 +549,7 @@ NETWORK:\n
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -561,7 +563,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.9238.47958.47360</string> </value>
<value> <string>975.57226.29060.57429</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -579,7 +581,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1556264848.5</float>
<float>1558489648.02</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -47,6 +47,7 @@
['critical_url', 'Critical RSS', 'exclamation-triangle'],
['start_url', 'Start', 'play'],
['stop_url', 'Stop', 'stop'],
['close_url', 'Close', 'stop'],
['destroy_url', 'Destroy', 'times'],
['supply_url', 'Supply', 'plus'],
['transfer_url', 'Transfer', 'exchange'],
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.32024.53732.34406</string> </value>
<value> <string>974.62049.17150.785</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1545649159.32</float>
<float>1558489401.94</float>
<string>UTC</string>
</tuple>
</state>
......
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
portal = context.getPortalObject()
return portal.portal_catalog(
portal_type="Hosting Subscription",
validation_state="validated",
query=NegatedQuery(Query(aggregate_related_portal_type="Subscription Request")),
**kw)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscriptionModule_getServiceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if context.getPortalType() == "Support Request" and \
person.getRelativeUrl() == context.getDestinationDecision() and \
context.getValidationState() != "invalidated":
context.invalidate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignee</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_close</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -122,6 +122,8 @@ web_page_module/rjs_gadget_erp5_page_slap_support_request_view_html
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_html
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html
......
......@@ -27,6 +27,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_html
web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_js
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_computer_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_computer_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_computer_list_html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment