#832 refactor ticket.request
This commit is contained in:
parent
a856bc11bf
commit
4283012b2b
|
@ -193,9 +193,22 @@
|
|||
"description": "Weekly"
|
||||
},
|
||||
{
|
||||
"url" : "/request",
|
||||
"url": "/request",
|
||||
"state": "ticket.card.request",
|
||||
"component": "vn-ticket-request",
|
||||
"abstract": true,
|
||||
"component": "ui-view"
|
||||
},
|
||||
{
|
||||
"url" : "/index",
|
||||
"state": "ticket.card.request.index",
|
||||
"component": "vn-ticket-request-index",
|
||||
"description": "Purchase request",
|
||||
"acl": ["salesPerson"]
|
||||
},
|
||||
{
|
||||
"url" : "/create",
|
||||
"state": "ticket.card.request.create",
|
||||
"component": "vn-ticket-request-create",
|
||||
"description": "Purchase request",
|
||||
"acl": ["salesPerson"]
|
||||
}
|
||||
|
@ -213,6 +226,6 @@
|
|||
{"state": "ticket.card.saleTracking", "icon": "assignment"},
|
||||
{"state": "ticket.card.picture", "icon": "image"},
|
||||
{"state": "ticket.card.log", "icon": "history"},
|
||||
{"state": "ticket.card.request", "icon": "info"}
|
||||
{"state": "ticket.card.request.index"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<mg-ajax path="/ticket/api/TicketRequests" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.ticketRequest"
|
||||
form="form"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" margin-medium>
|
||||
<div style="max-width: 50em; margin: 0 auto;">
|
||||
<vn-card pad-large>
|
||||
<vn-title>New request</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Description" field="$ctrl.ticketRequest.description" vn-focus></vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Buyer"
|
||||
field="$ctrl.ticketRequest.atenderFk"
|
||||
select-fields="['id', 'name']"
|
||||
url="/client/api/Clients/activeBuyer"
|
||||
show-field="name">
|
||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Quantity" field="$ctrl.ticketRequest.quantity"></vn-textfield>
|
||||
<vn-textfield vn-one label="Price" field="$ctrl.ticketRequest.price"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Create"></vn-submit>
|
||||
<vn-button ui-sref="ticket.card.request.index" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</div>
|
||||
</form>
|
|
@ -0,0 +1,25 @@
|
|||
import ngModule from '../../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope) {
|
||||
this.$ = $scope;
|
||||
this.$state = $state;
|
||||
this.ticketRequest = {
|
||||
ticketFk: $state.params.id
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(
|
||||
json => this.$state.go('ticket.card.request.index', {id: json.data.id})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$state', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketRequestCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
Purchase request: Petición de compra
|
||||
Atender: Comprador
|
||||
Remove request: Eliminar petición
|
||||
New request: Crear petición
|
|
@ -0,0 +1,7 @@
|
|||
vn-ticket-request {
|
||||
vn-textfield {
|
||||
margin: 0!important;
|
||||
max-width: 100px;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/ticket/api/TicketRequests"
|
||||
fields="['id', 'description', 'created', 'requesterFk', 'atenderFk', 'quantity', 'price', 'saleFk', 'isOk']"
|
||||
order="created ASC"
|
||||
data="purchaseRequests">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="purchaseRequests"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Purchase request</vn-title>
|
||||
<vn-horizontal ng-repeat="request in purchaseRequests">
|
||||
<vn-textfield
|
||||
vn-two
|
||||
label="Description"
|
||||
model="request.description"
|
||||
rule="TicketRequest.description"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Quantity"
|
||||
model="request.quantity"
|
||||
rule="TicketRequest.quantity"
|
||||
type="text">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Atender"
|
||||
field="request.atenderFk"
|
||||
select-fields="['id', 'name']"
|
||||
url="/client/api/Clients/activeBuyer"
|
||||
show-field="name">
|
||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Price"
|
||||
model="request.price"
|
||||
type="text">
|
||||
</vn-textfield>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
medium-grey
|
||||
margin-medium-v
|
||||
vn-tooltip="Remove request"
|
||||
icon="remove_circle_outline"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add request"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,29 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams, $scope) {
|
||||
this.$stateParams = $stateParams;
|
||||
this.$scope = $scope;
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$scope.model.insert({
|
||||
ticketFk: this.$stateParams.id
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$scope.watcher.check();
|
||||
this.$scope.model.save().then(() => {
|
||||
this.$scope.watcher.notifySaved();
|
||||
this.$scope.model.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$stateParams', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketRequest', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,78 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/ticket/api/TicketRequests"
|
||||
fields="['id', 'description', 'created', 'requesterFk', 'atenderFk', 'quantity', 'price', 'saleFk', 'isOk']"
|
||||
order="created ASC"
|
||||
filter="::$ctrl.filter"
|
||||
data="purchaseRequests">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="purchaseRequests"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Purchase request</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th number>Id</vn-th>
|
||||
<vn-th number>Description</vn-th>
|
||||
<vn-th number>Created</vn-th>
|
||||
<vn-th number>Requester</vn-th>
|
||||
<vn-th number>Atender</vn-th>
|
||||
<vn-th number>Quantity</vn-th>
|
||||
<vn-th number>Price</vn-th>
|
||||
<vn-th number>Sale id</vn-th>
|
||||
<vn-th number>Ok</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="request in purchaseRequests">
|
||||
<vn-td number>{{::request.id}}</vn-td>
|
||||
<vn-td number>{{::request.description}}</vn-td>
|
||||
<vn-td number>{{::request.created | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td number>{{::request.requester.firstName}} {{::request.requester.name}}</vn-td>
|
||||
<vn-td number>{{::request.atender.firstName}} {{::request.atender.name}}</vn-td>
|
||||
<vn-td number>{{::request.quantity}}</vn-td>
|
||||
<vn-td number>{{::request.price}}</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
ng-show="::request.saleFk"
|
||||
ng-click="$ctrl.showDescriptor($event, request.sale)"
|
||||
pointer class="link">
|
||||
{{("000000"+request.saleFk).slice(-6)}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<vn-check vn-one
|
||||
field="::request.isOk"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<vn-icon-button
|
||||
disabled="::request.saleFk"
|
||||
icon="delete"
|
||||
ng-click="$ctrl.removeLine($index)"
|
||||
vn-tooltip="Remove request"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||
No results
|
||||
</vn-empty-rows>
|
||||
</vn-table>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-item-descriptor-popover vn-id="descriptor"
|
||||
quicklinks="$ctrl.quicklinks">
|
||||
</vn-item-descriptor-popover>
|
||||
</form>
|
||||
<a ui-sref="ticket.card.request.create" vn-tooltip="New request" vn-bind="+" fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -0,0 +1,47 @@
|
|||
import ngModule from '../../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams, $scope) {
|
||||
this.$stateParams = $stateParams;
|
||||
this.$scope = $scope;
|
||||
this.filter = {
|
||||
include: [
|
||||
{relation: 'atender', fields: ['firstName', 'name']},
|
||||
{relation: 'requester', fields: ['firstName', 'name']},
|
||||
{relation: 'sale'}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
removeLine(index) {
|
||||
this.$scope.model.remove(index);
|
||||
this.$scope.watcher.check();
|
||||
this.$scope.model.save().then(() => {
|
||||
this.$scope.watcher.notifySaved();
|
||||
});
|
||||
}
|
||||
// Item Descriptor
|
||||
showDescriptor(event, sale) {
|
||||
this.quicklinks = {
|
||||
btnThree: {
|
||||
icon: 'icon-transaction',
|
||||
state: `item.card.diary({
|
||||
id: ${sale.itemFk},
|
||||
ticketFk: ${this.$stateParams.id}
|
||||
})`,
|
||||
tooltip: 'Item diary'
|
||||
}
|
||||
};
|
||||
this.$scope.descriptor.itemFk = sale.itemFk;
|
||||
this.$scope.descriptor.parent = event.target;
|
||||
this.$scope.descriptor.show();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$stateParams', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketRequestIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
Purchase request: Petición de compra
|
||||
Atender: Comprador
|
||||
Remove request: Eliminar petición
|
||||
New request: Crear petición
|
||||
Sale id: Id linea
|
||||
Requester: Solicitante
|
|
@ -0,0 +1,23 @@
|
|||
vn-ticket-request-index {
|
||||
vn-textfield {
|
||||
margin: 0!important;
|
||||
max-width: 150px;
|
||||
}
|
||||
vn-autocomplete {
|
||||
div.mdl-textfield {
|
||||
padding: 0px !important;
|
||||
}
|
||||
label.mdl-textfield__label:after {
|
||||
bottom: 0;
|
||||
}
|
||||
div.icons {
|
||||
display: none !important;
|
||||
}
|
||||
vn-drop-down {
|
||||
vn-textfield {
|
||||
max-width: initial !important
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Purchase request: Petición de compra
|
||||
Atender: Comprador
|
|
@ -20,6 +20,7 @@ import './sale-checked';
|
|||
import './component';
|
||||
import './sale-tracking';
|
||||
import './picture';
|
||||
import './request';
|
||||
import './request/index';
|
||||
import './request/create';
|
||||
// import './log';
|
||||
import './weekly';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import createNightmare from '../../helpers/nightmare';
|
||||
|
||||
describe('Ticket purchase request path', () => {
|
||||
xdescribe('Ticket purchase request path', () => {
|
||||
const nightmare = createNightmare();
|
||||
|
||||
beforeAll(() => {
|
||||
|
|
Loading…
Reference in New Issue