QSelectSection not saving values when scrolling QuickDialog - quickdialog

I've been struggling with this for 3 days. The documentation for the QSelectSection is the class itself, and the QuickDialog docs are minimal at best.
I'm trying to use the QSelectSection using the QuickDialog framework. I have it working for most of the controls (after diving head first into the code to see how the component works) but this one has beaten me. From my understanding, and the way the other controls work, this should dump the selected item values into the alerts array within my controller. I want to put as much in the JSON as I can, and only use the controller to store/submit the details if this is possible.
The JSON below generates the dialog and my multi select form. Awesome, but for some reason when I scroll the select section off screen, my values are gone. When I submit the form, the app does not see my selected items. When I try to use "controllerAction" to store these values, the app just crashes.
{
"grouped": true,
"title": "MyTitle",
"controllerName": "LOrderViewController",
"sections": [
{
"title": "Notifications",
"type": "QSelectSection",
"bind": "selectedItems:alerts",
"multipleAllowed": true,
"items": [
"Email Alerts",
"App Alerts"
],
"footer": "My Footer text."
}
...
]
}
What am I missing? What code is required in my controller, how can I trigger that code?
Am I better off scrapping QuickDialog for something that is better documented, or just stick with native methods?
Love the concept of QuickDialog, but the same isn't holding true for me with this taking so long to learn.

Related

Dialogflow buttons in Slack generating separate session from typed entries

My Dialogflow sessions seem to change by whether I manually type in text or click on a button. My backend function generates the buttons in a payload for slack that is displayed in Dialogflow.
The buttons show properly and work as expected except when I need something from the output contexts and existing session. The problem seems to be that when I am manually entering text in Slack, it is one session and when I click on a button, it is another session. I don't know why that would be the case, but I obviously want them to be treated as one session.
I created a simple intent and webhook call which simply returns the current session ID when called. I created a "what session" intent. I created a "what session" button with a value of "what session". When I type "what session" (or "which session"), the session comes back as a certain session with the buttons as expected. When I click on the "what session" button, I get the same result EXCEPT it is a DIFFERENT session. Every time I click on the button, I am in one session and when I manually type in "what session" again, I get the original session.
In the history, you can see two different conversation streams.
So, how do I have the buttons, when clicked, keep the user in the same session?
Here is the format for the buttons (pretty straight forward). The backend function also populates the "text" field with the session value, but doesn't change anything else.
{
"slack": {
"text": "",
"attachments": [
{
"blocks": [
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "test"
},
"value": "test"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "what session"
},
"value": "what session"
}
]
}
]
}
]
}
}
Here is what the interaction looks like on slack (on mobile):
Here is the history in Dialogflow showing the two separate streams:
Google support helped me on this - thank you!
The solution was to add the Request URL into the Interactivity & Shortcuts section.
Now, imagine my embarrassment when I reread the last step in the instructions to do exactly this:
"To use rich messages, copy the ‘Events Request URL' value below and paste it into the 'Request URL' field from the Interactive Messages section of your Slack app settings."
HOWEVER, in my defense, I wondered how I had missed this twice (since I set up everything again for testing to see what I was missing). I know I would have done this. The weird thing was that when I completed the step in Slack, I realized that my changes were not being saved on that page. I clicked on the "Save Changes" and assumed it had saved, but the button had not turned green so the changes had not been saved. So, my advice to anyone experiencing the issue above is to ensure that all their changes were saved in Slack.

Adaptive Cards - Get PostBack for actions

I have to use adaptive cards in certain situation. When I use these cards, I need to have some buttons that can perform different actions when clicked. Previously, I have been using Hero Cards to return data and create the buttons. I have found that postBack (for hero cards) is the way to accept the button output most effectively for me. Unfortunately, adaptive cards doesn’t seem to have postBack. Instead, I need to use Action.Submit. However, when I do this, I end up with the text from the button showing as part of the conversation. I don’t want that and need it to be consistent with postBack. I tried to use the method from this comment https://github.com/Microsoft/AdaptiveCards/issues/558 (the guy has the exact same ask as me) but, it doesn’t seem to work anymore (from 2017). Any suggestions? I'm using SDK V4 and the basic bot NodeJS build found in the Azure portal.
Thanks for the help in advance
Adding the code for more detail:
var card = {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{"type": "TextBlock",
"text": answer},
table],
"actions" : [{
"type": "Action.Submit",
"title": wrap(promptQuestions[0]),
"data": promptQuestions[0]
},
{
"type": "Action.Submit",
"title": wrap(promptQuestions[1]),
"data": promptQuestions[1]
}]
}
console.log(card)
return CardFactory.adaptiveCard(card);
Submit action data is supposed to be an object and not a string. See my blog post for more information: https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/

SAPUI5 - Mobile app paging, alternatives to paginator

I'm investing a survey / questionnaire app in SAPUI5...
As it's mainly to be used on a mobile device, and the questionnaires will consist of many questions, what are the best SAPUI5 components to use for paging through the questions?
Paginator is ugly and will be deprecated soon, so I'm looking for alternative suggestions.
Can anyone help?
how about NavContainer. https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.NavContainer/preview
It is very good fit for your use case , and it has good user experience in mobile devices. You can define your own Back and Next button in the footer to navigate between different questions.
Thank you.
I know the question is already answered by Allen, so this is an alternavtive suggestion.
Assuming that your model will be something like:
{
"Questions": [{
"QuestionID": "0001",
"QuestionText":"What is a Blah?"
"Options": [{
"OptionA":"Blah",
"OptionB":"BlahBlah",
"OptionC":"BlahBlahBlah",
"OptionD":"None Of the Above Blahs"
}]
},{
"QuestionID": "0002",
"QuestionText":"To Blah or not to Blah?"
"Options": [{
"OptionA":"Yes",
"OptionB":"No",
"OptionC":"Blah",
"OptionD":"Blah ha ha ha"
}]
}]
}
You can also accomplish the same effect without a NavContainer and a Single View. The View will be bound to the above model. The View / Page might have two buttons for the "next" and "previous" functionality. On click of each button you can manipulate the BindingContext that is bound to the view so that the Context changes and not the view. To set a new BindingContext, you can track which question is currently displayed on the screen and use the .bindElement function to set the Path of the next / previous element to be displayed.
Pros: Only one View and Controller
Cons: Need to manage the context and paths, Also means that the binding is little more complex and you might need factory functions based on whether the number of answers can vary between 2 (True / False questions) to 4 (MCP as in the above example)
Helpful link for Element Binding: https://sapui5.hana.ondemand.com/explored.html#/sample/sap.ui.core.tutorial.databinding.13/preview
Thanks for all you help on this. I'd like to use binding path/context to create a new survey create app, but just need some examples of manipulating the binding to create a new path for example, I've created a new question
here

chrome extension background script confirm message title

I have a chrome extension. In its background script I want to present a confirm() dialog box to accept (Ok/Cancel) input from user. Have no problem doing that.
The only problem is that the title of message shows up as "chrome-extension://32_char_extension_id". Not what I want to see.
On the other hand in the safari extension (global.html) the title shows up as the "Extension name".
Would be nice to have the same functionality in Chrome Extension.
Any idea if there is a way to see extension name in the message box instead of the ID.
Anything I"m doing it wrong ?
I understand confirm() is the not the recommended solution for prompt to take user input (as it is a blocking call). But this seems like a quicker solution for what I"m doing.
The other alternatives I"m looking into using JQuery message boxes. But if I can resolve this thru simple confirm(), it would be great for now.
Probably, you should use the chrome.notifications API to display the dialog so that you ask the user something in this case. You can show a notification which has two buttons by like the following code:
chrome.notifications.onButtonClicked.addListener((notificationId, buttonIndex) => {
// If buttonIndex == 0, Ok button clicked.
chrome.notifications.clear(notificationId, wasCleared => { ... });
});
chrome.notifications.create("notificationId", {
type: "basic",
iconUrl: "SOME_ICON_PATH",
title: "YOUR_EXTENSION_NAME",
message: "SOME_MESSAGE",
buttons: [
{
title: "Ok"
},
{
title: "Cancel"
}
]
});
Of course, you need to get a "notifications" permission from the user.
You can't change window.confirm() title, it is for anti-phishing.
You should try other approaches such as Bootstrap Modal

Communicating with a content script on active tab from a Chrome extension's page action popup

I'm not getting how to pass data between content script and page action popup.
I've started with the following simple skeleton, that shows an page action for any page having a minus-dash in title:
Extension manifest (manifest.json):
{
…
"permissions": ["http://example.org/*"],
"background": {"scripts": ["background.js"]},
"page_action": {"default_popup": "popup.html", …},
"content_scripts": {
"matches": ["http://example.org/*"],
"js": ["content.js"]
}
}
Background script (background.js):
chrome.extension.onRequest.addListener(function (msg, sender, respond) {
if (msg && msg.what === "match") {
console.log("Match:", msg.title);
chrome.pageAction.show(sender.tab.id);
}
}
Content script (content.js), checking document titles:
var title = document.title;
if (title.indexOf("-") >= 0) {
chrome.extension.sendRequest({"what": "match", "title": title});
}
Now, in a page action's popup, I want to show matched page's title. Not the last loaded page's title (as would be done by using this answer), but the title of the active tab.
My first though was to send a query to the content script, but according to documentation chrome.extension.sendMessage will send it to all listeners (i.e. all my content scripts on all tabs), without any clear definition on whose response I'll receive back. Also, I can't use chrome.tabs.sendMessage as it requires tabId. Trying to find the current tab using chrome.tabs.getCurrent will return null, as the query comes from non-tab context (from a popup).
I guess I could probably use chrome.tabs.executeScript to communicate, but this just feels dirty.
Still, I believe, this is a basic thing that should be very simple to do and I'm just missing something. Could someone, please, help me, preferably, with an example code?
Update: I've found Mappy example extension and it uses chrome.tabs.onUpdated to keep track of the active tab. This, unfortunately, requires tabs permission. Personally, I'd like to use least privileges possible.
So, is it just unfortunately bad permission system design and I have no choice but to do it this way, or there's any workaround? I'd be happy if chrome.pageAction.onClicked event handler (which provides Tab object that I need) would allow me to show a popup...
I think you need to add the onClick event listener in your popup:
chrome.pageAction.onClicked.addListener(function(tabs.Tab tab) {...});
See documentation here.
Callback of the event listener would provide you the tabId which would surely be the active tab.
There are multiple Problems in your code
chrome.extension.sendRequest in chrome.extension.sendRequest({"what": "match", "title": title}); is deprecated
chrome.pageAction.onClicked will not fire when you have "page_action": {"default_popup": "popup.html", …}, in your manifest.
chrome.extension.sendMessage will send it to all listeners (i.e. all my content scripts on all tabs), is an invalid assumption, it will send to Extension Pages.
I tried to read your question multiple times but couldn't understand what is you want to achieve, could you explain it?

Resources