Merge pull request 'add restrictions in ticket descriptor' (#317) from 2061-ticket_descriptor into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2020-06-23 09:39:42 +00:00
commit 5a225b05ba
3 changed files with 11 additions and 9 deletions

View File

@ -5,6 +5,7 @@
<vn-item <vn-item
ng-click="addTurn.show()" ng-click="addTurn.show()"
vn-acl="buyer" vn-acl="buyer"
ng-show="$ctrl.isEditable"
vn-acl-action="remove" vn-acl-action="remove"
name="addTurn" name="addTurn"
translate> translate>
@ -60,7 +61,7 @@
</vn-item> </vn-item>
<vn-item <vn-item
ng-click="makeInvoiceConfirmation.show()" ng-click="makeInvoiceConfirmation.show()"
ng-show="!$ctrl.isInvoiced" ng-show="$ctrl.isEditable"
vn-acl="invoicing" vn-acl="invoicing"
vn-acl-action="remove" vn-acl-action="remove"
name="makeInvoice" name="makeInvoice"

View File

@ -8,6 +8,7 @@ class Controller extends Descriptor {
set ticket(value) { set ticket(value) {
this.entity = value; this.entity = value;
this.isTicketEditable();
} }
get entity() { get entity() {
@ -22,14 +23,6 @@ class Controller extends Descriptor {
this.showSMSDialog(); this.showSMSDialog();
} }
get isEditable() {
try {
return !this.ticket.tracking.state.alertLevel;
} catch (e) {}
return true;
}
get isInvoiced() { get isInvoiced() {
return this.ticket.refFk !== null; return this.ticket.refFk !== null;
} }
@ -45,6 +38,12 @@ class Controller extends Descriptor {
return this.ticket.stowaway || this.ticket.ship; return this.ticket.stowaway || this.ticket.ship;
} }
isTicketEditable() {
this.$http.get(`Tickets/${this.$state.params.id}/isEditable`).then(res => {
this.isEditable = res.data;
});
}
showChangeShipped() { showChangeShipped() {
this.newShipped = this.ticket.shipped; this.newShipped = this.ticket.shipped;
this.$.changeShippedDialog.show(); this.$.changeShippedDialog.show();

View File

@ -28,8 +28,10 @@ describe('Ticket Component vnTicketDescriptor', () => {
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$state_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$state_) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpBackend.whenGET(`Tickets/${ticket.id}/canHaveStowaway`).respond(true); $httpBackend.whenGET(`Tickets/${ticket.id}/canHaveStowaway`).respond(true);
$httpBackend.whenGET(`Tickets/1/isEditable`).respond(true);
$state = _$state_; $state = _$state_;
$state.params.id = 1;
$state.getCurrentPath = () => [null, {state: {name: 'ticket'}}]; $state.getCurrentPath = () => [null, {state: {name: 'ticket'}}];
controller = $componentController('vnTicketDescriptor', {$element: null}, {ticket}); controller = $componentController('vnTicketDescriptor', {$element: null}, {ticket});