Last active
August 14, 2018 05:22
-
-
Save patocallaghan/b4e2bc4f0e00575d54ebd3bf1877f3ea to your computer and use it in GitHub Desktop.
Helper Reproduction
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
type: 'all', | |
init() { | |
this.set('comment', this.comment1); | |
}, | |
comment1: { | |
parentComment: { | |
isOpen: false, | |
}, | |
isReply: true | |
}, | |
comment2: { | |
parentComment: { | |
isOpen: true, | |
}, | |
isReply: false | |
}, | |
}); |
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 { helper as buildHelper } from '@ember/component/helper'; | |
export default buildHelper(function(params) { | |
let comment = params[0], | |
type = params[1], | |
retValue = false; | |
switch (type) { | |
case 'all': | |
if(comment[0] !== undefined) { | |
retValue = false; | |
} else { | |
retValue = true; | |
} | |
break; | |
case 'unresolved': | |
if(comment[0] !== undefined) { | |
if((comment.filterBy('isOpen', true)).length > 0) { | |
retValue = false; | |
} retValue = true; | |
} else if (comment.isReply && comment.parentComment.isOpen) { | |
retValue = true; | |
} else if (!(comment.isReply) && comment.isOpen) { | |
retValue = true; | |
} | |
break; | |
case 'resolved': | |
if(comment[0] !== undefined) { | |
if((comment.filterBy('isOpen', false)).length > 0) { | |
retValue = false; | |
} | |
retValue = true; | |
} else if (comment.isReply && comment.parentComment.isOpen !== true) { | |
retValue = true; | |
} else if (!(comment.isReply) && comment.isOpen !== true) { | |
retValue = true; | |
} | |
break; | |
} | |
return retValue; | |
}); |
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.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.0.0", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment