template,widget delete bug updates

This commit is contained in:
2025-04-02 18:49:01 +05:30
parent 61d0a8c4ed
commit bc97dfa1ed
4 changed files with 14 additions and 4 deletions

View File

@@ -145,6 +145,7 @@ export class templateService {
const newWidget = await widgetSchema(organization).create({
widgetID: widgetData.id,
zoneId: zoneId,
elementType: widgetData.type,
widgetName: widgetData.widgetName || "Widget",
panelID: addedExistingPanel._id,

View File

@@ -95,15 +95,17 @@ export class widgetService {
static async deleteWidget(req: Request, res: Response): Promise<any> {
try {
const { widgetID, organization } = req.body;
const { widgetID, organization,zoneId} = req.body;
console.log(' req.body: ', req.body);
const findWidget = await widgetSchema(organization).findOne({
zoneId: zoneId,
widgetID: widgetID,
isArchive: false,
});
if (!findWidget)
return res.status(409).json({ message: "Widget not found" });
const widgetData = await widgetSchema(organization).updateOne(
{ _id: findWidget._id, isArchive: false },
{ _id: findWidget._id, isArchive: false,zoneId: zoneId },
{ $set: { isArchive: true } }
);
@@ -111,6 +113,7 @@ export class widgetService {
// Find all widgets in the same panel and sort them by widgetOrder
const widgets = await widgetSchema(organization).find({
panelID: findWidget.panelID,
zoneId: zoneId,
isArchive: false,
});
// .sort({ widgetOrder: 1 });
@@ -122,6 +125,7 @@ export class widgetService {
// }
const panelData = await panelSchema(organization).findOne({
_id: findWidget.panelID,
zoneId: zoneId,
isArchive: false,
});
if (panelData.widgets.includes(findWidget._id)) {