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
2016-10-07 00:14:33 -07:00

40 lines
878 B
JavaScript

import Ember from 'ember';
const {
Component,
$
} = Ember;
export default Component.extend({
actions: {
close: function(){
this.sendAction();
},
delete: function(){
let groupId = this.get('groupId');
$.ajax(this.get('apiURL') + '/groups/' + groupId, {
contentType: 'application/json',
type: 'DELETE'
});
let 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();
}
}
});