Skip to content

Commit

Permalink
Merge pull request #645 from san650/fix-for-ember-canary
Browse files Browse the repository at this point in the history
Fix ember canary(v6.0.0-beta.1) scenario
  • Loading branch information
ro0gr authored Sep 30, 2024
2 parents f458428 + f5fabab commit 5e43a78
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 111 deletions.
27 changes: 27 additions & 0 deletions test-app/app/components/calculating-device.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="calculator">
<div class="screen">
{{this.result}}
<div class="expression">
{{this.expression}}
</div>
</div>
<div class="keyboard">
<div class="numbers">
<button type="button" onclick={{fn this.keyPress "1"}}>1</button>
<button type="button" onclick={{fn this.keyPress "2"}}>2</button>
<button type="button" onclick={{fn this.keyPress "3"}}>3</button>
<button type="button" onclick={{fn this.keyPress "4"}}>4</button>
<button type="button" onclick={{fn this.keyPress "5"}}>5</button>
<button type="button" onclick={{fn this.keyPress "6"}}>6</button>
<button type="button" onclick={{fn this.keyPress "7"}}>7</button>
<button type="button" onclick={{fn this.keyPress "8"}}>8</button>
<button type="button" onclick={{fn this.keyPress "9"}}>9</button>
<button type="button" onclick={{fn this.keyPress "0"}}>0</button>
</div>
<div class="operators">
<button type="button" onclick={{fn this.keyPress "+"}}>+</button>
<button type="button" onclick={{fn this.keyPress "-"}}>-</button>
<button type="button" onclick={{fn this.keyPress "="}}>=</button>
</div>
</div>
</div>
53 changes: 26 additions & 27 deletions test-app/app/components/calculating-device.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Component from '@ember/component';
import { action } from '@ember/object';
import { computed as c } from '@ember/object';

export default Component.extend({
Expand All @@ -11,33 +12,31 @@ export default Component.extend({
},
}),

actions: {
keyPress(key) {
let result = this.result;
let stack = this.stack;
let op = this.op;
keyPress: action(function (key) {
let result = this.result;
let stack = this.stack;
let op = this.op;

switch (key) {
case '+':
case '-':
case '=':
stack.push(parseInt(op + result));
this.set('result', '');
break;
default:
this.set('result', result + key.toString());
break;
}
switch (key) {
case '+':
case '-':
case '=':
stack.push(parseInt(op + result));
this.set('result', '');
break;
default:
this.set('result', result + key.toString());
break;
}

switch (key) {
case '-':
this.set('op', '-');
break;
case '=':
result = stack.reduce((result, value) => result + value, 0);
this.set('result', result.toString());
break;
}
},
},
switch (key) {
case '-':
this.set('op', '-');
break;
case '=':
result = stack.reduce((result, value) => result + value, 0);
this.set('result', result.toString());
break;
}
}),
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 37 additions & 38 deletions test-app/app/controllers/calculator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { later } from '@ember/runloop';
import Controller from '@ember/controller';
import { computed as c } from '@ember/object';
import { action } from '@ember/object';

export default Controller.extend({
init() {
Expand All @@ -20,46 +21,44 @@ export default Controller.extend({
},
}),

actions: {
keyPress(key, asyncOp) {
let exec = () => {
let result = this.expression;
let stack = this.stack;
let op = this.op;
keyPress: action(function (key, asyncOp) {
let exec = () => {
let result = this.expression;
let stack = this.stack;
let op = this.op;

switch (key) {
case '+':
case '-':
case '=':
stack.push(parseInt(op + result));
this.set('result', result);
this.set('expression', '');
break;
default:
this.set('expression', result + key.toString());
break;
}
switch (key) {
case '+':
case '-':
case '=':
stack.push(parseInt(op + result));
this.set('result', result);
this.set('expression', '');
break;
default:
this.set('expression', result + key.toString());
break;
}

switch (key) {
case '-':
this.set('op', '-');
break;
case '=':
result = stack.reduce((result, value) => result + value, 0);
this.set('expression', result.toString());
break;
}
};
switch (key) {
case '-':
this.set('op', '-');
break;
case '=':
result = stack.reduce((result, value) => result + value, 0);
this.set('expression', result.toString());
break;
}
};

if (asyncOp) {
this.set('loading', true);
later(() => {
this.set('loading', false);
exec();
}, 50);
} else {
if (asyncOp) {
this.set('loading', true);
later(() => {
this.set('loading', false);
exec();
}
},
},
}, 50);
} else {
exec();
}
}),
});
33 changes: 18 additions & 15 deletions test-app/app/templates/calculator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@
</div>
<div class="keyboard">
<div class="numbers">
<button type="button" {{action "keyPress" "1"}}>1</button>
<button type="button" {{action "keyPress" "2"}}>2</button>
<button type="button" {{action "keyPress" "3"}}>3</button>
<button type="button" {{action "keyPress" "4"}}>4</button>
<button type="button" {{action "keyPress" "5"}}>5</button>
<button type="button" {{action "keyPress" "6"}}>6</button>
<button type="button" {{action "keyPress" "7"}}>7</button>
<button type="button" {{action "keyPress" "8"}}>8</button>
<button type="button" {{action "keyPress" "9"}}>9</button>
<button type="button" {{action "keyPress" "0"}}>0</button>
<button type="button" onclick={{fn this.keyPress "1"}}>1</button>
<button type="button" onclick={{fn this.keyPress "2"}}>2</button>
<button type="button" onclick={{fn this.keyPress "3"}}>3</button>
<button type="button" onclick={{fn this.keyPress "4"}}>4</button>
<button type="button" onclick={{fn this.keyPress "5"}}>5</button>
<button type="button" onclick={{fn this.keyPress "6"}}>6</button>
<button type="button" onclick={{fn this.keyPress "7"}}>7</button>
<button type="button" onclick={{fn this.keyPress "8"}}>8</button>
<button type="button" onclick={{fn this.keyPress "9"}}>9</button>
<button type="button" onclick={{fn this.keyPress "0"}}>0</button>
</div>
<div class="operators">
<button type="button" {{action "keyPress" "+"}}>+</button>
<button type="button" {{action "keyPress" "-"}}>-</button>
<button type="button" {{action "keyPress" "="}}>=</button>
<button type="button" {{action "keyPress" "=" true}}>async=</button>
<button type="button" onclick={{fn this.keyPress "+"}}>+</button>
<button type="button" onclick={{fn this.keyPress "-"}}>-</button>
<button type="button" onclick={{fn this.keyPress "="}}>=</button>
<button
type="button"
onclick={{fn this.keyPress "=" true}}
>async=</button>
</div>
</div>
</div>
</div>
Empty file.
27 changes: 0 additions & 27 deletions test-app/app/templates/components/calculating-device.hbs

This file was deleted.

5 changes: 1 addition & 4 deletions test-app/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ module.exports = function (environment) {
rootURL: '/',
locationType: 'auto',
EmberENV: {
EXTEND_PROTOTYPES: false,
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},

APP: {
Expand Down

0 comments on commit 5e43a78

Please sign in to comment.