2176 - Added contextmenu
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-05-28 08:07:26 +02:00
parent dfa6472fcf
commit 0fe78a2b8f
5 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,5 @@
<section vn-id="contextmenu" style="position: absolute">
<vn-menu vn-id="menu">
<vn-list ng-transclude="menu"></vn-list>
</vn-menu>
</section>

View File

@ -0,0 +1,68 @@
import ngModule from '../../module';
export default class Contextmenu {
constructor($element, $, $window) {
this.$element = $element;
this.element = $element[0];
this.$ = $;
this.$window = $window;
// this.displayMode = 'relative';
// Foreach element, apply an addEventListener???
/*
document.body.addEventListener('contextmenu', event => {
if (!event.defaultPrevented)
event.preventDefault();
const target = event.target;
const rect = target.getBoundingClientRect();
console.log('ScreenY', event.pageY);
console.log('OffsetY', event.pageX);
const parent = $.contextmenu;
parent.style.top = event.pageY + 'px';
parent.style.left = event.pageX + 'px';
$.menu.show(parent);
}); */
}
get target() {
return this._target;
}
set target(value) {
this._target = value;
if (!value) return;
const target = document.querySelector(value);// Find elements
console.log(this.element);
if (!target) return;
target.addEventListener('contextmenu', event => {
if (!event.defaultPrevented)
event.preventDefault();
const parent = this.$.contextmenu;
parent.style.top = event.pageY + 'px';
parent.style.left = event.pageX + 'px';
this.$.menu.show(parent);
});
}
}
Contextmenu.$inject = ['$element', '$scope', '$window'];
ngModule.vnComponent('vnContextmenu', {
controller: Contextmenu,
template: require('./index.html'),
bindings: {
target: '@?'
},
transclude: {
menu: '?slotMenu'
}
});

View File

@ -50,3 +50,4 @@ import './th';
import './treeview'; import './treeview';
import './wday-picker'; import './wday-picker';
import './datalist'; import './datalist';
import './contextmenu';

View File

@ -19,6 +19,10 @@ export default class Controller extends Section {
this.$state.go(`ticket.index`, this.$state.go(`ticket.index`,
{q: JSON.stringify({clientFk: client.id})}); {q: JSON.stringify({clientFk: client.id})});
} }
filterBySelection() {
console.log('Filtro por seleccion');
}
} }
ngModule.component('vnClientIndex', { ngModule.component('vnClientIndex', {

View File

@ -122,4 +122,13 @@
<vn-item-summary <vn-item-summary
item="$ctrl.itemSelected"> item="$ctrl.itemSelected">
</vn-item-summary> </vn-item-summary>
</vn-popup> </vn-popup>
<vn-contextmenu target="vn-data-viewer">
<slot-menu>
<vn-item ng-click="$ctrl.filterBySelection()">Filter by selection</vn-item>
<vn-item>Exclude selection</vn-item>
<vn-item>Remove filter by selection</vn-item>
<vn-item>Order DESC</vn-item>
<vn-item>Order ASC</vn-item>
</slot-menu>
</vn-contextmenu>