Commit a7969c7d authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_officejs_support_request_ui: New gadget to generate RSS Link

Also, remove RSS link from dashboard
parent 880fd080
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>generate_rss_link</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>3.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Generate RSS</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SupportRequestModule_viewGenerateRSSLinkDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -21,7 +21,6 @@
<div class="ui-field-contain">
<div class="bottom">
<a><input type="submit" class="first-line-buttons ui-disabled" data-i18n="[value]Submit New Support Request" value="Submit New Support Request" disabled /></a>
<a target="_blank"><input class="first-line-buttons ui-disabled" type="submit" data-i18n="[value]Generate RSS" value="Generate RSS" disabled /></a>
</div>
</div>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.17075.21280.35942</string> </value>
<value> <string>983.3535.62274.35669</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,8 +256,8 @@
</tuple>
<state>
<tuple>
<float>1537518325.21</float>
<string>GMT+9</string>
<float>1592854185.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -108,7 +108,7 @@
throw error;
})
.push(function () {
var restore_filter_input = gadget.element.querySelectorAll("input")[2];
var restore_filter_input = gadget.element.querySelectorAll("input")[1];
restore_filter_input.disabled = false;
restore_filter_input.classList.remove("ui-disabled");
});
......@@ -264,7 +264,7 @@
})
.declareService(function () {
var gadget = this,
restore_filter_input = gadget.element.querySelectorAll("input")[2];
restore_filter_input = gadget.element.querySelectorAll("input")[1];
return gadget.getUrlParameter('extended_search')
.push(function (result) {
if (result !== undefined) {
......@@ -277,29 +277,8 @@
var gadget = this;
return new RSVP.Queue()
.push(function () {
var generate_rss_input = gadget.element.querySelectorAll("input")[1],
restore_filter_input = gadget.element.querySelectorAll("input")[2],
one = new RSVP.Queue().push(function () {
return promiseEventListener(generate_rss_input, "click", false);
}).push(function () {
generate_rss_input.disabled = true;
generate_rss_input.classList.add("ui-disabled");
return gadget.getSetting("hateoas_url")
.push(function (hateoas_url) {
return gadget.jio_getAttachment(
'support_request_module',
hateoas_url + 'support_request_module'
+ "/SupportRequestModule_generateRSSLinkAsJson"
);
})
.push(function (result) {
generate_rss_input.parentNode.href = result.restricted_access_url;
generate_rss_input.value = "RSS Link";
generate_rss_input.disabled = false;
generate_rss_input.classList.remove("ui-disabled");
});
}),
two = loopEventListener(restore_filter_input, "click", false, function () {
var restore_filter_input = gadget.element.querySelectorAll("input")[1],
one = loopEventListener(restore_filter_input, "click", false, function () {
restore_filter_input.disabled = true;
restore_filter_input.classList.add("ui-disabled");
return gadget.redirect({
......@@ -311,9 +290,7 @@
});
}, true);
generate_rss_input.disabled = false;
generate_rss_input.classList.remove("ui-disabled");
return RSVP.all([one, two]);
return one;
});
})
.onStateChange(function () {
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>983.46010.49549.22528</string> </value>
<value> <string>984.48957.14599.64153</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1588755553.56</float>
<float>1592917663.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>983.35938.18075.42103</string> </value>
<value> <string>984.51645.41378.19729</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1589291785.06</float>
<float>1593352275.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -27,8 +27,10 @@
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
......@@ -260,7 +262,12 @@
});
}, false, true)
.onEvent('click', function (evt) {
if ((evt.target.nodeType === Node.ELEMENT_NODE) &&
(evt.target.tagName === 'BUTTON')) {
return this.toggle();
}
}, false, false)
.onEvent('blur', function (evt) {
// XXX Horrible hack to clear the search when focus is lost
// This does not follow renderJS design, as a gadget should not touch
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.15074.42522.46830</string> </value>
<value> <string>984.51645.41378.19729</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1559893029.52</float>
<float>1593352467.41</float>
<string>UTC</string>
</tuple>
</state>
......
import json
absolute_url = context.absolute_url()
request_url = "%s/SupportRequestModule_viewLastSupportRequestListAsRss" % (absolute_url,)
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None:
return json.dumps({'restricted_access_url': request_url})
return request_url
access_token = None
......@@ -35,4 +33,4 @@ url = "%s?access_token=%s&access_token_secret=%s" % (
access_token.getId(),
reference)
return json.dumps({'restricted_access_url': url})
return url
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequestModule_generateRSSLinkAsJson</string> </value>
<value> <string>SupportRequestModule_generateRSSLinkUrl</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>SupportRequestModule_viewGenerateRSSDialog</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string>Refresh page</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>generate_rss_link_gadget</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequestModule_viewGenerateRSSLinkDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>GET</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>SupportRequestModule_generateRSSLink</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>report_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Click the link bellow to obtain it</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>generate_rss_link_gadget</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>no_validator</string> </key>
<value> <string>Does not support this operation.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>gadget_generate_rss_link.html</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>generate_rss_link_gadget</string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [("rss_url", here.SupportRequestModule_generateRSSLinkUrl())]</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>string:</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
div[data-gadget-url$="gadget_generate_rss_link.html"] button {
padding: 6pt;
background-color: #FF6600;
color: #FFFFFF;
border-radius: 0.325em;
border-width: 1px;
border-style: solid;
border-color: #FF6600;
min-width: 8em;
}
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>gadget_generate_rss_link.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_generate_rss_link.html</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Copied
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<link rel="stylesheet" href="gadget_generate_rss_link.css">
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_generate_rss_link.js" type="text/javascript"></script>
</head>
<body>
<button type="button" class="ui-btn ui-icon-copy ui-btn-icon-notext ui-btn-right" data-i18n="[value]Copy to Clipboard">
Copy to Clipboard
</button>
</body>
</html>
\ No newline at end of file
/*global rJS, window, navigator, RSVP*/
/*jslint nomen: true, maxlen:80, indent:2*/
(function (rJS, window, navigator, RSVP) {
'use strict';
rJS(window)
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareMethod('render', function (options) {
return this.changeState({
rss_url: options.rss_url
});
})
.onEvent(
'click',
function (evt) {
var gadget = this,
root = this.element,
button = evt.target,
button_text;
evt.preventDefault();
return gadget.getTranslationList(["Copied"])
.push(function (result) {
button_text = result[0];
button.classList.remove("ui-icon-copy");
return navigator.clipboard.writeText(gadget.state.rss_url);
})
.push(function () {
button.classList.add("ui-icon-check");
button.textContent = " " + button_text;
});
},
false,
false
);
}(rJS, window, navigator, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>gadget_generate_rss_link.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Support Request Module | fast_input
Support Request Module | generate_rss_link
Support Request Module | officejs_support_request_view
Support Request Module | view_last_support_request
Support Request | officejs_support_request_view
\ No newline at end of file
......@@ -461,11 +461,8 @@ class TestSupportRequestRSSSOneEvent(SupportRequestRSSTestCase, DefaultTestRSSMi
self._checkRSS(response)
def test_RSS_with_token(self):
response = self.publish(
"%s/support_request_module/SupportRequestModule_generateRSSLinkAsJson" % self.getWebSite().getPath(),
basic='%s:%s' % (self.user.erp5_login.getReference(), self.user_password))
restricted_access_url = json.loads(response.getBody())['restricted_access_url']
# make it relative url
self.login(self.user.getUserId())
restricted_access_url = self.portal.support_request_module.SupportRequestModule_generateRSSLinkUrl()
parsed_url = urlparse.urlparse(restricted_access_url)
restricted_access_url = restricted_access_url.replace(
'%s://%s' % (parsed_url.scheme, parsed_url.netloc), '', 1)
......
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