Hello team,
just for win "1 click" .. it's possible to have print-to-pdf (see attachment) ?
Kinds regards
just for win "1 click" .. it's possible to have print-to-pdf (see attachment) ?
Kinds regards
{
"recordViews": {
"list": "custom:views/record/list-with-pdf"
}
}
Espo.define('custom:views/record/list-with-pdf', 'views/record/list', function (Dep) {
return Dep.extend({
rowActionsView: 'custom:views/record/row-actions/plus-pdf',
actionPrintPdf: function () {
this.createView('pdfTemplate', 'views/modals/select-template', {
entityType: this.entityType
}, function (view) {
view.render();
this.listenToOnce(view, 'select', function (model) {
this.clearView('pdfTemplate');
window.open('?entryPoint=pdf&entityType='+this.model.name+'&entityId='+this.model.id+'&templateId=' + model.id, '_blank');
}, this);
});
}
});
});
Espo.define('custom:views/record/row-actions/plus-pdf', 'views/record/row-actions/default', function (Dep) {
return Dep.extend({
getActionList: function () {
var list = [{
action: 'quickView',
label: 'View',
data: {
id: this.model.id
},
link: '#' + this.model.name + '/view/' + this.model.id
}];
if (this.options.acl.edit) {
list.push({
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
},
link: '#' + this.model.name + '/edit/' + this.model.id
});
}
if (this.options.acl.delete) {
list.push({
action: 'quickRemove',
label: 'Remove',
data: {
id: this.model.id
}
});
}
list.push({
action: 'printPdf',
label: 'Print Pdf',
data: {
entityId: this.model.id,
entityType: this.model.name
}
});
return list;
}
});
});

view.render();
console.log(data);
this.listenToOnce(view, 'select', function (model) {
this.clearView('pdfTemplate');
console.log(data);
window.open('?entryPoint=pdf&entityType='+data.entityType+'&entityId='+data.entityId+'&templateId=' + model.id, '_blank');
first console.log => action: "printPdf", entitytype: "MyEntity", entityid: "5e92dabbdfd5d7f22", el: "#select-modal-container-3436", factory:....
second condole.log => nothing
{
"relationshipPanels":
"opportunities": {
"rowActionsView": "custom:views/record/row-actions/plus-pdf",
"layout": "listForAccount"
}
}
?entryPoint=pdf&entityType=Template&entityId=5e8ef27d28900a2d3&templateId=5e8ef27d28900a2d3
this.createView('pdfTemplate', 'views/modals/select-template', {
entityType: this.entityType
}, function (view)
Uncaught TypeError: Cannot read properties of undefined (reading 'name')

"rowActionDefs": {
"print": {
"label": "Print",
"handler": "custom:handlers/list-row-action-print",
"acl": "edit"
}
},
"rowActionList": [
"print"
],
define('custom:handlers/list-row-action-print', ['action-handler','views/modal', 'model'], function (Dep) {
return Dep.extend({
isAvailable(model, action) {
return true;
},
process(model, action) {
if (action === 'print') {
this.print(model);
return;
}
},
print: function (model) {
this.view.createView('pdfTemplate', 'views/modals/select-template', {
entityType: model.entityType,
entityId: model.id,
model: model,
}, (view) => {
view.render();
view.listenToOnce(view, 'select', (model) => {
view.clearView('pdfTemplate');
window.open(
'?entryPoint=pdf&entityType=' +
view.model.entityType + '&entityId=' +
view.model.id + '&templateId=' + model.id, '_blank'
);
});
});
},
});
});

Comment