template,widget delete bug updates
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user