mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
⚡ Add parameter include time when setting field type date on Notion node (#1879)
* ⚡ Add parameter include time when setting field type date Fixes issue #1878 * Fix issue with date format
This commit is contained in:
parent
b2e0bcea16
commit
d095588ac7
|
@ -339,6 +339,20 @@ export const databasePageFields = [
|
|||
default: false,
|
||||
description: 'Weather or not you want to define a date range.',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Time',
|
||||
name: 'includeTime',
|
||||
displayOptions: {
|
||||
show: {
|
||||
type: [
|
||||
'date',
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Weather or not to include the time in the date.',
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
|
@ -685,6 +699,20 @@ export const databasePageFields = [
|
|||
default: false,
|
||||
description: 'Weather or not you want to define a date range.',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Time',
|
||||
name: 'includeTime',
|
||||
displayOptions: {
|
||||
show: {
|
||||
type: [
|
||||
'date',
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Weather or not to include the time in the date.',
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
|
|
|
@ -270,15 +270,14 @@ function getPropertyKeyValue(value: any, type: string, timezone: string) {
|
|||
};
|
||||
break;
|
||||
case 'date':
|
||||
//&& value.dateStart !== 'Invalid date' && value.dateEnd !== 'Invalid date'
|
||||
const format = getDateFormat(value.includeTime);
|
||||
if (value.range === true) {
|
||||
result = {
|
||||
type: 'date', date: { start: moment.tz(value.dateStart, timezone).utc().format(), end: moment.tz(value.dateEnd, timezone).utc().format() },
|
||||
type: 'date', date: { start: moment.tz(value.dateStart, timezone).format(format), end: moment.tz(value.dateEnd, timezone).format(format) },
|
||||
};
|
||||
//if (value.date !== 'Invalid date')
|
||||
} else {
|
||||
result = {
|
||||
type: 'date', date: { start: moment.tz(value.date, timezone).utc().format(), end: null },
|
||||
type: 'date', date: { start: moment.tz(value.date, timezone).format(format), end: null },
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
@ -287,6 +286,13 @@ function getPropertyKeyValue(value: any, type: string, timezone: string) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function getDateFormat(includeTime: boolean) {
|
||||
if (includeTime === false) {
|
||||
return 'yyyy-MM-DD';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getNameAndType(key: string) {
|
||||
const [name, type] = key.split('|');
|
||||
return {
|
||||
|
|
|
@ -158,7 +158,7 @@ export class Notion implements INodeType {
|
|||
const databases = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body);
|
||||
for (const database of databases) {
|
||||
returnData.push({
|
||||
name: database.title[0].plain_text,
|
||||
name: database.title[0]?.plain_text || database.id,
|
||||
value: database.id,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue