Whenever I try to add a variable to my dialog title, dialog.open does not work and no errors are thrown.
If I remove the variable from the title everything works fine, it is only when I add the variable to the title
I execute this before I define dialog
app.post('/create', function(req, res) {
var users = []
var {
text, trigger_id
} = req.body;
text = text.toUpperCase()
var issuetypes = []
axios({
method: 'get',
url: baseURL + 'project/' + text
}).then(function(response) {
for (var i = 0; i < response.data.issueTypes.length; i++) {
issuetypes.push({
label: response.data.issueTypes[i].name,
value: response.data.issueTypes[i].name
});
}
Does not work:
const dialog = {
token: botToken,
trigger_id,
dialog: JSON.stringify({
title: 'Create a new ' + text + ' Ticket',
callback_id: 'submit-ticket',
submit_label: 'Submit',
elements: [{
label: 'Project',
type: 'text',
name: 'project'
}, {
label: 'Summary',
type: 'text',
name: 'summary',
}, {
label: 'Description',
type: 'textarea',
name: 'description',
optional: true,
}, {
label: 'Type',
type: 'select',
name: 'type',
options: issuetypes,
}, {
label: 'Reporter',
type: 'select',
name: 'reporter',
optional: true,
options: [{
label: 'Reporter',
value: 'reporter'
}, ],
}, {
label: 'Link',
type: 'select',
name: 'epic',
optional: true,
options: [{
label: 'Epic',
value: 'epic'
}, ],
}, ],
}),
};
Works:
const dialog = {
token: botToken,
trigger_id,
dialog: JSON.stringify({
title: 'Create a new Ticket',
callback_id: 'submit-ticket',
submit_label: 'Submit',
elements: [{
label: 'Project',
type: 'text',
name: 'project'
}, {
label: 'Summary',
type: 'text',
name: 'summary',
}, {
label: 'Description',
type: 'textarea',
name: 'description',
optional: true,
}, {
label: 'Type',
type: 'select',
name: 'type',
options: issuetypes,
}, {
label: 'Reporter',
type: 'select',
name: 'reporter',
optional: true,
options: [{
label: 'Reporter',
value: 'reporter'
}, ],
}, {
label: 'Link',
type: 'select',
name: 'epic',
optional: true,
options: [{
label: 'Epic',
value: 'epic'
}, ],
}, ],
}),
};
Then I call dialog.open
axios.post("https://slack.com/api/dialog.open", qs.stringify(dialog))
.then(
(result) => {
res.send('');
}).catch(function(err) {
console.error(err);
})
}).catch(function(err) {
console.error(err);
})
});
Any ideas as to why dialog.open does not work?
The reason the Dialog is not shown when you have the variable in the title is that you exceed the maximum length of 24 chars for a title. (see here for reference)
You should however received the validation error from the API though as documented for the dialog.open method:
"The field `title` cannot be longer than 24 characters"
There must be another reason why you are not receiving it.
Related
I have to use the data I receive, in particular I have to be able to use the data in 'properties':
I don't understand how to call them, instead of console.log
I tried to use an Object.values(), but so I can't access the 'properties' data that I have to reuse later.
const response = await notion.databases.query({
database_id: databaseId,
page_size: 2
});
var effort_data = []
effort_data.push({
response
})
effort_data.map(data => {
Object.values(data.response.results).map((data) => {
console.log('data', data)
})
})
this is my response :
data {
object: 'page',
id: '3b8e203e-79ae-4ddc-ba3a-e0f5b30f4d4e',
created_time: '2023-01-25T13:51:00.000Z',
last_edited_time: '2023-01-25T13:59:00.000Z',
created_by: { object: 'user', id: '204c1b2e-0c59-4605-be45-de1fc9916416' },
last_edited_by: { object: 'user', id: '204c1b2e-0c59-4605-be45-de1fc9916416' },
cover: null,
icon: { type: 'emoji', emoji: '👽' },
parent: {
type: 'database_id',
database_id: '1b02ff59-8cdb-47fb-a6f9-5904bcecbe72'
},
archived: false,
properties: {
Assignees: { id: '%24v1Q', type: 'people', people: [] },
Type: { id: '9dB%5E', type: 'select', select: [Object] },
Progetti: {
id: '%3AirU',
type: 'relation',
relation: [Array],
has_more: false
},
Epics: { id: 'B%7BSE', type: 'relation', relation: [], has_more: false },
'Creato da': { id: 'D%5Dzr', type: 'created_by', created_by: [Object] },
'Flussi coinvolti': { id: 'EFdR', type: 'relation', relation: [], has_more: false },
'Sprint corrente?': { id: 'G%5Cvg', type: 'formula', formula: [Object] },
Sprint: { id: 'Jz.%40', type: 'multi_select', multi_select: [] },
'🏃 Sprint': { id: 'O%3DHc', type: 'relation', relation: [], has_more: false },
Settore: { id: 'XYh%5D', type: 'select', select: null },
Timeline: { id: '_G%2Bl', type: 'date', date: [Object] },
Tasks: {
id: 'bXv%3F',
type: 'relation',
relation: [Array],
has_more: false
},
'Data creazione': {
id: 'e_r%7D',
type: 'created_time',
created_time: '2023-01-25T13:51:00.000Z'
},
'Epic status': { id: 'nRGT', type: 'rollup', rollup: [Object] },
'Ultimo aggiornamento da': { id: 'ogbh', type: 'last_edited_by', last_edited_by: [Object] },
'Data ultimo aggiornamento': {
id: 'p%5CYK',
type: 'last_edited_time',
last_edited_time: '2023-01-25T13:59:00.000Z'
},
Priority: { id: '%7BMEq', type: 'select', select: [Object] },
Status: { id: '%7CF4-', type: 'select', select: [Object] },
Name: { id: 'title', type: 'title', title: [Array] }
},
url: 'https://www.notion.so/Endpoint-per-ordini-card-da-esterni-3b8e203e79ae4ddcba3ae0f5b30f4d4e'
}
I am following this toutorial: https://github.com/codeBelt/open-api-documentation/blob/master/src/openApiDocumentation.js
Can I validate my openApiDocumentation.js file somewhow? I get:
Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).
I am attaching mi .js file. Maybe you guys will see a typo here. Thanks in advance.
.js file:
const USER_TYPES = {
EXCHANGE: 'xxx',
GIVEAWAY: 'xxx'
}
const openApiDocumentation = {
openapi: '3.0.1',
info: {
version: '1.3.0',
title: 'xxx',
description: 'xxx',
contact: {
name: 'xxx',
email: 'xxx',
}
},
license: {
name: 'Apache 2.0',
url: 'https://www.apache.org/licenses/LICENSE-2.0.html',
},
servers: [
{
url: 'http://localhost:4000/',
description: 'Local server',
},
],
tags: [
{
name: 'Books CRUD operations',
},
],
paths: {
'/findAllBooks': {
get: {
tags: ['CRUD operations'],
description: 'Get all Book offers',
operationId: 'getUsers',
parameters: [
{
name: 'page',
in: 'query',
schema: {
type: 'integer',
default: 1,
},
required: true,
description: 'Page numer used pagination.',
},
],
responses: {
'200': {
description: 'Books were obtained',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Books',
},
},
},
},
'500': {
description: 'Missing parameters',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error',
},
example: {
message: 'page qyery parameter is missing',
internal_code: 'missing_parameters',
},
},
},
},
},
},
},
},
components: {
schemas: {
coverImg: {
type: 'string',
example: 'http:',
},
image: {
type: 'string',
example: 'http',
},
category: {
type: 'string',
example: 'Crafts & Hobbies',
},
linkTypes: {
type: 'object',
properties: {
coverImg: {
$ref: '#/components/schemas/coverImg',
},
images: {
type: 'array',
items: {
$ref: '#/components/schemas/image',
},
}
}
},
offerID: {
type: 'string',
example: '27301927',
},
userID: {
type: 'string',
example: 'efdc5192',
},
title: {
type: 'string',
example: 'Quilting For Dummies',
},
description: {
type: 'string',
example: 'You ',
},
categories: {
type: 'array',
items: {
$ref: '#/components/schemas/category',
},
},
links: {
type: 'object',
items: {
$ref: '#/components/schemas/linkTypes',
},
},
offerType: {
type: 'string',
enum: USER_TYPES,
default: USER_TYPES.EXCHANGE,
},
Book: {
type: 'object',
properties: {
offerID: {
$ref: '#/components/schemas/offerID',
},
userID: {
$ref: '#/components/schemas/userID',
},
title: {
$ref: '#/components/schemas/title',
},
description: {
$ref: '#/components/schemas/description',
},
categories: {
$ref: '#/components/schemas/categories',
},
imageLinks: {
$ref: '#/components/schemas/links',
},
offerType: {
$ref: '#/components/schemas/offerType',
},
},
},
Books: {
type: 'object',
properties: {
users: {
type: 'array',
items: {
$ref: '#/components/schemas/Book',
},
},
},
},
Error: {
type: 'object',
properties: {
message: {
type: 'string',
},
internal_code: {
type: 'string',
},
},
},
},
},
};
There are few mistakes,
license must be inside the info object
info: {
version: '1.3.0',
title: 'xxx',
description: 'xxx',
contact: {
name: 'xxx',
email: 'xxx' // make sure you have used valid email address!
},
license: {
name: 'Apache 2.0',
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
}
}
enum will allow only array not an object and here you have passed object USER_TYPES, corrected below:
const USER_TYPES = {
EXCHANGE: 'xxx',
GIVEAWAY: 'xxx'
};
const USER_TYPES_ENUM = [
USER_TYPES.EXCHANGE,
USER_TYPES.GIVEAWAY
];
offerType: {
type: 'string',
enum: USER_TYPES_ENUM,
default: USER_TYPES.EXCHANGE,
},
For best practice use https://editor.swagger.io/ (also they have provided a option to convert json to yaml under Edit > Convert to YAML)!
I tried to create a vcard via an API call. The following code shows,
var vcard = require('vcard-generator');
const vcardContent = vcard({
name: {
givenName: 'test',
middleName: '',
prefix: '',
suffix: '',
},
formattedNames: [{
text: '',
}],
nicknames: [{
text: '',
}],
works: [{
organization: 'AMT'
}],
emails: [{
type: 'work',
text: 'test#test.com',
}],
phones: [{
type: 'sms',
text: '+14035551515',
}, {
uri: 'sms://+14035551515',
}],
urls: [{
type: 'test1',
uri: 'https://test1.com',
}, {
type: 'test2',
uri: 'https://test2.com',
}],
});
console.log(vcardContent)
How can I write the above data as test.vcf file or any other npm available for handling vcard generation. And also I need to get the generated vcard via scaning QR code.
The Node.js fs package will allow you to write to the file system.
Writing to File System
var fs = require('fs');
var vcard = require('vcard-generator');
const vcardContent = vcard(
{
name: {
givenName: 'test',
middleName: '',
prefix: '',
suffix: '',
},
formattedNames: [{
text: '',
}],
nicknames: [{
text: '',
}],
works: [{
organization: 'AMT'
}],
emails: [{
type: 'work',
text: 'test#test.com',
}],
phones: [
{
type: 'sms',
text: '+14035551515',
},
{
uri: 'sms://+14035551515',
}
],
urls: [{
type: 'test1',
uri: 'https://test1.com',
}, {
type: 'test2',
uri: 'https://test2.com',
}],
});
fs.writeFile("/path/to/save/to", vardContent, function(err) {
if(err) {
return console.log(err);
}
console.log("Your vCard was saved!");
});
i am creating a form using formly there are two input text box and i want that both the text box should not be empty.How to set validation
my code is:
form: FormGroup = new FormGroup({});
userFields: FormlyFieldConfig = [{
className: 'row',
fieldGroup: [{
className: 'col-xs-6',
key: 'identity',
type: 'input',
templateOptions: {
validate: true,
required: true,
type: 'email',
label: 'Email address',
placeholder: 'Enter email',
}
}, {
className: 'col-xs-6',
key: 'password',
type: 'input',
templateOptions: {
validate: true,
required: true,
type: 'password',
label: 'Password',
placeholder: 'Password',
validationsCustom: 'validation.html'
}
}]
}];
You should include FormlyModule with some configuration to your AppModule. In your case, you should include error name required and message 'This field is required.'
For example:
import { FormlyModule } from '#ngx-formly/core';
#NgModule({
imports: [
FormlyModule.forRoot({
validationMessages: [
{ name: 'required', message: 'This field is required.' },
],
}),
],
})
export class AppModule {}
More information related to validation you can see there https://formly.dev/guide/validation
I am working with ExtJS MVC and implementing Scheduler.
I want to load my Store in my combo box but it was not load successfully.
My Store is
Ext.define('gantt.store.serviceStore', {
extend: 'Ext.data.Store',
model: 'gantt.model.Service',
storeId: 'serviceStore',
autoLoad: true,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: 'Event/Get'
},
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
encode: true,
writeAllFields: true,
root: 'data'
}
}
});
My Model is
Ext.define('gantt.model.Service', {
extend: 'Sch.model.Event',
fields: [{ name: 'ServiceId' },
{ name: 'ServiceName' },
{ name: 'Description' },
{ name: 'Rate' }
],
proxy: {
type: 'ajax',
api: {
read: 'Service/Get'
},
reader: {
type: 'json',
root: 'data'
},
writer: {
root: 'data',
type: 'json',
encode: true,
writeAllFields: true
}
}
});
and My ComboBox Code is below..
this.combo = new Ext.form.ComboBox({
id: 'statesCombo',
store: 'serviceStore',
displayField: 'ServiceName',
valueField: 'ServiceName',
hiddenName: 'ServiceId',
typeAhead: true,
mode: 'local',
fieldLabel: 'Services',
anchor: '100%',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Select a Service',
selectOnFocus: true })
My Problem is when I am Click on combo box my value is not loaded..
and didnt display any Error.
You're missing the "name" option... Like this:
name: 'ServiceName',