dot menu along with clone option
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c0b2ef9666
commit
dc7a6d4ce1
|
@ -0,0 +1,21 @@
|
|||
<vn-icon-button
|
||||
icon="more_vert"
|
||||
vn-popover="menu">
|
||||
</vn-icon-button>
|
||||
<vn-menu vn-id="menu">
|
||||
<vn-list>
|
||||
<vn-item
|
||||
ng-click="clone.show()"
|
||||
translate>
|
||||
Clone travel
|
||||
</vn-item>
|
||||
</vn-list>
|
||||
</vn-menu>
|
||||
|
||||
<!-- Clone travel popup -->
|
||||
<vn-confirm
|
||||
vn-id="clone"
|
||||
on-accept="$ctrl.onCloneAccept()"
|
||||
question="Do you want to clone this travel?"
|
||||
message="All it's properties will be copied">
|
||||
</vn-confirm>
|
|
@ -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: '<',
|
||||
}
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Travel Component vnTravelDescriptorMenu', () => {
|
||||
let controller;
|
||||
beforeEach(ngModule('travel'));
|
||||
|
||||
beforeEach(inject(($componentController, $state,) => {
|
||||
const $element = angular.element('<vn-travel-descriptor-menu></vn-travel-descriptor-menu>');
|
||||
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});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
<vn-descriptor-content
|
||||
module="travel"
|
||||
description="$ctrl.travel.ref">
|
||||
<slot-dot-menu>
|
||||
<vn-travel-descriptor-menu travel="$ctrl.travel"/>
|
||||
</slot-dot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
|
|
|
@ -13,3 +13,4 @@ import './thermograph/index/';
|
|||
import './thermograph/create/';
|
||||
import './thermograph/edit/';
|
||||
import './descriptor-popover';
|
||||
import './descriptor-menu';
|
||||
|
|
Loading…
Reference in New Issue