Skip to content

Commit

Permalink
secs and closing iframe in AES
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Dec 5, 2014
1 parent 4be3196 commit d3eeaf7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
20 changes: 20 additions & 0 deletions newscoop/src/Newscoop/NewscoopBundle/Resources/public/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ var app = angular.module('treeApp', ['ui.tree', 'ui.tree-filter', 'ui.highlight'
uiTreeFilterSettingsProvider.descendantCollection = "__children";
});

app.directive('ngCloseIframeClick', [
function(){
return {
link: function (scope, element, attr) {
var attachFunction = attr.ngCloseIframeClick;
var clickAction = attr.ngConfirmedClick;
element.bind('click', function (event) {
//console.log(attachFunction);
var result = scope.$eval(function(scope, locals) {
//$scope.attachFunction()
console.log(scope);
console.log(locals);
});
console.log(scope);
});
}
};
}]);

app.factory('TopicsFactory', function($http) {
return {
getTopics: function(languageCode, articleNumber) {
Expand Down Expand Up @@ -381,6 +400,7 @@ app.controller('treeCtrl', function($scope, TopicsFactory, $filter) {
TopicsFactory.attachTopics(topicsIds, articleNumber, languageCode).success(function (response) {
if (response.status) {
flashMessage(response.message);
return true;
} else {
flashMessage(response.message, 'error');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{% block admin_content %}

<div class="system_pref" ng-app="treeApp" ng-controller="treeCtrl">
<button class="button right-floated" type="button" ng-click="attachTopics('{{ articleNumber }}', '{{ articleLanguage }}')">{{ 'topics.btn.saveandclose'|trans }}</button>
<button class="button right-floated" type="button" confirmed-click="parent.$.fancybox.close()" ng-close-iframe-click="attachTopics('{{ articleNumber }}', '{{ articleLanguage }}')">{{ 'topics.btn.saveandclose'|trans }}</button>
<button class="button right-floated" onclick="parent.$.fancybox.close(); return false;">{{ 'topics.btn.close'|trans }}</button>
<h3>{{ 'topics.title'|trans }}</h3>
{% if compactView == false %}
Expand Down
24 changes: 23 additions & 1 deletion spec/Newscoop/GimmeBundle/Controller/TopicsControllerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Newscoop\NewscoopBundle\Entity\Topic;
use Symfony\Component\HttpFoundation\ParameterBag;
use Doctrine\Common\Collections\ArrayCollection;
use Newscoop\Entity\Repository\ArticleTopicRepository;

class TopicsControllerSpec extends ObjectBehavior
{
Expand All @@ -22,7 +23,8 @@ public function let(
AbstractQuery $query,
TopicRepository $topicRepository,
PaginatorService $paginator,
Topic $topic
Topic $topic,
ArticleTopicRepository $articleTopicRepository
) {
$container->get('em')->willReturn($entityManager);
$container->get('request')->willReturn($request);
Expand Down Expand Up @@ -129,4 +131,24 @@ public function its_searchTopicsAction_should_return_empty_array_when_no_results

$this->searchTopicsAction($request)->shouldReturn(array());
}

public function its_getArticlesTopicsAction_should_return_list_of_topics_for_given_article($request, $entityManager, $articleTopicRepository, $query, $topic, $paginator)
{
$entityManager->getRepository('Newscoop\Entity\ArticleTopic')->willReturn($articleTopicRepository);
$topic->getId()->willReturn(1);
$topic->getTitle()->willReturn('test topic');
$topic->getRoot()->willReturn(1);
$topic->getParent()->willReturn(null);
$topics = array('items' => array(
$topic
));

$articleTopicRepository->getAllArticleTopics(64, 'en')->willReturn($query);

$paginator->paginate($query, array(
'distinct' => false
))->willReturn($topics);

$this->getArticlesTopicsAction(64, 'en')->shouldReturn($topics);
}
}

0 comments on commit d3eeaf7

Please sign in to comment.