How do I get the view_id of a pushed view when pushing it with a response_action - slack

I receive a submit callback from my first modal, and I push a new view unto the view stack using the response_action (which seems to be the only functioning way to do this from within a submit callback function.
let newView = {
response_action: 'push',
view: {
type: "modal",
title: {
type: "plain_text",
text: "Result",
emoji: true
},
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "Processing Request"
}
}
]
}
};
await ack(newView);
However, the ack function doesn't return anything. It appears I have no way of getting the view_id of this newly pushed view, which I need to update it at a later time when a long-running database query finishes.
Is there any way to get the view_id's of the view stack, or this newly pushed view?

Related

Slack Shortcut not working in my Bolt integration

I'm using this code snippet from the documentation to acknowledge a shortcut button click
app.shortcut('create-engagement', async ({ shortcut, ack, client }) => {
try {
// Acknowledge shortcut request
await ack();
// Call the views.open method using one of the built-in WebClients
const result = await client.views.open({
trigger_id: shortcut.trigger_id,
view: {
type: "modal",
title: {
type: "plain_text",
text: "My App"
},
close: {
type: "plain_text",
text: "Close"
},
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "About the simplest modal you could conceive of :smile:\n\nMaybe <https://api.slack.com/reference/block-kit/interactive-components|*make the modal interactive*> or <https://api.slack.com/surfaces/modals/using#modifying|*learn more advanced modal use cases*>."
}
},
{
type: "context",
elements: [
{
type: "mrkdwn",
text: "Psssst this modal was designed using <https://api.slack.com/tools/block-kit-builder|*Block Kit Builder*>"
}
]
}
]
}
});
console.log(result);
}
catch (error) {
console.error(error);
}
});
But I'm receiving the following error
[ERROR] bolt-app An incoming event was not acknowledged within 3 seconds. Ensure that the ack() argument is called in a listener.
My Request URL is the same as my working Event Subscription request URL with /slack/events at the end of the URL.
The above "create-engagement" in the listener is my Callback ID setup in the shortcuts section.
Any ideas?

Kendo grid adding another data source as object to model on save

So I’m working on learning Kendo in an effort to push our employer closer towards purchasing a few licenses for our new web development agenda.
I have an Core2 API set up and functioning on an internal web server and am attempting to use that to create an administration page for another application.
What would cause this (described below) to occur and what's the best way to handle it or what I'm attempting?
Setting up the grid and displays is done but having a problem getting data back to the API, correctly.
It seems to be an odd problem related to having drop down lists as the data source for 2 fields.
When the page first loads, the model matches that as defined in the data source schema.
schema: {
model: {
id: "id",
fields: {
projectName: { validation: { required: true, max: 150 } },
projectDescr: { validation: { required: true, max: 500 } },
projectOwner: { validation: { required: true, max: 125 } },
projectCoder: {type:"number", required:true, validation: { required: true }, from:"projectCoder"},
projectCoderNavigation: { from: "projectCoderNavigation", nullable:false},
projectEstHours: {type: "number", validation: {min: 0}},
statusId: { validation: { required: true }, from:"statusId"},
statusReason: { validation: { max: 125 },from:"statusReason" }
}
}
Kendo grid columns
columns: [
{field: "projectName", title: "Project Name"},
{field: "projectDescr", title: "Description", editor: descrEditor},
{field: "projectOwner", title: "Project Owner"},
{field: "projectCoder", title: "Programmer", editor: programmerDDL, template:"#= projectCoderNavigation.adName#" },
{field: "statusId", title:"Status", editor: statusDDL, template:"#= statusReason#"},
{field: "projectEstHours", title: "Estimated Hours"}
Model data returned from server (chrome dev tools). Here it matches above model, with the exception that the projectCoderNavigation property also includes projectTime, Tasks, and a repeat of projects.
When I click the add new record button, the model data is updated with blank data correctly.
However once I hit save, the model changes and a new object “adName” is added and matches the data source for the drop down list used for selection.
The projectCoder remains 0, projectCoderNavigation remains null, and the other fields are updated.
And of course, POST fails due to invalid model state.
EDIT
This is the function to populate the DDL editor.
function programmerDDL(container, options) {
// var input = $("<input/>");
//input.attr("projectCoderNavigation.adName",options.field);
// input.append(container);
$('<input type="text" class="k-input k-textbox" name="adName"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
//valuePrimitive: true,
dataTextField: "adName",
dataValueField: "id",
dataSource: usersListDs,
text: "Select someone"
});
}
This is assigning the editor to the dropdown.
{field: "projectCoder", title: "Programmer", editor: programmerDDL,
template:"#= projectCoderNavigation.adName#" },
Note:
I have managed to work it out so that I assign the projectCoder via the parameter map, but still have the empty projectCoderNavigation property and the unwanted "adName" object in the options.models.
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
console.log("model: "+options.models);
if (operation === "create") {
options.models[0].projectCoder = options.models[0].adName.id;
}
console.log(options.models);
console.log(kendo.stringify(options.models));
return options.models;
}
}
EDIT 2
So I've progressed to where I can verify the request is reaching the API and will probably close this question, but I'll provide more information first.
When save is clicked, the API receives the POST request. However, the data from the payload isn't used by the method.
The response is HTTP code 500, as the model was null and the insert failed due to foreign key constraints.
The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_att_projects_att_Users". The conflict occurred in database
"ASSIST_TimeTracking", table "dbo.att_users", column 'id'. The
statement has been terminated.

Setting Value programmatically in KendoUI multiselect

I have my KendoUI MultiSelect widget initialized like this:
$("#" + key).kendoMultiSelect({
placeholder: placeholder,
dataTextField: dataText,
dataValueField: dataValue,
filter: "contains",
autoBind: false,
dataSource: {
type: "jsonp",
transport: {
read: {
url: urlValue
}
},
error: function(e) {
console.log(e);
}
},
value: GetSavedJSONObject(key),
//value: [
//{ Name: "Chang", Id: 2 },
// { Name: "Uncle Bob's Organic Dried Pears", Id: 7 }
//],
select: removeMark,
change: multiselect_checkForChanges,
autoClose: isAutoClose
});
where GetSavedJSONObject(key) is an array of objects like this:
[Object { Id=1, Name="AA"}, Object { Id=2, Name="BB"}]
The issue I'm facing is when the page loads, I can see "AA" and "BB" in the multiselect widget and no call is made to the url. However, when I attempt to add more items to the widget, there are none to be added because the widget thinks the only items available are the items I specified in the "value" field of the widget during initialization.
In the Server Filtering demo, you will see that the example sets the value of the widget just like I did but when you try to add more items to the widget, then a call is made to the url for more data and the widget opens.
I'm sure this is user error but I just need some pointers on what to try next in order to get the widget to display the rest of the data.
EDIT:
When I made GetSavedJSONObject(key) return an array of the Ids so
[1,2,3]
I was able to click on the widget to get the rest of the data. However, the desired outcome is being able to set the values of the widget (because I have the Id/Name pairs) without having to make the call to the datasource and being able to click on the widget to fetch the rest of the data)
Keeping my array of Objects and setting the serverFiltering: true attribute fixed the issue. Hope this saves someone else time. sigh

KendoUI Image browser

I have added the KendoUI Image Browser to my application but when it opens up, I get the browser (upload, select, delete, sort, search...etc) but do not get the "Insert or Cancel" buttons... Nor do I get the "Web address" and "tooltip" bit at the bottom.
I'd like to have the whole image browser (I don't want to use the editor).
Any help would be appreciated.
Instead of this:
I get this:
Here is my code:
<div id="imgBrowser"></div>
$(document).ready(function () {
$("#imgBrowser").kendoImageBrowser({
//imageBrowser: {
messages: {
dropFilesHere: "Drop files here"
},
transport: {
read: "/ImageBrowser/Read",
destroy: {
url: "/ImageBrowser/Destroy",
type: "POST"
},
create: {
url: "/ImageBrowser/Create",
type: "POST"
},
thumbnailUrl: "/ImageBrowser/Thumbnail",
uploadUrl: "/ImageBrowser/Upload",
imageUrl: "/ImageBrowser/Image?path={0}"
},
change: function () {
//this.value(); //Selected image URL
console.log(this.value());
}
// }
});
});
It appears the ImageBrowser can technically be used outside of the Editor, but it is not officially supported. Here is a thread on the Telerik forum concerning this issue:
http://www.telerik.com/forums/why-not-make-image-browser-in-editor-as-separate-controle
Here are the most notable quotes:
You can initialize an image browser widget from a regular element. The configuration is the same as when using the image browser inside an Editor.
http://docs.kendoui.com/api/web/editor#imagebrowser-object
<div id="imgBrowser"></div>
$("#imgBrowser").kendoImageBrowser({
transport: {
read: "/service/ImageBrowser/Read",
destroy: {
url: "/service/ImageBrowser/Destroy",
type: "POST"
},
create: {
url: "/service/ImageBrowser/Create",
type: "POST"
},
thumbnailUrl: "/service/ImageBrowser/Thumbnail",
uploadUrl: "/service/ImageBrowser/Upload",
imageUrl: "/service/ImageBrowser/Image?path={0}"
}
});
The ImageBrowser exposes three events
change - when a file is clicked
apply - when a file is double-clicked
error - when a request fails
The change and apply events do not expose the clicked file, but you can find it out by checking which .k-tile element has a k-state-selected class.
The ImageBrowser does not expose an event related to folder navigation. You can get or set the current location with the widget's path() method.
The change and apply events do not expose the clicked file, but you can find it out by checking which .k-tile element has a k-state-selected class.
It's possible to get current selected item with something like this without checking for k-state-selected class:
change: function(е) {
var selectedImage = e.sender._selectedItem();
console.log('selectedImage', selectedImage);
}
I haven't checked it for apply event.

Sencha Touch fireEvent

I have a main panel that is comprised of sub panels and I would like to fire an event in the main panel and listen to it on the sub panel.
I can fire the event within the subpanel and everything works but i can't seem the fire the event from the main panel.
My namespace for the sub panel is "test.testCard" and I've tried to fire the event on it with no success.
Here is an example of how to do this:
Ext.setup({
onReady: function() {
var mainPanel = new Ext.Panel({
fullscreen: true,
layout: 'fit',
renderTo: Ext.getBody(),
listeners: {
'mycustomevent': function() {
alert('event fired!');
}
},
items: [
{
items: [
{
html: 'My inner panel'
},
{
xtype: 'button',
text: 'Click me!',
handler: function() {
mainPanel.fireEvent('mycustomevent', this);
}
}
]
}
]
});
}
});
You can see that I am creating a reference to mainPanel and then referencing it later in my code in the button handler, where I then call fireEvent with my custom event. Then in my mainPanel, I am adding a listener for mycustomevent.
And as previously noted, it is best to post on the Sencha Forums, as you will get a much faster response.

Resources