{"action":"created","comment":{"url":"https://api.github.com/repos/fidals/shopelectro/pulls/comments/68186887","id":68186887,"diff_hunk":"@@ -40,32 +47,51 @@ const order = (() => {\n       componentRestrictions: {\n         country: 'ru',\n       },\n-    }\n+    },\n+    sePayments: ['cash', 'cashless'],\n+    paymentKey: 'payment'\n   };\n \n   const init = () => {\n     pluginsInit();\n     setUpListeners();\n-    fillInputs();\n+    fillSavedInputs();\n+    restoreSelectedPayment();\n+    selectPaymentSubmit();\n   };\n \n   /**\n-   * Fill inputs of a form.\n-   * Implemented without jQuery because it badly handles dynamically added\n-   * elements.\n+   * Fill inputs, which have saved to localstorage value.\n+   * Runs on page load, and on every cart's update.\n    */\n-  const fillInputs = () => {\n-    let getFieldByName = (name) => document.getElementById(`id_${name}`);\n+  const fillSavedInputs = () => {\n+    const getFieldByName = (name) => $(`#id_${name}`);\n \n     for (let fieldName in DOM.orderForm) {\n-      let field = getFieldByName(fieldName);\n+      let $field = getFieldByName(fieldName);\n       let savedValue = localStorage.getItem(fieldName);\n-      if (savedValue && field) {\n-        field.value = savedValue;\n+      if ($field && savedValue) {\n+        $field.val(savedValue);\n       }\n     }\n   };\n \n+  /**\n+   * Select saved payment if there is one.\n+   */\n+  const restoreSelectedPayment = () => {\n+    let savedPayment = localStorage.getItem(CONFIG.paymentKey);\n+\n+    if (savedPayment) {\n+      const isSelected = ($option) => $option.val() === savedPayment;\n+\n+      $(DOM.paymentOptions).each((_, el) => {\n+        let $inputOption = $(el);\n+        isSelected($inputOption) ?  $inputOption.attr('checked', true) : $inputOption.attr('checked', false);\n+      });\n+    }\n+  };\n+\n   const pluginsInit = () => {\n     const autocomplete = () => {\n       let cityField = document.getElementById('id_city');","path":"front/js/components/order.es6","position":93,"original_position":93,"commit_id":"8a746a2a62639b8d2bd2af742804fbd81ea646cb","original_commit_id":"8a746a2a62639b8d2bd2af742804fbd81ea646cb","user":{"login":"YozhEzhi","id":2706062,"avatar_url":"https://avatars.githubusercontent.com/u/2706062?v=3","gravatar_id":"","url":"https://api.github.com/users/YozhEzhi","html_url":"https://github.com/YozhEzhi","followers_url":"https://api.github.com/users/YozhEzhi/followers","following_url":"https://api.github.com/users/YozhEzhi/following{/other_user}","gists_url":"https://api.github.com/users/YozhEzhi/gists{/gist_id}","starred_url":"https://api.github.com/users/YozhEzhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YozhEzhi/subscriptions","organizations_url":"https://api.github.com/users/YozhEzhi/orgs","repos_url":"https://api.github.com/users/YozhEzhi/repos","events_url":"https://api.github.com/users/YozhEzhi/events{/privacy}","received_events_url":"https://api.github.com/users/YozhEzhi/received_events","type":"User","site_admin":false},"body":"Давай тут переделаем через `$` для единообразия. ","created_at":"2016-06-23T07:25:38Z","updated_at":"2016-06-23T07:25:38Z","html_url":"https://github.com/fidals/shopelectro/pull/28#discussion_r68186887","pull_request_url":"https://api.github.com/repos/fidals/shopelectro/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/comments/68186887"},"html":{"href":"https://github.com/fidals/shopelectro/pull/28#discussion_r68186887"},"pull_request":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/fidals/shopelectro/pulls/28","id":74752399,"html_url":"https://github.com/fidals/shopelectro/pull/28","diff_url":"https://github.com/fidals/shopelectro/pull/28.diff","patch_url":"https://github.com/fidals/shopelectro/pull/28.patch","issue_url":"https://api.github.com/repos/fidals/shopelectro/issues/28","number":28,"state":"open","locked":false,"title":"Yandex kassa integration.","user":{"login":"begor","id":10001148,"avatar_url":"https://avatars.githubusercontent.com/u/10001148?v=3","gravatar_id":"","url":"https://api.github.com/users/begor","html_url":"https://github.com/begor","followers_url":"https://api.github.com/users/begor/followers","following_url":"https://api.github.com/users/begor/following{/other_user}","gists_url":"https://api.github.com/users/begor/gists{/gist_id}","starred_url":"https://api.github.com/users/begor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/begor/subscriptions","organizations_url":"https://api.github.com/users/begor/orgs","repos_url":"https://api.github.com/users/begor/repos","events_url":"https://api.github.com/users/begor/events{/privacy}","received_events_url":"https://api.github.com/users/begor/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-22T09:37:24Z","updated_at":"2016-06-23T07:25:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd54244639a4ed52f57ef826f01249a163acdbb0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fidals/shopelectro/pulls/28/commits","review_comments_url":"https://api.github.com/repos/fidals/shopelectro/pulls/28/comments","review_comment_url":"https://api.github.com/repos/fidals/shopelectro/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fidals/shopelectro/issues/28/comments","statuses_url":"https://api.github.com/repos/fidals/shopelectro/statuses/8a746a2a62639b8d2bd2af742804fbd81ea646cb","head":{"label":"fidals:yandex_kassa","ref":"yandex_kassa","sha":"8a746a2a62639b8d2bd2af742804fbd81ea646cb","user":{"login":"fidals","id":16228604,"avatar_url":"https://avatars.githubusercontent.com/u/16228604?v=3","gravatar_id":"","url":"https://api.github.com/users/fidals","html_url":"https://github.com/fidals","followers_url":"https://api.github.com/users/fidals/followers","following_url":"https://api.github.com/users/fidals/following{/other_user}","gists_url":"https://api.github.com/users/fidals/gists{/gist_id}","starred_url":"https://api.github.com/users/fidals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidals/subscriptions","organizations_url":"https://api.github.com/users/fidals/orgs","repos_url":"https://api.github.com/users/fidals/repos","events_url":"https://api.github.com/users/fidals/events{/privacy}","received_events_url":"https://api.github.com/users/fidals/received_events","type":"Organization","site_admin":false},"repo":{"id":57301144,"name":"shopelectro","full_name":"fidals/shopelectro","owner":{"login":"fidals","id":16228604,"avatar_url":"https://avatars.githubusercontent.com/u/16228604?v=3","gravatar_id":"","url":"https://api.github.com/users/fidals","html_url":"https://github.com/fidals","followers_url":"https://api.github.com/users/fidals/followers","following_url":"https://api.github.com/users/fidals/following{/other_user}","gists_url":"https://api.github.com/users/fidals/gists{/gist_id}","starred_url":"https://api.github.com/users/fidals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidals/subscriptions","organizations_url":"https://api.github.com/users/fidals/orgs","repos_url":"https://api.github.com/users/fidals/repos","events_url":"https://api.github.com/users/fidals/events{/privacy}","received_events_url":"https://api.github.com/users/fidals/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fidals/shopelectro","description":"shopelectro.ru site's code","fork":false,"url":"https://api.github.com/repos/fidals/shopelectro","forks_url":"https://api.github.com/repos/fidals/shopelectro/forks","keys_url":"https://api.github.com/repos/fidals/shopelectro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fidals/shopelectro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fidals/shopelectro/teams","hooks_url":"https://api.github.com/repos/fidals/shopelectro/hooks","issue_events_url":"https://api.github.com/repos/fidals/shopelectro/issues/events{/number}","events_url":"https://api.github.com/repos/fidals/shopelectro/events","assignees_url":"https://api.github.com/repos/fidals/shopelectro/assignees{/user}","branches_url":"https://api.github.com/repos/fidals/shopelectro/branches{/branch}","tags_url":"https://api.github.com/repos/fidals/shopelectro/tags","blobs_url":"https://api.github.com/repos/fidals/shopelectro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fidals/shopelectro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fidals/shopelectro/git/refs{/sha}","trees_url":"https://api.github.com/repos/fidals/shopelectro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fidals/shopelectro/statuses/{sha}","languages_url":"https://api.github.com/repos/fidals/shopelectro/languages","stargazers_url":"https://api.github.com/repos/fidals/shopelectro/stargazers","contributors_url":"https://api.github.com/repos/fidals/shopelectro/contributors","subscribers_url":"https://api.github.com/repos/fidals/shopelectro/subscribers","subscription_url":"https://api.github.com/repos/fidals/shopelectro/subscription","commits_url":"https://api.github.com/repos/fidals/shopelectro/commits{/sha}","git_commits_url":"https://api.github.com/repos/fidals/shopelectro/git/commits{/sha}","comments_url":"https://api.github.com/repos/fidals/shopelectro/comments{/number}","issue_comment_url":"https://api.github.com/repos/fidals/shopelectro/issues/comments{/number}","contents_url":"https://api.github.com/repos/fidals/shopelectro/contents/{+path}","compare_url":"https://api.github.com/repos/fidals/shopelectro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fidals/shopelectro/merges","archive_url":"https://api.github.com/repos/fidals/shopelectro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fidals/shopelectro/downloads","issues_url":"https://api.github.com/repos/fidals/shopelectro/issues{/number}","pulls_url":"https://api.github.com/repos/fidals/shopelectro/pulls{/number}","milestones_url":"https://api.github.com/repos/fidals/shopelectro/milestones{/number}","notifications_url":"https://api.github.com/repos/fidals/shopelectro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fidals/shopelectro/labels{/name}","releases_url":"https://api.github.com/repos/fidals/shopelectro/releases{/id}","deployments_url":"https://api.github.com/repos/fidals/shopelectro/deployments","created_at":"2016-04-28T12:43:43Z","updated_at":"2016-05-12T08:41:23Z","pushed_at":"2016-06-22T15:53:29Z","git_url":"git://github.com/fidals/shopelectro.git","ssh_url":"git@github.com:fidals/shopelectro.git","clone_url":"https://github.com/fidals/shopelectro.git","svn_url":"https://github.com/fidals/shopelectro","homepage":null,"size":3145,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"fidals:master","ref":"master","sha":"a4893034aa7bfa856d76d714ac8aeb4a8973af7d","user":{"login":"fidals","id":16228604,"avatar_url":"https://avatars.githubusercontent.com/u/16228604?v=3","gravatar_id":"","url":"https://api.github.com/users/fidals","html_url":"https://github.com/fidals","followers_url":"https://api.github.com/users/fidals/followers","following_url":"https://api.github.com/users/fidals/following{/other_user}","gists_url":"https://api.github.com/users/fidals/gists{/gist_id}","starred_url":"https://api.github.com/users/fidals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidals/subscriptions","organizations_url":"https://api.github.com/users/fidals/orgs","repos_url":"https://api.github.com/users/fidals/repos","events_url":"https://api.github.com/users/fidals/events{/privacy}","received_events_url":"https://api.github.com/users/fidals/received_events","type":"Organization","site_admin":false},"repo":{"id":57301144,"name":"shopelectro","full_name":"fidals/shopelectro","owner":{"login":"fidals","id":16228604,"avatar_url":"https://avatars.githubusercontent.com/u/16228604?v=3","gravatar_id":"","url":"https://api.github.com/users/fidals","html_url":"https://github.com/fidals","followers_url":"https://api.github.com/users/fidals/followers","following_url":"https://api.github.com/users/fidals/following{/other_user}","gists_url":"https://api.github.com/users/fidals/gists{/gist_id}","starred_url":"https://api.github.com/users/fidals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidals/subscriptions","organizations_url":"https://api.github.com/users/fidals/orgs","repos_url":"https://api.github.com/users/fidals/repos","events_url":"https://api.github.com/users/fidals/events{/privacy}","received_events_url":"https://api.github.com/users/fidals/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fidals/shopelectro","description":"shopelectro.ru site's code","fork":false,"url":"https://api.github.com/repos/fidals/shopelectro","forks_url":"https://api.github.com/repos/fidals/shopelectro/forks","keys_url":"https://api.github.com/repos/fidals/shopelectro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fidals/shopelectro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fidals/shopelectro/teams","hooks_url":"https://api.github.com/repos/fidals/shopelectro/hooks","issue_events_url":"https://api.github.com/repos/fidals/shopelectro/issues/events{/number}","events_url":"https://api.github.com/repos/fidals/shopelectro/events","assignees_url":"https://api.github.com/repos/fidals/shopelectro/assignees{/user}","branches_url":"https://api.github.com/repos/fidals/shopelectro/branches{/branch}","tags_url":"https://api.github.com/repos/fidals/shopelectro/tags","blobs_url":"https://api.github.com/repos/fidals/shopelectro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fidals/shopelectro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fidals/shopelectro/git/refs{/sha}","trees_url":"https://api.github.com/repos/fidals/shopelectro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fidals/shopelectro/statuses/{sha}","languages_url":"https://api.github.com/repos/fidals/shopelectro/languages","stargazers_url":"https://api.github.com/repos/fidals/shopelectro/stargazers","contributors_url":"https://api.github.com/repos/fidals/shopelectro/contributors","subscribers_url":"https://api.github.com/repos/fidals/shopelectro/subscribers","subscription_url":"https://api.github.com/repos/fidals/shopelectro/subscription","commits_url":"https://api.github.com/repos/fidals/shopelectro/commits{/sha}","git_commits_url":"https://api.github.com/repos/fidals/shopelectro/git/commits{/sha}","comments_url":"https://api.github.com/repos/fidals/shopelectro/comments{/number}","issue_comment_url":"https://api.github.com/repos/fidals/shopelectro/issues/comments{/number}","contents_url":"https://api.github.com/repos/fidals/shopelectro/contents/{+path}","compare_url":"https://api.github.com/repos/fidals/shopelectro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fidals/shopelectro/merges","archive_url":"https://api.github.com/repos/fidals/shopelectro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fidals/shopelectro/downloads","issues_url":"https://api.github.com/repos/fidals/shopelectro/issues{/number}","pulls_url":"https://api.github.com/repos/fidals/shopelectro/pulls{/number}","milestones_url":"https://api.github.com/repos/fidals/shopelectro/milestones{/number}","notifications_url":"https://api.github.com/repos/fidals/shopelectro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fidals/shopelectro/labels{/name}","releases_url":"https://api.github.com/repos/fidals/shopelectro/releases{/id}","deployments_url":"https://api.github.com/repos/fidals/shopelectro/deployments","created_at":"2016-04-28T12:43:43Z","updated_at":"2016-05-12T08:41:23Z","pushed_at":"2016-06-22T15:53:29Z","git_url":"git://github.com/fidals/shopelectro.git","ssh_url":"git@github.com:fidals/shopelectro.git","clone_url":"https://github.com/fidals/shopelectro.git","svn_url":"https://github.com/fidals/shopelectro","homepage":null,"size":3145,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/28"},"html":{"href":"https://github.com/fidals/shopelectro/pull/28"},"issue":{"href":"https://api.github.com/repos/fidals/shopelectro/issues/28"},"comments":{"href":"https://api.github.com/repos/fidals/shopelectro/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fidals/shopelectro/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/fidals/shopelectro/statuses/8a746a2a62639b8d2bd2af742804fbd81ea646cb"}}}}
{"actor":{"display_login":"YozhEzhi"}}