{"action":"created","comment":{"url":"https://api.github.com/repos/superdesk/superdesk/pulls/comments/30612877","id":30612877,"diff_hunk":"@@ -116,37 +126,114 @@\n         };\n     }\n \n-    var app = angular.module('superdesk.templates', ['superdesk.authoring']);\n-    app.service('templatesSettingsService', TemplatesSettingsService)\n-        .directive('sdTemplates', TemplatesDirective);\n-\n-    app\n-        .config(['superdeskProvider', function(superdesk) {\n-            superdesk\n-                .activity('/settings/templates', {\n-                    label: gettext('Templates'),\n-                    templateUrl: 'scripts/superdesk-templates/views/settings.html',\n-                    controller: TemplatesSettingsController,\n-                    category: superdesk.MENU_SETTINGS,\n-                    privileges: {content_templates: 1},\n-                    priority: 2000,\n-                    beta: true\n-                });\n-        }])\n-        .config(['apiProvider', function(apiProvider) {\n-            apiProvider.api('templates', {\n-                type: 'http',\n-                backend: {\n-                    rel: 'templates'\n-                }\n+    CreateTemplateController.$inject = ['item', 'templates', 'api', 'desks', '$q'];\n+    function CreateTemplateController(item, templates, api, desks, $q) {\n+        var vm = this,\n+            metadata = [\n+                'headline',\n+                'slugline',\n+                'abstract',\n+                'dateline',\n+                'byline',\n+                'usage_terms',\n+                'subject',\n+                'genre',\n+                'type',\n+                'language',\n+                'anpa-category',\n+                'anpa_take_key',\n+                'keywords',\n+                'priority',\n+                'urgency',\n+                'pubstatus',\n+                'description',\n+                'body_html',\n+                'body_text',\n+                'place',\n+                'located',\n+                'creditline'\n+            ];\n+\n+        this.type = 'create';\n+        this.name = item.slugline || null;\n+        this.desk = desks.active.desk || null;\n+\n+        this.types = templates.types;\n+        this.save = save;\n+\n+        activate();\n+\n+        function activate() {","path":"client/app/scripts/superdesk-templates/templates.js","position":117,"original_position":117,"commit_id":"8a27e3f14c388f161c139db004a1020800b72557","original_commit_id":"8a27e3f14c388f161c139db004a1020800b72557","user":{"login":"plamut","id":1235663,"avatar_url":"https://avatars.githubusercontent.com/u/1235663?v=3","gravatar_id":"","url":"https://api.github.com/users/plamut","html_url":"https://github.com/plamut","followers_url":"https://api.github.com/users/plamut/followers","following_url":"https://api.github.com/users/plamut/following{/other_user}","gists_url":"https://api.github.com/users/plamut/gists{/gist_id}","starred_url":"https://api.github.com/users/plamut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamut/subscriptions","organizations_url":"https://api.github.com/users/plamut/orgs","repos_url":"https://api.github.com/users/plamut/repos","events_url":"https://api.github.com/users/plamut/events{/privacy}","received_events_url":"https://api.github.com/users/plamut/received_events","type":"User","site_admin":false},"body":"Since this `activate()` function is invoked only once at controller instantiation and is not visible to the outside world, it might make sense to get rid of it and simply only retain its body?","created_at":"2015-05-19T15:40:33Z","updated_at":"2015-05-19T15:40:33Z","html_url":"https://github.com/superdesk/superdesk/pull/600#discussion_r30612877","pull_request_url":"https://api.github.com/repos/superdesk/superdesk/pulls/600","_links":{"self":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/comments/30612877"},"html":{"href":"https://github.com/superdesk/superdesk/pull/600#discussion_r30612877"},"pull_request":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/600"}}},"pull_request":{"url":"https://api.github.com/repos/superdesk/superdesk/pulls/600","id":35720254,"html_url":"https://github.com/superdesk/superdesk/pull/600","diff_url":"https://github.com/superdesk/superdesk/pull/600.diff","patch_url":"https://github.com/superdesk/superdesk/pull/600.patch","issue_url":"https://api.github.com/repos/superdesk/superdesk/issues/600","number":600,"state":"open","locked":false,"title":"feat(templates): add save as template action","user":{"login":"petrjasek","id":179249,"avatar_url":"https://avatars.githubusercontent.com/u/179249?v=3","gravatar_id":"","url":"https://api.github.com/users/petrjasek","html_url":"https://github.com/petrjasek","followers_url":"https://api.github.com/users/petrjasek/followers","following_url":"https://api.github.com/users/petrjasek/following{/other_user}","gists_url":"https://api.github.com/users/petrjasek/gists{/gist_id}","starred_url":"https://api.github.com/users/petrjasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrjasek/subscriptions","organizations_url":"https://api.github.com/users/petrjasek/orgs","repos_url":"https://api.github.com/users/petrjasek/repos","events_url":"https://api.github.com/users/petrjasek/events{/privacy}","received_events_url":"https://api.github.com/users/petrjasek/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-19T11:29:05Z","updated_at":"2015-05-19T15:40:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19cb9d3ee8628d1bda1bb7a660afd2c37fbc1d5d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/superdesk/superdesk/pulls/600/commits","review_comments_url":"https://api.github.com/repos/superdesk/superdesk/pulls/600/comments","review_comment_url":"https://api.github.com/repos/superdesk/superdesk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/superdesk/superdesk/issues/600/comments","statuses_url":"https://api.github.com/repos/superdesk/superdesk/statuses/8a27e3f14c388f161c139db004a1020800b72557","head":{"label":"petrjasek:feat-save-as-template","ref":"feat-save-as-template","sha":"8a27e3f14c388f161c139db004a1020800b72557","user":{"login":"petrjasek","id":179249,"avatar_url":"https://avatars.githubusercontent.com/u/179249?v=3","gravatar_id":"","url":"https://api.github.com/users/petrjasek","html_url":"https://github.com/petrjasek","followers_url":"https://api.github.com/users/petrjasek/followers","following_url":"https://api.github.com/users/petrjasek/following{/other_user}","gists_url":"https://api.github.com/users/petrjasek/gists{/gist_id}","starred_url":"https://api.github.com/users/petrjasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrjasek/subscriptions","organizations_url":"https://api.github.com/users/petrjasek/orgs","repos_url":"https://api.github.com/users/petrjasek/repos","events_url":"https://api.github.com/users/petrjasek/events{/privacy}","received_events_url":"https://api.github.com/users/petrjasek/received_events","type":"User","site_admin":false},"repo":{"id":23593594,"name":"superdesk","full_name":"petrjasek/superdesk","owner":{"login":"petrjasek","id":179249,"avatar_url":"https://avatars.githubusercontent.com/u/179249?v=3","gravatar_id":"","url":"https://api.github.com/users/petrjasek","html_url":"https://github.com/petrjasek","followers_url":"https://api.github.com/users/petrjasek/followers","following_url":"https://api.github.com/users/petrjasek/following{/other_user}","gists_url":"https://api.github.com/users/petrjasek/gists{/gist_id}","starred_url":"https://api.github.com/users/petrjasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrjasek/subscriptions","organizations_url":"https://api.github.com/users/petrjasek/orgs","repos_url":"https://api.github.com/users/petrjasek/repos","events_url":"https://api.github.com/users/petrjasek/events{/privacy}","received_events_url":"https://api.github.com/users/petrjasek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/petrjasek/superdesk","description":"","fork":true,"url":"https://api.github.com/repos/petrjasek/superdesk","forks_url":"https://api.github.com/repos/petrjasek/superdesk/forks","keys_url":"https://api.github.com/repos/petrjasek/superdesk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/petrjasek/superdesk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/petrjasek/superdesk/teams","hooks_url":"https://api.github.com/repos/petrjasek/superdesk/hooks","issue_events_url":"https://api.github.com/repos/petrjasek/superdesk/issues/events{/number}","events_url":"https://api.github.com/repos/petrjasek/superdesk/events","assignees_url":"https://api.github.com/repos/petrjasek/superdesk/assignees{/user}","branches_url":"https://api.github.com/repos/petrjasek/superdesk/branches{/branch}","tags_url":"https://api.github.com/repos/petrjasek/superdesk/tags","blobs_url":"https://api.github.com/repos/petrjasek/superdesk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/petrjasek/superdesk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/petrjasek/superdesk/git/refs{/sha}","trees_url":"https://api.github.com/repos/petrjasek/superdesk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/petrjasek/superdesk/statuses/{sha}","languages_url":"https://api.github.com/repos/petrjasek/superdesk/languages","stargazers_url":"https://api.github.com/repos/petrjasek/superdesk/stargazers","contributors_url":"https://api.github.com/repos/petrjasek/superdesk/contributors","subscribers_url":"https://api.github.com/repos/petrjasek/superdesk/subscribers","subscription_url":"https://api.github.com/repos/petrjasek/superdesk/subscription","commits_url":"https://api.github.com/repos/petrjasek/superdesk/commits{/sha}","git_commits_url":"https://api.github.com/repos/petrjasek/superdesk/git/commits{/sha}","comments_url":"https://api.github.com/repos/petrjasek/superdesk/comments{/number}","issue_comment_url":"https://api.github.com/repos/petrjasek/superdesk/issues/comments{/number}","contents_url":"https://api.github.com/repos/petrjasek/superdesk/contents/{+path}","compare_url":"https://api.github.com/repos/petrjasek/superdesk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/petrjasek/superdesk/merges","archive_url":"https://api.github.com/repos/petrjasek/superdesk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/petrjasek/superdesk/downloads","issues_url":"https://api.github.com/repos/petrjasek/superdesk/issues{/number}","pulls_url":"https://api.github.com/repos/petrjasek/superdesk/pulls{/number}","milestones_url":"https://api.github.com/repos/petrjasek/superdesk/milestones{/number}","notifications_url":"https://api.github.com/repos/petrjasek/superdesk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/petrjasek/superdesk/labels{/name}","releases_url":"https://api.github.com/repos/petrjasek/superdesk/releases{/id}","created_at":"2014-09-02T20:00:13Z","updated_at":"2015-05-07T14:00:14Z","pushed_at":"2015-05-19T13:31:51Z","git_url":"git://github.com/petrjasek/superdesk.git","ssh_url":"git@github.com:petrjasek/superdesk.git","clone_url":"https://github.com/petrjasek/superdesk.git","svn_url":"https://github.com/petrjasek/superdesk","homepage":null,"size":51749,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"superdesk:master","ref":"master","sha":"13a71d2fa725acea58816d8bc0d6e94d85b883d9","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":23570030,"name":"superdesk","full_name":"superdesk/superdesk","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/superdesk","description":"The open source end-to-end news platform.","fork":false,"url":"https://api.github.com/repos/superdesk/superdesk","forks_url":"https://api.github.com/repos/superdesk/superdesk/forks","keys_url":"https://api.github.com/repos/superdesk/superdesk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/superdesk/superdesk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/superdesk/superdesk/teams","hooks_url":"https://api.github.com/repos/superdesk/superdesk/hooks","issue_events_url":"https://api.github.com/repos/superdesk/superdesk/issues/events{/number}","events_url":"https://api.github.com/repos/superdesk/superdesk/events","assignees_url":"https://api.github.com/repos/superdesk/superdesk/assignees{/user}","branches_url":"https://api.github.com/repos/superdesk/superdesk/branches{/branch}","tags_url":"https://api.github.com/repos/superdesk/superdesk/tags","blobs_url":"https://api.github.com/repos/superdesk/superdesk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/superdesk/superdesk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/superdesk/superdesk/git/refs{/sha}","trees_url":"https://api.github.com/repos/superdesk/superdesk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/superdesk/superdesk/statuses/{sha}","languages_url":"https://api.github.com/repos/superdesk/superdesk/languages","stargazers_url":"https://api.github.com/repos/superdesk/superdesk/stargazers","contributors_url":"https://api.github.com/repos/superdesk/superdesk/contributors","subscribers_url":"https://api.github.com/repos/superdesk/superdesk/subscribers","subscription_url":"https://api.github.com/repos/superdesk/superdesk/subscription","commits_url":"https://api.github.com/repos/superdesk/superdesk/commits{/sha}","git_commits_url":"https://api.github.com/repos/superdesk/superdesk/git/commits{/sha}","comments_url":"https://api.github.com/repos/superdesk/superdesk/comments{/number}","issue_comment_url":"https://api.github.com/repos/superdesk/superdesk/issues/comments{/number}","contents_url":"https://api.github.com/repos/superdesk/superdesk/contents/{+path}","compare_url":"https://api.github.com/repos/superdesk/superdesk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/superdesk/superdesk/merges","archive_url":"https://api.github.com/repos/superdesk/superdesk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/superdesk/superdesk/downloads","issues_url":"https://api.github.com/repos/superdesk/superdesk/issues{/number}","pulls_url":"https://api.github.com/repos/superdesk/superdesk/pulls{/number}","milestones_url":"https://api.github.com/repos/superdesk/superdesk/milestones{/number}","notifications_url":"https://api.github.com/repos/superdesk/superdesk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/superdesk/superdesk/labels{/name}","releases_url":"https://api.github.com/repos/superdesk/superdesk/releases{/id}","created_at":"2014-09-02T07:56:17Z","updated_at":"2015-05-19T12:15:40Z","pushed_at":"2015-05-19T14:43:05Z","git_url":"git://github.com/superdesk/superdesk.git","ssh_url":"git@github.com:superdesk/superdesk.git","clone_url":"https://github.com/superdesk/superdesk.git","svn_url":"https://github.com/superdesk/superdesk","homepage":"","size":62189,"stargazers_count":12,"watchers_count":12,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":8,"forks":28,"open_issues":8,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/600"},"html":{"href":"https://github.com/superdesk/superdesk/pull/600"},"issue":{"href":"https://api.github.com/repos/superdesk/superdesk/issues/600"},"comments":{"href":"https://api.github.com/repos/superdesk/superdesk/issues/600/comments"},"review_comments":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/600/comments"},"review_comment":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/superdesk/superdesk/pulls/600/commits"},"statuses":{"href":"https://api.github.com/repos/superdesk/superdesk/statuses/8a27e3f14c388f161c139db004a1020800b72557"}}}}