Commit 01ab6773 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_officejs_support_request_ui: Improve rss gadget

- change the generate_rss_link action in Support Request Module, to directly call SupportRequestModule_generateRSSLinkUrl.py instead of the form.
- 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 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/SupportRequestModule_viewGenerateRSSLinkDialog</string> </value> <value> <string>string:${object_url}/SupportRequestModule_generateRSSLinkUrl</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -4,33 +4,33 @@ portal = context.getPortalObject() ...@@ -4,33 +4,33 @@ portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None: if person is None:
return request_url url = request_url
else:
access_token = None 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( if access_token is None:
portal_type="Restricted Access Token", access_token = portal.access_token_module.newContent(
default_agent_uid=person.getUid(), portal_type="Restricted Access Token",
validation_state='validated' url_string=request_url,
): url_method="GET",
if token_item.getUrlString() == request_url: )
access_token = token_item access_token.setAgentValue(person)
reference = access_token.getReference() reference = access_token.getReference()
break access_token.validate()
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()
url = "%s?access_token=%s&access_token_secret=%s" % ( url = "%s?access_token=%s&access_token_secret=%s" % (
request_url, request_url,
access_token.getId(), access_token.getId(),
reference) reference)
return url context.REQUEST.form["your_rss_url"] = url
return context.Base_renderForm('SupportRequestModule_viewGenerateRSSLinkDialog')
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
</item> </item>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>SupportRequestModule_viewGenerateRSSDialog</string> </value> <value> <string>SupportRequestModule_generateRSSLinkUrl</string> </value>
</item> </item>
<item> <item>
<key> <string>action_title</string> </key> <key> <string>action_title</string> </key>
<value> <string>Refresh page</string> </value> <value> <string>Copy to clipboard</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<value> <value>
<list> <list>
<string>generate_rss_link_gadget</string> <string>generate_rss_link_gadget</string>
<string>your_rss_url</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -95,15 +96,15 @@ ...@@ -95,15 +96,15 @@
</item> </item>
<item> <item>
<key> <string>method</string> </key> <key> <string>method</string> </key>
<value> <string>GET</string> </value> <value> <string>POST</string> </value>
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>SupportRequestModule_generateRSSLink</string> </value> <value> <string>SupportRequestModule_viewGenerateRSSLinkDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>report_view</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
...@@ -115,7 +116,7 @@ ...@@ -115,7 +116,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <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>
<item> <item>
<key> <string>unicode_mode</string> </key> <key> <string>unicode_mode</string> </key>
......
...@@ -235,11 +235,11 @@ ...@@ -235,11 +235,11 @@
</item> </item>
<item> <item>
<key> <string>validator_field_id</string> </key> <key> <string>validator_field_id</string> </key>
<value> <string></string> </value> <value> <string>my_core_mode_text_content_validator</string> </value>
</item> </item>
<item> <item>
<key> <string>validator_form_id</string> </key> <key> <string>validator_form_id</string> </key>
<value> <string></string> </value> <value> <string>erp5_core/Base_viewFieldLibrary</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </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 @@ ...@@ -12,8 +12,5 @@
<script src="gadget_generate_rss_link.js" type="text/javascript"></script> <script src="gadget_generate_rss_link.js" type="text/javascript"></script>
</head> </head>
<body> <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> </body>
</html> </html>
\ No newline at end of file
/*global rJS, window, navigator, RSVP*/ /*global rJS, window, navigator*/
/*jslint nomen: true, maxlen:80, indent:2*/ /*jslint nomen: true, maxlen:80, indent:2*/
(function (rJS, window, navigator, RSVP) { (function (rJS, window, navigator) {
'use strict'; 'use strict';
rJS(window) rJS(window)
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("notifySubmit", "notifySubmit")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
return this.changeState({ return this.changeState({
rss_url: options.rss_url rss_url: options.rss_url
}); });
}) })
.onEvent( .declareMethod('getContent', function () {
'click', var gadget = this,
function (evt) { button_text;
var gadget = this, return gadget.getTranslationList(["Copied"])
root = this.element, .push(function (result) {
button = evt.target, button_text = result[0];
button_text; return navigator.clipboard.writeText(gadget.state.rss_url);
evt.preventDefault(); })
return gadget.getTranslationList(["Copied"]) .push(function () {
.push(function (result) { return gadget.notifySubmit(button_text);
button_text = result[0]; });
button.classList.remove("ui-icon-copy"); });
return navigator.clipboard.writeText(gadget.state.rss_url); }(rJS, window, navigator));
}) \ No newline at end of file
.push(function () {
button.classList.add("ui-icon-check");
button.textContent = " " + button_text;
});
},
false,
false
);
}(rJS, window, navigator, RSVP));
\ No newline at end of file
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