@ozdao/prometheus-framework 0.2.66 → 0.2.68

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/dist/community.server.js +3 -3
  2. package/dist/community.server.mjs +2 -2
  3. package/dist/events.server.js +3 -3
  4. package/dist/events.server.mjs +2 -2
  5. package/dist/main-BDrW8oeL.mjs +13755 -0
  6. package/dist/main-CNIKtifM.js +91 -0
  7. package/dist/main.css +1 -1
  8. package/dist/metadata.schema-BLGSCSmy.mjs +55 -0
  9. package/dist/metadata.schema-DWR97jhW.js +54 -0
  10. package/dist/ownership.schema-CGqscZIi.js +159 -0
  11. package/dist/ownership.schema-DtT2IgqC.mjs +160 -0
  12. package/dist/products.server.js +51 -15
  13. package/dist/products.server.mjs +51 -15
  14. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  15. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  16. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.cjs +1 -1
  17. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.js +55 -1
  18. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.cjs +1 -1
  19. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.js +1 -55
  20. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  21. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +40 -39
  22. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Field/Field.vue.js +7 -6
  24. package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Select/Select.vue.js +97 -1
  26. package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Select/Select.vue2.js +1 -97
  28. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.js +1 -45
  30. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.cjs +1 -1
  31. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.js +45 -1
  32. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  34. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
  38. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +5 -1
  39. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +66 -0
  40. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +1 -5
  41. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +0 -66
  42. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.js +1 -1
  44. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
  46. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +1 -1
  48. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +9 -8
  50. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
  52. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +1 -1
  54. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +59 -45
  56. package/dist/prometheus-framework/src/modules/globals/store/globals.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/globals/store/globals.js +5 -5
  58. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +1 -1
  60. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +1 -1
  64. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +1 -1
  66. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +1 -1
  68. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +1 -1
  70. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
  72. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +2 -2
  74. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.js +86 -56
  76. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
  78. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
  80. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  81. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +82 -67
  82. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  83. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +14 -14
  84. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  85. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
  86. package/dist/prometheus-framework/src/modules/products/store/leftovers.cjs +1 -1
  87. package/dist/prometheus-framework/src/modules/products/store/leftovers.js +10 -9
  88. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  89. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +1 -1
  90. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  91. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +1 -1
  92. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  93. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +24 -23
  94. package/dist/prometheus-framework.cjs.js +1 -1
  95. package/dist/prometheus-framework.es.js +1 -1
  96. package/dist/style.css +1 -1
  97. package/dist/web-6-zYDWMA.js +1 -0
  98. package/dist/web-TZtLKurO.mjs +54 -0
  99. package/package.json +1 -1
  100. package/src/modules/products/controllers/leftovers.controller.js +3 -3
  101. package/src/modules/products/models/leftover.model.js +2 -3
  102. package/src/modules/products/store/leftovers.js +4 -3
@@ -0,0 +1,55 @@
1
+ var common_schema = function applyCommonSchema(schema, db) {
2
+ schema.add({
3
+ status: {
4
+ type: String,
5
+ enum: ["draft", "published", "removed"],
6
+ default: "draft",
7
+ required: true
8
+ }
9
+ });
10
+ };
11
+ var engagement_schema = function applyEngagementSchema(schema, db) {
12
+ schema.add({ views: { type: Number, default: 0 } });
13
+ schema.post("aggregate", async function(docs) {
14
+ if (docs.length === 0)
15
+ return;
16
+ console.log("Post-aggregate hook in engagement schema triggered");
17
+ const model = this._model;
18
+ if (!model) {
19
+ console.error("No model is associated with this schema!");
20
+ return;
21
+ }
22
+ try {
23
+ await updateDocumentViews(docs, model);
24
+ } catch (error) {
25
+ console.error("Error updating views:", error);
26
+ }
27
+ });
28
+ async function updateDocumentViews(docs, model) {
29
+ const updateViewsPromises = docs.map((doc) => model.findOneAndUpdate(
30
+ { _id: doc._id },
31
+ { $inc: { views: 1 } }
32
+ ).exec());
33
+ await Promise.all(updateViewsPromises);
34
+ }
35
+ };
36
+ var metadata_schema = function applyMetadataSchema(schema, db) {
37
+ schema.add({
38
+ url: {
39
+ type: String,
40
+ required: true
41
+ },
42
+ tags: [{
43
+ type: String
44
+ }]
45
+ });
46
+ schema.index({
47
+ "url": 1,
48
+ "tags": 1
49
+ });
50
+ };
51
+ export {
52
+ common_schema as c,
53
+ engagement_schema as e,
54
+ metadata_schema as m
55
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var common_schema = function applyCommonSchema(schema, db) {
3
+ schema.add({
4
+ status: {
5
+ type: String,
6
+ enum: ["draft", "published", "removed"],
7
+ default: "draft",
8
+ required: true
9
+ }
10
+ });
11
+ };
12
+ var engagement_schema = function applyEngagementSchema(schema, db) {
13
+ schema.add({ views: { type: Number, default: 0 } });
14
+ schema.post("aggregate", async function(docs) {
15
+ if (docs.length === 0)
16
+ return;
17
+ console.log("Post-aggregate hook in engagement schema triggered");
18
+ const model = this._model;
19
+ if (!model) {
20
+ console.error("No model is associated with this schema!");
21
+ return;
22
+ }
23
+ try {
24
+ await updateDocumentViews(docs, model);
25
+ } catch (error) {
26
+ console.error("Error updating views:", error);
27
+ }
28
+ });
29
+ async function updateDocumentViews(docs, model) {
30
+ const updateViewsPromises = docs.map((doc) => model.findOneAndUpdate(
31
+ { _id: doc._id },
32
+ { $inc: { views: 1 } }
33
+ ).exec());
34
+ await Promise.all(updateViewsPromises);
35
+ }
36
+ };
37
+ var metadata_schema = function applyMetadataSchema(schema, db) {
38
+ schema.add({
39
+ url: {
40
+ type: String,
41
+ required: true
42
+ },
43
+ tags: [{
44
+ type: String
45
+ }]
46
+ });
47
+ schema.index({
48
+ "url": 1,
49
+ "tags": 1
50
+ });
51
+ };
52
+ exports.common_schema = common_schema;
53
+ exports.engagement_schema = engagement_schema;
54
+ exports.metadata_schema = metadata_schema;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ const require$$0 = require("mongoose");
3
+ const ObjectId = require$$0.Types.ObjectId;
4
+ function getBasicOptions(query) {
5
+ const { _id, url, status, type, owner, creator } = query;
6
+ const conditions = [];
7
+ if (_id) {
8
+ conditions.push({ _id: new ObjectId(_id) });
9
+ }
10
+ if (url) {
11
+ conditions.push({ url });
12
+ }
13
+ if (status) {
14
+ conditions.push({ status });
15
+ }
16
+ if (type) {
17
+ conditions.push({ type });
18
+ }
19
+ if (owner) {
20
+ conditions.push({ "owner.target": new ObjectId(owner) });
21
+ }
22
+ if (creator) {
23
+ conditions.push({ "creator.target": new ObjectId(creator) });
24
+ }
25
+ if (conditions.length > 0) {
26
+ return [{ $match: { $and: conditions } }];
27
+ } else {
28
+ return [];
29
+ }
30
+ }
31
+ function getTagsOptions(tags) {
32
+ if (tags && tags.length > 0) {
33
+ [{ $in: tags.split(",") }];
34
+ } else {
35
+ return [];
36
+ }
37
+ }
38
+ function getSortingOptions(param = "createdAt", order = "desc") {
39
+ let sort = {
40
+ [param]: order === "desc" ? -1 : 1,
41
+ "_id": 1
42
+ };
43
+ return [{ $sort: sort }];
44
+ }
45
+ function getPaginationOptions(skip, limit) {
46
+ let pagination = {
47
+ skip: parseInt(skip) || 0,
48
+ limit: parseInt(limit) || 20
49
+ };
50
+ return [{ $skip: pagination.skip }, { $limit: pagination.limit }];
51
+ }
52
+ function getCreatorUserLookupStage() {
53
+ return {
54
+ $lookup: {
55
+ from: "users",
56
+ localField: "creator.target",
57
+ foreignField: "_id",
58
+ as: "creatorUser"
59
+ }
60
+ };
61
+ }
62
+ function getCreatorOrganizationLookupStage() {
63
+ return {
64
+ $lookup: {
65
+ from: "organizations",
66
+ localField: "creator.target",
67
+ foreignField: "_id",
68
+ as: "creatorOrganization"
69
+ }
70
+ };
71
+ }
72
+ function getOwnerUserLookupStage() {
73
+ return {
74
+ $lookup: {
75
+ from: "users",
76
+ localField: "owner.target",
77
+ foreignField: "_id",
78
+ as: "ownerUser"
79
+ }
80
+ };
81
+ }
82
+ function getOwnerOrganizationLookupStage() {
83
+ return {
84
+ $lookup: {
85
+ from: "organizations",
86
+ localField: "owner.target",
87
+ foreignField: "_id",
88
+ as: "ownerOrganization"
89
+ }
90
+ };
91
+ }
92
+ function getAddFieldsCreatorOwnerStage() {
93
+ return {
94
+ $addFields: {
95
+ "creator.target": {
96
+ $cond: [
97
+ { $eq: ["$creator.type", "user"] },
98
+ { $arrayElemAt: ["$creatorUser", 0] },
99
+ { $arrayElemAt: ["$creatorOrganization", 0] }
100
+ ]
101
+ },
102
+ "owner.target": {
103
+ $cond: [
104
+ { $eq: ["$owner.type", "user"] },
105
+ { $arrayElemAt: ["$ownerUser", 0] },
106
+ { $arrayElemAt: ["$ownerOrganization", 0] }
107
+ ]
108
+ }
109
+ }
110
+ };
111
+ }
112
+ var queryProcessor = {
113
+ getBasicOptions,
114
+ getSortingOptions,
115
+ getPaginationOptions,
116
+ getTagsOptions,
117
+ // Creator and Owner
118
+ getCreatorUserLookupStage,
119
+ getCreatorOrganizationLookupStage,
120
+ getOwnerUserLookupStage,
121
+ getOwnerOrganizationLookupStage,
122
+ getAddFieldsCreatorOwnerStage
123
+ };
124
+ var ownership_schema = function applyOwnershipSchema(schema, db) {
125
+ schema.add({
126
+ owner: {
127
+ type: {
128
+ type: String,
129
+ required: true
130
+ },
131
+ target: {
132
+ type: db.mongoose.Schema.Types.ObjectId,
133
+ refPath: "owner.type",
134
+ required: true
135
+ }
136
+ },
137
+ creator: {
138
+ hidden: {
139
+ type: Boolean,
140
+ default: false
141
+ },
142
+ type: {
143
+ type: String,
144
+ required: true
145
+ },
146
+ target: {
147
+ type: db.mongoose.Schema.Types.ObjectId,
148
+ refPath: "creator.type",
149
+ required: true
150
+ }
151
+ }
152
+ });
153
+ schema.index({
154
+ "owner.target": 1,
155
+ "creator.target": 1
156
+ });
157
+ };
158
+ exports.ownership_schema = ownership_schema;
159
+ exports.queryProcessor = queryProcessor;
@@ -0,0 +1,160 @@
1
+ import require$$0 from "mongoose";
2
+ const ObjectId = require$$0.Types.ObjectId;
3
+ function getBasicOptions(query) {
4
+ const { _id, url, status, type, owner, creator } = query;
5
+ const conditions = [];
6
+ if (_id) {
7
+ conditions.push({ _id: new ObjectId(_id) });
8
+ }
9
+ if (url) {
10
+ conditions.push({ url });
11
+ }
12
+ if (status) {
13
+ conditions.push({ status });
14
+ }
15
+ if (type) {
16
+ conditions.push({ type });
17
+ }
18
+ if (owner) {
19
+ conditions.push({ "owner.target": new ObjectId(owner) });
20
+ }
21
+ if (creator) {
22
+ conditions.push({ "creator.target": new ObjectId(creator) });
23
+ }
24
+ if (conditions.length > 0) {
25
+ return [{ $match: { $and: conditions } }];
26
+ } else {
27
+ return [];
28
+ }
29
+ }
30
+ function getTagsOptions(tags) {
31
+ if (tags && tags.length > 0) {
32
+ [{ $in: tags.split(",") }];
33
+ } else {
34
+ return [];
35
+ }
36
+ }
37
+ function getSortingOptions(param = "createdAt", order = "desc") {
38
+ let sort = {
39
+ [param]: order === "desc" ? -1 : 1,
40
+ "_id": 1
41
+ };
42
+ return [{ $sort: sort }];
43
+ }
44
+ function getPaginationOptions(skip, limit) {
45
+ let pagination = {
46
+ skip: parseInt(skip) || 0,
47
+ limit: parseInt(limit) || 20
48
+ };
49
+ return [{ $skip: pagination.skip }, { $limit: pagination.limit }];
50
+ }
51
+ function getCreatorUserLookupStage() {
52
+ return {
53
+ $lookup: {
54
+ from: "users",
55
+ localField: "creator.target",
56
+ foreignField: "_id",
57
+ as: "creatorUser"
58
+ }
59
+ };
60
+ }
61
+ function getCreatorOrganizationLookupStage() {
62
+ return {
63
+ $lookup: {
64
+ from: "organizations",
65
+ localField: "creator.target",
66
+ foreignField: "_id",
67
+ as: "creatorOrganization"
68
+ }
69
+ };
70
+ }
71
+ function getOwnerUserLookupStage() {
72
+ return {
73
+ $lookup: {
74
+ from: "users",
75
+ localField: "owner.target",
76
+ foreignField: "_id",
77
+ as: "ownerUser"
78
+ }
79
+ };
80
+ }
81
+ function getOwnerOrganizationLookupStage() {
82
+ return {
83
+ $lookup: {
84
+ from: "organizations",
85
+ localField: "owner.target",
86
+ foreignField: "_id",
87
+ as: "ownerOrganization"
88
+ }
89
+ };
90
+ }
91
+ function getAddFieldsCreatorOwnerStage() {
92
+ return {
93
+ $addFields: {
94
+ "creator.target": {
95
+ $cond: [
96
+ { $eq: ["$creator.type", "user"] },
97
+ { $arrayElemAt: ["$creatorUser", 0] },
98
+ { $arrayElemAt: ["$creatorOrganization", 0] }
99
+ ]
100
+ },
101
+ "owner.target": {
102
+ $cond: [
103
+ { $eq: ["$owner.type", "user"] },
104
+ { $arrayElemAt: ["$ownerUser", 0] },
105
+ { $arrayElemAt: ["$ownerOrganization", 0] }
106
+ ]
107
+ }
108
+ }
109
+ };
110
+ }
111
+ var queryProcessor = {
112
+ getBasicOptions,
113
+ getSortingOptions,
114
+ getPaginationOptions,
115
+ getTagsOptions,
116
+ // Creator and Owner
117
+ getCreatorUserLookupStage,
118
+ getCreatorOrganizationLookupStage,
119
+ getOwnerUserLookupStage,
120
+ getOwnerOrganizationLookupStage,
121
+ getAddFieldsCreatorOwnerStage
122
+ };
123
+ var ownership_schema = function applyOwnershipSchema(schema, db) {
124
+ schema.add({
125
+ owner: {
126
+ type: {
127
+ type: String,
128
+ required: true
129
+ },
130
+ target: {
131
+ type: db.mongoose.Schema.Types.ObjectId,
132
+ refPath: "owner.type",
133
+ required: true
134
+ }
135
+ },
136
+ creator: {
137
+ hidden: {
138
+ type: Boolean,
139
+ default: false
140
+ },
141
+ type: {
142
+ type: String,
143
+ required: true
144
+ },
145
+ target: {
146
+ type: db.mongoose.Schema.Types.ObjectId,
147
+ refPath: "creator.type",
148
+ required: true
149
+ }
150
+ }
151
+ });
152
+ schema.index({
153
+ "owner.target": 1,
154
+ "creator.target": 1
155
+ });
156
+ };
157
+ export {
158
+ ownership_schema as o,
159
+ queryProcessor as q
160
+ };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
4
- const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
4
+ const ownership_schema = require("./ownership.schema-CGqscZIi.js");
5
5
  require("uuid");
6
6
  const require$$0 = require("mongoose");
7
7
  require("path");
@@ -200,6 +200,9 @@ var leftover_model = (db) => {
200
200
  order: {
201
201
  type: String
202
202
  },
203
+ comment: {
204
+ type: String
205
+ },
203
206
  store: {
204
207
  type: Object
205
208
  },
@@ -867,21 +870,53 @@ var categories_routes = function(app, db) {
867
870
  );
868
871
  };
869
872
  const categories_routes$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(categories_routes);
873
+ const queryProcessorGlobals = ownership_schema.queryProcessor;
870
874
  const controllerFactory$1 = (db) => {
871
875
  const Leftover = db.leftover;
872
- const getAll = async (req, res) => {
876
+ const read = async (req, res) => {
873
877
  try {
874
- let query = {};
875
- let options = {};
876
- if (req.query.organization) {
877
- query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
878
- }
879
- if (req.query.type) {
880
- query.type = req.query.type;
878
+ let matchConditions = [];
879
+ const search = req.query.search;
880
+ if (search) {
881
+ const parts = search.split(".");
882
+ let regexPattern = "";
883
+ if (parts.length === 2) {
884
+ regexPattern = parts.map((part) => part.substr(0, part.length - 1) + ".{1}").join("\\.");
885
+ } else {
886
+ regexPattern = search.substr(0, search.length - 1) + ".{1}";
887
+ }
888
+ matchConditions.push({
889
+ $or: [
890
+ { "comment ": { $regex: regexPattern, $options: "i" } },
891
+ { "positions.name": { $regex: regexPattern, $options: "i" } }
892
+ ]
893
+ });
881
894
  }
882
- console.log(query);
883
- const leftoveres = await Leftover.find(query, null, options).sort({ createdAt: "desc" }).exec();
884
- if (!leftoveres) {
895
+ const matchStage = matchConditions.length > 0 ? { $match: { $and: matchConditions } } : null;
896
+ let stages = [
897
+ ...queryProcessorGlobals.getBasicOptions(
898
+ req.query
899
+ ),
900
+ // For creator
901
+ queryProcessorGlobals.getCreatorUserLookupStage(),
902
+ queryProcessorGlobals.getCreatorOrganizationLookupStage(),
903
+ // For owner
904
+ queryProcessorGlobals.getOwnerUserLookupStage(),
905
+ queryProcessorGlobals.getOwnerOrganizationLookupStage(),
906
+ queryProcessorGlobals.getAddFieldsCreatorOwnerStage(),
907
+ ...matchStage != null ? [matchStage] : [],
908
+ // Pagination
909
+ ...queryProcessorGlobals.getSortingOptions(
910
+ req.query.sortParam,
911
+ req.query.sortOrder
912
+ ),
913
+ ...queryProcessorGlobals.getPaginationOptions(
914
+ req.query.skip,
915
+ req.query.limit
916
+ )
917
+ ];
918
+ const leftoveres = await Leftover.aggregate(stages).exec();
919
+ if (!leftoveres.length) {
885
920
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
886
921
  }
887
922
  res.status(200).send(leftoveres);
@@ -892,11 +927,12 @@ const controllerFactory$1 = (db) => {
892
927
  };
893
928
  const create = async (req, res) => {
894
929
  try {
895
- console.log(req.body);
930
+ console.log("order is", req.body.order);
896
931
  const leftover = await Leftover.create({
897
932
  organization: req.body.organization,
898
933
  type: req.body.type,
899
934
  order: req.body.order,
935
+ comment: req.body.comment,
900
936
  positions: req.body.positions,
901
937
  creator: req.body.creator,
902
938
  owner: req.body.owner
@@ -945,7 +981,7 @@ const controllerFactory$1 = (db) => {
945
981
  }
946
982
  };
947
983
  return {
948
- getAll,
984
+ read,
949
985
  create,
950
986
  get,
951
987
  update,
@@ -962,7 +998,7 @@ var leftovers_routes = function(app, db) {
962
998
  });
963
999
  app.get(
964
1000
  "/leftovers",
965
- controller.getAll
1001
+ controller.read
966
1002
  );
967
1003
  app.get(
968
1004
  "/leftovers/:_id",
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
- import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
2
+ import { o as ownership_schema, q as queryProcessor } from "./ownership.schema-DtT2IgqC.mjs";
3
3
  import "uuid";
4
4
  import require$$0 from "mongoose";
5
5
  import "path";
@@ -198,6 +198,9 @@ var leftover_model = (db) => {
198
198
  order: {
199
199
  type: String
200
200
  },
201
+ comment: {
202
+ type: String
203
+ },
201
204
  store: {
202
205
  type: Object
203
206
  },
@@ -865,21 +868,53 @@ var categories_routes = function(app, db) {
865
868
  );
866
869
  };
867
870
  const categories_routes$1 = /* @__PURE__ */ getDefaultExportFromCjs(categories_routes);
871
+ const queryProcessorGlobals = queryProcessor;
868
872
  const controllerFactory$1 = (db) => {
869
873
  const Leftover = db.leftover;
870
- const getAll = async (req, res) => {
874
+ const read = async (req, res) => {
871
875
  try {
872
- let query = {};
873
- let options = {};
874
- if (req.query.organization) {
875
- query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
876
- }
877
- if (req.query.type) {
878
- query.type = req.query.type;
876
+ let matchConditions = [];
877
+ const search = req.query.search;
878
+ if (search) {
879
+ const parts = search.split(".");
880
+ let regexPattern = "";
881
+ if (parts.length === 2) {
882
+ regexPattern = parts.map((part) => part.substr(0, part.length - 1) + ".{1}").join("\\.");
883
+ } else {
884
+ regexPattern = search.substr(0, search.length - 1) + ".{1}";
885
+ }
886
+ matchConditions.push({
887
+ $or: [
888
+ { "comment ": { $regex: regexPattern, $options: "i" } },
889
+ { "positions.name": { $regex: regexPattern, $options: "i" } }
890
+ ]
891
+ });
879
892
  }
880
- console.log(query);
881
- const leftoveres = await Leftover.find(query, null, options).sort({ createdAt: "desc" }).exec();
882
- if (!leftoveres) {
893
+ const matchStage = matchConditions.length > 0 ? { $match: { $and: matchConditions } } : null;
894
+ let stages = [
895
+ ...queryProcessorGlobals.getBasicOptions(
896
+ req.query
897
+ ),
898
+ // For creator
899
+ queryProcessorGlobals.getCreatorUserLookupStage(),
900
+ queryProcessorGlobals.getCreatorOrganizationLookupStage(),
901
+ // For owner
902
+ queryProcessorGlobals.getOwnerUserLookupStage(),
903
+ queryProcessorGlobals.getOwnerOrganizationLookupStage(),
904
+ queryProcessorGlobals.getAddFieldsCreatorOwnerStage(),
905
+ ...matchStage != null ? [matchStage] : [],
906
+ // Pagination
907
+ ...queryProcessorGlobals.getSortingOptions(
908
+ req.query.sortParam,
909
+ req.query.sortOrder
910
+ ),
911
+ ...queryProcessorGlobals.getPaginationOptions(
912
+ req.query.skip,
913
+ req.query.limit
914
+ )
915
+ ];
916
+ const leftoveres = await Leftover.aggregate(stages).exec();
917
+ if (!leftoveres.length) {
883
918
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
884
919
  }
885
920
  res.status(200).send(leftoveres);
@@ -890,11 +925,12 @@ const controllerFactory$1 = (db) => {
890
925
  };
891
926
  const create = async (req, res) => {
892
927
  try {
893
- console.log(req.body);
928
+ console.log("order is", req.body.order);
894
929
  const leftover = await Leftover.create({
895
930
  organization: req.body.organization,
896
931
  type: req.body.type,
897
932
  order: req.body.order,
933
+ comment: req.body.comment,
898
934
  positions: req.body.positions,
899
935
  creator: req.body.creator,
900
936
  owner: req.body.owner
@@ -943,7 +979,7 @@ const controllerFactory$1 = (db) => {
943
979
  }
944
980
  };
945
981
  return {
946
- getAll,
982
+ read,
947
983
  create,
948
984
  get,
949
985
  update,
@@ -960,7 +996,7 @@ var leftovers_routes = function(app, db) {
960
996
  });
961
997
  app.get(
962
998
  "/leftovers",
963
- controller.getAll
999
+ controller.read
964
1000
  );
965
1001
  app.get(
966
1002
  "/leftovers/:_id",
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("../Tooltip/Tooltip.vue.cjs"),c={class:"bg-grey pd-medium radius-medium"},a={class:"mn-b-small flex-v-center flex-nowrap flex"},s={key:0,class:"mn-r-thin t-medium p-big"},u=["onClick"],d=e.createElementVNode("p",{class:"bg-main radius-small t-center i-medium"},"i",-1),m={key:0,class:"w-100"},p={__name:"Block",props:{title:{type:String,default:null},tooltip:{type:String,default:null},actions:{type:Array,default:null},placeholder:{type:String,default:"Nothing here"},options:{type:Object,default:{theme:"white"}}},setup(t){e.useSlots();const r=(n,o={})=>n?n(o).some(l=>Array.isArray(l.children)?!!l.children.length:l.type!==e.Comment):!1;return(n,o)=>(e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",a,[t.title?(e.openBlock(),e.createElementBlock("p",s,e.toDisplayString(t.title),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.actions,l=>(e.openBlock(),e.createElementBlock("button",{onClick:l.function,class:"i-small pd-thin button-delete button"},e.toDisplayString(l.label),9,u))),256)),t.tooltip?(e.openBlock(),e.createBlock(i.default,{key:1,text:t.tooltip},{default:e.withCtx(()=>[d]),_:1},8,["text"])):e.createCommentVNode("",!0)]),r(n.$slots.default)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",m,e.toDisplayString(t.placeholder),1)),e.renderSlot(n.$slots,"default")]))}};exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("../Tooltip/Tooltip.vue2.cjs"),c={class:"bg-grey pd-medium radius-medium"},a={class:"mn-b-small flex-v-center flex-nowrap flex"},s={key:0,class:"mn-r-thin t-medium p-big"},u=["onClick"],d=e.createElementVNode("p",{class:"bg-main radius-small t-center i-medium"},"i",-1),m={key:0,class:"w-100"},p={__name:"Block",props:{title:{type:String,default:null},tooltip:{type:String,default:null},actions:{type:Array,default:null},placeholder:{type:String,default:"Nothing here"},options:{type:Object,default:{theme:"white"}}},setup(t){e.useSlots();const r=(n,o={})=>n?n(o).some(l=>Array.isArray(l.children)?!!l.children.length:l.type!==e.Comment):!1;return(n,o)=>(e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",a,[t.title?(e.openBlock(),e.createElementBlock("p",s,e.toDisplayString(t.title),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.actions,l=>(e.openBlock(),e.createElementBlock("button",{onClick:l.function,class:"i-small pd-thin button-delete button"},e.toDisplayString(l.label),9,u))),256)),t.tooltip?(e.openBlock(),e.createBlock(i.default,{key:1,text:t.tooltip},{default:e.withCtx(()=>[d]),_:1},8,["text"])):e.createCommentVNode("",!0)]),r(n.$slots.default)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",m,e.toDisplayString(t.placeholder),1)),e.renderSlot(n.$slots,"default")]))}};exports.default=p;
@@ -1,5 +1,5 @@
1
1
  import { useSlots as c, openBlock as l, createElementBlock as i, createElementVNode as a, toDisplayString as o, createCommentVNode as r, Fragment as d, renderList as m, createBlock as h, withCtx as f, renderSlot as p, Comment as y } from "vue";
2
- import g from "../Tooltip/Tooltip.vue.js";
2
+ import g from "../Tooltip/Tooltip.vue2.js";
3
3
  const b = { class: "bg-grey pd-medium radius-medium" }, k = { class: "mn-b-small flex-v-center flex-nowrap flex" }, S = {
4
4
  key: 0,
5
5
  class: "mn-r-thin t-medium p-big"
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("../FieldPhone/click-outside.cjs");require("./Dropdown.vue2.cjs");const u=require("../../../../_virtual/_plugin-vue_export-helper.cjs"),d={key:0},f={key:1},p={__name:"Dropdown",props:{label:{type:[String,Object],default:"Open"},align:{type:String,default:"left"}},setup(t){let n=c.default;const i=t,l=e.ref(!1),a=e.computed(()=>typeof i.label=="object");function s(){l.value=!1}return(r,o)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:"dropdown pos-relative",onClick:o[0]||(o[0]=e.withModifiers(m=>l.value=!l.value,["stop"]))},[a.value?(e.openBlock(),e.createElementBlock("div",d,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.label.component),{class:e.normalizeClass(t.label.class)},null,8,["class"]))])):(e.openBlock(),e.createElementBlock("div",f,e.toDisplayString(t.label),1)),e.createVNode(e.Transition,{name:"TransitionTranslateY",mode:"out-in"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{style:e.normalizeStyle({left:t.align==="left"?"0":"auto",right:t.align==="right"?"0":"auto"}),class:"dropdown-content w-15r radius-big"},[e.renderSlot(r.$slots,"default",{},void 0,!0)],4),[[e.vShow,l.value]])]),_:3})])),[[e.unref(n),s]])}},v=u.default(p,[["__scopeId","data-v-542fc6b9"]]);exports.default=v;