add notes field

This commit is contained in:
Flatlogic Bot 2025-06-02 18:43:34 +00:00
parent 8da67a15cb
commit 61545f3be9
19 changed files with 140 additions and 58 deletions

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@ module.exports = class LeadsDBApi {
country: data.country || null,
company_size: data.company_size || null,
conversion_likelihood: data.conversion_likelihood || null,
notes: data.notes || null,
importHash: data.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -51,6 +52,7 @@ module.exports = class LeadsDBApi {
country: item.country || null,
company_size: item.company_size || null,
conversion_likelihood: item.conversion_likelihood || null,
notes: item.notes || null,
importHash: item.importHash || null,
createdById: currentUser.id,
updatedById: currentUser.id,
@ -85,6 +87,8 @@ module.exports = class LeadsDBApi {
if (data.conversion_likelihood !== undefined)
updatePayload.conversion_likelihood = data.conversion_likelihood;
if (data.notes !== undefined) updatePayload.notes = data.notes;
updatePayload.updatedById = currentUser.id;
await leads.update(updatePayload, { transaction });
@ -272,6 +276,13 @@ module.exports = class LeadsDBApi {
};
}
if (filter.notes) {
where = {
...where,
[Op.and]: Utils.ilike('leads', 'notes', filter.notes),
};
}
if (filter.conversion_likelihoodRange) {
const [start, end] = filter.conversion_likelihoodRange;

View File

@ -0,0 +1,47 @@
module.exports = {
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async up(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.addColumn(
'leads',
'notes',
{
type: Sequelize.DataTypes.TEXT,
},
{ transaction },
);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
/**
* @param {QueryInterface} queryInterface
* @param {Sequelize} Sequelize
* @returns {Promise<void>}
*/
async down(queryInterface, Sequelize) {
/**
* @type {Transaction}
*/
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.removeColumn('leads', 'notes', { transaction });
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
},
};

View File

@ -36,6 +36,10 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.DECIMAL,
},
notes: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,

View File

@ -47,16 +47,6 @@ const CampaignsData = [
// type code here for "relation_many" field
},
{
title: 'Year-End Bonanza',
start_date: new Date('2023-11-01T00:00:00Z'),
end_date: new Date('2023-11-30T23:59:59Z'),
// type code here for "relation_many" field
},
];
const LeadsData = [
@ -67,13 +57,15 @@ const LeadsData = [
country: 'USA',
company_size: 'Small',
company_size: 'Medium',
conversion_likelihood: 0.75,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Arthur Eddington',
},
{
@ -83,13 +75,15 @@ const LeadsData = [
country: 'Canada',
company_size: 'Small',
company_size: 'Medium',
conversion_likelihood: 0.6,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Max von Laue',
},
{
@ -99,13 +93,15 @@ const LeadsData = [
country: 'UK',
company_size: 'Medium',
company_size: 'Large',
conversion_likelihood: 0.85,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Max von Laue',
},
{
@ -122,22 +118,8 @@ const LeadsData = [
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
name: 'Soylent Corp',
contact: 'frank.thorn@soylent.com',
country: 'Australia',
company_size: 'Small',
conversion_likelihood: 0.55,
// type code here for "relation_one" field
// type code here for "relation_one" field
notes: 'Edward Teller',
},
];
@ -165,12 +147,6 @@ const StagesData = [
order: 4,
},
{
name: 'Negotiation',
order: 5,
},
];
// Similar logic for "relation_many"
@ -221,17 +197,6 @@ async function associateLeadWithStage() {
if (Lead3?.setStage) {
await Lead3.setStage(relatedStage3);
}
const relatedStage4 = await Stages.findOne({
offset: Math.floor(Math.random() * (await Stages.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Lead4?.setStage) {
await Lead4.setStage(relatedStage4);
}
}
async function associateLeadWithOwner() {
@ -278,17 +243,6 @@ async function associateLeadWithOwner() {
if (Lead3?.setOwner) {
await Lead3.setOwner(relatedOwner3);
}
const relatedOwner4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Lead4 = await Leads.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Lead4?.setOwner) {
await Lead4.setOwner(relatedOwner4);
}
}
module.exports = {

View File

@ -29,6 +29,9 @@ router.use(checkCrudPermissions('leads'));
* country:
* type: string
* default: country
* notes:
* type: string
* default: notes
* conversion_likelihood:
* type: integer
@ -315,6 +318,7 @@ router.get(
'name',
'contact',
'country',
'notes',
'conversion_likelihood',
];

View File

@ -45,7 +45,7 @@ module.exports = class SearchService {
campaigns: ['title'],
leads: ['name', 'contact', 'country'],
leads: ['name', 'contact', 'country', 'notes'],
stages: ['name'],
};

View File

@ -144,6 +144,13 @@ const CardLeads = ({
</div>
</dd>
</div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>Notes</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>{item.notes}</div>
</dd>
</div>
</dl>
</li>
))}

View File

@ -93,6 +93,11 @@ const ListLeads = ({
{dataFormatter.usersOneListFormatter(item.owner)}
</p>
</div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Notes</p>
<p className={'line-clamp-2'}>{item.notes}</p>
</div>
</Link>
<ListActionsPopover
onDelete={onDelete}

View File

@ -140,6 +140,18 @@ export const loadColumns = async (
params?.value?.id ?? params?.value,
},
{
field: 'notes',
headerName: 'Notes',
flex: 1,
minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
},
{
field: 'actions',
type: 'actions',

View File

@ -116,6 +116,8 @@ const CampaignsView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -139,6 +141,8 @@ const CampaignsView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>

View File

@ -49,6 +49,8 @@ const EditLeads = () => {
stage: null,
owner: null,
notes: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -153,6 +155,10 @@ const EditLeads = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -49,6 +49,8 @@ const EditLeadsPage = () => {
stage: null,
owner: null,
notes: '',
};
const [initialValues, setInitialValues] = useState(initVals);
@ -151,6 +153,10 @@ const EditLeadsPage = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -32,6 +32,7 @@ const LeadsTablesPage = () => {
{ label: 'Name', title: 'name' },
{ label: 'Contact', title: 'contact' },
{ label: 'Country', title: 'country' },
{ label: 'Notes', title: 'notes' },
{
label: 'ConversionLikelihood',

View File

@ -46,6 +46,8 @@ const initialValues = {
stage: '',
owner: '',
notes: '',
};
const LeadsNew = () => {
@ -125,6 +127,10 @@ const LeadsNew = () => {
></Field>
</FormField>
<FormField label='Notes'>
<Field name='notes' placeholder='Notes' />
</FormField>
<BaseDivider />
<BaseButtons>
<BaseButton type='submit' color='info' label='Submit' />

View File

@ -32,6 +32,7 @@ const LeadsTablesPage = () => {
{ label: 'Name', title: 'name' },
{ label: 'Contact', title: 'contact' },
{ label: 'Country', title: 'country' },
{ label: 'Notes', title: 'notes' },
{
label: 'ConversionLikelihood',

View File

@ -91,6 +91,11 @@ const LeadsView = () => {
<p>{leads?.owner?.firstName ?? 'No data'}</p>
</div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Notes</p>
<p>{leads?.notes}</p>
</div>
<BaseDivider />
<BaseButton

View File

@ -83,6 +83,8 @@ const StagesView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -106,6 +108,8 @@ const StagesView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>

View File

@ -157,6 +157,8 @@ const UsersView = () => {
<th>CompanySize</th>
<th>ConversionLikelihood</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@ -180,6 +182,8 @@ const UsersView = () => {
<td data-label='conversion_likelihood'>
{item.conversion_likelihood}
</td>
<td data-label='notes'>{item.notes}</td>
</tr>
))}
</tbody>