{"action":"created","comment":{"url":"https://api.github.com/repos/superdesk/liveblog/pulls/comments/48143685","id":48143685,"diff_hunk":"@@ -0,0 +1,87 @@\n+(function() {\n+    'use strict';\n+\n+    ThemeSettingsModalController.$inject = ['$scope', 'api', '$q', 'lodash'];\n+    function ThemeSettingsModalController($scope, api, $q, _) {\n+        var vm = this;\n+        angular.extend(vm, {\n+            optionsAreloading: true,\n+            modalOpened: angular.isDefined(vm.theme),\n+            settings: angular.copy(vm.theme.settings) || {},\n+            options: [],\n+            submitSettings: function() {\n+                api.themes.update(vm.theme, {settings: vm.settings}).then(function(data) {\n+                    vm.closeModal();\n+                }, function(error) {\n+                    console.log('error!', error);\n+                });\n+            },\n+            closeModal: function() {\n+                vm.modalOpened = false;\n+                vm.theme = undefined;\n+            }\n+        });\n+        // Initialization\n+        /**\n+         * Collect a list of options for the given theme and its parents\n+         * @param {object} theme\n+         * @returns {array} list of options\n+         */\n+        function collectOptions(theme, options) {\n+            // options is used for recursiveness\n+            options = options || [];\n+            // keep the theme's options in `options`\n+            if (theme.options) {\n+                var alreadyPresent = _.map(options, function(o) {return o.name;});\n+                // keep only options that are not already saved (children options are prioritary)\n+                options = _.filter(theme.options, function(option) {\n+                    return alreadyPresent.indexOf(option.name) === -1;\n+                }).concat(options);\n+            }\n+            // retrieve parent options\n+            if (theme['extends']) {\n+                return api.themes.getById(theme['extends']).then(function(parentTheme) {\n+                    return collectOptions(parentTheme, options);\n+                });\n+            } else {\n+                // return the options when there is no more parent theme\n+                return $q.when(options);\n+            }\n+        }\n+        // collect the options for the theme and its parents\n+        collectOptions(vm.theme).then(function(options) {\n+            // set default settings value from options default values\n+            options.forEach(function(option) {\n+                if (!angular.isDefined(vm.settings[option.name])) {\n+                    vm.settings[option.name] = option['default'];\n+                }\n+            });\n+            angular.extend(vm, {\n+                options: options,\n+                optionsAreloading: false\n+            });\n+        });\n+        // watch the modalOpened model to reset the selected theme when the user close the modal\n+        $scope.$watch(\n+            function() {return vm.modalOpened;},\n+            function(isOpened) {\n+                if (!isOpened) {\n+                    vm.closeModal();\n+                }\n+            }\n+        );\n+    }\n+\n+    angular.module('liveblog.themes')\n+    .directive('themeSettingsModal', function() {\n+        return {\n+            templateUrl: 'scripts/liveblog-themes/views/theme-settings-modal.html',\n+            scope: {\n+                theme: '=theme'","path":"client/app/scripts/liveblog-themes/theme-settings-modal.js","position":80,"original_position":80,"commit_id":"3736bd52bf7bd1aaad8b5729fe344677f92d9bf8","original_commit_id":"3736bd52bf7bd1aaad8b5729fe344677f92d9bf8","user":{"login":"vied12","id":180617,"avatar_url":"https://avatars.githubusercontent.com/u/180617?v=3","gravatar_id":"","url":"https://api.github.com/users/vied12","html_url":"https://github.com/vied12","followers_url":"https://api.github.com/users/vied12/followers","following_url":"https://api.github.com/users/vied12/following{/other_user}","gists_url":"https://api.github.com/users/vied12/gists{/gist_id}","starred_url":"https://api.github.com/users/vied12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vied12/subscriptions","organizations_url":"https://api.github.com/users/vied12/orgs","repos_url":"https://api.github.com/users/vied12/repos","events_url":"https://api.github.com/users/vied12/events{/privacy}","received_events_url":"https://api.github.com/users/vied12/received_events","type":"User","site_admin":false},"body":"Why ? I think it is needed","created_at":"2015-12-21T13:07:33Z","updated_at":"2015-12-21T13:07:33Z","html_url":"https://github.com/superdesk/liveblog/pull/305#discussion_r48143685","pull_request_url":"https://api.github.com/repos/superdesk/liveblog/pulls/305","_links":{"self":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/comments/48143685"},"html":{"href":"https://github.com/superdesk/liveblog/pull/305#discussion_r48143685"},"pull_request":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/305"}}},"pull_request":{"url":"https://api.github.com/repos/superdesk/liveblog/pulls/305","id":53985829,"html_url":"https://github.com/superdesk/liveblog/pull/305","diff_url":"https://github.com/superdesk/liveblog/pull/305.diff","patch_url":"https://github.com/superdesk/liveblog/pull/305.patch","issue_url":"https://api.github.com/repos/superdesk/liveblog/issues/305","number":305,"state":"open","locked":false,"title":"Feature/theme settings in theme manager LBSD-780","user":{"login":"vied12","id":180617,"avatar_url":"https://avatars.githubusercontent.com/u/180617?v=3","gravatar_id":"","url":"https://api.github.com/users/vied12","html_url":"https://github.com/vied12","followers_url":"https://api.github.com/users/vied12/followers","following_url":"https://api.github.com/users/vied12/following{/other_user}","gists_url":"https://api.github.com/users/vied12/gists{/gist_id}","starred_url":"https://api.github.com/users/vied12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vied12/subscriptions","organizations_url":"https://api.github.com/users/vied12/orgs","repos_url":"https://api.github.com/users/vied12/repos","events_url":"https://api.github.com/users/vied12/events{/privacy}","received_events_url":"https://api.github.com/users/vied12/received_events","type":"User","site_admin":false},"body":"- [x] We can now list and change the settings for a theme in the Theme Manager\r\n- [x] After a theme update, all the related blogs (+ inheritance) are deployed\r\n- [x] A blog link is now available even on a development environment (local link)","created_at":"2015-12-17T14:56:23Z","updated_at":"2015-12-21T13:07:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1dc549cd8585312b10dc58b3b5230e83f4e5095","assignee":{"login":"vied12","id":180617,"avatar_url":"https://avatars.githubusercontent.com/u/180617?v=3","gravatar_id":"","url":"https://api.github.com/users/vied12","html_url":"https://github.com/vied12","followers_url":"https://api.github.com/users/vied12/followers","following_url":"https://api.github.com/users/vied12/following{/other_user}","gists_url":"https://api.github.com/users/vied12/gists{/gist_id}","starred_url":"https://api.github.com/users/vied12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vied12/subscriptions","organizations_url":"https://api.github.com/users/vied12/orgs","repos_url":"https://api.github.com/users/vied12/repos","events_url":"https://api.github.com/users/vied12/events{/privacy}","received_events_url":"https://api.github.com/users/vied12/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/superdesk/liveblog/pulls/305/commits","review_comments_url":"https://api.github.com/repos/superdesk/liveblog/pulls/305/comments","review_comment_url":"https://api.github.com/repos/superdesk/liveblog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/superdesk/liveblog/issues/305/comments","statuses_url":"https://api.github.com/repos/superdesk/liveblog/statuses/3736bd52bf7bd1aaad8b5729fe344677f92d9bf8","head":{"label":"superdesk:feature/theme-settings","ref":"feature/theme-settings","sha":"3736bd52bf7bd1aaad8b5729fe344677f92d9bf8","user":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"repo":{"id":30958944,"name":"liveblog","full_name":"superdesk/liveblog","owner":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/superdesk/liveblog","description":"Sourcefabric's Live Blog is an open source web app that enables journalists to provide immediate and ongoing coverage on rapidly evolving news events.","fork":false,"url":"https://api.github.com/repos/superdesk/liveblog","forks_url":"https://api.github.com/repos/superdesk/liveblog/forks","keys_url":"https://api.github.com/repos/superdesk/liveblog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/superdesk/liveblog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/superdesk/liveblog/teams","hooks_url":"https://api.github.com/repos/superdesk/liveblog/hooks","issue_events_url":"https://api.github.com/repos/superdesk/liveblog/issues/events{/number}","events_url":"https://api.github.com/repos/superdesk/liveblog/events","assignees_url":"https://api.github.com/repos/superdesk/liveblog/assignees{/user}","branches_url":"https://api.github.com/repos/superdesk/liveblog/branches{/branch}","tags_url":"https://api.github.com/repos/superdesk/liveblog/tags","blobs_url":"https://api.github.com/repos/superdesk/liveblog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/superdesk/liveblog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/superdesk/liveblog/git/refs{/sha}","trees_url":"https://api.github.com/repos/superdesk/liveblog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/superdesk/liveblog/statuses/{sha}","languages_url":"https://api.github.com/repos/superdesk/liveblog/languages","stargazers_url":"https://api.github.com/repos/superdesk/liveblog/stargazers","contributors_url":"https://api.github.com/repos/superdesk/liveblog/contributors","subscribers_url":"https://api.github.com/repos/superdesk/liveblog/subscribers","subscription_url":"https://api.github.com/repos/superdesk/liveblog/subscription","commits_url":"https://api.github.com/repos/superdesk/liveblog/commits{/sha}","git_commits_url":"https://api.github.com/repos/superdesk/liveblog/git/commits{/sha}","comments_url":"https://api.github.com/repos/superdesk/liveblog/comments{/number}","issue_comment_url":"https://api.github.com/repos/superdesk/liveblog/issues/comments{/number}","contents_url":"https://api.github.com/repos/superdesk/liveblog/contents/{+path}","compare_url":"https://api.github.com/repos/superdesk/liveblog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/superdesk/liveblog/merges","archive_url":"https://api.github.com/repos/superdesk/liveblog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/superdesk/liveblog/downloads","issues_url":"https://api.github.com/repos/superdesk/liveblog/issues{/number}","pulls_url":"https://api.github.com/repos/superdesk/liveblog/pulls{/number}","milestones_url":"https://api.github.com/repos/superdesk/liveblog/milestones{/number}","notifications_url":"https://api.github.com/repos/superdesk/liveblog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/superdesk/liveblog/labels{/name}","releases_url":"https://api.github.com/repos/superdesk/liveblog/releases{/id}","created_at":"2015-02-18T09:22:19Z","updated_at":"2015-11-06T09:08:28Z","pushed_at":"2015-12-21T11:46:22Z","git_url":"git://github.com/superdesk/liveblog.git","ssh_url":"git@github.com:superdesk/liveblog.git","clone_url":"https://github.com/superdesk/liveblog.git","svn_url":"https://github.com/superdesk/liveblog","homepage":"https://www.sourcefabric.org/en/liveblog/","size":5226,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":5,"forks":10,"open_issues":5,"watchers":7,"default_branch":"master"}},"base":{"label":"superdesk:devel","ref":"devel","sha":"760d4253db13f52c2923bd3d758147e813fe0106","user":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"repo":{"id":30958944,"name":"liveblog","full_name":"superdesk/liveblog","owner":{"login":"superdesk","id":5527298,"avatar_url":"https://avatars.githubusercontent.com/u/5527298?v=3","gravatar_id":"","url":"https://api.github.com/users/superdesk","html_url":"https://github.com/superdesk","followers_url":"https://api.github.com/users/superdesk/followers","following_url":"https://api.github.com/users/superdesk/following{/other_user}","gists_url":"https://api.github.com/users/superdesk/gists{/gist_id}","starred_url":"https://api.github.com/users/superdesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdesk/subscriptions","organizations_url":"https://api.github.com/users/superdesk/orgs","repos_url":"https://api.github.com/users/superdesk/repos","events_url":"https://api.github.com/users/superdesk/events{/privacy}","received_events_url":"https://api.github.com/users/superdesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/superdesk/liveblog","description":"Sourcefabric's Live Blog is an open source web app that enables journalists to provide immediate and ongoing coverage on rapidly evolving news events.","fork":false,"url":"https://api.github.com/repos/superdesk/liveblog","forks_url":"https://api.github.com/repos/superdesk/liveblog/forks","keys_url":"https://api.github.com/repos/superdesk/liveblog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/superdesk/liveblog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/superdesk/liveblog/teams","hooks_url":"https://api.github.com/repos/superdesk/liveblog/hooks","issue_events_url":"https://api.github.com/repos/superdesk/liveblog/issues/events{/number}","events_url":"https://api.github.com/repos/superdesk/liveblog/events","assignees_url":"https://api.github.com/repos/superdesk/liveblog/assignees{/user}","branches_url":"https://api.github.com/repos/superdesk/liveblog/branches{/branch}","tags_url":"https://api.github.com/repos/superdesk/liveblog/tags","blobs_url":"https://api.github.com/repos/superdesk/liveblog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/superdesk/liveblog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/superdesk/liveblog/git/refs{/sha}","trees_url":"https://api.github.com/repos/superdesk/liveblog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/superdesk/liveblog/statuses/{sha}","languages_url":"https://api.github.com/repos/superdesk/liveblog/languages","stargazers_url":"https://api.github.com/repos/superdesk/liveblog/stargazers","contributors_url":"https://api.github.com/repos/superdesk/liveblog/contributors","subscribers_url":"https://api.github.com/repos/superdesk/liveblog/subscribers","subscription_url":"https://api.github.com/repos/superdesk/liveblog/subscription","commits_url":"https://api.github.com/repos/superdesk/liveblog/commits{/sha}","git_commits_url":"https://api.github.com/repos/superdesk/liveblog/git/commits{/sha}","comments_url":"https://api.github.com/repos/superdesk/liveblog/comments{/number}","issue_comment_url":"https://api.github.com/repos/superdesk/liveblog/issues/comments{/number}","contents_url":"https://api.github.com/repos/superdesk/liveblog/contents/{+path}","compare_url":"https://api.github.com/repos/superdesk/liveblog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/superdesk/liveblog/merges","archive_url":"https://api.github.com/repos/superdesk/liveblog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/superdesk/liveblog/downloads","issues_url":"https://api.github.com/repos/superdesk/liveblog/issues{/number}","pulls_url":"https://api.github.com/repos/superdesk/liveblog/pulls{/number}","milestones_url":"https://api.github.com/repos/superdesk/liveblog/milestones{/number}","notifications_url":"https://api.github.com/repos/superdesk/liveblog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/superdesk/liveblog/labels{/name}","releases_url":"https://api.github.com/repos/superdesk/liveblog/releases{/id}","created_at":"2015-02-18T09:22:19Z","updated_at":"2015-11-06T09:08:28Z","pushed_at":"2015-12-21T11:46:22Z","git_url":"git://github.com/superdesk/liveblog.git","ssh_url":"git@github.com:superdesk/liveblog.git","clone_url":"https://github.com/superdesk/liveblog.git","svn_url":"https://github.com/superdesk/liveblog","homepage":"https://www.sourcefabric.org/en/liveblog/","size":5226,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":5,"forks":10,"open_issues":5,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/305"},"html":{"href":"https://github.com/superdesk/liveblog/pull/305"},"issue":{"href":"https://api.github.com/repos/superdesk/liveblog/issues/305"},"comments":{"href":"https://api.github.com/repos/superdesk/liveblog/issues/305/comments"},"review_comments":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/305/comments"},"review_comment":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/superdesk/liveblog/pulls/305/commits"},"statuses":{"href":"https://api.github.com/repos/superdesk/liveblog/statuses/3736bd52bf7bd1aaad8b5729fe344677f92d9bf8"}}}}