@ozdao/prometheus-framework 0.2.52 → 0.2.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. package/dist/main-0a2437f4.js +91 -0
  2. package/dist/main-4fnApBsF.js +91 -0
  3. package/dist/main-cdd0be68.mjs +13628 -0
  4. package/dist/main-kjbLXQEa.mjs +13606 -0
  5. package/dist/main.css +1 -1
  6. package/dist/products.server.js +61 -49
  7. package/dist/products.server.mjs +61 -49
  8. package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
  9. package/dist/prometheus-framework/src/components/Button/Button.vue.js +2 -223
  10. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  11. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +223 -2
  12. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  13. package/dist/prometheus-framework/src/components/Field/Field.vue.js +2 -76
  14. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  15. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +78 -2
  16. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  17. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  18. package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
  19. package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +2 -44
  20. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
  21. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +44 -2
  22. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +3 -3
  24. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  26. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +3 -3
  28. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +3 -3
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +3 -3
  32. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +3 -3
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +3 -3
  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 +2 -2
  38. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  40. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  42. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +2 -2
  44. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +1 -1
  46. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +2 -2
  48. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +2 -2
  50. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
  52. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +1 -1
  54. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +2 -2
  56. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +1 -1
  58. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
  60. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +1 -1
  64. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  66. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +3 -3
  68. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +1 -1
  70. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  72. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  74. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  76. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +2 -2
  78. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
  80. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  81. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  82. package/dist/prometheus-framework/src/modules/organizations/router/products.router.cjs +1 -1
  83. package/dist/prometheus-framework/src/modules/organizations/router/products.router.js +22 -0
  84. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.cjs +1 -0
  85. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue.js +45 -0
  86. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue2.cjs +1 -0
  87. package/dist/prometheus-framework/src/modules/products/components/blocks/CardCategory.vue2.js +4 -0
  88. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  89. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
  90. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
  91. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
  92. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
  93. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
  94. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -0
  95. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +79 -0
  96. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -0
  97. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +193 -0
  98. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue2.cjs +1 -0
  99. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue2.js +4 -0
  100. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  101. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
  102. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  103. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +1 -1
  104. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  105. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +67 -57
  106. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.cjs +1 -1
  107. package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.js +1 -1
  108. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
  109. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
  110. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  111. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
  112. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +21 -18
  114. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  115. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  116. package/dist/prometheus-framework/src/modules/products/products.client.cjs +1 -1
  117. package/dist/prometheus-framework/src/modules/products/products.client.js +2 -2
  118. package/dist/prometheus-framework/src/modules/products/store/categories.cjs +1 -1
  119. package/dist/prometheus-framework/src/modules/products/store/categories.js +39 -27
  120. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  121. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +1 -1
  122. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  123. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  124. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.cjs +1 -1
  125. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
  126. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  127. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +3 -3
  128. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
  129. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
  130. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  131. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +1 -1
  132. package/dist/prometheus-framework.cjs.js +1 -1
  133. package/dist/prometheus-framework.es.js +1 -1
  134. package/dist/style.css +1 -1
  135. package/dist/web-0066fd51.mjs +55 -0
  136. package/dist/web-6b9fa713.js +1 -0
  137. package/dist/web-ngl7bNhF.js +1 -0
  138. package/dist/web-t91TrxXa.mjs +55 -0
  139. package/package.json +1 -1
  140. package/src/components/Button/Button.vue +1 -3
  141. package/src/components/Field/Field.vue +3 -1
  142. package/src/modules/marketplace/components/sections/Filters.vue +7 -1
  143. package/src/modules/organizations/router/products.router.js +24 -4
  144. package/src/modules/products/components/blocks/CardCategory.vue +53 -0
  145. package/src/modules/products/components/pages/Categories.vue +90 -0
  146. package/src/modules/products/components/pages/CategoryEdit.vue +214 -0
  147. package/src/modules/products/components/pages/ProductEdit.vue +9 -1
  148. package/src/modules/products/components/sections/FilterProducts.vue +4 -1
  149. package/src/modules/products/controllers/categories.controller.js +30 -13
  150. package/src/modules/products/models/category.model.js +42 -32
  151. package/src/modules/products/products.client.js +4 -2
  152. package/src/modules/products/store/categories.js +17 -3
  153. package/src/modules/backoffice/components/admin/Categories.vue +0 -53
  154. package/src/modules/backoffice/components/admin/CategoryEdit.vue +0 -98
  155. package/src/modules/products/components/blocks/CategoryCard.vue +0 -42
  156. package/src/modules/products/router/products.router.js +0 -48
  157. /package/src/modules/{products → organizations}/components/pages/OrganizationCreate.vue +0 -0
  158. /package/src/modules/{products → organizations}/components/pages/OrganizationDetails.vue +0 -0
  159. /package/src/modules/{products → organizations}/components/pages/OrganizationDocuments.vue +0 -0
  160. /package/src/modules/{products → organizations}/components/pages/OrganizationPeople.vue +0 -0
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="pd-thin">
3
+ <Block class="radius-big mn-b-thin flex-nowrap flex-v-center flex">
4
+ <h1 class="mn-r-auto">
5
+ Product Categories
6
+ </h1>
7
+
8
+ <router-link
9
+ :to="{
10
+ name: 'CategoryAdd',
11
+ params: {
12
+ _id: $route.params._id
13
+ }
14
+ }"
15
+ class="mn-r-medium uppercase t-medium pd-small radius-big bg-white nav-link"
16
+ >
17
+ Add category
18
+ </router-link>
19
+
20
+ <Button
21
+ @click="updateCategoriesOrder"
22
+ class="pd-small radius-big bg-black t-white uppercase t-medium"
23
+ >
24
+ Change Order
25
+ </Button>
26
+ </Block>
27
+
28
+ <VueDraggableNext
29
+ class="dragArea list-group w-full"
30
+ :list="categories.state.all"
31
+ item-key="order"
32
+ @end="updateOrder"
33
+ >
34
+ <CardCategory
35
+ v-for="(category, index) in categories.state.all"
36
+ :key="category.id"
37
+ :category="category"
38
+ @delete="deleteCategory"
39
+ class="pd-medium bg-grey radius-medium mn-b-thin"
40
+ />
41
+ </VueDraggableNext>
42
+ </div>
43
+ </template>
44
+
45
+ <script setup>
46
+ import { onMounted } from 'vue';
47
+ import { VueDraggableNext } from 'vue-draggable-next';
48
+
49
+ import { useRoute, useRouter } from 'vue-router';
50
+
51
+ import * as categories from '@pf/src/modules/products/store/categories';
52
+
53
+ const route = useRoute();
54
+ const router = useRouter();
55
+
56
+ import Button from "@pf/src/components/Button/Button.vue";
57
+ import Block from '@pf/src/components/Block/Block.vue';
58
+ import CardCategory from '@pf/src/modules/products/components/blocks/CardCategory.vue';
59
+
60
+ onMounted(async () => {
61
+ await categories.actions.fetchCategories();
62
+ });
63
+
64
+ function updateOrder() {
65
+ categories.state.all.forEach((category, index) => {
66
+ category.order = index;
67
+ });
68
+ updateCategoriesOrder();
69
+ }
70
+
71
+ async function updateCategoriesOrder() {
72
+ await categories.actions.updateCategories(categories.state.all);
73
+ }
74
+
75
+ async function deleteCategory(category) {
76
+ // Запрашиваем подтверждение у пользователя
77
+ const isConfirmed = confirm(`Are you sure you want to delete the category "${category.name}"?`);
78
+
79
+ // Если пользователь подтвердил удаление, продолжаем процесс
80
+ if (isConfirmed) {
81
+ await categories.actions.deleteCategory(category.url);
82
+ } else {
83
+ alert('Category deletion cancelled');
84
+ }
85
+ }
86
+
87
+ </script>
88
+
89
+ <style lang="scss">
90
+ </style>
@@ -0,0 +1,214 @@
1
+ <template>
2
+ <Block class="radius-big mn-b-thin flex-nowrap flex-v-center flex">
3
+ <h1 class="mn-r-auto">
4
+ {{route.params.category ? 'Edit Category' : 'Add Category'}}
5
+ </h1>
6
+
7
+ <Button
8
+ :submit="onSubmit"
9
+ :callback="redirectTo"
10
+ class="pd-small radius-big bg-main t-black uppercase t-medium"
11
+ >
12
+ Save Category
13
+ </Button>
14
+ </Block>
15
+
16
+ <Block
17
+ title="Profile"
18
+ class="mn-b-thin"
19
+ >
20
+ <div class="mn-b-medium w-100 flex-nowrap gap-thin flex">
21
+ <Field
22
+ v-model:field="categories.state.current.order"
23
+ label="Order"
24
+ :disabled="true"
25
+ class="w-25 bg-white radius-small pd-medium"
26
+ />
27
+ <Field
28
+ v-model:field="categories.state.current.url"
29
+ label="URL"
30
+ placeholder="Enter category URL"
31
+ class="w-100 bg-white radius-small pd-medium"
32
+ />
33
+ <Field
34
+ v-model:field="categories.state.current.name"
35
+ label="Name"
36
+ placeholder="Enter category name"
37
+ class="w-100 bg-white radius-small pd-medium"
38
+ />
39
+ </div>
40
+
41
+ <Select
42
+ v-model:select="categories.state.current.status"
43
+ label="Status"
44
+ :options="[
45
+ 'draft',
46
+ 'internal',
47
+ 'published',
48
+ 'removed'
49
+ ]"
50
+ placeholder="Display product"
51
+ class="pos-relative w-100 mn-b-small bg-white radius-small pd-medium"
52
+ />
53
+
54
+ <div class="flex-v-center flex-nowrap flex">
55
+ <h4 class="mn-r-thin t-medium">Localization</h4>
56
+
57
+ <button
58
+ @click="() => categories.state.current.localization.push({locale: '', text: ''})"
59
+ class="i-small pd-thin button-delete button"
60
+ >
61
+ +
62
+ </button>
63
+ </div>
64
+ <div
65
+ class="gap-thin mn-b-thin flex-nowrap flex"
66
+ v-for="(item, index) in categories.state.current.localization"
67
+ :key="index"
68
+ >
69
+ <Field
70
+ v-model:field="item.locale"
71
+ placeholder="Locale"
72
+ class="w-100 bg-white radius-small pd-medium"
73
+ />
74
+ <Field
75
+ v-model:field="item.text"
76
+ placeholder="Text"
77
+ class="w-100 bg-white radius-small pd-medium"
78
+ />
79
+ <div
80
+ @click="() => categories.state.current.localization.splice(index, 1)"
81
+ class="radius-small pd-small flex-center flex aspect-1x1 bg-red"
82
+ >
83
+ <IconDelete
84
+ class="i-medium"
85
+ />
86
+ </div>
87
+ </div>
88
+
89
+
90
+ </Block>
91
+ <!-- Subcategories -->
92
+ <Block
93
+ title="Subcategories"
94
+ placeholder="No subcategories added yet"
95
+ :actions="[{
96
+ label: '+',
97
+ function: () => categories.state.current.subcategories.push({name: '', url: ''})
98
+ }]"
99
+ class="mn-b-thin"
100
+ >
101
+ <div
102
+ class="gap-thin mn-b-thin flex-nowrap flex"
103
+ v-for="(item, index) in categories.state.current.subcategories"
104
+ :key="index"
105
+ >
106
+ <Field
107
+ v-model:field="item.name"
108
+ placeholder="Subcategory name"
109
+ class="w-100 bg-white radius-small pd-medium"
110
+ />
111
+ <Field
112
+ v-model:field="item.url"
113
+ placeholder="Subcategory"
114
+ class="w-100 bg-white radius-small pd-medium"
115
+ />
116
+ <div
117
+ @click="() => categories.state.current.subcategories.splice(index, 1)"
118
+ class="radius-small pd-small flex-center flex aspect-1x1 bg-red"
119
+ >
120
+ <IconDelete
121
+ class="i-medium"
122
+ />
123
+ </div>
124
+ </div>
125
+ </Block>
126
+ <!-- Filters -->
127
+ <Block
128
+ title="Filters"
129
+ placeholder="No filters added yet"
130
+ :actions="[{
131
+ label: '+',
132
+ function: () => categories.state.current.filters.push({name: '', url: ''})
133
+ }]"
134
+ >
135
+ <div
136
+ class="gap-thin mn-b-thin flex-nowrap flex"
137
+ v-for="(item, index) in categories.state.current.filters"
138
+ :key="index"
139
+ >
140
+ <Field
141
+ v-model:field="item.name"
142
+ placeholder="Filter name"
143
+ class="w-100 bg-white radius-small pd-medium"
144
+ />
145
+ <Field
146
+ v-model:field="item.options"
147
+ placeholder="Filter options divided by ,"
148
+ class="w-100 bg-white radius-small pd-medium"
149
+ />
150
+ <div
151
+ @click="() => categories.state.current.filters.splice(index, 1)"
152
+ class="radius-small pd-small flex-center flex aspect-1x1 bg-red"
153
+ >
154
+ <IconDelete
155
+ class="i-medium"
156
+ />
157
+ </div>
158
+ </div>
159
+ </Block>
160
+
161
+ </template>
162
+
163
+ <script setup>
164
+ // Import libs
165
+ import { computed } from 'vue'
166
+ import { useRoute,useRouter } from 'vue-router'
167
+
168
+ import IconDelete from '@pf/src/modules/icons/navigation/IconDelete.vue';
169
+
170
+ import Button from "@pf/src/components/Button/Button.vue";
171
+ import Select from "@pf/src/components/Select/Select.vue";
172
+ import Field from "@pf/src/components/Field/Field.vue";
173
+
174
+ import Block from '@pf/src/components/Block/Block.vue';
175
+
176
+ // Import the new store structure
177
+ import * as categories from '@pf/src/modules/products/store/categories';
178
+
179
+ const route = useRoute()
180
+ const router = useRouter()
181
+
182
+ // Data prefetching
183
+ if (route.params.category) {
184
+ categories.actions.fetchCategory(route.params.category)
185
+ } else {
186
+ categories.actions.resetCategory() // Adjusted based on the new store's method to reset the category state
187
+ }
188
+
189
+ // Accessing state
190
+ const category = computed(() => categories.state.current)
191
+ const routePath = computed(() => route.name)
192
+
193
+ // Functions
194
+ function onSubmit() {
195
+ if (route.params.category) {
196
+ categories.actions.updateCategory(route.params.category)
197
+ } else {
198
+ categories.actions.addCategory()
199
+ }
200
+ }
201
+
202
+ function redirectTo () {
203
+ router.push({
204
+ name: 'Categories Organization',
205
+ params: {
206
+ _id: route.params._id
207
+ }
208
+ })
209
+ }
210
+ </script>
211
+
212
+ <style lang="scss">
213
+ /* Your styles here */
214
+ </style>
@@ -48,6 +48,15 @@
48
48
 
49
49
  <Block
50
50
  title="Categories"
51
+ :actions="[{
52
+ label: '+',
53
+ function: () => router.push({
54
+ name: 'Categories Organization',
55
+ params: {
56
+ _id: route.params._id
57
+ }
58
+ })
59
+ }]"
51
60
  >
52
61
  <Checkbox
53
62
  v-for="(category, index) in categories.state.all"
@@ -224,7 +233,6 @@
224
233
  import Block from '@pf/src/components/Block/Block.vue';
225
234
  import Tab from "@pf/src/components/Tab/Tab.vue";
226
235
  import Field from "@pf/src/components/Field/Field.vue";
227
- import Select from "@pf/src/components/Select/Select.vue";
228
236
  import Checkbox from "@pf/src/components/Checkbox/Checkbox.vue";
229
237
  import Button from "@pf/src/components/Button/Button.vue";
230
238
  import Popup from "@pf/src/components/Popup/Popup.vue";
@@ -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
  }
@@ -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) => {
@@ -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>