Created
October 23, 2014 05:58
-
-
Save rmcauley/3793ba0078aac4f6ba81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FrameTransformer = function(frame, $state, $http, user) { | |
frame.go = function() { | |
if (frame.coach.user_id == user.user_id) { | |
$state.go("rt.frame.as_coach", { "frame_id": frame.id }); | |
} | |
else { | |
$state.go("rt.frame", { "frame_id": frame.id }); | |
} | |
}; | |
if (frame.posts) { | |
frame.posts = $.map(frame.posts, function(p) { | |
return PostDataTransformer(p, $http); | |
}); | |
} | |
console.log("ok"); | |
return frame; | |
}; | |
var FrameResolver = function($resource, $stateParams, $state, $http, user) { | |
return $resource("/dj/rt_mobile/api/frames/" + $stateParams.frame_id, null, | |
{ | |
get: { | |
method: "GET", | |
responseType: "json", | |
transformResponse: function(frame) { | |
return FrameTransformer(frame, $state, $http, user); | |
} | |
} | |
} | |
).get().$promise; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment