{"action":"created","comment":{"url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/comments/136696843","pull_request_review_id":60276682,"id":136696843,"diff_hunk":"@@ -0,0 +1,168 @@\n+<template lang=\"pug\">\n+div\n+  .alert.alert-danger(v-show=\"errors.length > 0\")\n+    ul.mb-0.pl-4\n+      li(v-for=\"(error, index) in errors\")\n+        | {{error}}\n+  .table-responsive\n+    table.table.table-striped\n+      thead\n+        tr\n+          td 人物名\n+          td 性別\n+          td 役割\n+          td 削除\n+      tbody\n+        tr(v-for=\"(row, index) in rows\")\n+          td\n+            input.form-control(type=\"text\", v-model=\"row.person_name\")\n+            suggest-person-form(:name=\"row.person_name\" :index=\"index\" v-on:name=\"getPerson\")\n+          td\n+            input(type=\"radio\", v-model=\"row.person_sex\", value=\"male\")\n+            label 男性\n+            input(type=\"radio\", v-model=\"row.person_sex\", value=\"female\")\n+            label 女性\n+          td\n+            select(v-model=\"row.role_id\")\n+              option(v-for=\"(value, key) in role_map\" :value=\"key\")\n+                | {{value}}\n+          td\n+            button.btn.btn-danger(@click=\"removeRow(row)\")\n+              | 削除\n+    .form-group\n+      button.btn.btn-secondary(@click=\"addRow\")\n+        | 追加\n+    .form-group\n+      div(v-if=\"isNewLocation()\")\n+        input.btn.btn-primary(@click=\"create\", type=\"submit\")\n+      div(v-else)\n+        input.btn.btn-primary(@click=\"update\", type=\"submit\")\n+</template>\n+<script>\n+import axios from 'axios/dist/axios'\n+import suggestPersonForm from '../../suggest_person_form.js'\n+\n+axios.defaults.headers['X-CSRF-TOKEN'] = $('meta[name=csrf-token]').attr('content')\n+\n+export default {\n+  props: {\n+    work_id: Number,\n+    role_map: Object\n+  },\n+  data() {\n+    return {\n+      errors: [],\n+      rows: []\n+    }\n+  },\n+  created() {\n+    const self = this\n+    const url = `/admin/works/${this.work_id}/staffs.json`\n+    axios.get(url)\n+      .then(function(res) {\n+        if(res.data === null) {\n+          self.rows = [\n+            { person_name: '',\n+              person_sex: '',\n+              role_id: '',\n+              work_id: self.work_id\n+            } ]\n+        } else {\n+          self.rows.push(...res.data)\n+        }\n+      })\n+  },\n+  components: {\n+    'suggest-person-form': suggestPersonForm\n+  },\n+  methods: {\n+    addRow() {\n+      const index = this.rows.length + 1\n+      const staff = {\n+        person_name: '',\n+        person_sex: '',\n+        role_id: '',\n+        work_id: this.work_id\n+      }\n+      this.rows.push(staff)\n+    },\n+    clearError() {\n+      this.errors = []\n+    },\n+    create() {\n+      const self = this;\n+      const staffParams = {\n+        staffs: self.rows\n+      }\n+      axios({\n+        method: \"post\",\n+        url: `/admin/works/${this.work_id}/staffs/`,\n+        data: staffParams\n+      })\n+      .then(function() {\n+        console.log(\"success\")\n+        location.href = \"/admin/works\"\n+      })\n+      .catch(function(error) {\n+        self.clearError()\n+        self.errors.push(...error.response.data)\n+        console.log(\"fail\")\n+      })\n+    },\n+    destroy(id) {\n+      axios({\n+        method: \"delete\",\n+        url: `/admin/works/${this.work_id}/staffs/${id}`\n+      })\n+      .then(function() {\n+        console.log(\"destroy success\")\n+      })\n+      .catch(function() {\n+        console.log(\"destroy fail\")\n+      })\n+    },\n+    getPerson(person, index) {\n+      const row = this.rows[index]\n+      row.person_name = person.name\n+      return row.person_sex = person.sex\n+    },\n+    isNewLocation() {\n+      const href = window.location.href\n+      const m = href.match(/new$/)","path":"app/javascript/packs/components/admin/work/staff_form.vue","position":131,"original_position":131,"commit_id":"f04b577e1eceaa06f11457186a7164947b1b90f0","original_commit_id":"6a93d2841da7cfff40cf88e673f6accb663837ba","user":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"body":"定数にわざわざ入れる必要がなさそう","created_at":"2017-09-02T14:30:10Z","updated_at":"2017-09-02T14:35:49Z","html_url":"https://github.com/ryosuke-endo/drareco/pull/66#discussion_r136696843","pull_request_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/comments/136696843"},"html":{"href":"https://github.com/ryosuke-endo/drareco/pull/66#discussion_r136696843"},"pull_request":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66","id":138830991,"html_url":"https://github.com/ryosuke-endo/drareco/pull/66","diff_url":"https://github.com/ryosuke-endo/drareco/pull/66.diff","patch_url":"https://github.com/ryosuke-endo/drareco/pull/66.patch","issue_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/66","number":66,"state":"open","locked":false,"title":"プロデューサー/脚本/を登録できるようにする","user":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"body":"- [x] スタッフロールモデルを作成する\r\n  - [x] 管理画面でCRUDできる\r\n- [x] スタッフモデルを作成する\r\n  - [x] 管理画面でCRUDできる\r\n- [ ] 作品画面に表示する","created_at":"2017-09-01T07:29:33Z","updated_at":"2017-09-02T14:35:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b2bfa10a111d32c4cbc0212662e9ea2fac9648e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66/commits","review_comments_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66/comments","review_comment_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/66/comments","statuses_url":"https://api.github.com/repos/ryosuke-endo/drareco/statuses/f04b577e1eceaa06f11457186a7164947b1b90f0","head":{"label":"ryosuke-endo:d/23-add-director","ref":"d/23-add-director","sha":"f04b577e1eceaa06f11457186a7164947b1b90f0","user":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"repo":{"id":90448342,"name":"drareco","full_name":"ryosuke-endo/drareco","owner":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryosuke-endo/drareco","description":null,"fork":false,"url":"https://api.github.com/repos/ryosuke-endo/drareco","forks_url":"https://api.github.com/repos/ryosuke-endo/drareco/forks","keys_url":"https://api.github.com/repos/ryosuke-endo/drareco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryosuke-endo/drareco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryosuke-endo/drareco/teams","hooks_url":"https://api.github.com/repos/ryosuke-endo/drareco/hooks","issue_events_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/events{/number}","events_url":"https://api.github.com/repos/ryosuke-endo/drareco/events","assignees_url":"https://api.github.com/repos/ryosuke-endo/drareco/assignees{/user}","branches_url":"https://api.github.com/repos/ryosuke-endo/drareco/branches{/branch}","tags_url":"https://api.github.com/repos/ryosuke-endo/drareco/tags","blobs_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryosuke-endo/drareco/statuses/{sha}","languages_url":"https://api.github.com/repos/ryosuke-endo/drareco/languages","stargazers_url":"https://api.github.com/repos/ryosuke-endo/drareco/stargazers","contributors_url":"https://api.github.com/repos/ryosuke-endo/drareco/contributors","subscribers_url":"https://api.github.com/repos/ryosuke-endo/drareco/subscribers","subscription_url":"https://api.github.com/repos/ryosuke-endo/drareco/subscription","commits_url":"https://api.github.com/repos/ryosuke-endo/drareco/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryosuke-endo/drareco/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryosuke-endo/drareco/contents/{+path}","compare_url":"https://api.github.com/repos/ryosuke-endo/drareco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryosuke-endo/drareco/merges","archive_url":"https://api.github.com/repos/ryosuke-endo/drareco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryosuke-endo/drareco/downloads","issues_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues{/number}","pulls_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls{/number}","milestones_url":"https://api.github.com/repos/ryosuke-endo/drareco/milestones{/number}","notifications_url":"https://api.github.com/repos/ryosuke-endo/drareco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryosuke-endo/drareco/labels{/name}","releases_url":"https://api.github.com/repos/ryosuke-endo/drareco/releases{/id}","deployments_url":"https://api.github.com/repos/ryosuke-endo/drareco/deployments","created_at":"2017-05-06T08:19:37Z","updated_at":"2017-05-12T11:24:50Z","pushed_at":"2017-09-02T14:26:10Z","git_url":"git://github.com/ryosuke-endo/drareco.git","ssh_url":"git@github.com:ryosuke-endo/drareco.git","clone_url":"https://github.com/ryosuke-endo/drareco.git","svn_url":"https://github.com/ryosuke-endo/drareco","homepage":null,"size":932,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"base":{"label":"ryosuke-endo:master","ref":"master","sha":"0e54fd91b428ddce46d0601d4a3885f3dcf89333","user":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"repo":{"id":90448342,"name":"drareco","full_name":"ryosuke-endo/drareco","owner":{"login":"ryosuke-endo","id":13434115,"avatar_url":"https://avatars2.githubusercontent.com/u/13434115?v=4","gravatar_id":"","url":"https://api.github.com/users/ryosuke-endo","html_url":"https://github.com/ryosuke-endo","followers_url":"https://api.github.com/users/ryosuke-endo/followers","following_url":"https://api.github.com/users/ryosuke-endo/following{/other_user}","gists_url":"https://api.github.com/users/ryosuke-endo/gists{/gist_id}","starred_url":"https://api.github.com/users/ryosuke-endo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryosuke-endo/subscriptions","organizations_url":"https://api.github.com/users/ryosuke-endo/orgs","repos_url":"https://api.github.com/users/ryosuke-endo/repos","events_url":"https://api.github.com/users/ryosuke-endo/events{/privacy}","received_events_url":"https://api.github.com/users/ryosuke-endo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryosuke-endo/drareco","description":null,"fork":false,"url":"https://api.github.com/repos/ryosuke-endo/drareco","forks_url":"https://api.github.com/repos/ryosuke-endo/drareco/forks","keys_url":"https://api.github.com/repos/ryosuke-endo/drareco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryosuke-endo/drareco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryosuke-endo/drareco/teams","hooks_url":"https://api.github.com/repos/ryosuke-endo/drareco/hooks","issue_events_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/events{/number}","events_url":"https://api.github.com/repos/ryosuke-endo/drareco/events","assignees_url":"https://api.github.com/repos/ryosuke-endo/drareco/assignees{/user}","branches_url":"https://api.github.com/repos/ryosuke-endo/drareco/branches{/branch}","tags_url":"https://api.github.com/repos/ryosuke-endo/drareco/tags","blobs_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryosuke-endo/drareco/statuses/{sha}","languages_url":"https://api.github.com/repos/ryosuke-endo/drareco/languages","stargazers_url":"https://api.github.com/repos/ryosuke-endo/drareco/stargazers","contributors_url":"https://api.github.com/repos/ryosuke-endo/drareco/contributors","subscribers_url":"https://api.github.com/repos/ryosuke-endo/drareco/subscribers","subscription_url":"https://api.github.com/repos/ryosuke-endo/drareco/subscription","commits_url":"https://api.github.com/repos/ryosuke-endo/drareco/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryosuke-endo/drareco/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryosuke-endo/drareco/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryosuke-endo/drareco/contents/{+path}","compare_url":"https://api.github.com/repos/ryosuke-endo/drareco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryosuke-endo/drareco/merges","archive_url":"https://api.github.com/repos/ryosuke-endo/drareco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryosuke-endo/drareco/downloads","issues_url":"https://api.github.com/repos/ryosuke-endo/drareco/issues{/number}","pulls_url":"https://api.github.com/repos/ryosuke-endo/drareco/pulls{/number}","milestones_url":"https://api.github.com/repos/ryosuke-endo/drareco/milestones{/number}","notifications_url":"https://api.github.com/repos/ryosuke-endo/drareco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryosuke-endo/drareco/labels{/name}","releases_url":"https://api.github.com/repos/ryosuke-endo/drareco/releases{/id}","deployments_url":"https://api.github.com/repos/ryosuke-endo/drareco/deployments","created_at":"2017-05-06T08:19:37Z","updated_at":"2017-05-12T11:24:50Z","pushed_at":"2017-09-02T14:26:10Z","git_url":"git://github.com/ryosuke-endo/drareco.git","ssh_url":"git@github.com:ryosuke-endo/drareco.git","clone_url":"https://github.com/ryosuke-endo/drareco.git","svn_url":"https://github.com/ryosuke-endo/drareco","homepage":null,"size":932,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66"},"html":{"href":"https://github.com/ryosuke-endo/drareco/pull/66"},"issue":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/issues/66"},"comments":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/ryosuke-endo/drareco/statuses/f04b577e1eceaa06f11457186a7164947b1b90f0"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ryosuke-endo"}}