Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
[#101] - adiciona nome do autor para fullpost (sem exibir)
Browse files Browse the repository at this point in the history
  • Loading branch information
teles committed Dec 27, 2016
1 parent 08d60bb commit be765f8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"];
9 changes: 8 additions & 1 deletion src/js/components/full-post/models/full-post.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down Expand Up @@ -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]);
Expand All @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span data-ng-bind="vc.post.authorName"></span>
2 changes: 1 addition & 1 deletion src/js/components/list-posts/models/list-posts.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit be765f8

Please sign in to comment.