@intelact/bright 0.9.177 → 0.9.179
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/author/author.model.d.ts +1 -1
- package/lib/author/author.model.js +4 -4
- package/lib/boost/boost.model.d.ts +1 -1
- package/lib/boost/boost.model.js +16 -16
- package/lib/brand/brand.model.d.ts +4 -0
- package/lib/brand/brand.model.js +21 -0
- package/lib/brand/brand.model.js.map +1 -1
- package/lib/category/category.model.d.ts +1 -1
- package/lib/category/category.model.js +4 -4
- package/lib/collection/collection.model.d.ts +1 -1
- package/lib/collection/collection.model.js +4 -4
- package/lib/feedback/feedback-item.model.d.ts +1 -1
- package/lib/feedback/feedback-item.model.js +8 -8
- package/lib/feedback/feedback.model.d.ts +1 -1
- package/lib/feedback/feedback.model.js +6 -6
- package/lib/post/post.model.d.ts +1 -1
- package/lib/post/post.model.js +48 -48
- package/lib/promotion/promotion.model.d.ts +1 -1
- package/lib/promotion/promotion.model.js +17 -17
- package/lib/publisher/publisher.model.d.ts +1 -1
- package/lib/publisher/publisher.model.js +19 -19
- package/lib/question/comment.model.d.ts +1 -1
- package/lib/question/comment.model.js +8 -8
- package/lib/question/question.model.d.ts +1 -1
- package/lib/question/question.model.js +10 -10
- package/lib/quote/quote.model.d.ts +1 -1
- package/lib/quote/quote.model.js +4 -4
- package/lib/survey/survey.model.d.ts +1 -1
- package/lib/survey/survey.model.js +18 -18
- package/lib/topic/topic.model.d.ts +1 -1
- package/lib/topic/topic.model.js +4 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/user/user.model.d.ts +1 -1
- package/lib/user/user.model.js +17 -17
- package/package.json +1 -1
@@ -31,7 +31,7 @@ class Author {
|
|
31
31
|
createdOn;
|
32
32
|
updatedBy;
|
33
33
|
updatedOn;
|
34
|
-
|
34
|
+
authorization = {
|
35
35
|
manage: false,
|
36
36
|
merge: false,
|
37
37
|
};
|
@@ -59,8 +59,8 @@ class Author {
|
|
59
59
|
return data ? (0, class_transformer_1.plainToInstance)(Author, data, { groups: groups || [] }) : [];
|
60
60
|
}
|
61
61
|
authorize(user) {
|
62
|
-
this.
|
63
|
-
this.
|
62
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.AuthorManage);
|
63
|
+
this.authorization.merge = user?.hasPermission(security_1.Permission.AuthorMerge);
|
64
64
|
}
|
65
65
|
}
|
66
66
|
exports.Author = Author;
|
@@ -123,7 +123,7 @@ __decorate([
|
|
123
123
|
__decorate([
|
124
124
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
125
125
|
__metadata("design:type", Object)
|
126
|
-
], Author.prototype, "
|
126
|
+
], Author.prototype, "authorization", void 0);
|
127
127
|
__decorate([
|
128
128
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
129
129
|
__metadata("design:type", Function),
|
package/lib/boost/boost.model.js
CHANGED
@@ -35,7 +35,7 @@ let Boost = Boost_1 = class Boost {
|
|
35
35
|
createdOn;
|
36
36
|
updatedBy;
|
37
37
|
updatedOn;
|
38
|
-
|
38
|
+
authorization = {
|
39
39
|
edit: false,
|
40
40
|
publish: false,
|
41
41
|
unpublish: false,
|
@@ -66,11 +66,11 @@ let Boost = Boost_1 = class Boost {
|
|
66
66
|
return this?.metrics?.find(i => i.event === user_1.UserEvent.Download);
|
67
67
|
}
|
68
68
|
authorize(user) {
|
69
|
-
this.
|
70
|
-
this.
|
71
|
-
this.
|
72
|
-
this.
|
73
|
-
this.
|
69
|
+
this.authorization.edit = false;
|
70
|
+
this.authorization.delete = false;
|
71
|
+
this.authorization.publish = false;
|
72
|
+
this.authorization.unpublish = false;
|
73
|
+
this.authorization.end = false;
|
74
74
|
this.setLabel();
|
75
75
|
if (!user?.isBrandUser()) {
|
76
76
|
return;
|
@@ -84,15 +84,15 @@ let Boost = Boost_1 = class Boost {
|
|
84
84
|
const isPublished = this.status === common_1.StatusType.Published;
|
85
85
|
const isLive = this.label === common_1.StatusLabel.Live;
|
86
86
|
if (isDraft) {
|
87
|
-
this.
|
88
|
-
this.
|
89
|
-
this.
|
87
|
+
this.authorization.edit = !isEnded && canManage;
|
88
|
+
this.authorization.delete = !isEnded && canManage;
|
89
|
+
this.authorization.publish = !isExpired && !isEnded && canPublish;
|
90
90
|
}
|
91
91
|
if (isPublished && isUpcoming) {
|
92
|
-
this.
|
92
|
+
this.authorization.unpublish = canPublish;
|
93
93
|
}
|
94
94
|
if (isPublished && isLive) {
|
95
|
-
this.
|
95
|
+
this.authorization.end = canPublish;
|
96
96
|
}
|
97
97
|
}
|
98
98
|
setValidators() {
|
@@ -121,7 +121,7 @@ let Boost = Boost_1 = class Boost {
|
|
121
121
|
if (!this.validators) {
|
122
122
|
this.setValidators();
|
123
123
|
}
|
124
|
-
this.
|
124
|
+
this.authorization.isValid = true;
|
125
125
|
this.validators = this.validators.map(i => {
|
126
126
|
i.value = true;
|
127
127
|
return i;
|
@@ -130,17 +130,17 @@ let Boost = Boost_1 = class Boost {
|
|
130
130
|
if (!this.title || this.title.trim().length === 0) {
|
131
131
|
validator = this.validators?.find(i => i.name === 'title');
|
132
132
|
validator.value = false;
|
133
|
-
this.
|
133
|
+
this.authorization.isValid = false;
|
134
134
|
}
|
135
135
|
if (!this.startDate || !this.endDate) {
|
136
136
|
validator = this.validators?.find(i => i.name === 'period');
|
137
137
|
validator.value = false;
|
138
|
-
this.
|
138
|
+
this.authorization.isValid = false;
|
139
139
|
}
|
140
140
|
if (!this.items || this.items.length === 0) {
|
141
141
|
validator = this.validators?.find(i => i.name === 'items');
|
142
142
|
validator.value = false;
|
143
|
-
this.
|
143
|
+
this.authorization.isValid = false;
|
144
144
|
}
|
145
145
|
}
|
146
146
|
setLabel() {
|
@@ -240,7 +240,7 @@ __decorate([
|
|
240
240
|
__decorate([
|
241
241
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
242
242
|
__metadata("design:type", Object)
|
243
|
-
], Boost.prototype, "
|
243
|
+
], Boost.prototype, "authorization", void 0);
|
244
244
|
__decorate([
|
245
245
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
246
246
|
(0, class_transformer_1.Type)(() => item_1.Item),
|
@@ -28,6 +28,9 @@ export declare class Brand {
|
|
28
28
|
contactEmail: string;
|
29
29
|
settings: BrandSetting[];
|
30
30
|
publishers: Publisher[];
|
31
|
+
authorization: {
|
32
|
+
manage: boolean;
|
33
|
+
};
|
31
34
|
constructor(props?: Partial<Brand>);
|
32
35
|
getMobileStoreLinks(): Link[];
|
33
36
|
getSocialLinks(): Link[];
|
@@ -38,4 +41,5 @@ export declare class Brand {
|
|
38
41
|
isValidVideoProvider(url: string): boolean;
|
39
42
|
static toInstance(data: object, groups?: string[]): Brand;
|
40
43
|
static toInstances(data: any[], groups?: string[]): Brand[];
|
44
|
+
authorize(user: User): void;
|
41
45
|
}
|
package/lib/brand/brand.model.js
CHANGED
@@ -17,6 +17,7 @@ const publisher_model_1 = require("../publisher/publisher.model");
|
|
17
17
|
const link_model_1 = require("../link/link.model");
|
18
18
|
const brand_setting_model_1 = require("./brand-setting.model");
|
19
19
|
const user_1 = require("../user");
|
20
|
+
const security_1 = require("../security");
|
20
21
|
class Brand {
|
21
22
|
id;
|
22
23
|
shortname;
|
@@ -40,6 +41,9 @@ class Brand {
|
|
40
41
|
contactEmail;
|
41
42
|
settings;
|
42
43
|
publishers;
|
44
|
+
authorization = {
|
45
|
+
manage: false
|
46
|
+
};
|
43
47
|
constructor(props) {
|
44
48
|
Object.assign(this, props);
|
45
49
|
}
|
@@ -135,6 +139,13 @@ class Brand {
|
|
135
139
|
static toInstances(data, groups = ['admin']) {
|
136
140
|
return data ? (0, class_transformer_1.plainToInstance)(Brand, data, { groups: groups || [] }) : [];
|
137
141
|
}
|
142
|
+
authorize(user) {
|
143
|
+
this.authorization.manage = false;
|
144
|
+
if (!user.isBrandUser()) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.BrandAccountManage);
|
148
|
+
}
|
138
149
|
}
|
139
150
|
exports.Brand = Brand;
|
140
151
|
__decorate([
|
@@ -232,6 +243,10 @@ __decorate([
|
|
232
243
|
(0, class_transformer_1.Type)(() => publisher_model_1.Publisher),
|
233
244
|
__metadata("design:type", Array)
|
234
245
|
], Brand.prototype, "publishers", void 0);
|
246
|
+
__decorate([
|
247
|
+
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
248
|
+
__metadata("design:type", Object)
|
249
|
+
], Brand.prototype, "authorization", void 0);
|
235
250
|
__decorate([
|
236
251
|
(0, class_transformer_1.Expose)(),
|
237
252
|
__metadata("design:type", Function),
|
@@ -274,6 +289,12 @@ __decorate([
|
|
274
289
|
__metadata("design:paramtypes", [String]),
|
275
290
|
__metadata("design:returntype", Boolean)
|
276
291
|
], Brand.prototype, "isValidVideoProvider", null);
|
292
|
+
__decorate([
|
293
|
+
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
294
|
+
__metadata("design:type", Function),
|
295
|
+
__metadata("design:paramtypes", [user_1.User]),
|
296
|
+
__metadata("design:returntype", void 0)
|
297
|
+
], Brand.prototype, "authorize", null);
|
277
298
|
__decorate([
|
278
299
|
(0, class_transformer_1.Expose)(),
|
279
300
|
__metadata("design:type", Function),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"brand.model.js","sourceRoot":"","sources":["../../src/brand/brand.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAkE;AAIlE,+DAA2D;AAC3D,6DAAmD;AACnD,kEAAyD;AACzD,mDAA0C;AAC1C,+DAAqD;AACrD,kCAA+B;
|
1
|
+
{"version":3,"file":"brand.model.js","sourceRoot":"","sources":["../../src/brand/brand.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAkE;AAIlE,+DAA2D;AAC3D,6DAAmD;AACnD,kEAAyD;AACzD,mDAA0C;AAC1C,+DAAqD;AACrD,kCAA+B;AAC/B,0CAAyC;AAEzC,MAAa,KAAK;IAIjB,EAAE,CAAS;IAWX,SAAS,CAAS;IAMlB,OAAO,CAAe;IAMtB,YAAY,CAAa;I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S,CAAC;;yCACE;AAGxB;IADC,IAAA,0BAAM,EAAC,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;;4CAG7B;AAaD;IADC,IAAA,0BAAM,GAAE;;;;gDA0BR;AASD;IADC,IAAA,0BAAM,GAAE;;;;2CA4BR;AASD;IADC,IAAA,0BAAM,GAAE;;;;0CAgBR;AAOD;IADC,IAAA,0BAAM,GAAE;;;;8CASR;AAGD;IADC,IAAA,0BAAM,GAAE;;;;iDAmBR;AAOD;IADC,IAAA,0BAAM,GAAE;;;;8CASR;AAGD;IADC,IAAA,0BAAM,GAAE;;;;iDAmBR;AAiBD;IADC,IAAA,0BAAM,EAAC,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;;qCACd,WAAI;;sCASnB;AAvBM;IADN,IAAA,0BAAM,GAAE;;;;6BAGR;AAGM;IADN,IAAA,0BAAM,GAAE;;;;8BAGR"}
|
@@ -28,7 +28,7 @@ class Category {
|
|
28
28
|
createdOn;
|
29
29
|
updatedBy;
|
30
30
|
updatedOn;
|
31
|
-
|
31
|
+
authorization = {
|
32
32
|
manage: false
|
33
33
|
};
|
34
34
|
constructor(props) {
|
@@ -67,11 +67,11 @@ class Category {
|
|
67
67
|
return data ? (0, class_transformer_1.plainToInstance)(Category, data, { groups: groups || [] }) : [];
|
68
68
|
}
|
69
69
|
authorize(user) {
|
70
|
-
this.
|
70
|
+
this.authorization.manage = false;
|
71
71
|
if (!user?.isBrandUser()) {
|
72
72
|
return;
|
73
73
|
}
|
74
|
-
this.
|
74
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.CategoryManage);
|
75
75
|
}
|
76
76
|
}
|
77
77
|
exports.Category = Category;
|
@@ -125,7 +125,7 @@ __decorate([
|
|
125
125
|
__decorate([
|
126
126
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
127
127
|
__metadata("design:type", Object)
|
128
|
-
], Category.prototype, "
|
128
|
+
], Category.prototype, "authorization", void 0);
|
129
129
|
__decorate([
|
130
130
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
131
131
|
__metadata("design:type", Function),
|
@@ -27,7 +27,7 @@ class Collection {
|
|
27
27
|
createdOn;
|
28
28
|
updatedBy;
|
29
29
|
updatedOn;
|
30
|
-
|
30
|
+
authorization = {
|
31
31
|
manage: false
|
32
32
|
};
|
33
33
|
publisher;
|
@@ -59,11 +59,11 @@ class Collection {
|
|
59
59
|
return data ? (0, class_transformer_1.plainToInstance)(Collection, data, { groups: groups || [] }) : [];
|
60
60
|
}
|
61
61
|
authorize(user, publisher) {
|
62
|
-
this.
|
62
|
+
this.authorization.manage = false;
|
63
63
|
if (!user.isPublisherUser() || publisher.status !== security_1.AccountStatus.Active) {
|
64
64
|
return;
|
65
65
|
}
|
66
|
-
this.
|
66
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.CollectionManage);
|
67
67
|
}
|
68
68
|
}
|
69
69
|
exports.Collection = Collection;
|
@@ -109,7 +109,7 @@ __decorate([
|
|
109
109
|
__decorate([
|
110
110
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
111
111
|
__metadata("design:type", Object)
|
112
|
-
], Collection.prototype, "
|
112
|
+
], Collection.prototype, "authorization", void 0);
|
113
113
|
__decorate([
|
114
114
|
(0, class_transformer_1.Expose)(),
|
115
115
|
(0, class_transformer_1.Type)(() => publisher_model_1.Publisher),
|
@@ -25,7 +25,7 @@ class FeedbackItem {
|
|
25
25
|
createdOn;
|
26
26
|
updatedBy;
|
27
27
|
updatedOn;
|
28
|
-
|
28
|
+
authorization = {
|
29
29
|
manage: false,
|
30
30
|
publish: false,
|
31
31
|
archive: false,
|
@@ -41,17 +41,17 @@ class FeedbackItem {
|
|
41
41
|
return data ? (0, class_transformer_1.plainToInstance)(FeedbackItem, data, { groups: groups || [] }) : [];
|
42
42
|
}
|
43
43
|
authorize(user) {
|
44
|
-
this.
|
45
|
-
this.
|
46
|
-
this.
|
44
|
+
this.authorization.manage = false;
|
45
|
+
this.authorization.publish = false;
|
46
|
+
this.authorization.archive = false;
|
47
47
|
if (!user?.isBrandUser()) {
|
48
48
|
return;
|
49
49
|
}
|
50
50
|
const canManage = user?.hasPermission(security_1.Permission.FeedbackManage);
|
51
51
|
const canPublish = user?.hasPermission(security_1.Permission.FeedbackPublish);
|
52
|
-
this.
|
53
|
-
this.
|
54
|
-
this.
|
52
|
+
this.authorization.manage = canManage && !this.published;
|
53
|
+
this.authorization.publish = canPublish && !this.published;
|
54
|
+
this.authorization.archive = canPublish && this.published;
|
55
55
|
}
|
56
56
|
validate() {
|
57
57
|
const content = this?.question?.trim();
|
@@ -122,7 +122,7 @@ __decorate([
|
|
122
122
|
__decorate([
|
123
123
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
124
124
|
__metadata("design:type", Object)
|
125
|
-
], FeedbackItem.prototype, "
|
125
|
+
], FeedbackItem.prototype, "authorization", void 0);
|
126
126
|
__decorate([
|
127
127
|
(0, class_transformer_1.Expose)(),
|
128
128
|
(0, class_transformer_1.Type)(() => feedback_option_model_1.FeedbackOption),
|
@@ -31,7 +31,7 @@ class Feedback {
|
|
31
31
|
createdOn;
|
32
32
|
updatedBy;
|
33
33
|
updatedOn;
|
34
|
-
|
34
|
+
authorization = {
|
35
35
|
manage: false,
|
36
36
|
publish: false,
|
37
37
|
};
|
@@ -66,13 +66,13 @@ class Feedback {
|
|
66
66
|
return data ? (0, class_transformer_1.plainToInstance)(Feedback, data, { groups: groups || [] }) : [];
|
67
67
|
}
|
68
68
|
authorize(user) {
|
69
|
-
this.
|
70
|
-
this.
|
69
|
+
this.authorization.manage = false;
|
70
|
+
this.authorization.publish = false;
|
71
71
|
if (!user?.isBrandUser()) {
|
72
72
|
return;
|
73
73
|
}
|
74
|
-
this.
|
75
|
-
this.
|
74
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.FeedbackManage);
|
75
|
+
this.authorization.publish = user?.hasPermission(security_1.Permission.FeedbackPublish);
|
76
76
|
if (this.items?.length) {
|
77
77
|
for (const item of this.items) {
|
78
78
|
item.authorize(user);
|
@@ -131,7 +131,7 @@ __decorate([
|
|
131
131
|
__decorate([
|
132
132
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
133
133
|
__metadata("design:type", Object)
|
134
|
-
], Feedback.prototype, "
|
134
|
+
], Feedback.prototype, "authorization", void 0);
|
135
135
|
__decorate([
|
136
136
|
(0, class_transformer_1.Expose)(),
|
137
137
|
(0, class_transformer_1.Type)(() => feedback_item_model_1.FeedbackItem),
|
package/lib/post/post.model.d.ts
CHANGED
@@ -68,7 +68,7 @@ export declare class Post {
|
|
68
68
|
feedback: Feedback;
|
69
69
|
collection: Post[];
|
70
70
|
gallery: GalleryItem[];
|
71
|
-
|
71
|
+
authorization: IPostAuthorization;
|
72
72
|
validators: Item<boolean>[];
|
73
73
|
constructor(props?: Partial<Post>);
|
74
74
|
get type(): PostType;
|
package/lib/post/post.model.js
CHANGED
@@ -61,7 +61,7 @@ class Post {
|
|
61
61
|
feedback;
|
62
62
|
collection;
|
63
63
|
gallery;
|
64
|
-
|
64
|
+
authorization = {
|
65
65
|
view: false,
|
66
66
|
create: false,
|
67
67
|
edit: false,
|
@@ -169,9 +169,9 @@ class Post {
|
|
169
169
|
}
|
170
170
|
}
|
171
171
|
validateForPublic() {
|
172
|
-
this.
|
173
|
-
this.
|
174
|
-
this.
|
172
|
+
this.authorization.canLike = true;
|
173
|
+
this.authorization.canShare = true;
|
174
|
+
this.authorization.canBookmark = [
|
175
175
|
post_type_1.PostType.Article,
|
176
176
|
post_type_1.PostType.Book,
|
177
177
|
post_type_1.PostType.Audio,
|
@@ -179,28 +179,28 @@ class Post {
|
|
179
179
|
post_type_1.PostType.News,
|
180
180
|
post_type_1.PostType.Event,
|
181
181
|
].includes(this.type) ? true : false;
|
182
|
-
this.
|
182
|
+
this.authorization.canDownload = [
|
183
183
|
post_type_1.PostType.Article,
|
184
184
|
post_type_1.PostType.Book,
|
185
185
|
].includes(this.type) ? true : false;
|
186
|
-
this.
|
186
|
+
this.authorization.showGallery = [
|
187
187
|
post_type_1.PostType.Event,
|
188
188
|
post_type_1.PostType.News,
|
189
189
|
].includes(this.type) ? true : false;
|
190
190
|
}
|
191
191
|
authorize(user, publisher) {
|
192
|
-
this.
|
193
|
-
this.
|
194
|
-
this.
|
195
|
-
this.
|
196
|
-
this.
|
197
|
-
this.
|
198
|
-
this.
|
199
|
-
this.
|
200
|
-
this.
|
201
|
-
this.
|
202
|
-
this.
|
203
|
-
this.
|
192
|
+
this.authorization.view = false;
|
193
|
+
this.authorization.create = false;
|
194
|
+
this.authorization.edit = false;
|
195
|
+
this.authorization.delete = false;
|
196
|
+
this.authorization.draft = false;
|
197
|
+
this.authorization.approve = false;
|
198
|
+
this.authorization.publish = false;
|
199
|
+
this.authorization.unpublish = false;
|
200
|
+
this.authorization.archive = false;
|
201
|
+
this.authorization.unarchive = false;
|
202
|
+
this.authorization.block = false;
|
203
|
+
this.authorization.unblock = false;
|
204
204
|
const isDraft = this.status === status_type_1.StatusType.Draft;
|
205
205
|
const isApproved = this.status === status_type_1.StatusType.Ready;
|
206
206
|
const isPublished = this.status === status_type_1.StatusType.Published;
|
@@ -235,14 +235,14 @@ class Post {
|
|
235
235
|
break;
|
236
236
|
}
|
237
237
|
if (isBlocked) {
|
238
|
-
this.
|
239
|
-
this.
|
238
|
+
this.authorization.block = false;
|
239
|
+
this.authorization.unblock = canBlock;
|
240
240
|
}
|
241
241
|
else {
|
242
|
-
this.
|
243
|
-
this.
|
242
|
+
this.authorization.block = canBlock;
|
243
|
+
this.authorization.unblock = false;
|
244
244
|
}
|
245
|
-
this.
|
245
|
+
this.authorization.view = canView;
|
246
246
|
return;
|
247
247
|
}
|
248
248
|
if (user.hasPublisherAuthorization(publisher.id)) {
|
@@ -284,28 +284,28 @@ class Post {
|
|
284
284
|
canArchive = user?.hasPermission(security_1.Permission.PostNewsArchive);
|
285
285
|
break;
|
286
286
|
}
|
287
|
-
this.
|
287
|
+
this.authorization.view = canView;
|
288
288
|
if (publisher.status !== security_1.AccountStatus.Active) {
|
289
289
|
return;
|
290
290
|
}
|
291
|
-
this.
|
291
|
+
this.authorization.create = canEdit && publisher.hasAuthorizedType(this.postType);
|
292
292
|
if (isDraft) {
|
293
|
-
this.
|
294
|
-
this.
|
295
|
-
this.
|
296
|
-
this.
|
293
|
+
this.authorization.edit = canEdit;
|
294
|
+
this.authorization.delete = canEdit;
|
295
|
+
this.authorization.approve = canEdit;
|
296
|
+
this.authorization.archive = canArchive;
|
297
297
|
}
|
298
298
|
if (isApproved) {
|
299
|
-
this.
|
300
|
-
this.
|
301
|
-
this.
|
299
|
+
this.authorization.draft = canEdit;
|
300
|
+
this.authorization.publish = canPublish;
|
301
|
+
this.authorization.archive = canArchive;
|
302
302
|
}
|
303
303
|
if (isPublished) {
|
304
|
-
this.
|
305
|
-
this.
|
304
|
+
this.authorization.unpublish = canPublish;
|
305
|
+
this.authorization.archive = canArchive;
|
306
306
|
}
|
307
307
|
if (isArchived) {
|
308
|
-
this.
|
308
|
+
this.authorization.unarchive = canArchive;
|
309
309
|
}
|
310
310
|
}
|
311
311
|
}
|
@@ -313,8 +313,8 @@ class Post {
|
|
313
313
|
if (!this.validators) {
|
314
314
|
this.setValidators();
|
315
315
|
}
|
316
|
-
this.
|
317
|
-
this.
|
316
|
+
this.authorization.isValid = true;
|
317
|
+
this.authorization.showGallery = [
|
318
318
|
post_type_1.PostType.Event,
|
319
319
|
post_type_1.PostType.News,
|
320
320
|
].includes(this.type) ? true : false;
|
@@ -327,53 +327,53 @@ class Post {
|
|
327
327
|
if (!this.author) {
|
328
328
|
validator = this.validators?.find(i => i.name === 'author');
|
329
329
|
validator.value = false;
|
330
|
-
this.
|
330
|
+
this.authorization.isValid = false;
|
331
331
|
}
|
332
332
|
if (!this.title || !this.title.trim()) {
|
333
333
|
validator = this.validators?.find(i => i.name === 'title');
|
334
334
|
validator.value = false;
|
335
|
-
this.
|
335
|
+
this.authorization.isValid = false;
|
336
336
|
}
|
337
337
|
if (!this.description || !this.description.trim()) {
|
338
338
|
validator = this.validators?.find(i => i.name === 'description');
|
339
339
|
validator.value = false;
|
340
|
-
this.
|
340
|
+
this.authorization.isValid = false;
|
341
341
|
}
|
342
342
|
if (!this.imageUrl || !this.imageUrl.trim()) {
|
343
343
|
validator = this.validators?.find(i => i.name === 'image');
|
344
344
|
validator.value = false;
|
345
|
-
this.
|
345
|
+
this.authorization.isValid = false;
|
346
346
|
}
|
347
347
|
if (!this.feedUrl || !this.feedUrl.trim()) {
|
348
348
|
validator = this.validators?.find(i => i.name === 'feed');
|
349
349
|
validator.value = false;
|
350
|
-
this.
|
350
|
+
this.authorization.isValid = false;
|
351
351
|
}
|
352
352
|
if (contentMandatory.includes(this.type) && !this.content?.trim()) {
|
353
353
|
validator = this.validators?.find(i => i.name === 'content');
|
354
354
|
validator.value = false;
|
355
|
-
this.
|
355
|
+
this.authorization.isValid = false;
|
356
356
|
}
|
357
357
|
if (this.type === post_type_1.PostType.Book && !this.pdfUrl?.trim()) {
|
358
358
|
validator = this.validators?.find(i => i.name === 'pdf');
|
359
359
|
validator.value = false;
|
360
|
-
this.
|
360
|
+
this.authorization.isValid = false;
|
361
361
|
}
|
362
362
|
if (this.type === post_type_1.PostType.Audio && !this.mediaUrl?.trim()) {
|
363
363
|
validator = this.validators?.find(i => i.name === 'audio');
|
364
364
|
validator.value = false;
|
365
|
-
this.
|
365
|
+
this.authorization.isValid = false;
|
366
366
|
}
|
367
367
|
if (this.type === post_type_1.PostType.Video && !this.mediaUrl?.trim()) {
|
368
368
|
validator = this.validators?.find(i => i.name === 'video');
|
369
369
|
validator.value = false;
|
370
|
-
this.
|
370
|
+
this.authorization.isValid = false;
|
371
371
|
}
|
372
372
|
if (this.type === post_type_1.PostType.Event
|
373
373
|
&& (!this?.info?.events || this?.info?.events?.length === 0)) {
|
374
374
|
validator = this.validators?.find(i => i.name === 'schedule');
|
375
375
|
validator.value = false;
|
376
|
-
this.
|
376
|
+
this.authorization.isValid = false;
|
377
377
|
}
|
378
378
|
}
|
379
379
|
get statusContext() {
|
@@ -631,7 +631,7 @@ __decorate([
|
|
631
631
|
__decorate([
|
632
632
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
633
633
|
__metadata("design:type", Object)
|
634
|
-
], Post.prototype, "
|
634
|
+
], Post.prototype, "authorization", void 0);
|
635
635
|
__decorate([
|
636
636
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
637
637
|
(0, class_transformer_1.Type)(() => item_model_1.Item),
|