This repository has been archived on 2026-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
huegasm/app/pods/components/delete-group-modal/component.js
2015-10-02 14:02:47 -07:00

35 lines
844 B
JavaScript

import Em from 'ember';
export default Em.Component.extend({
actions: {
close: function(){
this.sendAction();
},
delete: function(){
var groupId = this.get('groupId');
Em.$.ajax(this.get('apiURL') + '/groups/' + groupId, {
contentType: 'application/json',
type: 'DELETE'
});
var groupsData = this.get('groupsData'), newGroupsData = [];
for (let key in groupsData) {
if(groupsData.hasOwnProperty(key) && groupsData[key].name !== this.get('groupName') ){
newGroupsData[key] = groupsData[key];
}
}
if(groupId === this.get('groupIdSelection')){
this.set('groupIdSelection', '0');
}
this.setProperties({
updateGroupsData: true,
groupsData: newGroupsData
});
this.sendAction();
}
}
});