Last active
January 17, 2017 22:31
-
-
Save SuperCoolFrog/62b418c07753c56f84bd1be4cc5b20a1 to your computer and use it in GitHub Desktop.
PayAssistPrototype
This file contains hidden or 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
DISCUSSION: | |
Properties That would need to be added to call flow: | |
- isEnd | |
- branches | |
-- I am demoing branches as a boolean value but I am considering making it an array to show possibilities | |
- nextFlowId | |
-- We can possibly make this an array and not use the branches property | |
- max and min (for input validation) | |
-- Should work with number and dates | |
I am using session as a simple way of keeping track of dynamic steps, but I believe we may not need session if we pass in "startingCallFlowId" and "currentCallFlowId". Using those values we should be able to figure out which step we are at and how to go forward/backward. |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'span', | |
classNameBindings: ['valuesEqual:bold-me'], | |
valuesEqual: function() { | |
return this.get('value1') === this.get('value2'); | |
}.property('value1', 'value2') | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
items: [ | |
{ name: 'Main', id: 1 }, | |
{ name: '?' } | |
] | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
items: [] | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
isInput: Ember.computed.equal('callFlow.valueType', 'input'), | |
isInfo: Ember.computed.equal('callFlow.valueType', 'info'), | |
isCheckbox: Ember.computed.equal('callFlow.valueType', 'checkbox'), | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'h3', | |
classNames: ['simple-tab'] | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('pay-assist-main'); | |
this.route('pay-assist-1', { path: 'pay-assist/:callFlowId' }); | |
this.route('pay-assist-2'); | |
this.route('pay-assist-3'); | |
}); | |
export default Router; |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Route.extend({ | |
mockStore: Ember.inject.service('mock-store'), | |
model(params) { | |
let id = parseInt(params.callFlowId); | |
let store = this.get('mockStore'); | |
let items = store.getRecord('crawl-flow'); | |
let callFlow = store.getRecord('call-flow', id); | |
return { | |
items, | |
callFlow | |
} | |
}, | |
actions: { | |
goToPrevious(id) { | |
let store = this.get('mockStore'); | |
let cf = store.getPreviousCallflow('call-flow', id); | |
store.popSession(); // can use server side session to determine when to pop after getting a previous value in model route | |
this.send('goToNext', cf.id); | |
}, | |
goToNext(id, branches, value) { | |
let store = this.get('mockStore'); | |
if(branches) { | |
let cf = store.getDynamicNextCallflow(value); | |
id = cf.id | |
store.addRecord('session', { callFlowId: id }); | |
} | |
// We could save the value from this step's call flow here | |
this.transitionTo('pay-assist-1', id); | |
}, | |
clearSession() { | |
this.get('mockStore').clearRecords('session'); | |
alert('Complete'); | |
}, | |
willTransition: function() { | |
this.controllerFor('pay-assist-1').set('value', undefined); | |
} | |
} | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Route.extend({ | |
mockStore: Ember.inject.service('mock-store'), | |
model() { | |
return this.get('mockStore').getRecord('pay-assists-flows'); | |
}, | |
actions: { | |
goToNext(id) { | |
this.get('mockStore').clearRecords('session'); | |
this.get('mockStore').addRecord('session', { callFlowId: id }); | |
this.transitionTo('pay-assist-1', id); | |
} | |
} | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
const { isEmpty, get } = Ember; | |
// This is just used to mock server logic | |
export default Ember.Service.extend({ | |
_db: { | |
'session': [], | |
'call-flow': [ | |
{ id: 1, name: 'Static Steps Example', nextFlowId: 4 }, // | |
{ id: 2, name: 'Dynamic Steps Example', nextFlowId: 6 }, | |
{ id: 3, name: 'Goes right to last step', nextFlowId: 10 }, | |
{ id: 4, name: 'Call flow 4', valueType: 'info', | |
text: 'demo text call flow 4', nextFlowId: 5}, // | |
{ id: 5, name: 'Call flow 5', valueType: 'input', | |
text: 'demo text call flow 5', nextFlowId: 10}, // | |
//nextFlow is dynamic 7 or 8 | |
//branches can be array instead of boolean | |
{ id: 6, name: 'Call flow 6', valueType: 'input', | |
text: 'please enter 7 or 8 to dynamically choose that flow.<br>REQUIRED', | |
branches: true }, | |
{ id: 7, name: 'Call flow 7', text: 'You selected call flow 7!', | |
valueType: 'info', nextFlowId: 10}, | |
{ id: 8, name: 'Call flow 8', text: 'You selected call flow 8!', | |
valueType: 'checkbox', nextFlowId: 10}, | |
{ id: 9, name: 'Call flow 9', text: 'abc', valueType: 'checkbox', nextFlowId: 10}, | |
{ id: 10, name: 'End', | |
text: 'This is the final step click complete to clear session', | |
valueType: 'info', nextFlowId: null, isEnd: true } | |
] | |
}, | |
_translate: { | |
'pay-assists-flows': (db) => { | |
return db['call-flow'].filter(c => [1,2,3].contains(c.id)); | |
}, | |
'crawl-flow': (db) => { | |
// mock logic to figure out crawl but basically crawl items | |
//unless callFlow branches and if branches perform logic. | |
let session = db['session']; | |
let sessionId = get(session, 'firstObject.callFlowId'); | |
let crawls = { | |
'4': [ | |
{ name: 'Call flow 4', id: 4 }, | |
{ name: 'Call flow 5', id: 5 }, | |
{ name: 'End', id: 10 } | |
], | |
'6': [ | |
{ name: 'Call flow 6', id: 6 }, | |
{ name: '?' }, | |
{ name: 'End', id: 10 } | |
] | |
}; | |
let callFlow = db['call-flow'].findBy('id', sessionId); | |
if(callFlow.branches && session.length > 1) { | |
let r = [callFlow]; | |
for(let i = 1; i < session.length; i++) { | |
r.push(db['call-flow'] | |
.findBy('id', get(session[i], 'callFlowId'))); | |
} | |
r.push({ name: 'End', id: 10 }); | |
return r; | |
}else{ | |
return crawls[sessionId]; | |
} | |
} | |
}, | |
_bl(model, k) { | |
let db = this.get('_db'); | |
let t = this._translate[model]; | |
let v; | |
if(!isEmpty(t)) { | |
v = t(db, model, k); | |
}else { | |
v = !isEmpty(k) ? db[model].findBy('id', k) : db[model]; | |
} | |
return v; | |
}, | |
popSession() { | |
let db = this.get('_db'); | |
let session = db['session']; | |
if(session.length) { | |
return session.pop(); | |
} | |
}, | |
getPreviousCallflow(currentCallflowId) { | |
let crawl = this._bl('crawl-flow'); | |
let cf = crawl.findBy('id', currentCallflowId); | |
let i = crawl.indexOf(cf); | |
return i > 0 ? crawl[i-1] : crawl[0]; | |
}, | |
getDynamicNextCallflow(valueEntered) { | |
return this._bl('call-flow', parseInt(valueEntered)); | |
}, | |
getRecord(model, k) { | |
return this._bl(model, k); | |
}, | |
addRecord(model, value) { | |
let db = this.get('_db'); | |
db[model].push(value); | |
}, | |
clearRecords(model) { | |
let db = this.get('_db'); | |
db[model] = []; | |
} | |
}); |
This file contains hidden or 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.10.7", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.0", | |
"ember-data": "2.10.0", | |
"ember-template-compiler": "2.10.0", | |
"ember-testing": "2.10.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment