From fb404e8f3e3754623c01eb0c8e34f15c80de796e Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 24 Sep 2018 20:06:03 -0500 Subject: [PATCH] Allow modal to hardwire partialName for inheritance default template behaviour --- addon/mixins/application-route.coffee | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/addon/mixins/application-route.coffee b/addon/mixins/application-route.coffee index 5dec887..6d32a51 100644 --- a/addon/mixins/application-route.coffee +++ b/addon/mixins/application-route.coffee @@ -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'