Creating a button??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macMonkey
    Junior Member
    • Nov 2024
    • 18

    Creating a button??

    this my file sttructure from the src file inside the ext-template repo which i cloned and modified:
    .
    ├── files
    │ ├── Espo
    │ │ └── Modules
    │ │ └── LeadManagement
    │ │ ├── Controllers
    │ │ │ └── LeadAssignmentController.php
    │ │ ├── Jobs
    │ │ │ └── LeadDistributionJob.php
    │ │ ├── Resources
    │ │ │ ├── i18n
    │ │ │ │ └── en_US.json
    │ │ │ └── metadata
    │ │ │ ├── clientDefs
    │ │ │ │ └── Lead.json
    │ │ │ └── routes.json
    │ │ └── Services
    │ │ └── LeadDistributionService.php
    │ └── client
    │ └── custom
    │ └── modules
    │ └── lead-management
    │ ├── res
    │ │ └── templates
    │ │ └── myLead
    │ │ └── assign-leads.tpl
    │ └── src
    │ └── views
    │ └── myLead
    │ ├── assign-leads.js
    │ └── list.js
    └── scripts
    ├── AfterInstall.php
    └── AfterUninstall.php

    im trying to make a button at mass action in lead page but i get this error on inspect element console using Espo.require('client/costum/modules/lead-management/src/views/myLead/assign-leads’); command :

    request URL:

    Request Method:
    GET
    Status Code:
    404 Not Found​

    these are my file codes:

    assign-leads.tpl

    <div class="modal-header">
    <h4 class="modal-title">Assign Leads to Users</h4>
    </div>
    <div class="modal-body">
    <table class="table">
    <thead>
    <tr>
    <th><input type="checkbox" id="selectAllUsers"></th>
    <th>Name</th>
    <th>Email</th>
    </tr>
    </thead>
    <tbody>
    {{#each users}}
    <tr>
    <td><input type="checkbox" class="user-checkbox" data-id="{{id}}"></td>
    <td>{{name}}</td>
    <td>{{email}}</td>
    </tr>
    {{/each}}
    </tbody>
    </table>
    </div>
    <div class="modal-footer">
    <button class="btn btn-primary" id="assignUsersButton">Assign</button>​

    assign-leads.js
    define('LeadManagement:views/myLead/assign-leads', ['view'], function (Dep) {
    return Dep.extend({
    template: 'lead-management.res.templates.lead.assign-leads', // Updated template path

    events: {
    'click #assignUsersButton': function () {
    this.assignLeads();
    },
    },

    data: function () {
    return {
    users: this.options.users
    };
    },

    assignLeads: function () {
    let selectedUserIds = [];
    this.$el.find('.user-checkbox:checked').each(function () {
    selectedUserIds.push($(this).data('id'));
    });

    if (selectedUserIds.length === 0) {
    this.notify('Please select at least one user.');
    return;
    }

    this.notify('Assigning leads...');
    this.action('LeadManagement:assignLeads', {
    leadIds: this.options.leadIds,
    userIds: selectedUserIds
    }).then(() => {
    this.notify('Leads assigned successfully.');
    this.close();
    });
    }
    });
    });​

    Lead.json
    {
    "massActions": {
    "assignLeads": {
    "label": "Assign Leads",
    "action": "client/costum/modules/lead-management/src/views/myLead/assign-leads"
    }
    },

    "views": {
    "list": "Espo:views/myLead/list"
    }
    }​
  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    Your path is “costum” instead of “custom” in several places, fix it.

    Comment

    Working...