diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html new file mode 100644 index 000000000..45c745688 --- /dev/null +++ b/modules/travel/front/descriptor-menu/index.html @@ -0,0 +1,21 @@ + + + + + + Clone travel + + + + + + + diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js new file mode 100644 index 000000000..84a510e55 --- /dev/null +++ b/modules/travel/front/descriptor-menu/index.js @@ -0,0 +1,31 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +class Controller extends Section { + constructor($element, $) { + super($element, $); + } + + onCloneAccept() { + const params = JSON.stringify({ + ref: this.travel.ref, + agencyModeFk: this.travel.agencyFk, + shipped: this.travel.shipped, + landed: this.travel.landed, + warehouseInFk: this.travel.warehouseInFk, + warehouseOutFk: this.travel.warehouseOutFk + }); + this.$state.go('travel.create', {q: params}); + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnTravelDescriptorMenu', { + template: require('./index.html'), + controller: Controller, + bindings: { + travel: '<', + } +}); diff --git a/modules/travel/front/descriptor-menu/index.spec.js b/modules/travel/front/descriptor-menu/index.spec.js new file mode 100644 index 000000000..d66f3a435 --- /dev/null +++ b/modules/travel/front/descriptor-menu/index.spec.js @@ -0,0 +1,39 @@ +import './index.js'; + +describe('Travel Component vnTravelDescriptorMenu', () => { + let controller; + beforeEach(ngModule('travel')); + + beforeEach(inject(($componentController, $state,) => { + const $element = angular.element(''); + controller = $componentController('vnTravelDescriptorMenu', {$element}); + })); + + describe('onCloneAccept()', () => { + it('should call state.go with the travel data', () => { + jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); + + controller.travel = { + ref: 'the ref', + agencyFk: 'the agency', + shipped: 'the shipped date', + landed: 'the landing date', + warehouseInFk: 'the receiver warehouse', + warehouseOutFk: 'the sender warehouse' + }; + + controller.onCloneAccept(); + + const params = JSON.stringify({ + ref: controller.travel.ref, + agencyModeFk: controller.travel.agencyFk, + shipped: controller.travel.shipped, + landed: controller.travel.landed, + warehouseInFk: controller.travel.warehouseInFk, + warehouseOutFk: controller.travel.warehouseOutFk + }); + + expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {'q': params}); + }); + }); +}); diff --git a/modules/travel/front/descriptor-menu/style.scss b/modules/travel/front/descriptor-menu/style.scss new file mode 100644 index 000000000..beab9335e --- /dev/null +++ b/modules/travel/front/descriptor-menu/style.scss @@ -0,0 +1,24 @@ +@import "./effects"; +@import "variables"; + +vn-travel-descriptor-menu { + & > vn-icon-button[icon="more_vert"] { + display: flex; + min-width: 45px; + height: 45px; + box-sizing: border-box; + align-items: center; + justify-content: center; + } + & > vn-icon-button[icon="more_vert"] { + @extend %clickable; + color: inherit; + + & > vn-icon { + padding: 10px; + } + vn-icon { + font-size: 1.75rem; + } + } +} \ No newline at end of file diff --git a/modules/travel/front/descriptor/index.html b/modules/travel/front/descriptor/index.html index cd6143cae..1e5d0294f 100644 --- a/modules/travel/front/descriptor/index.html +++ b/modules/travel/front/descriptor/index.html @@ -1,6 +1,9 @@ + + +