#1039 ticket.summary

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-04 16:34:41 +01:00
parent e368e2021b
commit d1d11233ad
4 changed files with 61 additions and 5 deletions

View File

@ -15,11 +15,10 @@ export default class Button extends Input {
}
$onInit() {
if (!this.type) {
if (!this.type)
this.type = 'button';
}
}
}
Button.$inject = ['$element'];
ngModule.component('vnButton', {

View File

@ -1,5 +1,12 @@
<vn-card class="summary">
<h5 >{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.nickname}}</h5>
<h5 >{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.nickname}}
<vn-button
disabled="!$ctrl.isEditable"
label="poner OK"
ng-click="$ctrl.setOkState()"
vn-tooltip="Change ticket state to 'Ok'">
</vn-button>
</h5>
<vn-horizontal>
<vn-one>
<vn-label-value label="State"

View File

@ -2,9 +2,12 @@ import ngModule from '../module';
import './style.scss';
class Controller {
constructor($scope, $http) {
constructor($scope, $state, $http, vnApp, $translate) {
this.$scope = $scope;
this.vnApp = vnApp;
this.$translate = $translate;
this.$http = $http;
this.$state = $state;
}
get ticket() {
@ -51,14 +54,48 @@ class Controller {
onDescriptorLoad() {
this.$scope.popover.relocate();
}
get isEditable() {
try {
return !this.ticket.state.state.alertLevel;
} catch (e) {}
return true;
}
Controller.$inject = ['$scope', '$http'];
setOkState() {
let filter = {where: {code: 'OK'}, fields: ['id']};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/ticket/api/States?filter=${json}`).then(res => {
this.changeTicketState(res.data[0].id);
});
}
changeTicketState(value) {
let params;
if (this.$state.params.id)
params = {ticketFk: this.$state.params.id, stateFk: value};
if (!this.$state.params.id)
params = {ticketFk: this.ticket.id, stateFk: value};
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
if (this.card) this.card.reload();
});
}
}
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];
ngModule.component('vnTicketSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
},
require: {
card: '?^vnTicketCard'
}
});

View File

@ -3,6 +3,19 @@
vn-ticket-summary .summary {
max-width: $width-large;
vn-button {
max-height: 27px;
float: right;
button {
box-shadow: none;
height: inherit;
line-height: inherit;
&:active, &:focus {
box-shadow: none !important;
}
}
}
& > div > vn-horizontal > vn-one {
min-width: 10em;