{"id":316,"date":"2016-05-19T15:04:30","date_gmt":"2016-05-19T15:04:30","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=316"},"modified":"2016-05-19T15:23:00","modified_gmt":"2016-05-19T15:23:00","slug":"ember-instance-initializer-jira","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=316","title":{"rendered":"Ember &#8211; Instance Initializer &#8211; Jira"},"content":{"rendered":"<pre><code>\n`import injectScript from 'ember-inject-script'`\n`import config from 'your-app\/config\/environment'`\n\ninitialize = (instance) ->\n  # wait for session to return authenticated user\n  # after is configured below but returns before user is available\n  window.setTimeout( () ->\n    delayedConfig(instance)\n  ,2000);\n\ndelayedConfig = (instance) ->\n  window.ATL_JQ_PAGE_PROPS = {}\n  session = instance.lookup('service:session')\n  user = session.get('authenticatedUser')\n  if !!user\n    window.ATL_JQ_PAGE_PROPS.fieldValues = {\n      email: user.get('email')\n      fullname: \"#{user.get('firstName')} #{user.get('lastName')}\"\n    }\n  Ember.$.ajax(\n    url: \"https:\/\/jira.com\/form-url\",\n    type: \"get\",\n    cache: true,\n    dataType: \"script\"\n  )\n\n  window.ATL_JQ_PAGE_PROPS.triggerFunction = (showCollectorDialog) =>\n    jQuery(\".jiraFormTrigger\").click( (e) =>\n      e.preventDefault()\n      showCollectorDialog()\n    )\n\nJiraInitializer =\n  name: 'jira'\n  initialize: initialize\n  after: 'session-authenticated-user'\n\n`export {initialize}`\n`export default JiraInitializer`\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>`import injectScript from &#8217;ember-inject-script&#8217;` `import config from &#8216;your-app\/config\/environment&#8217;` initialize = (instance) -> # wait for session to return authenticated user # after is configured below but returns before user is available window.setTimeout( () -> delayedConfig(instance) ,2000); delayedConfig = (instance) -> window.ATL_JQ_PAGE_PROPS = {} session = instance.lookup(&#8216;service:session&#8217;) user = session.get(&#8216;authenticatedUser&#8217;) if !!user window.ATL_JQ_PAGE_PROPS.fieldValues = { email: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-316","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=316"}],"version-history":[{"count":10,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/316\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/316\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}