define('lead-split:views/lead/split-decision', ['action-handler'], (Dep) => {
return class extends Dep {
setup() {
super.setup();
console.log('Mass action for Leads initialized.');
}
launchUserSelect() {
console.log('Launching user selection modal for Leads.');
// Retrieve selected leads
const selectedLeads = this.model.get('ids'); // Assumes `ids` holds selected lead IDs
if (!selectedLeads || selectedLeads.length === 0) {
Espo.Ui.notify('No leads selected. Please select leads first.', 'warning');
return;
}
// Launch the user-selection modal
this.createView('userSelectionModal', 'lead-split:views/modal/user-selection', {
scope: 'User',
selectedLeadIds: selectedLeads, // Pass selected leads to the modal
onSubmit: (selectedUserIds) => {
if (!selectedUserIds || selectedUserIds.length === 0) {
Espo.Ui.notify('No users selected. Action canceled.', 'warning');
return;
}
console.log('Selected Leads:', selectedLeads);
console.log('Selected Users:', selectedUserIds);
// Send selected leads and users to the handler !! path might be wrong doublecheck!!
Espo.Ajax.postRequest('Espo/Modules/LeadSplit/Controllers/LeadController', {
leadIds: selectedLeads,
userIds: selectedUserIds
}).then((response) => {
Espo.Ui.notify(response.message, 'success');
this.updateListView(); // Refresh list view after action
}).catch((error) => {
console.error('Error distributing leads:', error);
Espo.Ui.notify('Failed to distribute leads.', 'error');
});
}
}).then((modalView) => {
modalView.render(); // Render the modal after it's created
});
}
afterRender() {
super.afterRender();
// Bind the button click to the `doSomething` function
this.$el.on('click', '.split-leads-button', () => {
this.launchUserSelect();
});
}
onRemove() {
super.onRemove();
// Clean up event listeners
this.$el.off('click', '.split-leads-button');
}
};
});
handler
{
"massActionList": [
"__APPEND__",
"Assign Users"
],
"checkAllResultMassActionList": [
"__APPEND__",
"Assign Users"
],
"massActionDefs": {
"handler": "lead-split:views/lead/record/split-decision",
"initFunction": "setup",
"actionFunction": "launchUserSelect"
}
}
WARNING: (404) Controller 'Undefined' does not exist. :: GET /undefined :: C:\xampp\htdocs\espocrm\application\Espo\Core\Api\ ControllerActionProcessor.php(189)
this error happens after i click massAction button i created, is there something im missing ?
return class extends Dep {
setup() {
super.setup();
console.log('Mass action for Leads initialized.');
}
launchUserSelect() {
console.log('Launching user selection modal for Leads.');
// Retrieve selected leads
const selectedLeads = this.model.get('ids'); // Assumes `ids` holds selected lead IDs
if (!selectedLeads || selectedLeads.length === 0) {
Espo.Ui.notify('No leads selected. Please select leads first.', 'warning');
return;
}
// Launch the user-selection modal
this.createView('userSelectionModal', 'lead-split:views/modal/user-selection', {
scope: 'User',
selectedLeadIds: selectedLeads, // Pass selected leads to the modal
onSubmit: (selectedUserIds) => {
if (!selectedUserIds || selectedUserIds.length === 0) {
Espo.Ui.notify('No users selected. Action canceled.', 'warning');
return;
}
console.log('Selected Leads:', selectedLeads);
console.log('Selected Users:', selectedUserIds);
// Send selected leads and users to the handler !! path might be wrong doublecheck!!
Espo.Ajax.postRequest('Espo/Modules/LeadSplit/Controllers/LeadController', {
leadIds: selectedLeads,
userIds: selectedUserIds
}).then((response) => {
Espo.Ui.notify(response.message, 'success');
this.updateListView(); // Refresh list view after action
}).catch((error) => {
console.error('Error distributing leads:', error);
Espo.Ui.notify('Failed to distribute leads.', 'error');
});
}
}).then((modalView) => {
modalView.render(); // Render the modal after it's created
});
}
afterRender() {
super.afterRender();
// Bind the button click to the `doSomething` function
this.$el.on('click', '.split-leads-button', () => {
this.launchUserSelect();
});
}
onRemove() {
super.onRemove();
// Clean up event listeners
this.$el.off('click', '.split-leads-button');
}
};
});
handler
{
"massActionList": [
"__APPEND__",
"Assign Users"
],
"checkAllResultMassActionList": [
"__APPEND__",
"Assign Users"
],
"massActionDefs": {
"handler": "lead-split:views/lead/record/split-decision",
"initFunction": "setup",
"actionFunction": "launchUserSelect"
}
}
WARNING: (404) Controller 'Undefined' does not exist. :: GET /undefined :: C:\xampp\htdocs\espocrm\application\Espo\Core\Api\ ControllerActionProcessor.php(189)
this error happens after i click massAction button i created, is there something im missing ?
Comment