Skip to content

Instantly share code, notes, and snippets.

@jgwhite
jgwhite / controllers.application\.js
Last active Jul 22, 2020
Modifier Forwarding Demo
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@tracked actionClicked = false;
@tracked onclickClicked = false;
@tracked onClicked = false;
@action enable(prop) {
View components.general-banner.blue-layout\.js
import Component from '@glimmer/component';
export default class extends Component {
}
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View SketchSystems.spec
Bindings
No bindings
add binding -> Selecting target
Selecting target
bind -> Sending request
done -> No bindings
Selecting target with error
try again -> Sending request
done -> No bindings
Sending request
View SketchSystems.spec
Required form field
Untouched
focus -> Untouched
blur -> Untouched
enter valid input -> Valid
enter invalid input -> Invalid
submit form -> Invalid
Invalid
@jgwhite
jgwhite / app\helpers\assert.js
Last active Dec 4, 2019
Ember {{assert}} helper
View app\helpers\assert.js
import { helper } from '@ember/component/helper';
import { assert } from '@ember/debug';
/**
* Verify that a certain expectation is met, or throw a exception
* otherwise.
*
* Delegates directly to `assert` from `@ember/debug`.
*
* @param {string} description - Describes the expectation. This will
@jgwhite
jgwhite / SketchSystems.spec
Created Sep 18, 2019
A login flow for NASA in the 1970s
View SketchSystems.spec
A login flow for NASA in the 1970s
Sign in
Submit correct email and password -> 2FA
Submit correct badge number and password -> 2FA
Submit incorrect email -> Sign in error
Submit incorrect badge number -> Sign in error
Submit incorrect password -> Sign in error
Click forgot -> Forgot
Sign in error
Submit correct email and password -> 2FA
@jgwhite
jgwhite / controllers.application.js
Last active Jun 18, 2019
readOnly('foos.@each.bars')
View controllers.application.js
import Ember from 'ember';
import { readOnly } from '@ember/object/computed';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
foos: [{
bars: ['a', 'b']
}, {
View loanCalculator.js
/* This function extracts user input from the Loan Calculator input form and uses it to set the variables of loanAmount, repayPeriod and protection*/
function getInput()
{
document.getElementById('error').style.display = 'none';
var loanAmount = document.getElementById('loan_amount').value;
/*Check whether user input for loan amount is valid*/
if (isNaN(loanAmount) == true || loanAmount<1000 || loanAmount>500000)
{
@jgwhite
jgwhite / controllers.application.js
Last active Oct 17, 2018
Confirms and Prompts with Tasks
View controllers.application.js
import Ember from 'ember';
import { task, waitForProperty, timeout } from 'ember-concurrency';
const promptTask = task({
answer: undefined,
* perform() {
yield waitForProperty(this, 'answer', a => a !== undefined);
return this.answer;
}
You can’t perform that action at this time.