{"action":"created","comment":{"url":"https://api.github.com/repos/assembl/assembl/pulls/comments/88558247","pull_request_review_id":9129671,"id":88558247,"diff_hunk":"@@ -0,0 +1,303 @@\n+'use strict';\n+/**\n+ *\n+ * @module app.views.admin.adminMessageColumns\n+ */\n+\n+var Assembl = require('../../app.js'),\n+    Ctx = require('../../common/context.js'),\n+    i18n = require('../../utils/i18n.js'),\n+    EditableField = require('../reusableDataFields/editableField.js'),\n+    IdeaMessageColumn = require('../../models/ideaMessageColumn.js'),\n+    LangString = require('../../models/langstring.js'),\n+    CollectionManager = require('../../common/collectionManager.js'),\n+    Marionette = require('../../shims/marionette.js'),\n+    Growl = require('../../utils/growl.js'),\n+    SimpleLangStringEditPanel = require('../simpleLangStringEdit.js'),\n+    $ = require('jquery'),\n+    _ = require('underscore'),\n+    Promise = require('bluebird');\n+\n+\n+/**\n+ * @class  app.views.admin.adminMessageColumns.AdminMessageColumnsPanel\n+ */\n+var AdminMessageColumnsPanel = Marionette.LayoutView.extend({\n+  constructor: function AdminMessageColumnsPanel() {\n+    Marionette.LayoutView.apply(this, arguments);\n+  },\n+  template: '#tmpl-adminMessageColumns',\n+\n+  ui: {\n+    activateColumns: '.js_activate_columns',\n+    addColumn: '.js_add_column',\n+    save: '.js_save',\n+    messageColumnsList: '.js_messageColumnsList',\n+  },\n+\n+  regions: {\n+    messageColumnsList: '@ui.messageColumnsList',\n+  },\n+\n+  events: {\n+    'click @ui.activateColumns': 'updateActivateColumns',\n+    'click @ui.addColumn': 'addColumn',\n+  },\n+\n+  initialize: function(options) {\n+    var that = this,\n+        currentIdea = options.model,\n+        collectionManager = new CollectionManager(),\n+        columns = currentIdea.get('message_columns');\n+    if(this.isViewDestroyed()) {\n+      return;\n+    }\n+    this.model = currentIdea;\n+    if (columns === undefined || columns.length === 0) {\n+      this.createColumnsFromDefaults(currentIdea);\n+    }\n+  },\n+\n+  createColumnsFromDefaults: function(currentIdea) {\n+    var columnCollection = new IdeaMessageColumn.Collection(undefined, {targetIdea: currentIdea}),\n+        prevColumn = null,\n+        i = 0,\n+        preferences = Ctx.getPreferences(),\n+        column_identifiers = preferences.default_column_identifiers,\n+        column_names = preferences.default_column_names,\n+        colors = preferences.default_column_colors;\n+\n+    for (var i in column_identifiers) {\n+      var column, identifier = column_identifiers[i],\n+          name = new LangString.Model();\n+      name.initFromDict(column_names[identifier]);\n+      column = new IdeaMessageColumn.Model({\n+        idea: currentIdea.id,\n+        message_classifier: identifier,\n+        name: name,\n+        color: colors[identifier],\n+      });\n+      columnCollection.add(column);\n+      prevColumn = column;\n+    }\n+    currentIdea.set('message_columns', columnCollection);\n+    // linearize saves\n+    function saveNext() {\n+      if (i < columnCollection.models.length) {\n+        var column = columnCollection.models[i];\n+        if (i > 0) {\n+          var prevColumn = columnCollection.models[i-1];\n+          column.set('previous_column', prevColumn.id);\n+        }\n+        i += 1;\n+        column.save(null, { success: saveNext, })\n+      } else {\n+        columnCollection.sort();\n+        Growl.showBottomGrowl(Growl.GrowlReason.SUCCESS,\n+              i18n.gettext(\"Columns saved\"));\n+      }\n+    }\n+    i = 0;\n+    saveNext();\n+  },\n+\n+  addColumn: function(ev) {\n+    var idea = this.model,\n+        columnCollection = idea.get('message_columns'),\n+        lastColumnId,\n+        column,\n+        name = new LangString.Model(),\n+        names = {},\n+        preferences = Ctx.getPreferences();\n+    if (columnCollection.length > 0) {\n+      lastColumnId = columnCollection.models[columnCollection.length-1].id;\n+    }\n+    _.map(preferences.preferred_locales, function(loc) {\n+      names[loc] = '';\n+    });\n+    name.initFromDict(names);\n+    column = new IdeaMessageColumn.Model({\n+      idea: idea.id,\n+      message_classifier: \"\",\n+      name: name,\n+      previous_column: lastColumnId,\n+    });\n+    columnCollection.add(column);\n+    column.save();\n+    ev.preventDefault();\n+  },\n+\n+  serializeData: function() {\n+    return {\n+      active: this.model.get('message_view_override') != null,\n+    };\n+  },\n+\n+  updateActivateColumns: function(ev) {\n+    var elm = $(ev.target),\n+        active = elm.is(':checked'),\n+        idea = this.model;\n+    if (active) {\n+      idea.set('message_view_override', 'messageColumns');\n+      idea.set('messages_in_parent', false);\n+    } else {\n+      idea.set('message_view_override', null);\n+      idea.set('messages_in_parent', true);\n+    }\n+    idea.save();\n+  },\n+\n+  onRender: function() {\n+    if (this.isViewDestroyed()) {\n+      return;\n+    }\n+    var idea = this.model,\n+        columns = idea.get('message_columns');\n+    this.showChildView(\n+      \"messageColumnsList\",\n+      new MessageColumnList({\n+        basePanel: this,\n+        idea: this.model,\n+        collection: columns,\n+      }));\n+  },\n+});\n+\n+\n+/**\n+ * @class  app.views.admin.adminMessageColumns.MessageColumnView\n+ */\n+var MessageColumnView = Marionette.LayoutView.extend({\n+  constructor: function MessageColumnView() {\n+    Marionette.LayoutView.apply(this, arguments);\n+  },\n+  template: '#tmpl-adminMessageColumn',\n+  ui: {\n+    columnId: '.js_column_id',\n+    columnName: '.js_column_name',\n+    columnColor: '.js_column_color',\n+    columnUp: '.js_column_up',\n+    columnDown: '.js_column_down',\n+    columnDelete: '.js_column_delete',\n+  },\n+  regions: {\n+    columnName: '@ui.columnName',\n+  },\n+  events: {\n+    'click @ui.columnUp': 'reorderColumnUp',\n+    'click @ui.columnDown': 'reorderColumnDown',\n+    'click @ui.columnDelete': 'deleteColumn',\n+    'change @ui.columnId': 'changeIdentifier',\n+    'change @ui.columnColor': 'changeColor',\n+  },\n+  getIndex: function() {\n+    return _.indexOf(this.model.collection.models, this.model);\n+  },\n+  serializeData: function() {\n+    return {\n+      column: this.model,\n+      index: this.getIndex(),\n+      collsize: this.model.collection.length,\n+    };\n+  },\n+  onRender: function() {\n+    this.showChildView(\n+      \"columnName\",\n+      new SimpleLangStringEditPanel({\n+        model: this.model.get('name'),\n+      }));\n+  },\n+  reorderColumnUp: function(ev) {\n+    var index = this.getIndex(),\n+        previousModel = this.model.collection.at(index-1);\n+    this.model.set('previous_column', previousModel.get('previous_column'));\n+    previousModel.set('previous_column', this.model.id);\n+    this.model.collection.sort();\n+    this.model.save(null, {success: function() {\n+      previousModel.save();\n+    }});","path":"assembl/static/js/app/views/admin/adminMessageColumns.js","position":218,"original_position":218,"commit_id":"af3f907ebbd17ac023851c28889e9a906de87400","original_commit_id":"8def27c5bb5d30d9d49ef8be912ed5707e270805","user":{"login":"maparent","id":202691,"avatar_url":"https://avatars.githubusercontent.com/u/202691?v=3","gravatar_id":"","url":"https://api.github.com/users/maparent","html_url":"https://github.com/maparent","followers_url":"https://api.github.com/users/maparent/followers","following_url":"https://api.github.com/users/maparent/following{/other_user}","gists_url":"https://api.github.com/users/maparent/gists{/gist_id}","starred_url":"https://api.github.com/users/maparent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maparent/subscriptions","organizations_url":"https://api.github.com/users/maparent/orgs","repos_url":"https://api.github.com/users/maparent/repos","events_url":"https://api.github.com/users/maparent/events{/privacy}","received_events_url":"https://api.github.com/users/maparent/received_events","type":"User","site_admin":false},"body":"Yes, a growl on save would be an improvement.","created_at":"2016-11-17T22:08:39Z","updated_at":"2016-11-17T22:08:39Z","html_url":"https://github.com/assembl/assembl/pull/53#discussion_r88558247","pull_request_url":"https://api.github.com/repos/assembl/assembl/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/assembl/assembl/pulls/comments/88558247"},"html":{"href":"https://github.com/assembl/assembl/pull/53#discussion_r88558247"},"pull_request":{"href":"https://api.github.com/repos/assembl/assembl/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/assembl/assembl/pulls/53","id":93592013,"html_url":"https://github.com/assembl/assembl/pull/53","diff_url":"https://github.com/assembl/assembl/pull/53.diff","patch_url":"https://github.com/assembl/assembl/pull/53.patch","issue_url":"https://api.github.com/repos/assembl/assembl/issues/53","number":53,"state":"open","locked":false,"title":"Twocolumns","user":{"login":"paolina92","id":17748791,"avatar_url":"https://avatars.githubusercontent.com/u/17748791?v=3","gravatar_id":"","url":"https://api.github.com/users/paolina92","html_url":"https://github.com/paolina92","followers_url":"https://api.github.com/users/paolina92/followers","following_url":"https://api.github.com/users/paolina92/following{/other_user}","gists_url":"https://api.github.com/users/paolina92/gists{/gist_id}","starred_url":"https://api.github.com/users/paolina92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paolina92/subscriptions","organizations_url":"https://api.github.com/users/paolina92/orgs","repos_url":"https://api.github.com/users/paolina92/repos","events_url":"https://api.github.com/users/paolina92/events{/privacy}","received_events_url":"https://api.github.com/users/paolina92/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-14T15:53:46Z","updated_at":"2016-11-17T22:08:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e1fabdf54c43880ea3256995bfd4b3d2b907dcc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/assembl/assembl/pulls/53/commits","review_comments_url":"https://api.github.com/repos/assembl/assembl/pulls/53/comments","review_comment_url":"https://api.github.com/repos/assembl/assembl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/assembl/assembl/issues/53/comments","statuses_url":"https://api.github.com/repos/assembl/assembl/statuses/af3f907ebbd17ac023851c28889e9a906de87400","head":{"label":"assembl:twocolumns","ref":"twocolumns","sha":"af3f907ebbd17ac023851c28889e9a906de87400","user":{"login":"assembl","id":20449542,"avatar_url":"https://avatars.githubusercontent.com/u/20449542?v=3","gravatar_id":"","url":"https://api.github.com/users/assembl","html_url":"https://github.com/assembl","followers_url":"https://api.github.com/users/assembl/followers","following_url":"https://api.github.com/users/assembl/following{/other_user}","gists_url":"https://api.github.com/users/assembl/gists{/gist_id}","starred_url":"https://api.github.com/users/assembl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assembl/subscriptions","organizations_url":"https://api.github.com/users/assembl/orgs","repos_url":"https://api.github.com/users/assembl/repos","events_url":"https://api.github.com/users/assembl/events{/privacy}","received_events_url":"https://api.github.com/users/assembl/received_events","type":"Organization","site_admin":false},"repo":{"id":18962634,"name":"assembl","full_name":"assembl/assembl","owner":{"login":"assembl","id":20449542,"avatar_url":"https://avatars.githubusercontent.com/u/20449542?v=3","gravatar_id":"","url":"https://api.github.com/users/assembl","html_url":"https://github.com/assembl","followers_url":"https://api.github.com/users/assembl/followers","following_url":"https://api.github.com/users/assembl/following{/other_user}","gists_url":"https://api.github.com/users/assembl/gists{/gist_id}","starred_url":"https://api.github.com/users/assembl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assembl/subscriptions","organizations_url":"https://api.github.com/users/assembl/orgs","repos_url":"https://api.github.com/users/assembl/repos","events_url":"https://api.github.com/users/assembl/events{/privacy}","received_events_url":"https://api.github.com/users/assembl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/assembl/assembl","description":"Assembl is an online debate and synthesis platform","fork":false,"url":"https://api.github.com/repos/assembl/assembl","forks_url":"https://api.github.com/repos/assembl/assembl/forks","keys_url":"https://api.github.com/repos/assembl/assembl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/assembl/assembl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/assembl/assembl/teams","hooks_url":"https://api.github.com/repos/assembl/assembl/hooks","issue_events_url":"https://api.github.com/repos/assembl/assembl/issues/events{/number}","events_url":"https://api.github.com/repos/assembl/assembl/events","assignees_url":"https://api.github.com/repos/assembl/assembl/assignees{/user}","branches_url":"https://api.github.com/repos/assembl/assembl/branches{/branch}","tags_url":"https://api.github.com/repos/assembl/assembl/tags","blobs_url":"https://api.github.com/repos/assembl/assembl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/assembl/assembl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/assembl/assembl/git/refs{/sha}","trees_url":"https://api.github.com/repos/assembl/assembl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/assembl/assembl/statuses/{sha}","languages_url":"https://api.github.com/repos/assembl/assembl/languages","stargazers_url":"https://api.github.com/repos/assembl/assembl/stargazers","contributors_url":"https://api.github.com/repos/assembl/assembl/contributors","subscribers_url":"https://api.github.com/repos/assembl/assembl/subscribers","subscription_url":"https://api.github.com/repos/assembl/assembl/subscription","commits_url":"https://api.github.com/repos/assembl/assembl/commits{/sha}","git_commits_url":"https://api.github.com/repos/assembl/assembl/git/commits{/sha}","comments_url":"https://api.github.com/repos/assembl/assembl/comments{/number}","issue_comment_url":"https://api.github.com/repos/assembl/assembl/issues/comments{/number}","contents_url":"https://api.github.com/repos/assembl/assembl/contents/{+path}","compare_url":"https://api.github.com/repos/assembl/assembl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/assembl/assembl/merges","archive_url":"https://api.github.com/repos/assembl/assembl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/assembl/assembl/downloads","issues_url":"https://api.github.com/repos/assembl/assembl/issues{/number}","pulls_url":"https://api.github.com/repos/assembl/assembl/pulls{/number}","milestones_url":"https://api.github.com/repos/assembl/assembl/milestones{/number}","notifications_url":"https://api.github.com/repos/assembl/assembl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/assembl/assembl/labels{/name}","releases_url":"https://api.github.com/repos/assembl/assembl/releases{/id}","deployments_url":"https://api.github.com/repos/assembl/assembl/deployments","created_at":"2014-04-20T10:52:11Z","updated_at":"2016-11-07T00:54:34Z","pushed_at":"2016-11-17T20:40:20Z","git_url":"git://github.com/assembl/assembl.git","ssh_url":"git@github.com:assembl/assembl.git","clone_url":"https://github.com/assembl/assembl.git","svn_url":"https://github.com/assembl/assembl","homepage":"http://assembl.org","size":25193,"stargazers_count":58,"watchers_count":58,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":20,"forks":17,"open_issues":20,"watchers":58,"default_branch":"develop"}},"base":{"label":"assembl:develop","ref":"develop","sha":"e391c921efc82344263589c1bf72d7edb69068a3","user":{"login":"assembl","id":20449542,"avatar_url":"https://avatars.githubusercontent.com/u/20449542?v=3","gravatar_id":"","url":"https://api.github.com/users/assembl","html_url":"https://github.com/assembl","followers_url":"https://api.github.com/users/assembl/followers","following_url":"https://api.github.com/users/assembl/following{/other_user}","gists_url":"https://api.github.com/users/assembl/gists{/gist_id}","starred_url":"https://api.github.com/users/assembl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assembl/subscriptions","organizations_url":"https://api.github.com/users/assembl/orgs","repos_url":"https://api.github.com/users/assembl/repos","events_url":"https://api.github.com/users/assembl/events{/privacy}","received_events_url":"https://api.github.com/users/assembl/received_events","type":"Organization","site_admin":false},"repo":{"id":18962634,"name":"assembl","full_name":"assembl/assembl","owner":{"login":"assembl","id":20449542,"avatar_url":"https://avatars.githubusercontent.com/u/20449542?v=3","gravatar_id":"","url":"https://api.github.com/users/assembl","html_url":"https://github.com/assembl","followers_url":"https://api.github.com/users/assembl/followers","following_url":"https://api.github.com/users/assembl/following{/other_user}","gists_url":"https://api.github.com/users/assembl/gists{/gist_id}","starred_url":"https://api.github.com/users/assembl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assembl/subscriptions","organizations_url":"https://api.github.com/users/assembl/orgs","repos_url":"https://api.github.com/users/assembl/repos","events_url":"https://api.github.com/users/assembl/events{/privacy}","received_events_url":"https://api.github.com/users/assembl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/assembl/assembl","description":"Assembl is an online debate and synthesis platform","fork":false,"url":"https://api.github.com/repos/assembl/assembl","forks_url":"https://api.github.com/repos/assembl/assembl/forks","keys_url":"https://api.github.com/repos/assembl/assembl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/assembl/assembl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/assembl/assembl/teams","hooks_url":"https://api.github.com/repos/assembl/assembl/hooks","issue_events_url":"https://api.github.com/repos/assembl/assembl/issues/events{/number}","events_url":"https://api.github.com/repos/assembl/assembl/events","assignees_url":"https://api.github.com/repos/assembl/assembl/assignees{/user}","branches_url":"https://api.github.com/repos/assembl/assembl/branches{/branch}","tags_url":"https://api.github.com/repos/assembl/assembl/tags","blobs_url":"https://api.github.com/repos/assembl/assembl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/assembl/assembl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/assembl/assembl/git/refs{/sha}","trees_url":"https://api.github.com/repos/assembl/assembl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/assembl/assembl/statuses/{sha}","languages_url":"https://api.github.com/repos/assembl/assembl/languages","stargazers_url":"https://api.github.com/repos/assembl/assembl/stargazers","contributors_url":"https://api.github.com/repos/assembl/assembl/contributors","subscribers_url":"https://api.github.com/repos/assembl/assembl/subscribers","subscription_url":"https://api.github.com/repos/assembl/assembl/subscription","commits_url":"https://api.github.com/repos/assembl/assembl/commits{/sha}","git_commits_url":"https://api.github.com/repos/assembl/assembl/git/commits{/sha}","comments_url":"https://api.github.com/repos/assembl/assembl/comments{/number}","issue_comment_url":"https://api.github.com/repos/assembl/assembl/issues/comments{/number}","contents_url":"https://api.github.com/repos/assembl/assembl/contents/{+path}","compare_url":"https://api.github.com/repos/assembl/assembl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/assembl/assembl/merges","archive_url":"https://api.github.com/repos/assembl/assembl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/assembl/assembl/downloads","issues_url":"https://api.github.com/repos/assembl/assembl/issues{/number}","pulls_url":"https://api.github.com/repos/assembl/assembl/pulls{/number}","milestones_url":"https://api.github.com/repos/assembl/assembl/milestones{/number}","notifications_url":"https://api.github.com/repos/assembl/assembl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/assembl/assembl/labels{/name}","releases_url":"https://api.github.com/repos/assembl/assembl/releases{/id}","deployments_url":"https://api.github.com/repos/assembl/assembl/deployments","created_at":"2014-04-20T10:52:11Z","updated_at":"2016-11-07T00:54:34Z","pushed_at":"2016-11-17T20:40:20Z","git_url":"git://github.com/assembl/assembl.git","ssh_url":"git@github.com:assembl/assembl.git","clone_url":"https://github.com/assembl/assembl.git","svn_url":"https://github.com/assembl/assembl","homepage":"http://assembl.org","size":25193,"stargazers_count":58,"watchers_count":58,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":20,"forks":17,"open_issues":20,"watchers":58,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/assembl/assembl/pulls/53"},"html":{"href":"https://github.com/assembl/assembl/pull/53"},"issue":{"href":"https://api.github.com/repos/assembl/assembl/issues/53"},"comments":{"href":"https://api.github.com/repos/assembl/assembl/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/assembl/assembl/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/assembl/assembl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/assembl/assembl/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/assembl/assembl/statuses/af3f907ebbd17ac023851c28889e9a906de87400"}}}}
{"actor":{"display_login":"maparent"}}