@ozdao/prometheus-framework 0.2.51 → 0.2.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/dist/main-0a2437f4.js +91 -0
  2. package/dist/main-482dc398.mjs +13626 -0
  3. package/dist/main-4fnApBsF.js +91 -0
  4. package/dist/main-b2JI9sFg.js +91 -0
  5. package/dist/main-c56d4c09.js +91 -0
  6. package/dist/main-cdd0be68.mjs +13628 -0
  7. package/dist/main-kjbLXQEa.mjs +13606 -0
  8. package/dist/main-x-9D8zvb.mjs +13604 -0
  9. package/dist/main.css +1 -1
  10. package/dist/organizations.server.js +2 -2
  11. package/dist/organizations.server.mjs +2 -2
  12. package/dist/products.server.js +81 -56
  13. package/dist/products.server.mjs +81 -56
  14. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  15. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +18 -20
  16. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  17. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +19 -19
  18. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  19. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +28 -26
  20. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
  21. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.js +2 -2
  22. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Map/Map.vue.js +35 -2
  24. package/dist/prometheus-framework/src/components/Map/Map.vue2.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Map/Map.vue2.js +2 -35
  26. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  28. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -0
  29. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +37 -0
  30. package/dist/prometheus-framework/src/modules/icons/entities/IconShopcart.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/icons/entities/IconShopcart.vue.js +21 -14
  32. package/dist/prometheus-framework/src/modules/icons/navigation/IconSearch.vue.cjs +1 -0
  33. package/dist/prometheus-framework/src/modules/icons/navigation/IconSearch.vue.js +24 -0
  34. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +2 -11
  38. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +11 -2
  40. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +49 -101
  42. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +25 -25
  43. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +68 -39
  45. package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.js +38 -48
  47. package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.cjs +1 -1
  48. package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.js +69 -62
  49. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +131 -126
  51. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +1 -1
  53. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +117 -146
  55. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.js +13 -13
  57. package/dist/prometheus-framework/src/modules/organizations/router/products.router.cjs +1 -1
  58. package/dist/prometheus-framework/src/modules/organizations/router/products.router.js +22 -0
  59. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.cjs +1 -0
  60. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.js +45 -0
  61. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue2.cjs +1 -0
  62. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue2.js +4 -0
  63. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -0
  64. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +79 -0
  65. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -0
  66. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +193 -0
  67. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue2.cjs +1 -0
  68. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue2.js +4 -0
  69. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +43 -43
  71. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +65 -55
  73. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +64 -51
  75. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +35 -33
  77. package/dist/prometheus-framework/src/modules/products/products.client.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/products/products.client.js +2 -2
  79. package/dist/prometheus-framework/src/modules/products/store/categories.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/products/store/categories.js +39 -27
  81. package/dist/prometheus-framework/src/modules/products/store/products.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/products/store/products.js +23 -23
  83. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +1 -1
  87. package/dist/prometheus-framework.cjs.js +1 -1
  88. package/dist/prometheus-framework.es.js +1 -1
  89. package/dist/style.css +1 -1
  90. package/dist/web-0066fd51.mjs +55 -0
  91. package/dist/web-6b9fa713.js +1 -0
  92. package/dist/web-6dcbb74b.mjs +55 -0
  93. package/dist/web-caJAdsxy.js +1 -0
  94. package/dist/web-ee302c1d.js +1 -0
  95. package/dist/web-i08OVMw9.mjs +55 -0
  96. package/dist/web-ngl7bNhF.js +1 -0
  97. package/dist/web-t91TrxXa.mjs +55 -0
  98. package/package.json +1 -1
  99. package/src/components/Button/Button.vue +4 -6
  100. package/src/components/Feed/Feed.vue +2 -1
  101. package/src/components/Field/Field.vue +3 -1
  102. package/src/components/LocationMarker/LocationMarker.vue +1 -0
  103. package/src/modules/applications/applications.client.js +0 -1
  104. package/src/modules/globals/components/blocks/BlockSearch.vue +42 -0
  105. package/src/modules/icons/entities/IconProfile.vue +10 -1
  106. package/src/modules/icons/entities/IconShopcart.vue +12 -2
  107. package/src/modules/marketplace/components/layouts/Marketplace.vue +7 -14
  108. package/src/modules/marketplace/components/sections/Filters.vue +7 -1
  109. package/src/modules/mobile/components/NavigationBar/NavigationBar.vue +27 -7
  110. package/src/modules/orders/components/partials/ShopCart.vue +4 -1
  111. package/src/modules/organizations/components/blocks/CardDepartment.vue +34 -66
  112. package/src/modules/organizations/components/blocks/DepartmentMemberModify.vue +50 -13
  113. package/src/modules/organizations/components/blocks/User.vue +18 -9
  114. package/src/modules/organizations/components/pages/Department.vue +19 -3
  115. package/src/modules/organizations/components/pages/DepartmentEdit.vue +14 -10
  116. package/src/modules/organizations/components/pages/Organization.vue +38 -71
  117. package/src/modules/organizations/components/sections/Feed.vue +1 -1
  118. package/src/modules/organizations/controllers/memberships.controller.js +2 -2
  119. package/src/modules/organizations/controllers/organizations.controller.js +0 -1
  120. package/src/modules/organizations/router/products.router.js +24 -4
  121. package/src/modules/products/components/blocks/CardCategory.vue +53 -0
  122. package/src/modules/products/components/pages/Categories.vue +90 -0
  123. package/src/modules/products/components/pages/CategoryEdit.vue +214 -0
  124. package/src/modules/products/components/pages/EditLeftover.vue +6 -4
  125. package/src/modules/products/components/pages/ProductEdit.vue +9 -1
  126. package/src/modules/products/components/pages/Products.vue +58 -38
  127. package/src/modules/products/components/sections/FilterProducts.vue +9 -6
  128. package/src/modules/products/controllers/categories.controller.js +30 -13
  129. package/src/modules/products/controllers/leftovers.controller.js +12 -5
  130. package/src/modules/products/controllers/products.controller.js +18 -0
  131. package/src/modules/products/models/category.model.js +42 -32
  132. package/src/modules/products/products.client.js +4 -2
  133. package/src/modules/products/store/categories.js +17 -3
  134. package/src/modules/products/store/products.js +4 -0
  135. package/src/modules/backoffice/components/admin/Categories.vue +0 -53
  136. package/src/modules/backoffice/components/admin/CategoryEdit.vue +0 -98
  137. package/src/modules/products/components/blocks/CategoryCard.vue +0 -42
  138. package/src/modules/products/router/products.router.js +0 -48
  139. /package/src/modules/{products → organizations}/components/pages/OrganizationCreate.vue +0 -0
  140. /package/src/modules/{products → organizations}/components/pages/OrganizationDetails.vue +0 -0
  141. /package/src/modules/{products → organizations}/components/pages/OrganizationDocuments.vue +0 -0
  142. /package/src/modules/{products → organizations}/components/pages/OrganizationPeople.vue +0 -0
@@ -1,47 +1,57 @@
1
1
  <template>
2
- <div class="cols-2-1_3 bg-grey radius-big gap-thin pd-thin">
2
+ <div class="cols-2-1_3 bg-grey pd-thin radius-big gap-thin">
3
+
3
4
  <FilterProducts
4
5
 
5
6
  />
6
- <Feed
7
- :states="{
8
- empty: {
9
- title: 'No Products Found',
10
- description: 'Currently, there are no products available.'
11
- }
12
- }"
13
- :store="{
14
- read: (options) => products.actions.read(options),
15
- state: products.state
16
- }"
17
- :options="{
18
- limit: 15,
19
- organization: route.params._id,
20
- categories: route.query.categories,
21
- prices: route.query.prices,
22
- delivery: route.query.delivery,
23
- // user: user
24
- }"
25
- v-slot="{
26
- items
27
- }"
28
- class="cols-3 gap-thin"
29
- >
30
- <CardProduct
31
- v-for="product in items"
32
- :key="product._id"
33
- :product="product"
34
- class="h-max"
35
- @click="$router.push({
36
- name: 'Product Organization',
37
- params: {
38
- _id: route.params._id,
39
- product: product._id
40
- }
41
- })"
7
+
8
+ <div>
9
+ <BlockSearch
10
+ @search="updateSearch"
11
+ placeholder="Enter product name"
12
+ class="bg-white mn-b-thin"
42
13
  />
43
- </Feed>
44
14
 
15
+ <Feed
16
+ :states="{
17
+ empty: {
18
+ title: 'No Products Found',
19
+ description: 'Currently, there are no products available.'
20
+ }
21
+ }"
22
+ :store="{
23
+ read: (options) => products.actions.read(options),
24
+ state: products.state
25
+ }"
26
+ :options="{
27
+ limit: 15,
28
+ organization: route.params._id,
29
+ categories: route.query.categories,
30
+ prices: route.query.prices,
31
+ delivery: route.query.delivery,
32
+ search: route.query.search
33
+ // user: user
34
+ }"
35
+ v-slot="{
36
+ items
37
+ }"
38
+ class="cols-3 gap-thin"
39
+ >
40
+ <CardProduct
41
+ v-for="product in items"
42
+ :key="product._id"
43
+ :product="product"
44
+ class="h-max"
45
+ @click="$router.push({
46
+ name: 'Product Organization',
47
+ params: {
48
+ _id: route.params._id,
49
+ product: product._id
50
+ }
51
+ })"
52
+ />
53
+ </Feed>
54
+ </div>
45
55
  </div>
46
56
  </template>
47
57
 
@@ -54,6 +64,8 @@
54
64
 
55
65
  // Import components
56
66
  import FilterProducts from '@pf/src/modules/products/components/sections/FilterProducts.vue'
67
+ import BlockSearch from '@pf/src/modules/globals/components/blocks/BlockSearch.vue'
68
+
57
69
 
58
70
  import Feed from '@pf/src/components/Feed/Feed.vue'
59
71
  import CardProduct from '@pf/src/modules/products/components/blocks/CardProduct.vue'
@@ -61,6 +73,14 @@
61
73
  // Accessing router and store
62
74
  import * as products from '@pf/src/modules/products/store/products';
63
75
 
76
+ function updateSearch(search) {
77
+ let query = { ...route.query}
78
+
79
+ query.search = search
80
+
81
+ router.push({ query });
82
+ }
83
+
64
84
  const route = useRoute()
65
85
  const router = useRouter()
66
86
  </script>
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <div class="pd-medium bg-grey radius-big">
2
+ <div class="pd-medium bg-white-transp-50 radius-big">
3
3
  <!-- Categories Filter -->
4
4
  <Spoiler
5
- class="radius-small o-hidden br-1px br-solid br-grey mn-b-small"
5
+ class="radius-small o-hidden mn-b-small"
6
6
  :status="true"
7
7
  >
8
8
  <template #header>
@@ -22,11 +22,11 @@
22
22
  </template>
23
23
  </Spoiler>
24
24
 
25
- <hr class="mn-b-small">
25
+ <hr class="mn-b-small t-transp">
26
26
 
27
27
  <!-- Prices Filter -->
28
28
  <Spoiler
29
- class="radius-small o-hidden br-1px br-solid br-grey mn-b-small"
29
+ class="radius-small o-hidden mn-b-small"
30
30
  :status="false"
31
31
  >
32
32
  <template #header>
@@ -46,7 +46,7 @@
46
46
  </template>
47
47
  </Spoiler>
48
48
 
49
- <hr class="mn-b-small">
49
+ <!-- <hr class="mn-b-small"> -->
50
50
 
51
51
  <!-- Delivery Filter -->
52
52
  <!-- <Spoiler
@@ -91,7 +91,10 @@ const router = useRouter()
91
91
  import * as categories from '@pf/src/modules/products/store/categories';
92
92
  import * as marketplace from '@pf/src/modules/marketplace/store/marketplace';
93
93
 
94
- await categories.actions.fetchCategories()
94
+ let options = {
95
+ status: 'published'
96
+ }
97
+ await categories.actions.fetchCategories(options)
95
98
 
96
99
  let selectedFilters = ref({
97
100
  categories: [],
@@ -4,7 +4,17 @@ const controllerFactory = (db) => {
4
4
  const getCategories = async (req, res) => {
5
5
  console.log(Category)
6
6
  try {
7
- const categories = await Category.find({}).sort({'order': 'asc'}).exec();
7
+
8
+ let query = {};
9
+ let options = {};
10
+
11
+ // Проверка наличия req.query.organization
12
+ if (req.query.status) {
13
+ // Создание ObjectId из строки
14
+ query.status = req.query.status;
15
+ }
16
+
17
+ const categories = await Category.find(query, null, options).sort({'order': 'asc'}).exec();
8
18
 
9
19
  if (!categories) {
10
20
  return res.status(404).send({ message: "Categories not found." });
@@ -17,25 +27,27 @@ const controllerFactory = (db) => {
17
27
  };
18
28
 
19
29
  const updateCategories = async (req, res) => {
30
+ console.log(req.body);
20
31
  try {
21
- const updates = req.body.all.map(async (categoryUpdated) => {
22
- const category = await Category.findOneAndUpdate(
23
- { url: categoryUpdated.url },
24
- { $set: categoryUpdated },
25
- { new: true }
26
- ).exec();
27
- if (!category) {
28
- throw new Error("Categories is not updated.");
32
+ const bulkOps = req.body.map((categoryUpdated) => ({
33
+ updateOne: {
34
+ filter: { url: categoryUpdated.url },
35
+ update: { $set: categoryUpdated },
36
+ upsert: false
29
37
  }
30
- });
31
- await Promise.all(updates);
32
- console.log('success');
38
+ }));
39
+
40
+ // Выполнение пакетного обновления
41
+ const result = await Category.bulkWrite(bulkOps, { ordered: false });
42
+ console.log('Success', result);
33
43
  res.status(200).send({ message: "Categories updated successfully." });
34
44
  } catch (err) {
35
- res.send({ message: err.message });
45
+ console.error('Error processing bulk update', err);
46
+ res.status(500).send({ message: err.message });
36
47
  }
37
48
  };
38
49
 
50
+
39
51
  const getCategory = async (req, res) => {
40
52
  try {
41
53
  const category = await Category.findOne({ url: req.params.url }).exec();
@@ -50,7 +62,12 @@ const controllerFactory = (db) => {
50
62
 
51
63
  const addCategory = async (req, res) => {
52
64
  try {
65
+
66
+ const highestOrderDoc = await Category.findOne().sort('-order');
67
+ req.body.order = highestOrderDoc ? highestOrderDoc.order + 1 : 1;
68
+
53
69
  const category = await Category.create(req.body);
70
+
54
71
  if (!category) {
55
72
  return res.status(404).send({ message: "Category is not created." });
56
73
  }
@@ -1,5 +1,3 @@
1
- const ObjectId = require('mongoose').Types.ObjectId;
2
-
3
1
  const controllerFactory = (db) => {
4
2
  const Leftover = db.leftover;
5
3
 
@@ -8,16 +6,25 @@ const controllerFactory = (db) => {
8
6
  let query = {};
9
7
  let options = {};
10
8
 
11
- if (req.query.organization) query.organization = new ObjectId(req.query.organization)
9
+ // Проверка наличия req.query.organization
10
+ if (req.query.organization) {
11
+ // Создание ObjectId из строки
12
+ query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
13
+ }
14
+
15
+ console.log(query);
16
+
17
+ const leftoveres = await Leftover.find(query, null, options)
18
+ .sort({ createdAt: "desc" })
19
+ .exec();
12
20
 
13
- const leftoveres = await Leftover.find(query, null, options).sort({ 'createdAt': 'desc' }).exec();
14
-
15
21
  if (!leftoveres) {
16
22
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
17
23
  }
18
24
 
19
25
  res.status(200).send(leftoveres);
20
26
  } catch (err) {
27
+ console.error(err);
21
28
  res.status(500).send({ message: "ERROR_GET_ALL_LEFTOVERES" });
22
29
  }
23
30
  };
@@ -62,6 +62,24 @@ const controllerFactory = (db) => {
62
62
  query.delivery = { $in: deliveryOptions };
63
63
  }
64
64
 
65
+ const search = req.query.search;
66
+
67
+ if (search) {
68
+ const parts = search.split('.');
69
+
70
+ let regexPattern = '';
71
+
72
+ if (parts.length === 2) {
73
+ // Создаем паттерн, который допускает замену одного символа в каждой части
74
+ regexPattern = parts.map(part => part.substr(0, part.length - 1) + '.{1}').join('\\.');
75
+ } else {
76
+ // Если нет точки, применяем аналогичный подход к всей строке
77
+ regexPattern = search.substr(0, search.length - 1) + '.{1}';
78
+ }
79
+
80
+ query.name = { $regex: regexPattern, $options: 'i' }
81
+ }
82
+
65
83
  // Handle price ranges
66
84
  const prices = req.query.prices?.split(',') || [];
67
85
 
@@ -5,6 +5,16 @@ module.exports = (mongoose) => {
5
5
  required: true,
6
6
  trim: true
7
7
  },
8
+ status: {
9
+ type: String,
10
+ enum: ['draft','internal','published','removed'],
11
+ default: 'draft',
12
+ required: true,
13
+ },
14
+ order: {
15
+ type: Number,
16
+ required: true
17
+ },
8
18
  url: {
9
19
  type: String,
10
20
  required: true,
@@ -19,38 +29,38 @@ module.exports = (mongoose) => {
19
29
  filters: {
20
30
  type: Array
21
31
  },
22
- owner: {
23
- type: {
24
- type: String,
25
- required: true
26
- },
27
- target: {
28
- type: mongoose.Schema.Types.ObjectId,
29
- ref: function (value) {
30
- if (this.owner.type === 'user') return 'User';
31
- if (this.owner.type === 'organization') return 'Organization';
32
- },
33
- required: true,
34
- },
35
- },
36
- creator: {
37
- hidden: {
38
- type: Boolean,
39
- required: true
40
- },
41
- type: {
42
- type: String,
43
- required: true
44
- },
45
- target: {
46
- type: mongoose.Schema.Types.ObjectId,
47
- ref: function (value) {
48
- if (this.owner.type === 'user') return 'User';
49
- if (this.owner.type === 'organization') return 'Organization';
50
- },
51
- required: true,
52
- },
53
- }
32
+ // owner: {
33
+ // type: {
34
+ // type: String,
35
+ // required: true
36
+ // },
37
+ // target: {
38
+ // type: mongoose.Schema.Types.ObjectId,
39
+ // ref: function (value) {
40
+ // if (this.owner.type === 'user') return 'User';
41
+ // if (this.owner.type === 'organization') return 'Organization';
42
+ // },
43
+ // required: true,
44
+ // },
45
+ // },
46
+ // creator: {
47
+ // hidden: {
48
+ // type: Boolean,
49
+ // required: true
50
+ // },
51
+ // type: {
52
+ // type: String,
53
+ // required: true
54
+ // },
55
+ // target: {
56
+ // type: mongoose.Schema.Types.ObjectId,
57
+ // ref: function (value) {
58
+ // if (this.owner.type === 'user') return 'User';
59
+ // if (this.owner.type === 'organization') return 'Organization';
60
+ // },
61
+ // required: true,
62
+ // },
63
+ // }
54
64
  }, {
55
65
  timestamps: {
56
66
  currentTime: () => Date.now()
@@ -3,9 +3,11 @@
3
3
  import ImagesThumbnails from './components/blocks/ImagesThumbnails.vue';
4
4
  import LeftoverPositions from './components/blocks/LeftoverPositions.vue';
5
5
  import ListPositions from './components/blocks/ListPositions.vue';
6
- import CategoryCard from './components/blocks/CategoryCard.vue';
6
+
7
+ import CardCategory from './components/blocks/CardCategory.vue';
7
8
  import CardProduct from './components/blocks/CardProduct.vue';
8
9
  import CardLeftover from './components/blocks/CardLeftover.vue';
10
+
9
11
  import Images360 from './components/blocks/Images360.vue';
10
12
  import CardPosition from './components/blocks/CardPosition.vue';
11
13
 
@@ -50,7 +52,7 @@ export {
50
52
  ImagesThumbnails,
51
53
  LeftoverPositions,
52
54
  ListPositions,
53
- CategoryCard,
55
+ CardCategory,
54
56
  CardProduct,
55
57
  CardLeftover,
56
58
  Images360,
@@ -11,9 +11,10 @@ const $axios = axios.create({baseURL: process.env.API_URL, withCredentials: true
11
11
  const state = reactive({
12
12
  all: [],
13
13
  current: {
14
- order: "1",
14
+ order: 1,
15
15
  name: "",
16
16
  url: "",
17
+ status: "draft",
17
18
  subcategories: [],
18
19
  filters: [],
19
20
  localization: [],
@@ -21,8 +22,9 @@ const state = reactive({
21
22
  });
22
23
 
23
24
  const actions = {
24
- async fetchCategories() {
25
- return await $axios.get(`/categories`).then(
25
+ async fetchCategories(options) {
26
+ console.log(options)
27
+ return await $axios.get(`/categories`, { params: options }).then(
26
28
  categories => {
27
29
  state.all = categories.data;
28
30
  return Promise.resolve(categories.data);
@@ -86,6 +88,18 @@ const actions = {
86
88
  );
87
89
  },
88
90
 
91
+ resetCategory(){
92
+ state.current = {
93
+ order: 0,
94
+ name: "",
95
+ url: "",
96
+ status: "draft",
97
+ subcategories: [],
98
+ filters: [],
99
+ localization: [],
100
+ }
101
+ },
102
+
89
103
  deleteCategory(url) {
90
104
  return $axios.delete("/categories/" + url).then(
91
105
  (response) => {
@@ -92,6 +92,10 @@ const actions = {
92
92
  query.status = options.status;
93
93
  }
94
94
 
95
+ if (options.search) {
96
+ query.search = options.search;
97
+ }
98
+
95
99
  query.sort = 'createdAt';
96
100
 
97
101
  query.skip = options.skip || 0;
@@ -1,53 +0,0 @@
1
- <template>
2
- <div>
3
- <!-- Toolbar -->
4
- <section class="pageheader section">
5
- <div class="mn-b-big title">
6
- <h1>Категории товаров</h1>
7
- <router-link :to="'/admin/categories/add'" class="i-regular pd-thin button-delete button"><img src="@/assets/icons/plus-white.svg"></router-link>
8
- </div>
9
- </section>
10
-
11
- <section class="bg-grey section-subsection section">
12
- <VueDraggableNext class="dragArea list-group w-full" :list="categories.all" :sort="true" @change="log">
13
- <div v-for="(category,index) in categories.all" >
14
- {{test(category,index)}}
15
- <CategoryCard :category="category" :key="index" class="list-group-item mn-b-medium"></CategoryCard>
16
- </div>
17
- </VueDraggableNext>
18
- <button @click="store.dispatch('categories/updateCategories', categories)" class="button">Обновить порядок</button>
19
- </section>
20
- </div>
21
- </template>
22
-
23
-
24
- <script setup>
25
-
26
- import { computed,ref} from 'vue'
27
-
28
-
29
- import { VueDraggableNext } from 'vue-draggable-next'
30
-
31
- import CategoryCard from '@/components/blocks/CategoryCard.vue';
32
-
33
-
34
- const store = useStore()
35
-
36
- await store.dispatch('categories/fetchCategories')
37
-
38
- const categories = ref(store.state.categories);
39
-
40
- function log(event) {
41
- // store.commit('categories/updateCategories', )
42
- }
43
- function test(category,index) {
44
- category.order = index;
45
- // store.commit('categories/updateCategories', )
46
- }
47
-
48
-
49
- </script>
50
-
51
- <style lang="scss">
52
-
53
- </style>
@@ -1,98 +0,0 @@
1
- <template>
2
- <!-- ---------------------------------------------------------------- -->
3
- <!-- 01. Page Title -->
4
- <!-- ---------------------------------------------------------------- -->
5
- <section class="pageheader section">
6
- <div class="mn-b-big title">
7
- <h1 v-if="route.params.url">Редактировать категорию</h1>
8
- <h1 v-else>Добавить категорию</h1>
9
- </div>
10
- </section>
11
-
12
- <!-- ---------------------------------------------------------------- -->
13
- <!-- 03. Page Content -->
14
- <!-- ---------------------------------------------------------------- -->
15
- <section class=" bg-grey br-bot-dark section-subsection section">
16
-
17
- <form onsubmit="return false">
18
- <!-- ---------------------------------------------------------------- -->
19
- <!-- Category Info -->
20
- <!-- ---------------------------------------------------------------- -->
21
- <div class="mn-b-big flex-column flex block">
22
- <div class="w-100 flex-nowrap flex">
23
- <InputText :obj="'categories'" :prop="'current.url'" :value="category.url" label="URL категории" class="mn-r-small"/>
24
- <InputText :obj="'categories'" :prop="'current.name'" :value="category.name" label="Название"/>
25
- </div>
26
- </div>
27
- <!-- Subcategories -->
28
- <EditCategories
29
- :category="category"
30
- title="Подкатегории"
31
- obj="categories"
32
- prop="current.subcategories"
33
- name="subcategories"
34
- keyname="name"
35
- parname="url"
36
- />
37
- <!-- Filters -->
38
- <EditCategories
39
- :category="category"
40
- title="Фильтры для категории"
41
- obj="categories"
42
- prop='current.filters'
43
- name="filters"
44
- keyname="name"
45
- parname="options"
46
- />
47
- <!-- Localization -->
48
- <EditCategories
49
- :category="category"
50
- title="Локализация"
51
- obj="categories"
52
- prop='current.localization'
53
- name="localization"
54
- keyname="locale"
55
- parname="text"
56
- />
57
- <!-- Sumbmit -->
58
- <a @click="onSubmit()" class="button">Сохранить</a>
59
- </form>
60
- <!-- End of page form -->
61
- </section>
62
- <!-- End of page content -->
63
- </template>
64
-
65
- <script setup>
66
- // Import components
67
- import InputText from '@/components/elements/InputText.vue'
68
- import EditCategories from '@pf/src/modules/products/components/blocks/EditCategories.vue'
69
- import EditFilters from '@/components/blocks/EditFilters.vue'
70
- // Import libs
71
- import { computed, onMounted } from 'vue'
72
-
73
- import { useRoute } from 'vue-router'
74
- // Accessing router and store
75
- const store = useStore()
76
- const route = useRoute()
77
- // Data prefetching
78
- if (route.params.url) {
79
- store.dispatch('categories/fetchCategory', route.params.url)
80
- } else {
81
- await store.commit('categories/cleanCategoryState')
82
- }
83
- // Accessing state
84
- const category = computed(() => store.state.categories.current)
85
- const routePath = computed(() => route.name)
86
- // Filters and subcategory
87
- function onSubmit() {
88
- if (route.params.url) {
89
- store.dispatch('categories/updateCategory', route.params.url)
90
- } else {
91
- store.dispatch('categories/addCategory')
92
- }
93
- }
94
- </script>
95
-
96
- <style lang="scss">
97
-
98
- </style>
@@ -1,42 +0,0 @@
1
- <template>
2
- <div class="card">
3
- <div class="flex-v-center flex">
4
- <h4>{{category.name}}</h4>
5
- <div class="actions">
6
- <router-link :to="'/admin/categories/' + category.url + '/edit'" class="mn-r-medium nav-link">Редактировать</router-link>
7
- <a class="nav-link" @click="deleteCategory(category)">Удалить</a>
8
- </div>
9
- </div>
10
- </div>
11
- </template>
12
-
13
-
14
- <script>
15
- import { toRef,onMounted } from 'vue'
16
-
17
- export default {
18
- props: ['category'],
19
- name: 'CategoryCard',
20
- setup(props) {
21
- onMounted(() => {
22
- })
23
-
24
- return {
25
- }
26
- },
27
- methods: {
28
- deleteCategory(category) {
29
- this.$store.commit('categories/deleteCategory', category);
30
- this.$store.dispatch('categories/deleteCategory', category.url)
31
- }
32
- }
33
- }
34
- </script>
35
-
36
- <style lang="scss">
37
- .categories-card {
38
-
39
- }
40
- </style>
41
-
42
-