`import injectScript from 'ember-inject-script'`
`import config from 'your-app/config/environment'`
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('service:session')
user = session.get('authenticatedUser')
if !!user
window.ATL_JQ_PAGE_PROPS.fieldValues = {
email: user.get('email')
fullname: "#{user.get('firstName')} #{user.get('lastName')}"
}
Ember.$.ajax(
url: "https://jira.com/form-url",
type: "get",
cache: true,
dataType: "script"
)
window.ATL_JQ_PAGE_PROPS.triggerFunction = (showCollectorDialog) =>
jQuery(".jiraFormTrigger").click( (e) =>
e.preventDefault()
showCollectorDialog()
)
JiraInitializer =
name: 'jira'
initialize: initialize
after: 'session-authenticated-user'
`export {initialize}`
`export default JiraInitializer`
Ember – Instance Initializer – Jira
Leave a reply