{"action":"created","comment":{"url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/comments/189479723","pull_request_review_id":121663544,"id":189479723,"diff_hunk":"@@ -0,0 +1,230 @@\n+import { rootRender } from 'edit-schedule'\n+import { newActivityId, defaultDurationFromActivityCode } from '../utils'\n+import {\n+  activityIndexInArray,\n+  roomWcifFromId,\n+  venueWcifFromRoomId,\n+} from 'wca/wcif-utils'\n+import { scheduleElementSelector } from './fullcalendar'\n+\n+const tzConverterHandlers = {\n+};\n+\n+const calendarHandlers = {\n+};\n+\n+function handleAddActivityToCalendar(reactElem, activityData, renderItOnCalendar) {\n+  let currentEventSelected = selectedEventInCalendar();\n+  let roomSelected = roomWcifFromId(reactElem.props.scheduleWcif, reactElem.state.selectedRoom);\n+  if (roomSelected) {\n+    let newActivity = {\n+      id: activityData.id || newActivityId(),\n+      name: activityData.name,\n+      activityCode: activityData.activityCode,\n+      childActivities: [],\n+    };\n+    if (activityData.startTime && activityData.endTime) {\n+      newActivity.startTime = activityData.startTime;\n+      newActivity.endTime = activityData.endTime;\n+    } else if (currentEventSelected) {\n+      let newStart = currentEventSelected.end.clone();\n+      newActivity.startTime = momentToIso(newStart);\n+      let newEnd = newStart.add(defaultDurationFromActivityCode(newActivity.activityCode), \"m\");\n+      newActivity.endTime = momentToIso(newEnd);\n+    } else {\n+      // Do nothing, user cliked an event without any event selected.\n+      return;\n+    }\n+    roomSelected.activities.push(newActivity);\n+    if (renderItOnCalendar) {\n+      // Cloning the object here: activityToFcEvent modifies in place,\n+      // and we don't want event.selected to propagate in the WCIF!\n+      let fcEvent = Object.assign({}, newActivity);\n+      fcEvent = activityToFcEvent(fcEvent);\n+      singleSelectEvent(fcEvent);\n+      $(scheduleElementSelector).fullCalendar(\"renderEvent\", fcEvent);\n+    }\n+    // update list of activityCode used, and rootRender to display the save message\n+    reactElem.setState({ usedActivityCodeList: [...reactElem.state.usedActivityCodeList, newActivity.activityCode] }, rootRender());\n+  }\n+}\n+\n+function handleEventModifiedInCalendar(reactElem, event) {\n+  let room = roomWcifFromId(reactElem.props.scheduleWcif, reactElem.state.selectedRoom);\n+  let activityIndex = activityIndexInArray(room.activities, event.id);\n+  if (activityIndex < 0) {\n+    alert(\"This is very very BAD, I couldn't find an activity matching the modified event!\");","path":"WcaOnRails/app/javascript/edit-schedule/SchedulesEditor/calendar-utils.js","position":56,"original_position":56,"commit_id":"a91511cec753baae14784e17236ea7ab56239b29","original_commit_id":"a91511cec753baae14784e17236ea7ab56239b29","user":{"login":"jfly","id":277474,"avatar_url":"https://avatars1.githubusercontent.com/u/277474?v=4","gravatar_id":"","url":"https://api.github.com/users/jfly","html_url":"https://github.com/jfly","followers_url":"https://api.github.com/users/jfly/followers","following_url":"https://api.github.com/users/jfly/following{/other_user}","gists_url":"https://api.github.com/users/jfly/gists{/gist_id}","starred_url":"https://api.github.com/users/jfly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfly/subscriptions","organizations_url":"https://api.github.com/users/jfly/orgs","repos_url":"https://api.github.com/users/jfly/repos","events_url":"https://api.github.com/users/jfly/events{/privacy}","received_events_url":"https://api.github.com/users/jfly/received_events","type":"User","site_admin":false},"body":"I think it might be a better pattern to instead do a `throw new Error()` here. The way this is written we'll proceed onto line 58, and I don't want to think about what happens after that!\r\n\r\nIf you're concerned about the users learning that something went wrong, then I think we should set up one of React's error boundaries (https://hackernoon.com/error-boundaries-in-react-16-32fb8e185a3). Please don't worry about adding an error boundary to this PR though, it's definitely big enough already!","created_at":"2018-05-21T01:38:20Z","updated_at":"2018-05-21T01:43:27Z","html_url":"https://github.com/thewca/worldcubeassociation.org/pull/2822#discussion_r189479723","pull_request_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/comments/189479723"},"html":{"href":"https://github.com/thewca/worldcubeassociation.org/pull/2822#discussion_r189479723"},"pull_request":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822"}}},"pull_request":{"url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822","id":184080025,"html_url":"https://github.com/thewca/worldcubeassociation.org/pull/2822","diff_url":"https://github.com/thewca/worldcubeassociation.org/pull/2822.diff","patch_url":"https://github.com/thewca/worldcubeassociation.org/pull/2822.patch","issue_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/2822","number":2822,"state":"open","locked":false,"title":"Edit schedule UI","user":{"login":"viroulep","id":1007485,"avatar_url":"https://avatars0.githubusercontent.com/u/1007485?v=4","gravatar_id":"","url":"https://api.github.com/users/viroulep","html_url":"https://github.com/viroulep","followers_url":"https://api.github.com/users/viroulep/followers","following_url":"https://api.github.com/users/viroulep/following{/other_user}","gists_url":"https://api.github.com/users/viroulep/gists{/gist_id}","starred_url":"https://api.github.com/users/viroulep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viroulep/subscriptions","organizations_url":"https://api.github.com/users/viroulep/orgs","repos_url":"https://api.github.com/users/viroulep/repos","events_url":"https://api.github.com/users/viroulep/events{/privacy}","received_events_url":"https://api.github.com/users/viroulep/received_events","type":"User","site_admin":false},"body":"Organizer/Delegate part for #278.\r\n\r\nSorry for the big PR, but I'm not sure how I could split it to make it easier to review, since it's basically just one js pack...\r\n\r\nI've not included any \"view schedule\" page or anything, so when it's merged it won't be usable just yet, which is why I've left out any link to this \"edit schedule\" page.\r\n\r\nIt's currently deployed on staging, and I've made two (very small) examples [here](https://staging.worldcubeassociation.org/competitions/ElsassOpen2018/schedule/edit) (to show an example with a regular main+side room), and [here](https://staging.worldcubeassociation.org/competitions/FMCEurope2018/schedule/edit) (to show how it could be used for FMC Europe-like competitions).\r\n\r\n!! There is no test yet !!\r\nA big part of the UI is drag and dropping, so I'm not very familiar with how it could be tested in our current spec setup...\r\nI can still write some basic tests where only clicking is required.\r\n","created_at":"2018-04-25T15:42:52Z","updated_at":"2018-05-21T01:43:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d74b69e2efeebf7fa2d87850ee83d853379f4628","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822/commits","review_comments_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822/comments","review_comment_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/2822/comments","statuses_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/statuses/a91511cec753baae14784e17236ea7ab56239b29","head":{"label":"viroulep:schedule_making_rebased","ref":"schedule_making_rebased","sha":"a91511cec753baae14784e17236ea7ab56239b29","user":{"login":"viroulep","id":1007485,"avatar_url":"https://avatars0.githubusercontent.com/u/1007485?v=4","gravatar_id":"","url":"https://api.github.com/users/viroulep","html_url":"https://github.com/viroulep","followers_url":"https://api.github.com/users/viroulep/followers","following_url":"https://api.github.com/users/viroulep/following{/other_user}","gists_url":"https://api.github.com/users/viroulep/gists{/gist_id}","starred_url":"https://api.github.com/users/viroulep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viroulep/subscriptions","organizations_url":"https://api.github.com/users/viroulep/orgs","repos_url":"https://api.github.com/users/viroulep/repos","events_url":"https://api.github.com/users/viroulep/events{/privacy}","received_events_url":"https://api.github.com/users/viroulep/received_events","type":"User","site_admin":false},"repo":{"id":49994335,"name":"worldcubeassociation.org","full_name":"viroulep/worldcubeassociation.org","owner":{"login":"viroulep","id":1007485,"avatar_url":"https://avatars0.githubusercontent.com/u/1007485?v=4","gravatar_id":"","url":"https://api.github.com/users/viroulep","html_url":"https://github.com/viroulep","followers_url":"https://api.github.com/users/viroulep/followers","following_url":"https://api.github.com/users/viroulep/following{/other_user}","gists_url":"https://api.github.com/users/viroulep/gists{/gist_id}","starred_url":"https://api.github.com/users/viroulep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viroulep/subscriptions","organizations_url":"https://api.github.com/users/viroulep/orgs","repos_url":"https://api.github.com/users/viroulep/repos","events_url":"https://api.github.com/users/viroulep/events{/privacy}","received_events_url":"https://api.github.com/users/viroulep/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/viroulep/worldcubeassociation.org","description":"[WCA Project] All of the code that runs on worldcubeassociation.org","fork":true,"url":"https://api.github.com/repos/viroulep/worldcubeassociation.org","forks_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/forks","keys_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/teams","hooks_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/hooks","issue_events_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/issues/events{/number}","events_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/events","assignees_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/assignees{/user}","branches_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/branches{/branch}","tags_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/tags","blobs_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/statuses/{sha}","languages_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/languages","stargazers_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/stargazers","contributors_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/contributors","subscribers_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/subscribers","subscription_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/subscription","commits_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/contents/{+path}","compare_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/merges","archive_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/downloads","issues_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/issues{/number}","pulls_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/pulls{/number}","milestones_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/milestones{/number}","notifications_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/labels{/name}","releases_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/releases{/id}","deployments_url":"https://api.github.com/repos/viroulep/worldcubeassociation.org/deployments","created_at":"2016-01-20T01:01:37Z","updated_at":"2018-04-23T14:57:31Z","pushed_at":"2018-05-08T10:04:45Z","git_url":"git://github.com/viroulep/worldcubeassociation.org.git","ssh_url":"git@github.com:viroulep/worldcubeassociation.org.git","clone_url":"https://github.com/viroulep/worldcubeassociation.org.git","svn_url":"https://github.com/viroulep/worldcubeassociation.org","homepage":"https://www.worldcubeassociation.org/","size":122713,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thewca:master","ref":"master","sha":"8768307a75fc0185fa536624d1e8578fce180544","user":{"login":"thewca","id":19806436,"avatar_url":"https://avatars0.githubusercontent.com/u/19806436?v=4","gravatar_id":"","url":"https://api.github.com/users/thewca","html_url":"https://github.com/thewca","followers_url":"https://api.github.com/users/thewca/followers","following_url":"https://api.github.com/users/thewca/following{/other_user}","gists_url":"https://api.github.com/users/thewca/gists{/gist_id}","starred_url":"https://api.github.com/users/thewca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thewca/subscriptions","organizations_url":"https://api.github.com/users/thewca/orgs","repos_url":"https://api.github.com/users/thewca/repos","events_url":"https://api.github.com/users/thewca/events{/privacy}","received_events_url":"https://api.github.com/users/thewca/received_events","type":"Organization","site_admin":false},"repo":{"id":34161579,"name":"worldcubeassociation.org","full_name":"thewca/worldcubeassociation.org","owner":{"login":"thewca","id":19806436,"avatar_url":"https://avatars0.githubusercontent.com/u/19806436?v=4","gravatar_id":"","url":"https://api.github.com/users/thewca","html_url":"https://github.com/thewca","followers_url":"https://api.github.com/users/thewca/followers","following_url":"https://api.github.com/users/thewca/following{/other_user}","gists_url":"https://api.github.com/users/thewca/gists{/gist_id}","starred_url":"https://api.github.com/users/thewca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thewca/subscriptions","organizations_url":"https://api.github.com/users/thewca/orgs","repos_url":"https://api.github.com/users/thewca/repos","events_url":"https://api.github.com/users/thewca/events{/privacy}","received_events_url":"https://api.github.com/users/thewca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thewca/worldcubeassociation.org","description":"All of the code that runs on worldcubeassociation.org","fork":false,"url":"https://api.github.com/repos/thewca/worldcubeassociation.org","forks_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/forks","keys_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/teams","hooks_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/hooks","issue_events_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/events{/number}","events_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/events","assignees_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/assignees{/user}","branches_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/branches{/branch}","tags_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/tags","blobs_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/statuses/{sha}","languages_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/languages","stargazers_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/stargazers","contributors_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/contributors","subscribers_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/subscribers","subscription_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/subscription","commits_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/contents/{+path}","compare_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/merges","archive_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/downloads","issues_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues{/number}","pulls_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls{/number}","milestones_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/milestones{/number}","notifications_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/labels{/name}","releases_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/releases{/id}","deployments_url":"https://api.github.com/repos/thewca/worldcubeassociation.org/deployments","created_at":"2015-04-18T10:21:53Z","updated_at":"2018-05-21T00:41:47Z","pushed_at":"2018-05-21T01:01:09Z","git_url":"git://github.com/thewca/worldcubeassociation.org.git","ssh_url":"git@github.com:thewca/worldcubeassociation.org.git","clone_url":"https://github.com/thewca/worldcubeassociation.org.git","svn_url":"https://github.com/thewca/worldcubeassociation.org","homepage":"https://www.worldcubeassociation.org/","size":122720,"stargazers_count":68,"watchers_count":68,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":250,"license":null,"forks":56,"open_issues":250,"watchers":68,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822"},"html":{"href":"https://github.com/thewca/worldcubeassociation.org/pull/2822"},"issue":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/2822"},"comments":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/issues/2822/comments"},"review_comments":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822/comments"},"review_comment":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/pulls/2822/commits"},"statuses":{"href":"https://api.github.com/repos/thewca/worldcubeassociation.org/statuses/a91511cec753baae14784e17236ea7ab56239b29"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jfly"}}