zone delivery days #668
This commit is contained in:
parent
837af23497
commit
5a5640143d
|
@ -1,4 +1,9 @@
|
|||
module.exports.watcher = {
|
||||
submit: () => {
|
||||
return new Promise(accept => {
|
||||
accept();
|
||||
});
|
||||
},
|
||||
realSubmit: () => {
|
||||
return new Promise(accept => {
|
||||
accept();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<vn-autocomplete vn-one
|
||||
url="/item/api/ItemTypes"
|
||||
label="Type"
|
||||
select-fields=["code","name"]
|
||||
select-fields="['code','name']"
|
||||
value-field="id"
|
||||
field="$ctrl.item.typeFk"
|
||||
where="{or: [{code: {regexp: 'search'}}, {name: {regexp: 'search'}}]}">
|
||||
|
|
|
@ -55,6 +55,18 @@
|
|||
"menu": {
|
||||
"icon": "settings"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/delivery-day",
|
||||
"state": "zone.card.deliveryDay",
|
||||
"component": "vn-zone-delivery-day",
|
||||
"description": "Delivery days",
|
||||
"params": {
|
||||
"zone": "$ctrl.zone"
|
||||
},
|
||||
"menu": {
|
||||
"icon": "today"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -7,4 +7,5 @@ import './zone/search-panel';
|
|||
import './zone/index';
|
||||
import './zone/create';
|
||||
import './zone/basic-data';
|
||||
|
||||
import './zone/delivery-day';
|
||||
import './zone/calendar';
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<!-- <vn-crud-model
|
||||
vn-id="model"
|
||||
url="/order/api/ItemCategories"
|
||||
data="categories">
|
||||
</vn-crud-model> -->
|
||||
<vn-horizontal>
|
||||
<vn-vertical vn-one>
|
||||
<vn-card >
|
||||
<vn-vertical>
|
||||
<vn-horizontal pad-medium>
|
||||
calendar
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
</vn-horizontal>
|
|
@ -0,0 +1,20 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
class Controller {
|
||||
constructor($scope) {
|
||||
this.$scope = $scope;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
||||
ngModule.component('vnZoneCalendar', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
catalog: '^vnZoneDeliveryDay'
|
||||
},
|
||||
bindings: {
|
||||
zone: '<'
|
||||
}
|
||||
});
|
|
@ -1,7 +1,9 @@
|
|||
<mg-ajax path="/route/api/Zones" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.zone"
|
||||
form="form">
|
||||
form="form"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" margin-medium>
|
||||
<div style="max-width: 50em; margin: 0 auto;">
|
||||
|
|
|
@ -1,32 +1,24 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($scope, $state, $http) {
|
||||
constructor($scope, $state) {
|
||||
this.$scope = $scope;
|
||||
this.$state = $state;
|
||||
this.$http = $http;
|
||||
this.zone = {
|
||||
travelingDays: 0,
|
||||
price: 0.50,
|
||||
bonus: 0.50
|
||||
bonus: 0.50,
|
||||
hour: new Date()
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$scope.watcher.check();
|
||||
|
||||
let data = Object.assign({}, this.zone);
|
||||
data.hour = new Date(this.zone.hour);
|
||||
|
||||
this.$http.post('/route/api/Zones', data).then(res => {
|
||||
this.$scope.watcher.updateOriginalData();
|
||||
this.$scope.watcher.setPristine();
|
||||
this.$scope.watcher.notifySaved();
|
||||
this.$scope.watcher.submit().then(res => {
|
||||
this.$state.go('zone.card.basicData', {id: res.data.id});
|
||||
});
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$scope', '$state', '$http'];
|
||||
Controller.$inject = ['$scope', '$state'];
|
||||
|
||||
ngModule.component('vnZoneCreate', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -21,6 +21,13 @@ describe('Route', () => {
|
|||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$scope.watcher = watcher;
|
||||
$scope.watcher.submit = () => {
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 1234}});
|
||||
}
|
||||
};
|
||||
};
|
||||
controller = $componentController('vnZoneCreate', {$scope: $scope});
|
||||
}));
|
||||
|
||||
|
@ -32,9 +39,7 @@ describe('Route', () => {
|
|||
name: 'Zone One'
|
||||
};
|
||||
|
||||
$httpBackend.expectPOST(`/route/api/Zones`).respond({id: 1234});
|
||||
controller.onSubmit();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('zone.card.basicData', {id: 1234});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.zone"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<vn-horizontal>
|
||||
<vn-vertical vn-one>
|
||||
<vn-card pad-large>
|
||||
<vn-title>Delivery days</vn-title>
|
||||
a
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
|
||||
<vn-auto class="right-block">
|
||||
<vn-zone-calendar zone="$ctrl.zone"></vn-zone-calendar>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
class Controller {
|
||||
|
||||
constructor($scope) {
|
||||
this.$scope = $scope;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
||||
ngModule.component('vnZoneDeliveryDay', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
zone: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnZoneCard'
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue