diff --git a/src/app/components/article-service/article.service.js b/src/app/components/article-service/article.service.js index 5f07308..a74667d 100644 --- a/src/app/components/article-service/article.service.js +++ b/src/app/components/article-service/article.service.js @@ -19,6 +19,7 @@ getTopics: getTopics, getTopicById: getTopicById, getProposals: getProposals, + getProposalById: getProposalById, getProposalsByTopicId: getProposalsByTopicId, getEvents: getEvents, subscribeToEvent: subscribeToEvent, @@ -108,26 +109,18 @@ // }); // - searchTopics(params, cbSuccess, cbError); + searchProposals({ + query: '' + }, cbSuccess, cbError); } - /** - * Ex.: /api/v1/articles/[article_id]/children?[params]content_type=ProposalsDiscussionPlugin::Proposal - * Ex.: /api/v1/articles/103644/children?limit=20&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal - * - * @param {Integer} topicId topic where has those proposals - * @param {Object} params params for pagination ant others - * @param {Function} cbSuccess callback for success - * @param {Function} cbError callback for error - * @return {Array} [description] - */ - function getProposalsByTopicId (topicId, params, cbSuccess, cbError) { - var url = service.apiArticles + topicId + '/children'; + function getProposalById (proposalId, params, cbSuccess, cbError) { + var url = service.apiArticles + proposalId; var paramsExtended = angular.extend({ // 'fields[]': ['id', 'title', 'abstract', 'children', 'children_count', 'ranking_position', 'hits', 'votes_for', 'votes_against'], - // 'limit':'20', // 'per_page':'1', + 'limit':'1', 'content_type':'ProposalsDiscussionPlugin::Proposal' }, params); @@ -137,6 +130,21 @@ }).catch(function(error){ cbError(error); }); + + } + + /** + * Ex.: /api/v1/articles/[article_id]/children?[params]content_type=ProposalsDiscussionPlugin::Proposal + * Ex.: /api/v1/articles/103644/children?limit=20&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal + * + * @param {Integer} topicId topic where has those proposals + * @param {Object} params params for pagination ant others + * @param {Function} cbSuccess callback for success + * @param {Function} cbError callback for error + * @return {Array} [description] + */ + function getProposalsByTopicId (topicId, params, cbSuccess, cbError) { + getProposalById(topicId + '/children', params, cbSuccess, cbError); } function getEvents (community_id, params, cbSuccess, cbError) { @@ -205,11 +213,12 @@ // Ex.: /api/v1/search/article?type=ProposalsDiscussionPlugin::Proposal&query=cisternas var url = '/api/v1/search/article'; var paramsExtended = angular.extend({ - 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'], + // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'], 'type': 'ProposalsDiscussionPlugin::Proposal' }, params); UtilService.get(url, {params: paramsExtended}).then(function(data){ + _pipeInjectSlugIntoParentProgram(data); cbSuccess(data); }).catch(function(error){ cbError(error); @@ -217,6 +226,9 @@ } function _pipeInjectSlugIntoParentProgram(data){ + if(!data.articles && data.article){ + data.articles = [data.article]; + } var proposals = data.articles; for (var i = proposals.length - 1; i >= 0; i--) { var proposal = proposals[i]; diff --git a/src/app/components/proposal-box/proposal-box.directive.js b/src/app/components/proposal-box/proposal-box.directive.js index 85dd159..7b40e64 100644 --- a/src/app/components/proposal-box/proposal-box.directive.js +++ b/src/app/components/proposal-box/proposal-box.directive.js @@ -27,11 +27,12 @@ }; - ProposalBoxController.prototype.showContent2 = function (topic) { + ProposalBoxController.prototype.showContent = function (slug) { var vm = this; vm.$state.go('programa-conteudo', { - slug: topic.slug + slug: slug, + proposal_id: vm.proposal.id }, { location: true }); diff --git a/src/app/components/proposal-box/proposal-box.html b/src/app/components/proposal-box/proposal-box.html index 8f4cb96..0076118 100644 --- a/src/app/components/proposal-box/proposal-box.html +++ b/src/app/components/proposal-box/proposal-box.html @@ -5,10 +5,13 @@