Last active
April 17, 2020 04:33
-
-
Save OmShiv/83b6f2a8ad68f9e02a57933c37084ac8 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { action, computed, set, get, setProperties } from '@ember/object'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
init() { | |
super.init(...arguments); | |
this.set('model', { | |
endsAt: 'some value', | |
totalBudget: { | |
amount: 'some amount' | |
} | |
}); | |
} | |
@action | |
someMethod(campaignGroupType) { | |
const endsAt = get(this, 'model.endsAt'); | |
const amount = get(this, 'model.totalBudget.amount'); | |
if (endsAt) { | |
set(this, '_tempEndsAt', endsAt); | |
} | |
if (amount) { | |
set(this, '_tempAmount', amount); | |
} | |
switch (campaignGroupType) { | |
case 1: | |
set(this, 'model.endsAt', ''); | |
break; | |
case 2: | |
set(this, 'model.endsAt', this._tempEndsAt); | |
break; | |
case 3: | |
set(this, 'model.endsAt', this._tempEndsAt); | |
set(this, 'model.totalBudget.amount', this._tempAmount); | |
break; | |
default: | |
} | |
} | |
@action | |
someOtherMethod(campaignGroupType) { | |
const endsAt = get(this, 'model.endsAt'); | |
const amount = get(this, 'model.totalBudget.amount'); | |
if (endsAt) { | |
set(this, '_tempEndsAt', endsAt); | |
} | |
if (amount) { | |
set(this, '_tempAmount', amount); | |
} | |
switch (campaignGroupType) { | |
case 1: | |
endsAt = ''; | |
break; | |
case 2: | |
endsAt = this._tempEndsAt; | |
break; | |
case 3: | |
endsAt = this._tempEndsAt; | |
amount = this._tempAmount; | |
break; | |
default: | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.0", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.17.0", | |
"ember-template-compiler": "3.17.0", | |
"ember-testing": "3.17.0" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment