Last active
October 6, 2020 16:11
-
-
Save mohamedali-s-4725/2279ff2a2f62982fc826b7a63d998125 to your computer and use it in GitHub Desktop.
Ember App without mixin dependency
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 Component from '@ember/component'; | |
import $ from 'jquery'; | |
import { run } from '@ember/runloop'; | |
export default Component.extend({ | |
classNames: ['create-issue-container'], | |
didInsertElement(){ | |
this._super(...arguments); | |
run.later(function() { | |
$('.create-issue-container input').focus(); | |
},100) | |
}, | |
actions: { | |
createTicket(){ | |
let self = this; | |
self.triggerAction('createIssue', self.bugtrackerService); | |
}, | |
closeDialog(){ | |
let self = this; | |
self.triggerAction('hideDialog', self.bugtrackerService); | |
} | |
} | |
}); | |
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 Component from '@ember/component'; | |
import { get, set } from '@ember/object'; | |
export default Component.extend({ | |
classNames: ['issue'], | |
detail: '', | |
hoveredOnIssue: false, | |
mouseEnter(){ | |
set(this, 'hoveredOnIssue', true); | |
}, | |
mouseLeave(){ | |
set(this, 'hoveredOnIssue', false); | |
}, | |
actions: { | |
closeTicket(){ | |
let self = this; | |
self.triggerAction('closeIssue', self.issueDetail); | |
}, | |
reopenTicket(){ | |
let self = this; | |
self.triggerAction('reopenIssue', self.issueDetail); | |
} | |
} | |
}); |
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 Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; // No I18N | |
import { set } from '@ember/object'; | |
export default Controller.extend( { | |
appName: 'Without Mixin', | |
bugtracker: service(), | |
actions: { | |
showIssueCreateDialog(){ | |
let self = this; | |
set(self.bugtracker, 'showCreateIssueDialog', true); | |
} | |
} | |
}); |
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 Service from '@ember/service'; | |
import { A } from '@ember/array'; | |
import object, { get, set } from '@ember/object'; | |
import BugManager from '../utils/bugmanager'; | |
export default Service.extend({ | |
issueList: A(), | |
newIssueObj: object.create({ | |
issueTitle: '', | |
isOpenIssue: true | |
}), | |
showCreateIssueDialog: false, | |
triggerUtilAction(actionName, params){ | |
BugManager[actionName](params); | |
} | |
}); |
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.17.1", | |
"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.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
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 object, { get, set } from '@ember/object'; | |
export default object.create({ | |
// Show the Create issue dialog in UI | |
showDialog(bugtrackerService){ | |
let self = this; | |
set(bugtrackerService, 'showCreateIssueDialog', true); | |
}, | |
// Hide the Create issue dialog from UI | |
hideDialog(bugtrackerService){ | |
let self = this; | |
set(bugtrackerService.newIssueObj, 'issueTitle', ''); | |
set(bugtrackerService, 'showCreateIssueDialog', false); | |
}, | |
// Create an Issue and push it to the issue list & close the dialog. | |
createIssue(bugtrackerService){ | |
let self = this, | |
issueObj = object.create({ | |
issueTitle: bugtrackerService.newIssueObj.issueTitle, | |
isOpenIssue: true | |
}); | |
if ( bugtrackerService.newIssueObj.issueTitle ){ | |
bugtrackerService.issueList.pushObject(issueObj); | |
} | |
self.hideDialog(bugtrackerService); | |
}, | |
// Change the issue status to Close | |
closeIssue(issueObj){ | |
let self = this; | |
set(issueObj, 'isOpenIssue', false); | |
}, | |
// Change the issue status to Re-open | |
reopenIssue(issueObj){ | |
let self = this; | |
set(issueObj, 'isOpenIssue', true); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment