Allow modal to hardwire partialName for inheritance default template behaviour
This commit is contained in:
@@ -124,27 +124,27 @@ export default Ember.Mixin.create ApplicationRouteMixin,
|
||||
# -edit-distribution-point
|
||||
# modals/-edit-distribution-point
|
||||
#
|
||||
partialPath = null
|
||||
while not partialPath and modalNameParts.length
|
||||
if container.lookup "template:#{modalNameParts.join('/')}/-#{partialName}"
|
||||
partialPath = "#{modalNameParts.join('/')}/#{partialName}" # without the dash
|
||||
else if container.lookup "template:#{modalNameParts.join('/')}/modals/-#{partialName}"
|
||||
partialPath = "#{modalNameParts.join('/')}/modals/#{partialName}" # without the dash
|
||||
else if container.lookup "template:modals/#{modalNameParts.join('/')}/modals/-#{partialName}"
|
||||
partialPath = "modals/#{modalNameParts.join('/')}/modals/#{partialName}" # without the dash
|
||||
else if container.lookup "template:components/#{modalNameParts.join('/')}/-#{partialName}"
|
||||
partialPath = "components/#{modalNameParts.join('/')}/#{partialName}" # without the dash
|
||||
modalNameParts.pop()
|
||||
partialPath ||= partialName if container.lookup("template:-#{partialName}") # can be root template
|
||||
partialPath ||= "modals/#{partialName}" if container.lookup("template:modals/-#{partialName}") # can be root template
|
||||
unless partialPath
|
||||
message = "Cannot find template for modal '#{modalName}'"
|
||||
console.log message
|
||||
@set "router.globals.flash_message", message
|
||||
return
|
||||
|
||||
unless controller.get('partialName')
|
||||
partialPath = null
|
||||
while not partialPath and modalNameParts.length
|
||||
if container.lookup "template:#{modalNameParts.join('/')}/-#{partialName}"
|
||||
partialPath = "#{modalNameParts.join('/')}/#{partialName}" # without the dash
|
||||
else if container.lookup "template:#{modalNameParts.join('/')}/modals/-#{partialName}"
|
||||
partialPath = "#{modalNameParts.join('/')}/modals/#{partialName}" # without the dash
|
||||
else if container.lookup "template:modals/#{modalNameParts.join('/')}/modals/-#{partialName}"
|
||||
partialPath = "modals/#{modalNameParts.join('/')}/modals/#{partialName}" # without the dash
|
||||
else if container.lookup "template:components/#{modalNameParts.join('/')}/-#{partialName}"
|
||||
partialPath = "components/#{modalNameParts.join('/')}/#{partialName}" # without the dash
|
||||
modalNameParts.pop()
|
||||
partialPath ||= partialName if container.lookup("template:-#{partialName}") # can be root template
|
||||
partialPath ||= "modals/#{partialName}" if container.lookup("template:modals/-#{partialName}") # can be root template
|
||||
unless partialPath
|
||||
message = "Cannot find template for modal '#{modalName}'"
|
||||
console.log message
|
||||
@set "router.globals.flash_message", message
|
||||
return
|
||||
controller.set 'partialName', partialPath
|
||||
@incrementProperty 'router.globals.modals_counter'
|
||||
controller.set 'partialName', partialPath
|
||||
controller.willOpenModal() # can be implemented to setup stuff before rendering and hooks
|
||||
@render 'modals/layout',
|
||||
into: 'application'
|
||||
|
||||
Reference in New Issue
Block a user