añadido callBack cambio estados

This commit is contained in:
Dani Herrero 2017-06-15 12:00:51 +02:00
parent bc4402ce22
commit 1ca5e20494
2 changed files with 22 additions and 6 deletions

View File

@ -13,6 +13,7 @@ vn-drop-down {
list-style-type: none;
padding: 5px 20px 5px 5px;
cursor: pointer;
white-space: nowrap;
}
li:hover{
background-color: #3D3A3B;

View File

@ -2,9 +2,10 @@ import ngModule from '../module';
import './style.scss';
export default class ProductionIndex {
constructor($element, $scope) {
constructor($element, $scope, $http) {
this.$element = $element;
this.$ = $scope;
this.$http = $http;
this.filter = {};
this._checkAll = false;
this.tickets = [];
@ -34,19 +35,33 @@ export default class ProductionIndex {
}
);
}
_changeState(ids, sateteId, stateName, index) {
this.$http.put(`/production/api/TicketStates/[${ids}]/${sateteId}/changeState`).then(
() => {
index.forEach(
val => {
this.tickets[val].state = this.actions.state.name;
}
);
}
);
}
doAction(action) {
let checks = this.$element[0].querySelectorAll('.list-body input[type="checkbox"]:checked');
if (checks.length) {
let ids = [];
let index = [];
checks.forEach(
(_, i) => {
ids.push(this.tickets[i].ticket);
// Fake change state
this.tickets[i].state = this.actions.state.name;
index.push(i);
}
);
console.log("TODO: call action -> endPoint with tickets's Ids", action, ids, this.actions);
// TODO: call action -> endPoint with tickets's Ids
switch (action) {
case 'changeState' :
this._changeState(ids, this.actions.state.id, this.actions.state.name, index);
break;
}
} else {
console.log("TODO: dialog with no items selected", action);
// TODO: dialog with no items selected
@ -85,7 +100,7 @@ export default class ProductionIndex {
}
}
}
ProductionIndex.$inject = ['$element', '$scope'];
ProductionIndex.$inject = ['$element', '$scope', '$http'];
ngModule.component('vnProductionIndex', {
template: require('./index.html'),