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

Commit 64afcf0

Browse files
committed
[#80] disponibilizando dados de data e id para a rota dos posts
1 parent 6214bc8 commit 64afcf0

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/js/components/list-posts/models/list-posts.model.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,22 @@ function ListPostsModel(PostsApi, MediaApi, $q, SlugsMapModel, ApiManager){
7171
return defer.promise;
7272
}
7373

74+
75+
function _appendDateInfoToPostsList(postsLists){
76+
for(var i=0; i < postsLists.length; i ++){
77+
var post = postsLists[i];
78+
var dateInfo = post.date.getDateInfo();
79+
post.year = dateInfo.year;
80+
post.month = dateInfo.month;
81+
post.day = dateInfo.day;
82+
}
83+
}
84+
7485
postPromises.getAllPostsPromise().then(function(postsResult){
7586
model.totalPostsNumber = parseInt(ApiManager.getPath(postsResult, "totalPostsNumber"));
7687
var allPosts = ApiManager.getPath(postsResult, "allPostsPath");
77-
88+
89+
_appendDateInfoToPostsList(allPosts);
7890
SlugsMapModel.updateFromPosts(allPosts);
7991

8092

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<h2><a ng-bind-html="vc.post.title | trustAsHtml " ui-sref="post({postSlug:vc.post.slug})"></a></h2>
1+
<h2><a ng-bind-html="vc.post.title | trustAsHtml " ui-sref="post({postSlug:vc.post.slug, postYear: vc.post.year, postMonth: vc.post.month, postDay: vc.post.day, postId: vc.post.ID})"></a></h2>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<h2><a ng-bind="vc.post.title.rendered" ui-sref="post({postSlug:vc.post.slug})"></a></h2>
1+
<h2><a ng-bind="vc.post.title.rendered" ui-sref="post({postSlug:vc.post.slug, postYear: vc.post.year, postMonth: vc.post.month, postDay: vc.post.day, postId: vc.post.id})"></a></h2>

src/js/frontpress.run.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ function frontpressRun(SlugsMapModel){
2424
};
2525
}
2626

27+
if(!String.prototype.getDateInfo){
28+
String.prototype.getDateInfo = function(){
29+
var dateInfo = {};
30+
var dateObject = new Date(this);
31+
dateInfo.year = dateObject.getFullYear();
32+
dateInfo.month = dateObject.getMonth() + 1;
33+
dateInfo.day = ('0' + dateObject.getDate()).slice(-2);
34+
return dateInfo;
35+
}
36+
}
37+
2738
}
2839

2940
function extendArrayPrototype(){

0 commit comments

Comments
 (0)