Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

short description in posts list #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mirzaevra
Copy link

Cut hr and br tags from descriptions

modules/posts/post/post.component.js Outdated Show resolved Hide resolved
@@ -13,7 +13,7 @@ angular
})
;
})
.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

@@ -7,7 +7,7 @@ angular
resolve: {
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.$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.

None yet

2 participants