#1234 route.create

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-22 16:47:20 +01:00
parent ae9ad7a6cd
commit ce43bd63c9
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,60 @@
<mg-ajax path="/api/Routes" options="vnPost"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.route"
form="form"
save="post">
</vn-watcher>
<div class="content-block">
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-autocomplete
vn-one
field="$ctrl.route.workerFk"
url="/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
</vn-autocomplete>
<vn-date-picker
vn-one
label="Created"
model="$ctrl.route.created"
ini-options="{dateFormat: 'd-m-Y'}">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
field="$ctrl.route.vehicleFk"
url="/api/Vehicles"
show-field="numberPlate"
value-field="id"
label="Vehicle">
</vn-autocomplete>
<vn-autocomplete
vn-one
field="$ctrl.route.agencyModeFk"
url="/api/AgencyModes"
show-field="name"
value-field="id"
label="Agency">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Description"
field="$ctrl.route.description">
</vn-textfield>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Create"></vn-submit>
<vn-button ui-sref="route.index" label="Cancel"></vn-button>
</vn-button-bar>
</form>
</div>

View File

@ -0,0 +1,20 @@
import ngModule from '../module';
export default class Controller {
constructor($scope, $state) {
this.$scope = $scope;
this.$state = $state;
}
onSubmit() {
this.$scope.watcher.submit().then(
res => this.$state.go('route.card.summary', {id: res.data.id})
);
}
}
Controller.$inject = ['$scope', '$state'];
ngModule.component('vnRouteCreate', {
template: require('./index.html'),
controller: Controller
});