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)) {
|
||||
|
||||
@@ -137,6 +137,7 @@ export const addTemplateZone = async (data: any) => {
|
||||
const newWidget = await widgetSchema(organization).create({
|
||||
widgetID: widgetData.id,
|
||||
elementType: widgetData.type,
|
||||
zoneId: zoneId,
|
||||
widgetName: widgetData.widgetName || "Widget",
|
||||
panelID: addedExistingPanel._id,
|
||||
widgetside: widgetData.panel,
|
||||
|
||||
@@ -96,12 +96,13 @@ export const Widgetdelete = async (data: any) => {
|
||||
return { success: false, message: "Zone not found", organization: organization }
|
||||
const findWidget = await widgetSchema(organization).findOne({
|
||||
widgetID: widgetID,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findWidget)
|
||||
return { success: false, message: "Widget not found", organization: organization }
|
||||
const widgetData = await widgetSchema(organization).updateOne(
|
||||
{ _id: findWidget._id, isArchive: false },
|
||||
{ _id: findWidget._id, isArchive: false,zoneId: zoneId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
@@ -109,7 +110,9 @@ export const Widgetdelete = async (data: any) => {
|
||||
// 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,
|
||||
|
||||
});
|
||||
// console.log('widgets: ', widgets);
|
||||
// .sort({ widgetOrder: 1 });
|
||||
@@ -122,6 +125,7 @@ export const Widgetdelete = async (data: any) => {
|
||||
const panelData = await panelSchema(organization).findOne({
|
||||
_id: findWidget.panelID,
|
||||
isArchive: false,
|
||||
zoneId: zoneId
|
||||
});
|
||||
if (panelData.widgets.includes(findWidget._id)) {
|
||||
const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||
@@ -160,7 +164,7 @@ export const Widgetdelete = async (data: any) => {
|
||||
widgetDeleteDatas: formattedWidgets, zoneId: zoneId, zoneName: existingZone.zoneName
|
||||
|
||||
}
|
||||
// console.log("formattedWidgets",widgetData1);
|
||||
console.log("formattedWidgets",widgetData1);
|
||||
return { success: true, message: "Widget deleted successfully", data: widgetData1, organization: organization }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user