{"action":"created","issue":{"url":"https://api.github.com/repos/hmrc/assets-frontend/issues/536","repository_url":"https://api.github.com/repos/hmrc/assets-frontend","labels_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/536/labels{/name}","comments_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/536/comments","events_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/536/events","html_url":"https://github.com/hmrc/assets-frontend/pull/536","id":148016293,"number":536,"title":"[API-1370] Added caching of cloneable item HTML","user":{"login":"stingrayfunk","id":1764083,"avatar_url":"https://avatars.githubusercontent.com/u/1764083?v=3","gravatar_id":"","url":"https://api.github.com/users/stingrayfunk","html_url":"https://github.com/stingrayfunk","followers_url":"https://api.github.com/users/stingrayfunk/followers","following_url":"https://api.github.com/users/stingrayfunk/following{/other_user}","gists_url":"https://api.github.com/users/stingrayfunk/gists{/gist_id}","starred_url":"https://api.github.com/users/stingrayfunk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stingrayfunk/subscriptions","organizations_url":"https://api.github.com/users/stingrayfunk/orgs","repos_url":"https://api.github.com/users/stingrayfunk/repos","events_url":"https://api.github.com/users/stingrayfunk/events{/privacy}","received_events_url":"https://api.github.com/users/stingrayfunk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-13T10:27:05Z","updated_at":"2016-04-14T15:18:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hmrc/assets-frontend/pulls/536","html_url":"https://github.com/hmrc/assets-frontend/pull/536","diff_url":"https://github.com/hmrc/assets-frontend/pull/536.diff","patch_url":"https://github.com/hmrc/assets-frontend/pull/536.patch"},"body":"## Problem\r\n\r\nCurrently, to add a new item, the AddRemove module clones a particular item in the list. It does this on click of the Add button. However, the cloned item might be in an error state, which results in copying over an error message and error class to the new element, as shown below:\r\n\r\n![screen shot 2016-04-12 at 11 42 49](https://cloud.githubusercontent.com/assets/1764083/14489780/04c3439a-0167-11e6-9ee2-ebe0f0c74e10.png)\r\n\r\n## Solution\r\n\r\nFor each instantiation of AddRemove module on the page, a cached template is created (against the index of that instance). To ensure the cached template is always clean (not in an error state), an empty item always needs to be available at the bottom of the list. Otherwise, there might only be one item in the list which is in an error state and cannot be cloned. This limitation is currently due to the fact that my usage of AddRemove only provides server-side validation on inputs. Further work will be needed to implement client-side validation.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/hmrc/assets-frontend/issues/comments/209998269","html_url":"https://github.com/hmrc/assets-frontend/pull/536#issuecomment-209998269","issue_url":"https://api.github.com/repos/hmrc/assets-frontend/issues/536","id":209998269,"user":{"login":"rpowis","id":1752124,"avatar_url":"https://avatars.githubusercontent.com/u/1752124?v=3","gravatar_id":"","url":"https://api.github.com/users/rpowis","html_url":"https://github.com/rpowis","followers_url":"https://api.github.com/users/rpowis/followers","following_url":"https://api.github.com/users/rpowis/following{/other_user}","gists_url":"https://api.github.com/users/rpowis/gists{/gist_id}","starred_url":"https://api.github.com/users/rpowis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpowis/subscriptions","organizations_url":"https://api.github.com/users/rpowis/orgs","repos_url":"https://api.github.com/users/rpowis/repos","events_url":"https://api.github.com/users/rpowis/events{/privacy}","received_events_url":"https://api.github.com/users/rpowis/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T15:18:55Z","updated_at":"2016-04-14T15:18:55Z","body":"@stingrayfunk Good work dude"}}