@lyxa.ai/core 1.0.263 → 1.0.265
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/mongo/models/banner.model.js +3 -72
- package/dist/libraries/mongo/models/banner.model.js.map +1 -1
- package/dist/libraries/mongo/models/cancellation-reason.model.d.ts +2 -2
- package/dist/libraries/mongo/models/cancellation-reason.model.js +12 -60
- package/dist/libraries/mongo/models/cancellation-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/dish.model.js +4 -22
- package/dist/libraries/mongo/models/dish.model.js.map +1 -1
- package/dist/libraries/mongo/models/faq.model.js +2 -21
- package/dist/libraries/mongo/models/faq.model.js.map +1 -1
- package/dist/libraries/mongo/models/filter-container.model.d.ts +1 -1
- package/dist/libraries/mongo/models/filter-container.model.js +11 -27
- package/dist/libraries/mongo/models/filter-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/list-container.model.d.ts +5 -3
- package/dist/libraries/mongo/models/list-container.model.js +25 -34
- package/dist/libraries/mongo/models/list-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/product.model.js +5 -23
- package/dist/libraries/mongo/models/product.model.js.map +1 -1
- package/dist/libraries/mongo/models/service-promotion.model.d.ts +1 -1
- package/dist/libraries/mongo/models/service-promotion.model.js +2 -2
- package/dist/libraries/mongo/models/service-promotion.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-category.model.js +4 -22
- package/dist/libraries/mongo/models/shop-category.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop.model.js +2 -32
- package/dist/libraries/mongo/models/shop.model.js.map +1 -1
- package/dist/libraries/mongo/models/support-reason.model.d.ts +2 -2
- package/dist/libraries/mongo/models/support-reason.model.js +10 -58
- package/dist/libraries/mongo/models/support-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/tag.model.js +3 -72
- package/dist/libraries/mongo/models/tag.model.js.map +1 -1
- package/dist/libraries/mongo/models/user-app-section-setting.model.js +6 -21
- package/dist/libraries/mongo/models/user-app-section-setting.model.js.map +1 -1
- package/dist/libraries/mongo/utilities/shopHooks.d.ts +9 -0
- package/dist/libraries/mongo/utilities/shopHooks.js +16 -0
- package/dist/libraries/mongo/utilities/shopHooks.js.map +1 -0
- package/dist/libraries/mongo/utilities/sortingOrderHooks.d.ts +14 -0
- package/dist/libraries/mongo/utilities/sortingOrderHooks.js +58 -0
- package/dist/libraries/mongo/utilities/sortingOrderHooks.js.map +1 -0
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/enum.d.ts +1 -1
- package/dist/types/utilities/enum.js +1 -1
- package/dist/types/utilities/enum.js.map +1 -1
- package/dist/types/utilities/validation/common-validation.js +1 -1
- package/dist/types/utilities/validation/common-validation.js.map +1 -1
- package/dist/utilities/enum.d.ts +1 -1
- package/dist/utilities/enum.js +1 -1
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/map.js +1 -1
- package/dist/utilities/map.js.map +1 -1
- package/dist/utilities/sorting.js +5 -1
- package/dist/utilities/sorting.js.map +1 -1
- package/dist/utilities/validation/common-validation.js +1 -1
- package/dist/utilities/validation/common-validation.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ const product_model_1 = require("./product.model");
|
|
|
18
18
|
const zone_model_1 = require("./zone.model");
|
|
19
19
|
const list_container_model_1 = require("./list-container.model");
|
|
20
20
|
const _1 = require(".");
|
|
21
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
21
22
|
let Banner = class Banner extends defaultClasses_1.TimeStamps {
|
|
22
23
|
title;
|
|
23
24
|
image;
|
|
@@ -94,81 +95,11 @@ __decorate([
|
|
|
94
95
|
exports.Banner = Banner = __decorate([
|
|
95
96
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'banners' } }),
|
|
96
97
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
const maxSortingOrder = await _1.BannerModel.aggregate([
|
|
100
|
-
{
|
|
101
|
-
$match: {
|
|
102
|
-
itemType: this.itemType,
|
|
103
|
-
status: enum_1.Status.ACTIVE,
|
|
104
|
-
deletedAt: null,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
$group: {
|
|
109
|
-
_id: null,
|
|
110
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
]).exec();
|
|
114
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
return next(error);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (this.isModified('status') && this.status === enum_1.Status.ACTIVE) {
|
|
121
|
-
const original = await _1.BannerModel.findById(this._id);
|
|
122
|
-
if (original && original.status !== enum_1.Status.ACTIVE) {
|
|
123
|
-
try {
|
|
124
|
-
const maxSortingOrder = await _1.BannerModel.aggregate([
|
|
125
|
-
{
|
|
126
|
-
$match: {
|
|
127
|
-
itemType: this.itemType,
|
|
128
|
-
status: enum_1.Status.ACTIVE,
|
|
129
|
-
deletedAt: null,
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
$group: {
|
|
134
|
-
_id: null,
|
|
135
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
]).exec();
|
|
139
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
return next(error);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
98
|
+
await sortingOrderHooks_1.handlePreSaveForSortingWithStatus.call(this, _1.BannerModel, { itemType: this.itemType });
|
|
146
99
|
next();
|
|
147
100
|
}),
|
|
148
101
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
149
|
-
|
|
150
|
-
if (update?.status === enum_1.Status.ACTIVE) {
|
|
151
|
-
const banner = await this.model.findOne(this.getQuery());
|
|
152
|
-
if (banner && banner.status !== enum_1.Status.ACTIVE) {
|
|
153
|
-
const maxSortingOrder = await _1.BannerModel.aggregate([
|
|
154
|
-
{
|
|
155
|
-
$match: {
|
|
156
|
-
itemType: banner.itemType,
|
|
157
|
-
status: enum_1.Status.ACTIVE,
|
|
158
|
-
deletedAt: null,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
$group: {
|
|
163
|
-
_id: null,
|
|
164
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
]).exec();
|
|
168
|
-
update.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
169
|
-
this.setUpdate(update);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
102
|
+
await sortingOrderHooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.BannerModel, ['itemType']);
|
|
172
103
|
next();
|
|
173
104
|
}),
|
|
174
105
|
(0, typegoose_1.index)({ title: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.model.js","sourceRoot":"/","sources":["libraries/mongo/models/banner.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAOiC;AACjC,6CAAoC;AACpC,mDAA0C;AAC1C,6CAAoC;AACpC,iEAAuD;AACvD,wBAAgC;
|
|
1
|
+
{"version":3,"file":"banner.model.js","sourceRoot":"/","sources":["libraries/mongo/models/banner.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAOiC;AACjC,6CAAoC;AACpC,mDAA0C;AAC1C,6CAAoC;AACpC,iEAAuD;AACvD,wBAAgC;AAEhC,sEAGwC;AAcjC,I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I,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;GACvE,MAAM,CA0ClB","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tBannerClickType,\n\tBannerLinkType,\n\tBannerUserType,\n\tItemType,\n\tStatus,\n\tUserAppSectionItemType,\n} from '../../../utilities/enum';\nimport { Shop } from './shop.model';\nimport { Product } from './product.model';\nimport { Zone } from './zone.model';\nimport { ListContainer } from './list-container.model';\nimport { BannerModel } from '.';\nimport { Query } from 'mongoose';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sortingOrderHooks';\n\n@modelOptions({ schemaOptions: { collection: 'banners' } })\n@pre<Banner>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, BannerModel, { itemType: this.itemType });\n\n\tnext();\n})\n@pre<Banner>('findOneAndUpdate', async function (this: Query<any, Banner>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, BannerModel, ['itemType']);\n\n\tnext();\n})\n@index({ title: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\nexport class Banner extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 50 })\n\tpublic title!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic image!: string;\n\n\t@prop({ required: true, type: String, enum: UserAppSectionItemType })\n\tpublic itemType!: UserAppSectionItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, enum: BannerUserType, default: BannerUserType.ALL })\n\tpublic visibility?: BannerUserType;\n\n\t@prop({ ref: () => Zone, default: [] })\n\tpublic zones?: Ref<Zone>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isClickable?: boolean;\n\n\t@prop({ type: String, enum: BannerClickType })\n\tpublic clickType?: BannerClickType;\n\n\t@prop({ type: String, enum: BannerLinkType })\n\tpublic linkType?: BannerLinkType;\n\n\t@prop({ type: String, trim: true })\n\tpublic link?: string;\n\n\t@prop({ ref: () => Shop })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ ref: () => Product })\n\tpublic product?: Ref<Product>;\n\n\t@prop({ ref: () => ListContainer })\n\tpublic listContainer?: Ref<ListContainer>;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
2
|
-
import {
|
|
2
|
+
import { CancellationReasonTypeEnum, Status } from '../../../utilities/enum';
|
|
3
3
|
export declare class CancellationReason extends TimeStamps {
|
|
4
4
|
reason: string;
|
|
5
5
|
reasonType: CancellationReasonTypeEnum;
|
|
6
|
-
status:
|
|
6
|
+
status: Status;
|
|
7
7
|
sortingOrder?: number;
|
|
8
8
|
}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
10
|
};
|
|
@@ -46,6 +13,8 @@ exports.CancellationReason = void 0;
|
|
|
46
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
47
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
48
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
|
+
const _1 = require(".");
|
|
17
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
49
18
|
let CancellationReason = class CancellationReason extends defaultClasses_1.TimeStamps {
|
|
50
19
|
reason;
|
|
51
20
|
reasonType;
|
|
@@ -62,41 +31,24 @@ __decorate([
|
|
|
62
31
|
__metadata("design:type", String)
|
|
63
32
|
], CancellationReason.prototype, "reasonType", void 0);
|
|
64
33
|
__decorate([
|
|
65
|
-
(0, typegoose_1.prop)({ required: true, enum: enum_1.
|
|
34
|
+
(0, typegoose_1.prop)({ required: true, enum: enum_1.Status }),
|
|
66
35
|
__metadata("design:type", String)
|
|
67
36
|
], CancellationReason.prototype, "status", void 0);
|
|
68
37
|
__decorate([
|
|
69
|
-
(0, typegoose_1.prop)(),
|
|
38
|
+
(0, typegoose_1.prop)({ type: Number }),
|
|
70
39
|
__metadata("design:type", Number)
|
|
71
40
|
], CancellationReason.prototype, "sortingOrder", void 0);
|
|
72
41
|
exports.CancellationReason = CancellationReason = __decorate([
|
|
73
42
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'cancellationReasons' } }),
|
|
74
43
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
deletedAt: null,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
$group: {
|
|
88
|
-
_id: null,
|
|
89
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
]).exec();
|
|
93
|
-
this.sortingOrder = (result?.maxSortingOrder ?? -1) + 1;
|
|
94
|
-
}
|
|
95
|
-
next();
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
next(error);
|
|
99
|
-
}
|
|
44
|
+
await sortingOrderHooks_1.handlePreSaveForSortingWithStatus.call(this, _1.CancellationReasonModel, {
|
|
45
|
+
reasonType: this.reasonType,
|
|
46
|
+
});
|
|
47
|
+
next();
|
|
48
|
+
}),
|
|
49
|
+
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
50
|
+
await sortingOrderHooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.CancellationReasonModel, ['reasonType']);
|
|
51
|
+
next();
|
|
100
52
|
})
|
|
101
53
|
], CancellationReason);
|
|
102
54
|
//# sourceMappingURL=cancellation-reason.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancellation-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cancellation-reason.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancellation-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cancellation-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAA6E;AAE7E,wBAA4C;AAC5C,sEAGwC;AAejC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,MAAM,CAAU;IAGhB,UAAU,CAA8B;IAGxC,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AAZY,gDAAkB;AAEvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACF;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,iCAA0B,EAAE,CAAC;;sDACZ;AAGxC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,aAAM,EAAE,CAAC;;kDAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDACM;6BAXjB,kBAAkB;IAb9B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;IACtE,IAAA,eAAG,EAAqB,MAAM,EAAE,KAAK,WAAW,IAAI;QACpD,MAAM,qDAAiC,CAAC,IAAI,CAAC,IAAI,EAAE,0BAAuB,EAAE;YAC3E,UAAU,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAqB,kBAAkB,EAAE,KAAK,WAAiD,IAAI;QACtG,MAAM,uDAAmC,CAAC,IAAI,CAAC,IAAI,EAAE,0BAAuB,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAE9F,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,kBAAkB,CAY9B","sourcesContent":["import { modelOptions, prop, pre } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CancellationReasonTypeEnum, Status } from '../../../utilities/enum';\nimport { Query } from 'mongoose';\nimport { CancellationReasonModel } from '.';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sortingOrderHooks';\n\n@modelOptions({ schemaOptions: { collection: 'cancellationReasons' } })\n@pre<CancellationReason>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, CancellationReasonModel, {\n\t\treasonType: this.reasonType,\n\t});\n\n\tnext();\n})\n@pre<CancellationReason>('findOneAndUpdate', async function (this: Query<any, CancellationReason>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, CancellationReasonModel, ['reasonType']);\n\n\tnext();\n})\nexport class CancellationReason extends TimeStamps {\n\t@prop({ required: true })\n\tpublic reason!: string;\n\n\t@prop({ required: true, enum: CancellationReasonTypeEnum })\n\tpublic reasonType!: CancellationReasonTypeEnum;\n\n\t@prop({ required: true, enum: Status })\n\tpublic status!: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -15,6 +15,7 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const shop_model_1 = require("./shop.model");
|
|
17
17
|
const _1 = require(".");
|
|
18
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
18
19
|
let Dish = class Dish extends defaultClasses_1.TimeStamps {
|
|
19
20
|
shop;
|
|
20
21
|
name;
|
|
@@ -82,28 +83,9 @@ exports.Dish = Dish = __decorate([
|
|
|
82
83
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'dishes' } }),
|
|
83
84
|
(0, typegoose_1.Index)({ shop: 1, deletedAt: 1 }),
|
|
84
85
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
$match: {
|
|
90
|
-
shop: this.shop,
|
|
91
|
-
deletedAt: null,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
$group: {
|
|
96
|
-
_id: null,
|
|
97
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
]).exec();
|
|
101
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return next(error);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
86
|
+
await sortingOrderHooks_1.handlePreSaveForSorting.call(this, _1.DishModel, {
|
|
87
|
+
shop: this.shop,
|
|
88
|
+
});
|
|
107
89
|
next();
|
|
108
90
|
})
|
|
109
91
|
], Dish);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dish.model.js","sourceRoot":"/","sources":["libraries/mongo/models/dish.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAAuD;AACvD,6CAAoC;AACpC,wBAA8B;
|
|
1
|
+
{"version":3,"file":"dish.model.js","sourceRoot":"/","sources":["libraries/mongo/models/dish.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;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,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oCAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;;+CACX;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACM;eAnCjB,IAAI;IAVhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC;IACzD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAChC,IAAA,eAAG,EAAO,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtC,MAAM,2CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAS,EAAE;YACnD,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAoChB","sourcesContent":["import { Index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { DishCategory } from '../../../utilities/enum';\nimport { Shop } from './shop.model';\nimport { DishModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sortingOrderHooks';\n\n@modelOptions({ schemaOptions: { collection: 'dishes' } })\n@Index({ shop: 1, deletedAt: 1 })\n@pre<Dish>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, DishModel, {\n\t\tshop: this.shop,\n\t});\n\n\tnext();\n})\nexport class Dish extends TimeStamps {\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ required: true, type: String, enum: DishCategory })\n\tpublic category!: DishCategory;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic ingredients?: string[];\n\n\t@prop({ required: true, type: Number })\n\tpublic calories!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic fat!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic fibers!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic protein!: number;\n\n\t@prop({ required: true, type: () => [Number] })\n\tpublic portionPercentage!: number[];\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -14,6 +14,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const _1 = require(".");
|
|
17
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
17
18
|
let Faq = class Faq extends defaultClasses_1.TimeStamps {
|
|
18
19
|
question;
|
|
19
20
|
answer;
|
|
@@ -45,27 +46,7 @@ __decorate([
|
|
|
45
46
|
exports.Faq = Faq = __decorate([
|
|
46
47
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'faqs' } }),
|
|
47
48
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
const maxSortingOrder = await _1.FaqModel.aggregate([
|
|
51
|
-
{
|
|
52
|
-
$match: {
|
|
53
|
-
deletedAt: null,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
$group: {
|
|
58
|
-
_id: null,
|
|
59
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
]).exec();
|
|
63
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
return next(error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
49
|
+
await sortingOrderHooks_1.handlePreSaveForSorting.call(this, _1.FaqModel);
|
|
69
50
|
next();
|
|
70
51
|
})
|
|
71
52
|
], Faq);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.model.js","sourceRoot":"/","sources":["libraries/mongo/models/faq.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAiE;AACjE,wBAA6B;
|
|
1
|
+
{"version":3,"file":"faq.model.js","sourceRoot":"/","sources":["libraries/mongo/models/faq.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAiE;AACjE,wBAA6B;AAC7B,sEAAyE;AASlE,IAAM,GAAG,GAAT,MAAM,GAAI,SAAQ,2BAAU;IAE3B,QAAQ,CAAU;IAGlB,MAAM,CAAU;IAGhB,WAAW,CAAkB;IAG7B,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AAfY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mCAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,qBAAc,EAAE,CAAC;;wCACX;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mCACxB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACM;cAdjB,GAAG;IAPf,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvD,IAAA,eAAG,EAAM,MAAM,EAAE,KAAK,WAAW,IAAI;QAErC,MAAM,2CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAQ,CAAC,CAAC;QAEnD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAef","sourcesContent":["import { modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { FaqAccountType, Status } from '../../../utilities/enum';\nimport { FaqModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sortingOrderHooks';\n\n@modelOptions({ schemaOptions: { collection: 'faqs' } })\n@pre<Faq>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, FaqModel);\n\n\tnext();\n})\nexport class Faq extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic question!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic answer!: string;\n\n\t@prop({ required: true, enum: FaqAccountType })\n\tpublic accountType!: FaqAccountType;\n\n\t@prop({ enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -14,13 +14,14 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const _1 = require(".");
|
|
17
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
17
18
|
let FilterContainer = class FilterContainer extends defaultClasses_1.TimeStamps {
|
|
18
19
|
name;
|
|
19
20
|
deals;
|
|
20
21
|
itemType;
|
|
21
22
|
status;
|
|
22
|
-
sortingOrder;
|
|
23
23
|
isVisible;
|
|
24
|
+
sortingOrder;
|
|
24
25
|
};
|
|
25
26
|
exports.FilterContainer = FilterContainer;
|
|
26
27
|
__decorate([
|
|
@@ -39,40 +40,23 @@ __decorate([
|
|
|
39
40
|
(0, typegoose_1.prop)({ type: String, enum: enum_1.Status, default: enum_1.Status.ACTIVE }),
|
|
40
41
|
__metadata("design:type", String)
|
|
41
42
|
], FilterContainer.prototype, "status", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
44
|
-
__metadata("design:type", Number)
|
|
45
|
-
], FilterContainer.prototype, "sortingOrder", void 0);
|
|
46
43
|
__decorate([
|
|
47
44
|
(0, typegoose_1.prop)({ type: Boolean, default: true }),
|
|
48
45
|
__metadata("design:type", Boolean)
|
|
49
46
|
], FilterContainer.prototype, "isVisible", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typegoose_1.prop)({ type: Number }),
|
|
49
|
+
__metadata("design:type", Number)
|
|
50
|
+
], FilterContainer.prototype, "sortingOrder", void 0);
|
|
50
51
|
exports.FilterContainer = FilterContainer = __decorate([
|
|
51
52
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'filterContainers' } }),
|
|
52
53
|
(0, typegoose_1.Index)({ itemType: 1, deletedAt: 1 }),
|
|
53
54
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
itemType: this.itemType,
|
|
60
|
-
deletedAt: null,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
$group: {
|
|
65
|
-
_id: null,
|
|
66
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
]).exec();
|
|
70
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return next(error);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
55
|
+
await sortingOrderHooks_1.handlePreSaveForSortingWithStatus.call(this, _1.FilterContainerModel, { itemType: this.itemType });
|
|
56
|
+
next();
|
|
57
|
+
}),
|
|
58
|
+
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
59
|
+
await sortingOrderHooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.FilterContainerModel, ['itemType']);
|
|
76
60
|
next();
|
|
77
61
|
})
|
|
78
62
|
], FilterContainer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/filter-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"filter-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/filter-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAAyE;AACzE,wBAAyC;AAEzC,sEAGwC;AAcjC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2BAAU;IAEvC,IAAI,CAAU;IAGd,KAAK,CAAY;IAGjB,QAAQ,CAA0B;IAGlC,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAlBY,0CAAe;AAEpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;8CACjB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAAsB,EAAE,CAAC;;iDACZ;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;+CACtC;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;kDACZ;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDACM;0BAjBjB,eAAe;IAZ3B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,kBAAkB,EAAE,EAAE,CAAC;IACnE,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpC,IAAA,eAAG,EAAkB,MAAM,EAAE,KAAK,WAAW,IAAI;QACjD,MAAM,qDAAiC,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEtG,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAkB,kBAAkB,EAAE,KAAK,WAA8C,IAAI;QAChG,MAAM,uDAAmC,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAoB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEzF,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,eAAe,CAkB3B","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status, UserAppSectionItemType } from '../../../utilities/enum';\nimport { FilterContainerModel } from '.';\nimport { Query } from 'mongoose';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sortingOrderHooks';\n\n@modelOptions({ schemaOptions: { collection: 'filterContainers' } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<FilterContainer>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, FilterContainerModel, { itemType: this.itemType });\n\n\tnext();\n})\n@pre<FilterContainer>('findOneAndUpdate', async function (this: Query<any, FilterContainer>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, FilterContainerModel, ['itemType']);\n\n\tnext();\n})\nexport class FilterContainer extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: [String] })\n\tpublic deals!: string[]; // e.g., \"5\", \"10\", \"20\", \"30\", \"double_menu\"\n\n\t@prop({ type: String, enum: UserAppSectionItemType })\n\tpublic itemType?: UserAppSectionItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Ref } from '@typegoose/typegoose';
|
|
2
2
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import {
|
|
3
|
+
import { ItemType, Status } from '../../../utilities/enum';
|
|
4
4
|
import { Shop } from './shop.model';
|
|
5
5
|
import { Tag } from './tag.model';
|
|
6
|
+
import { Zone } from './zone.model';
|
|
6
7
|
export declare class ListContainer extends TimeStamps {
|
|
7
8
|
name: string;
|
|
9
|
+
itemType: ItemType;
|
|
8
10
|
image: string;
|
|
9
11
|
banner: string;
|
|
12
|
+
zones?: Ref<Zone>[];
|
|
10
13
|
deals?: string[];
|
|
11
14
|
tags?: Ref<Tag>[];
|
|
12
15
|
shops?: Ref<Shop>[];
|
|
13
|
-
itemType?: UserAppSectionItemType;
|
|
14
16
|
status?: Status;
|
|
15
|
-
sortingOrder?: number;
|
|
16
17
|
isVisible: boolean;
|
|
18
|
+
sortingOrder?: number;
|
|
17
19
|
}
|
|
@@ -15,24 +15,31 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const shop_model_1 = require("./shop.model");
|
|
17
17
|
const tag_model_1 = require("./tag.model");
|
|
18
|
+
const zone_model_1 = require("./zone.model");
|
|
19
|
+
const sortingOrderHooks_1 = require("../utilities/sortingOrderHooks");
|
|
18
20
|
const _1 = require(".");
|
|
19
21
|
let ListContainer = class ListContainer extends defaultClasses_1.TimeStamps {
|
|
20
22
|
name;
|
|
23
|
+
itemType;
|
|
21
24
|
image;
|
|
22
25
|
banner;
|
|
26
|
+
zones;
|
|
23
27
|
deals;
|
|
24
28
|
tags;
|
|
25
29
|
shops;
|
|
26
|
-
itemType;
|
|
27
30
|
status;
|
|
28
|
-
sortingOrder;
|
|
29
31
|
isVisible;
|
|
32
|
+
sortingOrder;
|
|
30
33
|
};
|
|
31
34
|
exports.ListContainer = ListContainer;
|
|
32
35
|
__decorate([
|
|
33
|
-
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
36
|
+
(0, typegoose_1.prop)({ required: true, type: String, maxlength: 30 }),
|
|
34
37
|
__metadata("design:type", String)
|
|
35
38
|
], ListContainer.prototype, "name", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.ItemType }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], ListContainer.prototype, "itemType", void 0);
|
|
36
43
|
__decorate([
|
|
37
44
|
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
38
45
|
__metadata("design:type", String)
|
|
@@ -41,6 +48,10 @@ __decorate([
|
|
|
41
48
|
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
42
49
|
__metadata("design:type", String)
|
|
43
50
|
], ListContainer.prototype, "banner", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typegoose_1.prop)({ ref: () => zone_model_1.Zone, default: [] }),
|
|
53
|
+
__metadata("design:type", Array)
|
|
54
|
+
], ListContainer.prototype, "zones", void 0);
|
|
44
55
|
__decorate([
|
|
45
56
|
(0, typegoose_1.prop)({ type: () => [String], default: [] }),
|
|
46
57
|
__metadata("design:type", Array)
|
|
@@ -53,48 +64,28 @@ __decorate([
|
|
|
53
64
|
(0, typegoose_1.prop)({ ref: () => shop_model_1.Shop, default: [] }),
|
|
54
65
|
__metadata("design:type", Array)
|
|
55
66
|
], ListContainer.prototype, "shops", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.UserAppSectionItemType }),
|
|
58
|
-
__metadata("design:type", String)
|
|
59
|
-
], ListContainer.prototype, "itemType", void 0);
|
|
60
67
|
__decorate([
|
|
61
68
|
(0, typegoose_1.prop)({ enum: enum_1.Status, default: enum_1.Status.ACTIVE }),
|
|
62
69
|
__metadata("design:type", String)
|
|
63
70
|
], ListContainer.prototype, "status", void 0);
|
|
64
|
-
__decorate([
|
|
65
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
66
|
-
__metadata("design:type", Number)
|
|
67
|
-
], ListContainer.prototype, "sortingOrder", void 0);
|
|
68
71
|
__decorate([
|
|
69
72
|
(0, typegoose_1.prop)({ type: Boolean, default: true }),
|
|
70
73
|
__metadata("design:type", Boolean)
|
|
71
74
|
], ListContainer.prototype, "isVisible", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, typegoose_1.prop)({ type: Number }),
|
|
77
|
+
__metadata("design:type", Number)
|
|
78
|
+
], ListContainer.prototype, "sortingOrder", void 0);
|
|
72
79
|
exports.ListContainer = ListContainer = __decorate([
|
|
73
80
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'listContainers' } }),
|
|
74
|
-
(0, typegoose_1.
|
|
81
|
+
(0, typegoose_1.index)({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } }),
|
|
82
|
+
(0, typegoose_1.index)({ itemType: 1, deletedAt: 1 }),
|
|
75
83
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
itemType: this.itemType,
|
|
82
|
-
deletedAt: null,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
$group: {
|
|
87
|
-
_id: null,
|
|
88
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
]).exec();
|
|
92
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
return next(error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
84
|
+
await sortingOrderHooks_1.handlePreSaveForSortingWithStatus.call(this, _1.ListContainerModel, { itemType: this.itemType });
|
|
85
|
+
next();
|
|
86
|
+
}),
|
|
87
|
+
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
88
|
+
await sortingOrderHooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.ListContainerModel, ['itemType']);
|
|
98
89
|
next();
|
|
99
90
|
})
|
|
100
91
|
], ListContainer);
|