Skip to content

Commit c115c7c

Browse files
fix: createdocument & createtemplate api not working properly
1 parent 416d8c8 commit c115c7c

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,35 +108,48 @@ export default async function createDocumentwithCoordinate(request, response) {
108108
'Signers',
109109
contact?.map(x => x.contactPtr)
110110
);
111-
let updatePlaceholders = contact.map(x => {
111+
let updatePlaceholders = contact.map((signer, index) => {
112+
const placeHolder = [];
113+
114+
for (const widget of signer.widgets) {
115+
const pageNumber = widget.page;
116+
const page = placeHolder.find(page => page.pageNumber === pageNumber);
117+
118+
const widgetData = {
119+
xPosition: widget.x,
120+
yPosition: widget.y,
121+
isStamp: widget.type === 'stamp',
122+
key: Math.floor(Math.random() * 10000),
123+
isDrag: false,
124+
firstXPos: widget.x,
125+
firstYPos: widget.y,
126+
yBottom: 0,
127+
scale: 1,
128+
isMobile: false,
129+
zIndex: 1,
130+
type: widget.type,
131+
widgetValue: '',
132+
Width: widget.w,
133+
Height: widget.h,
134+
};
135+
136+
if (page) {
137+
page.pos.push(widgetData);
138+
} else {
139+
placeHolder.push({
140+
pageNumber,
141+
pos: [widgetData],
142+
});
143+
}
144+
}
145+
112146
return {
113-
signerObjId: x?.contactPtr?.objectId,
114-
signerPtr: x?.contactPtr,
115-
Role: x.role,
116-
Id: randomId(),
117-
blockColor: color[x?.index],
118-
placeHolder: x.widgets.map((widget, i) => ({
119-
pageNumber: widget.page,
120-
pos: [
121-
{
122-
xPosition: widget.x,
123-
yPosition: widget.y,
124-
isStamp: widget.type === 'stamp' || widget.type === 'image' ? true : false,
125-
key: randomId(),
126-
isDrag: false,
127-
firstXPos: widget.x,
128-
firstYPos: widget.y,
129-
yBottom: 0,
130-
scale: 1,
131-
isMobile: false,
132-
zIndex: i + 1,
133-
type: widget.type,
134-
widgetValue: '',
135-
Width: widget.w,
136-
Height: widget.h,
137-
},
138-
],
139-
})),
147+
signerObjId: signer?.contactPtr?.objectId,
148+
signerPtr: signer?.contactPtr,
149+
Role: signer.role,
150+
Id: 3000 + index * 1000,
151+
blockColor: color[signer?.index],
152+
placeHolder,
140153
};
141154
});
142155
object.set('Placeholders', updatePlaceholders);

apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -113,39 +113,50 @@ export default async function createTemplatewithCoordinate(request, response) {
113113
updatedSigners?.map(x => x.contactPtr)
114114
);
115115
}
116-
let updatePlaceholders = contact.map(x => {
116+
let updatePlaceholders = contact.map((signer, index) => {
117+
const placeHolder = [];
118+
119+
for (const widget of signer.widgets) {
120+
const pageNumber = widget.page;
121+
const page = placeHolder.find(page => page.pageNumber === pageNumber);
122+
123+
const widgetData = {
124+
xPosition: widget.x,
125+
yPosition: widget.y,
126+
isStamp: widget.type === 'stamp',
127+
key: Math.floor(Math.random() * 10000),
128+
isDrag: false,
129+
firstXPos: widget.x,
130+
firstYPos: widget.y,
131+
yBottom: 0,
132+
scale: 1,
133+
isMobile: false,
134+
zIndex: 1,
135+
type: widget.type,
136+
widgetValue: '',
137+
Width: widget.w,
138+
Height: widget.h,
139+
};
140+
141+
if (page) {
142+
page.pos.push(widgetData);
143+
} else {
144+
placeHolder.push({
145+
pageNumber,
146+
pos: [widgetData],
147+
});
148+
}
149+
}
150+
117151
return {
118-
signerObjId: x?.contactPtr?.objectId || '',
119-
signerPtr: x?.contactPtr || {},
120-
Role: x.role,
121-
Id: randomId(),
122-
blockColor: color[x?.index],
123-
placeHolder: x.widgets.map((widget, i) => ({
124-
pageNumber: widget.page,
125-
pos: [
126-
{
127-
xPosition: widget.x,
128-
yPosition: widget.y,
129-
isStamp: widget.type === 'stamp' || widget.type === 'image' ? true : false,
130-
key: randomId(),
131-
isDrag: false,
132-
firstXPos: widget.x,
133-
firstYPos: widget.y,
134-
yBottom: 0,
135-
scale: 1,
136-
isMobile: false,
137-
zIndex: i + 1,
138-
type: widget.type,
139-
widgetValue: '',
140-
Width: widget.w,
141-
Height: widget.h,
142-
},
143-
],
144-
})),
152+
signerObjId: signer?.contactPtr?.objectId,
153+
signerPtr: signer?.contactPtr,
154+
Role: signer.role,
155+
Id: 3000 + index * 1000,
156+
blockColor: color[signer?.index],
157+
placeHolder,
145158
};
146159
});
147-
// console.log('updatePLacholders', updatePlaceholders);
148-
149160
object.set('Placeholders', updatePlaceholders);
150161
}
151162
if (folderId) {

0 commit comments

Comments
 (0)