Last active
March 28, 2019 16:55
-
-
Save onechiporenko/97a1bd83092afdb90d8839b4fdfb9260 to your computer and use it in GitHub Desktop.
Context Menu Integration
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 GithubRepositoryAdapter from 'ember-data-github/adapters/github-repository'; | |
import {resolve} from 'rsvp'; | |
export default GithubRepositoryAdapter.extend({ | |
deleteRecord() { | |
return resolve(); | |
} | |
}); |
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 {computed, get} from '@ember/object'; | |
import {inject as service} from '@ember/service'; | |
import Row from 'ember-models-table/components/models-table/row'; | |
import ContextMenuMixin from 'ember-context-menu'; | |
export default Row.extend(ContextMenuMixin, { | |
modalsManager: service(), | |
contextItems: computed('isEditRow', function () { | |
const self = this; | |
const modalsManager = get(self, 'modalsManager'); | |
const common = [ | |
{ | |
label: 'Delete', | |
action() { | |
return modalsManager | |
.confirm({title: 'Please Confirm', body: 'Are you sure? Don\'t worry, nothing won\'t be deleted from Github'}) | |
.then(() => get(self, 'record') | |
.destroyRecord() | |
.then(() => modalsManager.alert({ | |
title: 'Simulation', | |
body: 'Deleted successfully' | |
}))); | |
} | |
} | |
]; | |
if (get(self, 'isEditRow')) { | |
return [ | |
...common, | |
{ | |
label: 'Cancel Edit', | |
action (selection, details, event) { | |
get(self, 'record').rollbackAttributes(); | |
self.send('cancelEditRow'); | |
} | |
}, | |
{ | |
label: 'Save', | |
action (selection, details, event) { | |
get(self, 'record').save(); | |
self.send('saveRow'); | |
} | |
} | |
]; | |
} | |
return [ | |
...common, | |
{ | |
label: 'Edit', | |
action (selection, details, event) { | |
self.send('editRow'); | |
} | |
} | |
] | |
}) | |
}); |
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'; | |
export default Ember.Controller.extend({ | |
columns: [ | |
{propertyName: 'name'}, | |
{propertyName: 'language', filterWithSelect: true}, | |
{propertyName: 'createdAt'}, | |
{propertyName: 'openIssues'}, | |
{propertyName: 'size'} | |
] | |
}); |
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 MyBs4Theme from '../themes/my-bs4'; | |
export function initialize(application) { | |
application.register('emt-theme:my-bs4', MyBs4Theme, {singleton: false}); | |
} | |
export default { | |
name: 'emt', | |
after: 'emt-themes', | |
initialize | |
}; |
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
export function initialize(appInstance) { | |
appInstance.inject('component:models-table', 'themeInstance', 'theme:my-bs4'); | |
} | |
export default { | |
name: 'emt', | |
after: 'emt-inject', | |
initialize | |
}; |
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({ | |
model() { | |
return this.get('store').query('github-repository', {user: 'onechiporenko'}); | |
} | |
}); |
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 Bootstrap4Theme from './ember-bootstrap-v4'; | |
export default Bootstrap4Theme.extend({ | |
components: { | |
row: 'models-table/themes/my-bs4/custom-row' | |
} | |
}); |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"fa": "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-models-table": "2.9.0", | |
"ember-context-menu": "0.4.3", | |
"ember-bootstrap": "2.5.0", | |
"ember-data-github": "0.8.1", | |
"ember-bootstrap-modals-manager": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment