From be765f82095c09c8c8caf7587154e8cbd2eb9631 Mon Sep 17 00:00:00 2001 From: Jota Teles Date: Tue, 27 Dec 2016 11:50:32 -0200 Subject: [PATCH] [#101] - adiciona nome do autor para fullpost (sem exibir) --- .../models/frontpress.model.js | 1 + .../full-post-author-name.directive.js | 20 +++++++++++++++++++ .../full-post/models/full-post.model.js | 9 ++++++++- .../full-post-author-name.template.html | 1 + .../list-posts/models/list-posts.model.js | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/js/components/full-post/directives/full-post-author-name.directive.js create mode 100644 src/js/components/full-post/templates/full-post-author-name.template.html diff --git a/src/js/components/frontpress-provider/models/frontpress.model.js b/src/js/components/frontpress-provider/models/frontpress.model.js index 5eddbd2..c832f2e 100644 --- a/src/js/components/frontpress-provider/models/frontpress.model.js +++ b/src/js/components/frontpress-provider/models/frontpress.model.js @@ -109,6 +109,7 @@ function FrontPressProvider(FrontPressConfigurationFile, $disqusProvider){ "components.fullpost": "/js/components/full-post/templates/full-post.template.html", "components.fullpost.categories": "/js/components/full-post/templates/full-post-categories-list.template.html", "components.fullpost.tags": "/js/components/full-post/templates/full-post-tags-list.template.html", + "components.fullpost.authorname": "/js/components/full-post/templates/full-post-author-name.template.html", "components.listposts": "/js/components/list-posts/templates/list-posts.template.html", "components.pagehead": "/js/components/page-head/templates/page-head.template.html", "components.postdate": "/js/components/post-date/templates/post-date.template.html", diff --git a/src/js/components/full-post/directives/full-post-author-name.directive.js b/src/js/components/full-post/directives/full-post-author-name.directive.js new file mode 100644 index 0000000..d869a8f --- /dev/null +++ b/src/js/components/full-post/directives/full-post-author-name.directive.js @@ -0,0 +1,20 @@ +var module = angular.module("frontpress.components.full-post"); + +function FullPostAuthorNameDirective($FrontPress){ + var directive = { + restrict: "AE", + scope: { + post: "=post" + }, + templateUrl: $FrontPress.getTemplateUrl("components.fullpost.authorname"), + controller: "FullPostGenericDirectiveController", + controllerAs: "vc", + bindToController: true, + replace: true + }; + + return directive; +} + +module.directive("fullPostAuthorName", FullPostAuthorNameDirective); +FullPostAuthorNameDirective.$inject = ["$FrontPress"]; diff --git a/src/js/components/full-post/models/full-post.model.js b/src/js/components/full-post/models/full-post.model.js index 331930a..23d486d 100644 --- a/src/js/components/full-post/models/full-post.model.js +++ b/src/js/components/full-post/models/full-post.model.js @@ -15,6 +15,8 @@ function FullPostModel(PostsApi, TagsApi, CategoriesApi, $q, MediaApi, $FrontPre setFeaturedImage: setFeaturedImage, setId: setId, setTitle: setTitle, + authorName: null, + setAuthorName: setAuthorName, slug: null, tags: [], title: null, @@ -24,6 +26,10 @@ function FullPostModel(PostsApi, TagsApi, CategoriesApi, $q, MediaApi, $FrontPre model.categories.push(category); } + function setAuthorName(authorName){ + model.authorName = authorName; + } + function addTag(tag){ model.tags.push(tag); } @@ -132,6 +138,7 @@ function FullPostModel(PostsApi, TagsApi, CategoriesApi, $q, MediaApi, $FrontPre case "v1": model.setFeaturedImage(result.featured_image); + model.setAuthorName(result.author.name); for (var category in result.categories){ model.addCategory(result.categories[category]); @@ -158,7 +165,7 @@ function FullPostModel(PostsApi, TagsApi, CategoriesApi, $q, MediaApi, $FrontPre return defer.promise; } - var fieldsFilterList = "title,featured_image,featured_media,date,categories,content,slug,tags,{0}".format(ApiManagerMap.postId[0]); + var fieldsFilterList = "title,featured_image,featured_media,date,categories,content,slug,tags,{0},author".format(ApiManagerMap.postId[0]); var promiseConfigs = { fields: fieldsFilterList }; diff --git a/src/js/components/full-post/templates/full-post-author-name.template.html b/src/js/components/full-post/templates/full-post-author-name.template.html new file mode 100644 index 0000000..4219f1e --- /dev/null +++ b/src/js/components/full-post/templates/full-post-author-name.template.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/js/components/list-posts/models/list-posts.model.js b/src/js/components/list-posts/models/list-posts.model.js index c66a7ce..91cab82 100644 --- a/src/js/components/list-posts/models/list-posts.model.js +++ b/src/js/components/list-posts/models/list-posts.model.js @@ -57,7 +57,7 @@ function ListPostsModel(PostsApi, MediaApi, $q, SlugsMapModel, ApiManager){ var defer = $q.defer(); var configs = { - fields: "ID,title,date,featured_image,excerpt" + fields: "ID,title,date,featured_image,excerpt,author" }; var postPromises = {