Skip to content

Commit 647eb7d

Browse files
authored
Merging pull request #17980
* add support for images * pnpm-lock.yaml * pnpm-lock.yaml
1 parent 86f713b commit 647eb7d

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

components/pandadoc/actions/create-document-from-template/create-document-from-template.mjs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Create Document From Template",
66
description: "Create a Document from a PandaDoc Template. [See the documentation here](https://developers.pandadoc.com/reference/create-document-from-pandadoc-template)",
77
type: "action",
8-
version: "0.0.7",
8+
version: "0.0.8",
99
props: {
1010
app,
1111
name: {
@@ -52,7 +52,12 @@ export default {
5252
},
5353
async additionalProps() {
5454
const props = {};
55-
const { fields } = await this.app.getTemplate({
55+
if (!this.templateId) {
56+
return props;
57+
}
58+
const {
59+
fields, images,
60+
} = await this.app.getTemplate({
5661
templateId: this.templateId,
5762
});
5863
for (const field of fields) {
@@ -65,6 +70,15 @@ export default {
6570
optional: true,
6671
};
6772
}
73+
if (images?.length) {
74+
for (const image of images) {
75+
props[image.block_uuid] = {
76+
type: "string",
77+
label: `${image.name} URL`,
78+
optional: true,
79+
};
80+
}
81+
}
6882
return props;
6983
},
7084
methods: {
@@ -91,7 +105,9 @@ export default {
91105
} = this;
92106

93107
const fields = {};
94-
const { fields: items } = await this.app.getTemplate({
108+
const {
109+
fields: items, images: templateImages,
110+
} = await this.app.getTemplate({
95111
templateId: this.templateId,
96112
});
97113
for (const field of items) {
@@ -103,6 +119,20 @@ export default {
103119
};
104120
}
105121

122+
const images = [];
123+
if (templateImages?.length) {
124+
for (const image of templateImages) {
125+
if (this[image.block_uuid]) {
126+
images.push({
127+
name: image.name,
128+
urls: [
129+
this[image.block_uuid],
130+
],
131+
});
132+
}
133+
}
134+
}
135+
106136
const response = await this.app.createDocument({
107137
$,
108138
data: {
@@ -113,6 +143,7 @@ export default {
113143
recipients: this.parseToAnyArray(recipients),
114144
tokens: this.parseToAnyArray(tokens),
115145
fields,
146+
images,
116147
},
117148
});
118149

components/pandadoc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pandadoc",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Pipedream PandaDoc Components",
55
"main": "pandadoc.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)