Skip to content

short description in posts list#15

Open
mirzaevra wants to merge 4 commits intoxepozz:masterfrom
mirzaevra:cut-functionality
Open

short description in posts list#15
mirzaevra wants to merge 4 commits intoxepozz:masterfrom
mirzaevra:cut-functionality

Conversation

@mirzaevra
Copy link

Cut hr and br tags from descriptions

;
})
.factory('PostFactory', function (POST_REQUIRED_TAGS) {
.factory('PostFactory', function ($routeParams, POST_REQUIRED_TAGS) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Неудачное место для метода. Фабрика - для создания объектов.
Текущий код можно положить прям в сущность, в которой будет getFullDescription и getShortDescription.
В контроллере уже вызывать нужный метод, основываясь на $routeParams

post: function (PostRepository, $route) {
post = PostRepository.getById($route.current.params.id);
return post
return post;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert any not related changes

this.dislikesCount = 0;

this.$onInit = () => {
setTimeout(()=> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug code should be removed

const delimiter = '<hr>'

if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) {
description = Post().getShortDescription(this.post)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = Post().getShortDescription(this.post)
description = this.post.getShortDescription()

Comment on lines +30 to +32
const delimiter = '<hr>'

if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const delimiter = '<hr>'
if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) {
if ($routeParams && !$routeParams.id) {

Comment on lines +171 to +175
getShortDescription: function (post) {
const delimiter = '<hr>'
return post.body.substring(0, post.body.indexOf(delimiter));
}
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getShortDescription: function (post) {
const delimiter = '<hr>'
return post.body.substring(0, post.body.indexOf(delimiter));
}
};
getShortDescription: function () {
const delimiter = '<hr>'
return this.body.substring(0, this.body.indexOf(delimiter));
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants