@ozdao/prometheus-framework 0.0.86 → 0.0.88

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-15e71ec4.js +1 -0
  2. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-cdbafd07.mjs +1944 -0
  3. package/dist/CardOrganization-ee5c34ab.js +1 -0
  4. package/dist/CardOrganization-f70bd169.mjs +202 -0
  5. package/dist/Comments-63f154a6.js +9 -0
  6. package/dist/Comments-c5afa4d6.mjs +459 -0
  7. package/dist/Feed-51e4e232.js +1 -0
  8. package/dist/Feed-8fd41524.js +1 -0
  9. package/dist/Feed-dc8b66bf.mjs +367 -0
  10. package/dist/Feed-ecf37814.mjs +367 -0
  11. package/dist/IconEdit-736c89be.js +1 -0
  12. package/dist/IconEdit-e9fd4c6c.mjs +21 -0
  13. package/dist/Image-6c7584f5.mjs +477 -0
  14. package/dist/Image-9a870c88.js +9 -0
  15. package/dist/Popup-105ef2c3.js +1 -0
  16. package/dist/Popup-82fb2c8a.mjs +76 -0
  17. package/dist/Product-1724d88d.mjs +837 -0
  18. package/dist/Product-2f3d592f.mjs +837 -0
  19. package/dist/Product-2fbf9d99.js +7 -0
  20. package/dist/Product-a94d8b65.js +7 -0
  21. package/dist/ProductEdit-20709821.mjs +349 -0
  22. package/dist/ProductEdit-57484f1e.mjs +349 -0
  23. package/dist/ProductEdit-a81d13b9.js +1 -0
  24. package/dist/ProductEdit-ef301baa.js +1 -0
  25. package/dist/ProfileBlogposts-eca9916c.js +1 -0
  26. package/dist/ProfileBlogposts-fb014bc6.mjs +63 -0
  27. package/dist/ProfileComments-58094a50.mjs +43 -0
  28. package/dist/ProfileComments-b919f021.js +1 -0
  29. package/dist/ProfileEvents-05485e20.js +1 -0
  30. package/dist/ProfileEvents-1cfe6858.mjs +55 -0
  31. package/dist/ProfileEvents-5d206e3d.mjs +55 -0
  32. package/dist/ProfileEvents-d8e16509.js +1 -0
  33. package/dist/ProfileLikes-2f3a4488.js +1 -0
  34. package/dist/ProfileLikes-b5ac7f48.mjs +43 -0
  35. package/dist/ProfileOrganizations-0b76e38f.js +1 -0
  36. package/dist/ProfileOrganizations-32ab1e30.mjs +211 -0
  37. package/dist/Publics-3f277c17.js +1 -0
  38. package/dist/Publics-9ebffff1.mjs +122 -0
  39. package/dist/Tab-58cd105f.mjs +46 -0
  40. package/dist/Tab-6f0a4909.js +1 -0
  41. package/dist/UploadImage-441e8526.js +1 -0
  42. package/dist/UploadImage-ff8f9a0c.mjs +83 -0
  43. package/dist/auth.client.cjs +2 -2
  44. package/dist/auth.client.js +60 -40
  45. package/dist/community.client.cjs +1 -9
  46. package/dist/community.client.js +361 -750
  47. package/dist/community.server.js +16 -4
  48. package/dist/community.server.mjs +16 -4
  49. package/dist/events.client.cjs +1 -1
  50. package/dist/events.client.js +442 -321
  51. package/dist/events.server.js +96 -2
  52. package/dist/events.server.mjs +96 -2
  53. package/dist/inputs.validation-24ae76b9.js +1 -0
  54. package/dist/modules/constructor/components/elements/Bullets.vue.d.ts +15 -0
  55. package/dist/modules/constructor/components/elements/Caption.vue.d.ts +15 -0
  56. package/dist/modules/constructor/components/elements/H2.vue.d.ts +16 -0
  57. package/dist/modules/constructor/components/elements/Image.vue.d.ts +8 -0
  58. package/dist/modules/constructor/components/elements/ImageUpload.vue.d.ts +9 -0
  59. package/dist/modules/constructor/components/elements/Textarea.vue.d.ts +12 -0
  60. package/dist/modules/constructor/components/sections/Constructor.vue.d.ts +7 -0
  61. package/dist/modules/events/components/sections/Feed.vue.d.ts +1 -0
  62. package/dist/organizations-1b4c84ee.mjs +121 -0
  63. package/dist/organizations-af43bda4.js +1 -0
  64. package/dist/organizations.client-253c8068.mjs +3179 -0
  65. package/dist/organizations.client-686845be.mjs +3179 -0
  66. package/dist/organizations.client-99bfc474.js +3 -0
  67. package/dist/organizations.client-c60d7659.js +3 -0
  68. package/dist/organizations.client.cjs +1 -3
  69. package/dist/organizations.client.js +49 -3025
  70. package/dist/style.css +1 -1
  71. package/dist/users.client.cjs +1 -1
  72. package/dist/users.client.js +10 -10
  73. package/package.json +1 -1
  74. package/src/modules/auth/router/auth.js +28 -7
  75. package/src/modules/community/community.client.js +1 -12
  76. package/src/modules/community/components/pages/BlogPost.vue +1 -1
  77. package/src/modules/community/components/pages/CreateBlogPost.vue +8 -151
  78. package/src/modules/community/middlewares/server/verifyBlogpost.js +24 -11
  79. package/src/modules/{community → constructor}/components/elements/Textarea.vue +3 -11
  80. package/src/modules/constructor/components/sections/Constructor.vue +167 -0
  81. package/src/modules/events/components/blocks/CardEvent.vue +15 -7
  82. package/src/modules/events/components/pages/EditEvent.vue +233 -133
  83. package/src/modules/events/components/pages/Event.vue +43 -4
  84. package/src/modules/events/components/sections/Feed.vue +7 -1
  85. package/src/modules/events/controllers/events.controller.js +9 -0
  86. package/src/modules/events/controllers/tickets.controller.js +2 -1
  87. package/src/modules/events/middlewares/server/index.js +10 -0
  88. package/src/modules/events/middlewares/server/verifyEvent.js +60 -0
  89. package/src/modules/events/models/event.model.js +10 -0
  90. package/src/modules/events/routes/events.routes.js +14 -1
  91. package/src/modules/events/store/events.js +15 -19
  92. package/src/modules/organizations/components/blocks/CardOrganization.vue +1 -3
  93. package/src/modules/organizations/components/sections/Publics.vue +2 -3
  94. package/src/modules/organizations/organizations.client.js +0 -2
  95. package/src/modules/users/components/pages/ProfileEvents.vue +3 -3
  96. package/src/modules/organizations/components/blocks/CardOrganizationSocial.vue +0 -46
  97. /package/src/modules/{community → constructor}/components/elements/Bullets.vue +0 -0
  98. /package/src/modules/{community → constructor}/components/elements/Caption.vue +0 -0
  99. /package/src/modules/{community → constructor}/components/elements/H2.vue +0 -0
  100. /package/src/modules/{community → constructor}/components/elements/Image.vue +0 -0
  101. /package/src/modules/{community → constructor}/components/elements/ImageUpload.vue +0 -0
@@ -1,146 +1,246 @@
1
1
  <template>
2
- <div class="for-transition w-100">
3
-
4
- <div class="pd-b-zero pd-t-zero pd-thin">
5
- <Breadcrumbs class="pd-medium bg-grey radius-big"/>
2
+ <article v-if="event" class="pd-thin">
3
+ <div class="mn-thin radius-small w-100 h-10r bg-grey flex-center flex-column flex">
4
+ <UploadImage
5
+ v-model:photo="event.cover"
6
+ :uploadPath="'users/' + auth.state.user._id + '/events'"
7
+ class="h-4r w-4r aspect-1x1 o-hidden mn-thin radius-extra"
8
+ />
9
+ <h4>Upload Event Cover</h4>
6
10
  </div>
7
11
 
8
- <div class="pd-thin">
9
- <header class="flex-nowrap flex bg-grey pd-medium radius-big">
10
- <h1 v-if="route.params.product" class="mn-r-auto">Edit Product</h1>
11
- <h1 v-else class="mn-r-auto">Create Product</h1>
12
-
13
- <section class="flex-nowrap flex pd-thin">
14
- <Button :submit="onSubmit" :callback="redirectTo">Save Product</Button>
15
- </section>
16
-
17
- </header>
18
- </div>
19
-
20
- <div class="pd-b-zero pd-t-zero pd-thin cols-2 gap-thin">
21
-
22
- <div class="mn-thin bg-grey pd-medium o-hidden radius-big">
23
- <h3 class="mn-semi">Profile</h3>
24
- <EditProductInfo
25
- :product="products.state.current"
26
- />
27
- <div class="mn-semi">
28
- <h5>Categories</h5>
29
- <Checkbox
30
- v-for="(category, index) in categories.state.all"
31
- :label="category.name"
32
- name="categories"
33
- :value="category.url"
34
- class="w-100 mn-t-small bg-white radius-small pd-small"
35
- :radio="products.state.current.category"
36
- />
12
+ <Field
13
+ v-model:field="event.name"
14
+ placeholder="Event name"
15
+ class="mn-thin w-100 bg-grey pd-medium radius-small"
16
+ />
17
+ <Field
18
+ v-model:field="event.description"
19
+ type="textfield"
20
+ placeholder="Enter short description"
21
+ class="mn-thin w-100 bg-grey pd-medium radius-small"
22
+ />
23
+
24
+ <h3 class="mn-small">Date</h3>
25
+ {{event.date.start}}
26
+ <Field
27
+ v-model:field="event.date.start"
28
+ label="Start"
29
+ type="datetime-local"
30
+ placeholder="Not specified"
31
+ class="mn-thin w-100 bg-grey pd-medium radius-small"
32
+ />
33
+
34
+ <Field
35
+ v-model:field="event.date.end"
36
+ label="End"
37
+ type="datetime-local"
38
+ placeholder="Not specified"
39
+ class="mn-thin w-100 bg-grey pd-medium radius-small"
40
+ />
41
+
42
+ <h3 class="mn-small">Description</h3>
43
+ <section v-if="event" class="pd-b-extra w-100 bg-grey pd-big radius-big">
44
+ <Constructor
45
+ :content="event.content"
46
+ @update="update => event.content = update"
47
+ />
48
+ </section>
49
+
50
+ <section v-if="event" class="pd-thin pos-fixed pos-l-0 pos-b-0 w-100 ">
51
+ <div class="pd-thin radius-big bg-main w-100 flex-nowrap flex">
52
+ <a v-if="route.params.url" @click="onDelete()" class="mn-r-auto bg-red t-white t-black button">Delete</a>
53
+ <a @click="onDrafts()" class="mn-l-auto bg-white t-black button">To Drafts</a>
54
+ <a @click="openPublicationPopup()" class="mn-l-thin bg-black t-white button">Publish</a>
55
+ </div>
56
+ </section>
57
+
58
+ <Popup
59
+ title="Добавить участника"
60
+ @close-popup="closePublicationPopup"
61
+ :isPopupOpen="isPublicationPopup"
62
+ >
63
+ <div class="w-m-66r t-left pd-big bg-white radius-big">
64
+ <h3 class="mn-small">Final Touches</h3>
65
+
66
+ <BlockTags
67
+ @tags-changed="newTags => event.tags = newTags"
68
+ :tags="event.tags"
69
+ />
70
+
71
+ <h5 class="mn-thin">Add to public:</h5>
72
+ <SelectMulti
73
+ v-model="selectedOrganization"
74
+ :options="publics"
75
+ :multiple="false"
76
+ :taggable="false"
77
+ placeholder="Type to search or add tag"
78
+ label="name"
79
+ track-by="_id"
80
+ class="mn-medium bg-grey radius-medium pd-small"
81
+ />
82
+ <h5 v-if="selectedOrganization" class="mn-thin">Options:</h5>
83
+ <div v-if="selectedOrganization" class="mn-medium br-grey br-2px br-solid pd-small radius-big">
84
+ <Checkbox
85
+ :label="'Hide Author'"
86
+ :radio="event.creator.hidden"
87
+ @update:radio="updateEvent => event.creator.hidden = updateEvent"
88
+ name="prices"
89
+ class="w-100"
90
+ />
37
91
  </div>
38
- <EditParameters
39
- :items="products.state.current.information"
40
- title="Parameters"
41
- emptyMessage="No parameters"
42
- addButtonLabel="Add parameter"
43
- keyName="name"
44
- valueName="value"
45
- @add-info="addInfo"
46
- @delete-info="deleteInfo"
47
- />
48
- <EditParameters
49
- :items="products.state.current.localization"
50
- title="Localization"
51
- emptyMessage="No localizations"
52
- addButtonLabel="Add localization"
53
- keyName="locale"
54
- valueName="text"
55
- @add-info="addLocale"
56
- @delete-info="deleteLocale"
57
- />
58
-
59
-
60
- </div>
61
-
62
- <div class="">
63
- <div class="mn-thin bg-grey pd-medium o-hidden radius-big">
64
- <h3 class="mn-semi">Images</h3>
65
- <EditProductImages
66
- :product="products.state.current"
67
- />
68
- </div>
69
- </div>
70
-
71
- </div>
72
- </div>
73
-
92
+ <Button :submit="onSubmit" :callback="redirectTo" class="w-100 bg-black t-white">Publish</Button>
93
+ </div>
94
+ </Popup>
95
+ </article>
74
96
  </template>
75
97
 
76
98
  <script setup>
77
- // Import libs
78
- import { reactive, computed, onMounted, toRefs } from 'vue'
79
- import { useRoute, useRouter } from 'vue-router'
80
- // Import components
81
- import Breadcrumbs from '@pf/src/components/Breadcrumbs/Breadcrumbs.vue'
82
-
83
- import Tab from "@pf/src/components/Tab/Tab.vue";
84
- import Field from "@pf/src/components/Field/Field.vue";
85
- import Select from "@pf/src/components/Select/Select.vue";
86
- import Checkbox from "@pf/src/components/Checkbox/Checkbox.vue";
87
- import Button from "@pf/src/components/Button/Button.vue";
88
- import Popup from "@pf/src/components/Popup/Popup.vue";
89
-
90
- import EditProductInfo from '@pf/src/modules/products/components/sections/EditProductInfo.vue';
91
- import EditCategories from '@pf/src/modules/products/components/blocks/EditCategories.vue'
92
- import EditParameters from '@pf/src/modules/products/components/sections/EditParameters.vue';
93
- import EditProductImages from '@pf/src/modules/products/components/sections/EditProductImages.vue';
94
- import EditModifications from '@pf/src/modules/products/components/sections/EditModifications.vue';
99
+ import Textarea from '@pf/src/modules/constructor/components/elements/Textarea.vue';
100
+ import Constructor from '@pf/src/modules/constructor/components/sections/Constructor.vue';
101
+
102
+ import Popup from '@pf/src/components/Popup/Popup.vue';
103
+ import Field from '@pf/src/components/Field/Field.vue'
104
+ import BlockTags from '@pf/src/components/FieldTags/BlockTags.vue';
105
+ import Checkbox from '@pf/src/components/Checkbox/Checkbox.vue';
106
+ import SelectMulti from '@pf/src/components/SelectMulti/SelectMulti.vue';
107
+ import UploadImage from '@pf/src/components/UploadImage/UploadImage.vue';
108
+ import Button from '@pf/src/components/Button/Button.vue';
109
+
110
+ import { ref, onMounted } from 'vue';
111
+ import { useRoute, useRouter } from 'vue-router';
112
+
113
+ import * as events from '@pf/src/modules/events/store/events.js';
114
+ import * as auth from '@pf/src/modules/auth/store/auth';
115
+ import * as organizations from '@pf/src/modules/organizations/store/organizations';
116
+
117
+ const route = useRoute();
118
+ const router = useRouter();
119
+
120
+ let event = ref(null);
121
+ let publics = ref(null);
122
+
123
+ const selectedTags = ref([]);
124
+ const selectedOrganization = ref(null);
125
+
126
+ onMounted(async () =>{
95
127
 
96
- // Accessing router and store
97
- import * as products from '@pf/src/modules/products/store/products';
98
- import * as categories from '@pf/src/modules/products/store/categories';
128
+ if (route.params.url) {
129
+ const data = await events.read({ user: auth.state.user._id, url: route.params.url });
130
+ event.value = data.pop();
131
+
132
+ event.value.date.start = event.value.date.start.slice(0, 16);
133
+ event.value.date.end = event.value.date.end.slice(0, 16);
134
+
135
+ } else {
136
+ events.clean();
137
+ event.value = events.state.current;
138
+ }
139
+
140
+ if (!event.value.owner) event.value.owner = {
141
+ target: auth.state.user._id,
142
+ type: 'user'
143
+ }
144
+
145
+ if (!event.value.creator) event.value.creator = {
146
+ target: auth.state.user._id,
147
+ type: 'user',
148
+ hidden: false
149
+ }
150
+
151
+ if (event.value.owner.type === 'organization') selectedOrganization.value = {
152
+ _id: event.value.owner.target._id,
153
+ name: event.value.owner.target.profile.name,
154
+ photo: event.value.owner.target.profile.photo
155
+ }
156
+
157
+ const dataPublics = await organizations.actions.read({
158
+ user: auth.state.user._id,
159
+ postable: auth.state.user._id
160
+ })
161
+
162
+ publics.value = dataPublics.map(publicItem => ({
163
+ name: publicItem.profile.name,
164
+ _id: publicItem._id,
165
+ photo: publicItem.profile.photo
166
+ }));
167
+ })
168
+
169
+ const isPublicationPopup = ref(false)
170
+
171
+ function openPublicationPopup() {
172
+ isPublicationPopup.value = true;
173
+ }
174
+ function closePublicationPopup() {
175
+ isPublicationPopup.value = false;
176
+ }
177
+
178
+ function onDrafts() {
179
+
180
+ if (selectedTags.value.length > 0) selectedTags.value.map(tag => (tag.text))
181
+
182
+ event.value.status = "draft"
183
+
184
+ if (route.params.url) {
185
+ events.update(event.value)
186
+ .then(response => {
187
+ router.push({ name: 'Event', params: { url: response.url } });
188
+ })
189
+ .catch(error => {
190
+ console.error(error);
191
+ })
192
+ } else {
193
+ events.create(event.value)
194
+ .then(response => {
195
+ router.push({ name: 'Event', params: { url: response.url } });
196
+ })
197
+ .catch(error => {
198
+ console.error(error);
199
+ })
200
+ }
201
+ }
202
+
203
+ function onDelete() {
204
+ if (confirm('Are you sure you want to delete this event?')) {
205
+ events.delete(event.value._id)
206
+ .then(response => {
207
+ router.push({ name: 'Drafts' });
208
+ })
209
+ .catch(error => {
210
+ console.error(error);
211
+ })
212
+ }
213
+ }
214
+
215
+ function onSubmit() {
216
+
217
+ if (selectedOrganization.value) event.value.owner = {
218
+ target: selectedOrganization.value._id,
219
+ type: 'organization'
220
+ }
99
221
 
100
- const route = useRoute()
101
- const router = useRouter()
222
+ if (!selectedOrganization.value) event.value.creator.hidden = false
223
+ if (!selectedOrganization.value) event.value.organization = event.value.creator
102
224
 
103
- // Data prefetching
104
- await categories.actions.fetchCategories()
225
+ event.value.status = "published"
105
226
 
106
- if (route.params.product) {
107
- await products.actions.read({ _id: route.params.product });
227
+ console.log(event.value)
228
+ if (route.params.url) {
229
+ events.update(event.value)
230
+ .then(response => {
231
+ router.push({ name: 'Blogevent', params: { url: response.url } });
232
+ })
233
+ .catch(error => {
234
+ console.log(error);
235
+ });
108
236
  } else {
109
- // await commit('products/clearProductState')
237
+ events.create(event.value)
238
+ .then(response => {
239
+ router.push({ name: 'Event', params: { url: response.url } });
240
+ })
241
+ .catch(error => {
242
+ console.log(error);
243
+ });
110
244
  }
111
- // Accessing state
112
- function addInfo() {
113
- products.state.current.information.push({name: '', value: ''});
114
- }
115
-
116
- function deleteInfo(index) {
117
- products.state.current.information.splice(index, 1);
118
- }
119
-
120
- function addLocale() {
121
- products.state.current.localization.push({locale: '', text: ''});
122
- }
123
-
124
- function deleteLocale(index) {
125
- products.state.current.localization.splice(index, 1);
126
- }
127
-
128
- function onSubmit() {
129
- if (route.params.product) {
130
- products.actions.update(route.params.product, products.state.current)
131
- } else {
132
- products.actions.create(route.params._id, products.state.current)
133
- }
134
- }
135
-
136
- function redirectTo () {
137
- router.push({name: 'ProductEdit', params: { _id: route.params._id, product: products.state.current._id } })
138
- }
139
- </script>
140
-
141
- <style lang="scss">
142
- .main-photo {
143
- max-width: 50%;
144
- img { width: 100%; }
145
- }
146
- </style>
245
+ }
246
+ </script>
@@ -27,10 +27,7 @@
27
27
  :owner="event.owner"
28
28
  :user="auth.state.user._id"
29
29
  :type="'normal'"
30
- class="mn-medium"
31
- :class="{
32
- 'br-b br-solid br-black-transp-10': index !== event.length - 1
33
- }"
30
+ class="mn-medium bg-grey radius-big"
34
31
  >
35
32
  <ButtonJoin
36
33
  v-if="auth.state.user._id"
@@ -41,6 +38,23 @@
41
38
  class="mn-small w-100 pd-medium mn-auto"
42
39
  @updateTicket="handleTicketUpdate"
43
40
  />
41
+
42
+ <section>
43
+ <component
44
+ v-if="event && event.content"
45
+ v-for="(block, index) in event.content"
46
+ :is="ComponentMap[block.type]"
47
+ :key="index"
48
+ :index="index"
49
+ :component="block"
50
+ :prop="block"
51
+ :class="block.class"
52
+ content="content"
53
+ v-bind="getBlockProps(block)"
54
+ class="mn-regular"
55
+ />
56
+ </section>
57
+
44
58
  </CardEvent>
45
59
 
46
60
 
@@ -68,6 +82,8 @@
68
82
  import ButtonJoin from '@pf/src/modules/events/components/elements/ButtonJoin.vue';
69
83
  import Comments from '@pf/src/modules/community/components/sections/Comments.vue';
70
84
 
85
+ import Image from '@pf/src/modules/constructor/components/elements/Image.vue';
86
+
71
87
  import * as events from '@pf/src/modules/events/store/events.js';
72
88
  import * as tickets from '@pf/src/modules/events/store/tickets.js';
73
89
  import * as auth from '@pf/src/modules/auth/store/auth';
@@ -80,6 +96,29 @@
80
96
  tickets.mutations.handleTicketUpdate(event.value, ticket, hasTicket, targetId);
81
97
  };
82
98
 
99
+
100
+ const ComponentMap = {
101
+ 'Textarea': 'p',
102
+ 'H2': 'h2',
103
+ 'Bullets': 'p',
104
+ 'Caption': 'p',
105
+ 'ImageUpload': Image
106
+ };
107
+
108
+ function getBlockProps(block) {
109
+ if (block.type === 'Textarea') {
110
+ return { innerHTML: block.content, class: "p-medium" };
111
+ } else if (block.type === 'H2') {
112
+ return { innerHTML: block.content, class: "h3" };
113
+ } else if (block.type === 'Caption') {
114
+ return { innerHTML: block.content };
115
+ } else if (block.type === 'ImageUpload') {
116
+ return { src: block.content };
117
+ }
118
+ return {};
119
+ }
120
+
121
+
83
122
  const event = ref(null);
84
123
  const isLoading = ref(true);
85
124
 
@@ -1,4 +1,4 @@
1
- <template>
1
+ f<template>
2
2
  <section class="feed">
3
3
  <TransitionGroup tag="ul" name="fade" class="o-hidden bg-grey radius-big">
4
4
  <SkeletonEvent
@@ -68,6 +68,10 @@
68
68
  type: String,
69
69
  default: null
70
70
  },
71
+ creator: {
72
+ type: String,
73
+ default: null
74
+ },
71
75
  user: {
72
76
  type: [String, Number],
73
77
  default: null
@@ -107,6 +111,7 @@
107
111
  category: props.category,
108
112
  sortOrder: props.sortOrder,
109
113
  participant: props.participant,
114
+ creator: props.creator,
110
115
  user: props.user,
111
116
  date: props.selectedDate,
112
117
  owner: props.owner,
@@ -136,6 +141,7 @@
136
141
  sortOrder: props.sortOrder,
137
142
  user: props.user,
138
143
  owner: props.owner,
144
+ creator: props.creator,
139
145
  date: props.selectedDate,
140
146
  organization: props.organization,
141
147
  period: props.period,
@@ -107,6 +107,7 @@ const middlewareFactory = (db) => {
107
107
  ...(dateConditions.length > 0 ? [{ $and: dateConditions }] : []),
108
108
  ...(req.query.url ? [{ url: req.query.url }] : []),
109
109
  ...(req.query.owner ? [{ "owner.target": new ObjectId(req.query.owner) }] : []),
110
+ ...(req.query.creator ? [{ "creator.target": new ObjectId(req.query.creator) }] : []),
110
111
  ];
111
112
 
112
113
  const matchStage = matchConditions.length > 0 ? { $match: { $and: matchConditions } } : null;
@@ -219,6 +220,7 @@ const middlewareFactory = (db) => {
219
220
  url: 1,
220
221
  cover: 1,
221
222
  name: 1,
223
+ status: 1,
222
224
  description: 1,
223
225
  content: 1,
224
226
  owner: 1,
@@ -275,12 +277,18 @@ const middlewareFactory = (db) => {
275
277
 
276
278
  const create = async (req, res) => {
277
279
  try {
280
+
281
+ delete req.body._id;
282
+ req.body.url = req.body.name.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
283
+
278
284
  const event = await Event.create(req.body);
285
+
279
286
  if (!event) {
280
287
  return res.status(404).send({ message: "Event is not created." });
281
288
  }
282
289
  res.status(200).send(event);
283
290
  } catch (err) {
291
+ console.log(err)
284
292
  return res.status(500).send({ message: err.message });
285
293
  }
286
294
  };
@@ -305,6 +313,7 @@ const middlewareFactory = (db) => {
305
313
  }
306
314
  res.status(200).send(event);
307
315
  } catch (err) {
316
+ console.log(err)
308
317
  return res.status(500).send({ message: err.message });
309
318
  }
310
319
  };
@@ -70,9 +70,10 @@ const controllerFactory = (db) => {
70
70
  return res.status(404).send({ errorCode: 'TICKET_NOT_FOUND' });
71
71
  }
72
72
 
73
- await ticket.remove();
73
+ await Ticket.deleteOne({ _id: ticket._id });
74
74
  res.status(200).send(ticket);
75
75
  } catch (error) {
76
+ console.log(error)
76
77
  res.status(500).send({ errorCode: 'SERVER_ERROR' });
77
78
  }
78
79
  };
@@ -0,0 +1,10 @@
1
+ // middlewareIndexFactory.js
2
+ const middlewareIndexFactory = (db) => {
3
+ const verifyEvent = require("./verifyEvent")(db);
4
+
5
+ return {
6
+ verifyEvent
7
+ };
8
+ };
9
+
10
+ module.exports = middlewareIndexFactory;
@@ -0,0 +1,60 @@
1
+ // middlewareFactory.js
2
+ const middlewareFactory = (db) => {
3
+ const Event = db.event; // Изменено с Blogpost на Event
4
+
5
+ const checkEventExistOrNot = async (req, res, next) => { // Изменено с checkBlogpostExistOrNot на checkEventExistOrNot
6
+ try {
7
+ // Обработка URL
8
+ const url = req.body.url
9
+ ? req.body.url
10
+ : req.body.name.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, '');
11
+
12
+ // Создание события
13
+ if (!req.body._id) { // Логика создания события может отличаться от логики создания блога
14
+ const event = await Event.findOne({ url }); // Изменено с Blogpost на Event
15
+ if (event) { // Изменено с blogpost на event
16
+ res.status(400).send({ errorCode: 'EVENT_URL_ALREADY_IN_USE', accessToken: null }); // Изменено с POST_URL_ALREADY_IN_USE на EVENT_URL_ALREADY_IN_USE
17
+ return;
18
+ }
19
+ next();
20
+ return;
21
+ }
22
+
23
+ // Обновление события
24
+ const updatingEventId = req.body._id; // Изменено с updatingBlogpostId на updatingEventId
25
+ const existingEvent = await Event.findById(updatingEventId); // Изменено с Blogpost на Event и с existingBlogpost на existingEvent
26
+ if (!existingEvent) { // Изменено с existingBlogpost на existingEvent
27
+ res.status(404).send({ errorCode: 'EVENT_NOT_FOUND', accessToken: null }); // Изменено с BLOGPOST_NOT_FOUND на EVENT_NOT_FOUND
28
+ return;
29
+ }
30
+ if (existingEvent.url !== url) { // Изменено с existingBlogpost на existingEvent
31
+ const event = await Event.findOne({ url }); // Изменено с Blogpost на Event и с blogpost на event
32
+ if (event) { // Изменено с blogpost на event
33
+ res.status(400).send({ errorCode: 'EVENT_URL_ALREADY_IN_USE', accessToken: null }); // Изменено с POST_URL_ALREADY_IN_USE на EVENT_URL_ALREADY_IN_USE
34
+ return;
35
+ }
36
+ }
37
+
38
+ next();
39
+ } catch (err) {
40
+ console.log(err);
41
+ res.status(500).send({ message: err });
42
+ }
43
+ }
44
+
45
+ const checkNameNotEmpty = (req, res, next) => {
46
+ if (!req.body.name || req.body.name.trim() === '') {
47
+ res.status(400).send({ errorCode: "NAME_CANNOT_BE_EMPTY", accessToken: null });
48
+ return;
49
+ }
50
+
51
+ next();
52
+ };
53
+
54
+ return {
55
+ checkEventExistOrNot, // Изменено с checkBlogpostExistOrNot на checkEventExistOrNot
56
+ checkNameNotEmpty
57
+ };
58
+ };
59
+
60
+ module.exports = middlewareFactory;
@@ -11,6 +11,12 @@ module.exports = (mongoose) => {
11
11
  type: String,
12
12
  required: true
13
13
  },
14
+ status: {
15
+ type: String,
16
+ enum: ['draft','published','removed'],
17
+ default: 'draft',
18
+ required: true,
19
+ },
14
20
  description: {
15
21
  type: String,
16
22
  required: true
@@ -45,6 +51,10 @@ module.exports = (mongoose) => {
45
51
  },
46
52
  },
47
53
  creator: {
54
+ hidden: {
55
+ type: Boolean,
56
+ required: true
57
+ },
48
58
  type: {
49
59
  type: String,
50
60
  required: true
@@ -1,9 +1,15 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/events.controller");
3
+ // Middlewares
4
+ const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
5
+ const middlewareFactoryEvents = require('../middlewares/server');
3
6
  // Routes
4
7
  module.exports = function(app, db) {
5
8
  const controller = controllerFactory(db);
6
9
 
10
+ const { authJwt } = middlewareFactoryGlobal(db);
11
+ const { verifyEvent } = middlewareFactoryEvents(db);
12
+
7
13
  app.use(function(req, res, next) {
8
14
 
9
15
  res.header(
@@ -21,11 +27,19 @@ module.exports = function(app, db) {
21
27
 
22
28
  app.post(
23
29
  "/api/events/create",
30
+ [
31
+ verifyEvent.checkNameNotEmpty,
32
+ verifyEvent.checkEventExistOrNot,
33
+ ],
24
34
  controller.create
25
35
  );
26
36
 
27
37
  app.post(
28
38
  "/api/events/update",
39
+ [
40
+ verifyEvent.checkNameNotEmpty,
41
+ verifyEvent.checkEventExistOrNot,
42
+ ],
29
43
  controller.update
30
44
  );
31
45
 
@@ -34,4 +48,3 @@ module.exports = function(app, db) {
34
48
  controller.delete
35
49
  );
36
50
  };
37
-