Commit 85b8cdd1 authored by Gabriel Monnerat's avatar Gabriel Monnerat

fixup! erp5_officejs_support_request_ui: New gadget to generate RSS Link

- change the bt5/erp5_officejs_support_request_ui/ActionTemplateItem/portal_types/Support%20Request%20Module/generate_rss_link.xml action, to directly call bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_generateRSSLinkUrl.py instead of the form. See a7e8e5fe

- change SupportRequestModule_generateRSSLinkUrl to display the form at the end.
- Use Base_renderForm like for erp5_crm
- Put the RSS url in the REQUEST
- change the gadget field configuration to use the value from the REQUEST (if not found, put None)
parent ca81fe82
......@@ -77,7 +77,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SupportRequestModule_viewGenerateRSSLinkDialog</string> </value>
<value> <string>string:${object_url}/SupportRequestModule_generateRSSLinkUrl</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -4,33 +4,33 @@ portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None:
return request_url
access_token = None
url = request_url
else:
access_token = None
for token_item in portal.portal_catalog(
portal_type="Restricted Access Token",
default_agent_uid=person.getUid(),
validation_state='validated'
):
if token_item.getUrlString() == request_url:
access_token = token_item
reference = access_token.getReference()
break
for token_item in portal.portal_catalog(
portal_type="Restricted Access Token",
default_agent_uid=person.getUid(),
validation_state='validated'
):
if token_item.getUrlString() == request_url:
access_token = token_item
if access_token is None:
access_token = portal.access_token_module.newContent(
portal_type="Restricted Access Token",
url_string=request_url,
url_method="GET",
)
access_token.setAgentValue(person)
reference = access_token.getReference()
break
if access_token is None:
access_token = portal.access_token_module.newContent(
portal_type="Restricted Access Token",
url_string=request_url,
url_method="GET",
)
access_token.setAgentValue(person)
reference = access_token.getReference()
access_token.validate()
access_token.validate()
url = "%s?access_token=%s&access_token_secret=%s" % (
request_url,
access_token.getId(),
reference)
url = "%s?access_token=%s&access_token_secret=%s" % (
request_url,
access_token.getId(),
reference)
return url
context.REQUEST.form["your_rss_url"] = url
return context.Base_renderForm('SupportRequestModule_viewGenerateRSSLinkDialog')
......@@ -18,7 +18,7 @@
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string>Refresh page</string> </value>
<value> <string>Copy to clipboard</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -77,6 +77,7 @@
<value>
<list>
<string>generate_rss_link_gadget</string>
<string>your_rss_url</string>
</list>
</value>
</item>
......@@ -95,15 +96,15 @@
</item>
<item>
<key> <string>method</string> </key>
<value> <string>GET</string> </value>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>SupportRequestModule_generateRSSLink</string> </value>
<value> <string>SupportRequestModule_viewGenerateRSSLinkDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>report_view</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......@@ -115,7 +116,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Click the link bellow to obtain it</string> </value>
<value> <string>Click below to copy to clipboard</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
......
......@@ -255,7 +255,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [("rss_url", here.SupportRequestModule_generateRSSLinkUrl())]</string> </value>
<value> <string>python: [("rss_url", request.get("your_rss_url"))]</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_rss_url</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>RSS Link</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,8 +12,5 @@
<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
......@@ -5,28 +5,29 @@
rJS(window)
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("nofitySubmited", "nofitySubmited")
.declareMethod('render', function (options) {
return this.changeState({
rss_url: options.rss_url
});
})
.declareMethod('getContent', function () {
return {"your_rss_url": this.state.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;
return gadget.nofitySubmited(button_text);
});
},
false,
......
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