Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing template property deprecation, so the addon can work with latest ember v2.10.0 #88

Merged
merged 6 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ Template `dialog-layouts/delete.hbs`:
```hbs
<h1 style="color: #F00;">Confirm Deletion</h1>
<div class="body">
{{yield}}
{{#if templateName}}
<div class="dialog-body">{{partial templateName}}</div>
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context class="dialog-body"}}
{{/if}}
</div>
<button class="danger" onclick={{action "accept"}}>DELETE!</button>
<button onclick={{action "decline"}}>Cancel</button>
Expand Down
3 changes: 3 additions & 0 deletions addon/components/dialog-body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Ember from "ember";

export default Ember.Component.extend();
10 changes: 6 additions & 4 deletions addon/services/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ export default Ember.Service.extend(Ember.Evented, {
* @param {module:ember-dialog/components/presenter} presenter
*/
remove(presenter) {
if (this.get('isDestroyed')) return;
var id = presenter.get("presenterId") || guidFor(presenter);
var dialogs = this.get("dialogs").filter((item) => {
return item.id !== id;
});

//filter would return Array not EmberArray?
this.set("dialogs", Ember.A(dialogs));
},

Expand Down Expand Up @@ -261,7 +260,7 @@ export default Ember.Service.extend(Ember.Evented, {
*/
show(layout, template, context, options = {}, componentName = DEFAULT_COMPONENT_NAME) {

/* Generate presenterId from (layoutName + templateName) or provided id
/* Generate presenterId from (layoutName + templateName) or provided id
to make sure the dialog won't open multiple times */
var presenterId = options.id || "";
if(typeof layout === "string" && typeof template === "string"){
Expand Down Expand Up @@ -291,9 +290,12 @@ export default Ember.Service.extend(Ember.Evented, {
}

if (Ember.typeOf(template) === "object") {
// The template will be included into the presenter's body as
// dialog-body component
options = Ember.merge(options, { template: template });
} else {
options = Ember.merge(options, { template: getOwner(this).lookup(["template", template].join(":")) });
// The template will be included into the presenter's body as partial
options = Ember.merge(options, { templateName: template });
}

presenter = presenter.reopen(options);
Expand Down
1 change: 1 addition & 0 deletions app/components/dialog-body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-dialog/components/dialog-body';
6 changes: 5 additions & 1 deletion app/templates/layouts/alert.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<div class="dialog-title">{{title}}</div>
</div>

<div class="dialog-body">{{yield}}</div>
{{#if templateName}}
<div class="dialog-body">{{partial templateName}}</div>
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context class="dialog-body"}}
{{/if}}

<div class="dialog-footer">
<button class="btn btn__accept" type="button" {{action "accept"}}>OK</button>
Expand Down
8 changes: 6 additions & 2 deletions app/templates/layouts/blank.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="ember-dialog-dialog {{className}} {{if substrate "substrate"}}">
<div class="dialog-content" tabindex="-1">
{{yield}}
</div>
{{#if templateName}}
<div class="dialog-body">{{partial templateName}}</div>
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context class="dialog-body"}}
{{/if}}
</div>
</div>
8 changes: 6 additions & 2 deletions app/templates/layouts/confirm.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

<div class="dialog-header">
<button type="button" class="dialog-close" {{action "decline"}}></button>
<div class="dialog-title">{{ title }}</div>
<div class="dialog-title">{{title}}</div>
</div>

<div class="dialog-body">{{yield}}</div>
{{#if templateName}}
<div class="dialog-body">{{partial templateName}}</div>
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context class="dialog-body"}}
{{/if}}

<div class="dialog-footer">
<button class="btn btn__accept" type="button" {{action "accept"}}>Yes</button>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-dialog",
"dependencies": {
"ember": "2.9.1",
"ember": "v2.10.0",
"ember-cli-shims": "^0.1.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"codacy-coverage": "^2.0.0",
"ember-cli": "2.9.1",
"ember-cli": "2.10.0",
"ember-cli-app-version": "^2.0.0",
"ember-cli-blanket": "0.9.9",
"ember-cli-content-security-policy": "0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/components/presenter-animate-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default Presenter.extend({
Ember.run.later(this, "_decline", this.get("delay"));
},

willInsertElement() {
didRender() {
this.$(".dialog-content").addClass("animated");
return this._super(...arguments);
},
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/components/presenter-animated.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default Presenter.extend({
Ember.run.later(this, "_decline", this.get("delay"));
},

willInsertElement() {
didRender() {
this.$(".ember-dialog-dialog").addClass("animation");
return this._super(...arguments);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div class="notice-dialog">
<div class="notice-dialog-content" tabindex="-1">
{{yield}}
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
<div><a class="w-link w-link__pseudo" onclick={{action "accept"}}>Close</a></div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div class="top-error-dialog">
<div class="top-error-dialog-content" tabindex="-1">{{yield}}</div>
<div class="top-error-dialog-content" tabindex="-1">
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
</div>
8 changes: 7 additions & 1 deletion tests/dummy/app/templates/examples/dialog/information.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<div class="ember-dialog-dialog class_1">
<div class="row">
<div class="col-sm-1" style="text-align: right;"><a class="w-link" onclick={{action "accept"}}>X</a></div>
<div class="col-sm-11">{{yield}}</div>
<div class="col-sm-11">
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div class="ember-dialog-dialog red-corner-dialog {{if substrate 'substrate'}}">
<div class="dialog-content" tabindex="-1">
<div>{{yield}}</div>
<div>
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
<div><a class="w-link" onclick={{action "accept"}}>Close</a></div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div class="notice-dialog">
<div class="notice-dialog-content" tabindex="-1">{{yield}}</div>
<div class="notice-dialog-content" tabindex="-1">
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div class="top-error-dialog">
<div class="top-error-dialog-content" tabindex="-1">{{yield}}</div>
<div class="top-error-dialog-content" tabindex="-1">
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div class="ember-dialog-dialog red-corner-dialog">
<div class="dialog-content" tabindex="-1">
<div>{{yield}}</div>
<div>
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
<div><a onclick={{action "accept"}}>Close</a></div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<div class="ember-dialog-dialog class_1">
<div class="row">
<div class="col-sm-1" style="text-align: right;"><a class="w-link" onclick={{action "accept"}}>X</a></div>
<div class="col-sm-11">{{yield}}</div>
<div class="col-sm-11">
{{#if templateName}}
{{partial templateName}}
{{else}}
{{component "dialog-body" layout=template contextObject=contextObject context=context}}
{{/if}}
</div>
</div>
</div>