UX: Use a template for the `d-modal` component

This commit is contained in:
Robin Ward 2017-08-30 15:08:23 -04:00
parent e7885c20cb
commit 8fcd5af5b1
3 changed files with 43 additions and 23 deletions

View File

@ -1,10 +1,20 @@
import { on } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
elementId: 'discourse-modal',
classNameBindings: [':modal', 'modalClass'],
classNameBindings: [':modal', ':d-modal', 'modalClass', 'modalStyle'],
attributeBindings: ['data-keyboard'],
init() {
this._super(...arguments);
// If we need to render a second modal for any reason, we can't
// use `elementId`
if (this.get('modalStyle') !== 'inline-modal') {
this.set('elementId', 'discourse-modal');
this.set('modalStyle', 'popup-modal');
}
},
// We handle ESC ourselves
'data-keyboard': 'false',

View File

@ -0,0 +1,24 @@
<div class="modal-outer-container">
<div class="modal-middle-container">
<div class="modal-inner-container">
<div class="modal-header">
<div class='modal-close'>
<a class="close" {{action closeModal}}>{{d-icon "times"}}</a>
</div>
<h3>{{title}}</h3>
</div>
<div id='modal-alert'></div>
{{yield}}
{{#each errors as |error|}}
<div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button>
{{error}}
</div>
{{/each}}
</div>
</div>
</div>

View File

@ -1,24 +1,10 @@
{{#d-modal modalClass=modalClass title=title class="hidden"}}
<div class="modal-outer-container">
<div class="modal-middle-container">
<div class="modal-inner-container">
<div class="modal-header">
<div class='modal-close'>
<a class="close" {{action "closeModal"}}>{{d-icon "times"}}</a>
</div>
{{#d-modal
modalClass=modalClass
title=title
class="hidden"
errors=errors
closeModal=(route-action "closeModal")}}
<h3>{{title}}</h3>
</div>
{{outlet "modalBody"}}
<div id='modal-alert'></div>
{{outlet "modalBody"}}
{{#each errors as |error|}}
<div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button>
{{error}}
</div>
{{/each}}
</div>
</div>
</div>
{{/d-modal}}