merge
This commit is contained in:
commit
2d2ce304b5
|
@ -6,6 +6,7 @@ pipeline {
|
|||
disableConcurrentBuilds()
|
||||
}
|
||||
environment {
|
||||
PROJECT_NAME = 'salix'
|
||||
REGISTRY = 'registry.verdnatura.es'
|
||||
DOCKER_HOST_1 = 'vch1.verdnatura.es'
|
||||
DOCKER_HOST_2 = 'vch2.verdnatura.es'
|
||||
|
@ -15,7 +16,7 @@ pipeline {
|
|||
stage('Checkout') {
|
||||
steps {
|
||||
script {
|
||||
env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-')
|
||||
env.COMPOSE_PROJECT_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
||||
env.GIT_COMMITTER_EMAIL = sh(
|
||||
script: 'git --no-pager show -s --format="%ae"',
|
||||
returnStdout: true
|
||||
|
@ -28,9 +29,6 @@ pipeline {
|
|||
case 'test':
|
||||
env.PORT = 5001
|
||||
break
|
||||
case 'test':
|
||||
env.PORT = 5000
|
||||
break
|
||||
}
|
||||
switch (env.BRANCH_NAME) {
|
||||
case 'master':
|
||||
|
@ -39,9 +37,6 @@ pipeline {
|
|||
case 'test':
|
||||
env.NODE_ENV = 'test'
|
||||
break
|
||||
case 'dev':
|
||||
env.NODE_ENV = 'development'
|
||||
break
|
||||
}
|
||||
}
|
||||
echo "Committer: ${env.GIT_COMMITTER_EMAIL}"
|
||||
|
@ -59,9 +54,10 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
branch 'dev'
|
||||
}
|
||||
when { not { anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}}}
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
FIREFOX_BIN = "/opt/firefox/firefox-bin"
|
||||
|
@ -75,9 +71,10 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('Build') {
|
||||
when {
|
||||
not { branch 'dev' }
|
||||
}
|
||||
when { anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}}
|
||||
environment {
|
||||
CREDS = credentials('docker-registry')
|
||||
}
|
||||
|
@ -92,9 +89,10 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when {
|
||||
not { branch 'dev' }
|
||||
}
|
||||
when { anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}}
|
||||
environment {
|
||||
DOCKER_TLS_VERIFY = 1
|
||||
}
|
||||
|
@ -124,9 +122,10 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('Cleanup') {
|
||||
when {
|
||||
not { branch 'dev' }
|
||||
}
|
||||
when { anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}}
|
||||
steps {
|
||||
sh 'docker logout $REGISTRY'
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ pipeline {
|
|||
post {
|
||||
always {
|
||||
script {
|
||||
if (env.BRANCH_NAME == 'dev') {
|
||||
if (!['master', 'test'].contains(env.BRANCH_NAME)) {
|
||||
try {
|
||||
junit '*/junitresults.xml'
|
||||
junit 'junitresults.xml'
|
||||
|
|
|
@ -19,5 +19,11 @@
|
|||
"expired": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
|
||||
"scope": {
|
||||
"where" :{
|
||||
"expired": null
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('loopback model Company', () => {
|
||||
it('should check that the company FTH doesnt exists', async() => {
|
||||
let result = await app.models.Company.findOne({where: {code: 'FTH'}});
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
|
@ -31,7 +31,7 @@ describe('User config', () => {
|
|||
expect(userLocalBank).toEqual('');
|
||||
expect(userLocalCompany).toEqual('');
|
||||
expect(userWarehouse).toEqual('Warehouse Three');
|
||||
expect(userCompany).toEqual('FTH');
|
||||
expect(userCompany).toEqual('VNH');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -103,7 +103,7 @@ describe('User config', () => {
|
|||
expect(userLocalBank).toContain('Pay on receipt');
|
||||
expect(userLocalCompany).toContain('VNL');
|
||||
expect(userWarehouse).toEqual('Warehouse Three');
|
||||
expect(userCompany).toEqual('FTH');
|
||||
expect(userCompany).toEqual('VNH');
|
||||
});
|
||||
|
||||
it('should now clear the local settings', async() => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<md-checkbox
|
||||
aria-label="Checkbox 1"
|
||||
aria-label="::$ctrl.label"
|
||||
md-indeterminate="$ctrl.isIntermediate"
|
||||
ng-disabled="$ctrl.disabled"
|
||||
ng-checked="$ctrl.isChecked"
|
||||
|
|
|
@ -16,9 +16,7 @@ export default class Controller extends Component {
|
|||
set model(value) {
|
||||
if (value === null) return;
|
||||
|
||||
if (this.model === true)
|
||||
value = false;
|
||||
else if (this.model === false && this.tripleState)
|
||||
if (this.model === false && this.tripleState)
|
||||
value = null;
|
||||
|
||||
this.emit('change', {value});
|
||||
|
@ -38,9 +36,10 @@ export default class Controller extends Component {
|
|||
}
|
||||
|
||||
get isIntermediate() {
|
||||
return this.intermediate
|
||||
|| this.model === null
|
||||
|| this.model === undefined;
|
||||
if (this.intermediate || (this.tripleState && (this.model === null || this.model === undefined)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
get isChecked() {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
describe('Component vnCheck', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('vnCore'));
|
||||
|
||||
beforeEach(inject(($compile, $rootScope) => {
|
||||
$element = $compile(`<vn-check></vn-check`)($rootScope);
|
||||
controller = $element.controller('vnCheck');
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
$element.remove();
|
||||
});
|
||||
|
||||
describe('model() setter', () => {
|
||||
it(`should set model value`, () => {
|
||||
controller.model = true;
|
||||
|
||||
expect(controller.model).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should set model value to null if current model value is false and is a triple-state checkbox`, () => {
|
||||
controller._model = false;
|
||||
controller.tripleState = true;
|
||||
controller.model = true;
|
||||
|
||||
expect(controller.model).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('field() setter', () => {
|
||||
it(`should set model value`, () => {
|
||||
controller.field = true;
|
||||
|
||||
expect(controller.field).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should set model value and convert numerical values to boolean values`, () => {
|
||||
controller.field = 1;
|
||||
|
||||
expect(controller.field).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isIntermediate() getter', () => {
|
||||
it(`should return true if intermediate property is truthy`, () => {
|
||||
controller.intermediate = true;
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should return true if is a triple-state checkbox and has null or undefined value`, () => {
|
||||
controller.tripleState = true;
|
||||
controller.model = null;
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
vn-check {
|
||||
position: relative;
|
||||
& > .mdl-checkbox {
|
||||
width: initial;
|
||||
}
|
||||
|
||||
& > i {
|
||||
padding-left: 5px;
|
||||
position: absolute;
|
||||
bottom: 3px;
|
||||
color: $color-font-secondary;
|
||||
font-size: 20px !important
|
||||
font-size: 20px !important;
|
||||
cursor: help
|
||||
}
|
||||
|
||||
md-checkbox.md-checked .md-icon {
|
||||
background-color: $color-main;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,23 +8,37 @@ export default class Controller {
|
|||
this.hasInfo = Boolean($attrs.info);
|
||||
this.info = $attrs.info || null;
|
||||
}
|
||||
|
||||
set label(value) {
|
||||
let label = this.element.querySelector('vn-label');
|
||||
label.textContent = this._.instant(value);
|
||||
this._label = value;
|
||||
}
|
||||
|
||||
get label() {
|
||||
return this._label;
|
||||
}
|
||||
|
||||
set value(value) {
|
||||
let span = this.element.querySelector('span');
|
||||
span.title = value;
|
||||
span.textContent = value ? value : '-';
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
get title() {
|
||||
return this._title;
|
||||
}
|
||||
|
||||
set title(value) {
|
||||
let span = this.element.querySelector('span');
|
||||
span.title = value;
|
||||
this._title = value;
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$translate', '$attrs'];
|
||||
|
||||
|
@ -32,6 +46,7 @@ ngModule.component('vnLabelValue', {
|
|||
controller: Controller,
|
||||
template: require('./label-value.html'),
|
||||
bindings: {
|
||||
title: '@?',
|
||||
label: '@',
|
||||
value: '@'
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<ul ng-if="$ctrl.items">
|
||||
<li ng-repeat="item in $ctrl.items" ng-class="{'selected' : item.selected && !item.excluded, 'included': item.included}">
|
||||
<li ng-repeat="item in $ctrl.items"
|
||||
ng-class="{
|
||||
'expanded': item.active,
|
||||
'collapsed': !item.active,
|
||||
'included': item.isIncluded == 1,
|
||||
'excluded': item.isIncluded == 0
|
||||
}">
|
||||
<vn-horizontal>
|
||||
<vn-auto class="actions">
|
||||
<vn-icon icon="keyboard_arrow_up" ng-if="item.childs.length"
|
||||
ng-click="$ctrl.toggle(item, $event)">
|
||||
</vn-icon>
|
||||
<vn-icon icon="keyboard_arrow_down" ng-if="item.sons > 0 && !item.childs"
|
||||
ng-click="$ctrl.toggle(item, $event)">
|
||||
<vn-icon icon="keyboard_arrow_down"
|
||||
ng-show="item.sons > 0"
|
||||
ng-click="$ctrl.toggle(item, $event)" >
|
||||
</vn-icon>
|
||||
</vn-auto>
|
||||
<vn-one class="description">
|
||||
<vn-horizontal>
|
||||
<vn-check vn-auto field="item.selected && !item.excluded"
|
||||
on-change="$ctrl.select(item)">
|
||||
<div class="description">
|
||||
<vn-check vn-auto field="item.isIncluded"
|
||||
on-change="$ctrl.select(item, value)" triple-state="true">
|
||||
</vn-check>
|
||||
<vn-one ng-dblclick="$ctrl.toggle(item)" class="text unselectable">
|
||||
{{::item.name}}
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
</div>
|
||||
</vn-horizontal>
|
||||
<vn-treeview-child items="item.childs"></vn-treeview-child>
|
||||
</li>
|
||||
|
|
|
@ -10,8 +10,8 @@ class Controller extends Component {
|
|||
this.treeview.onToggle(item);
|
||||
}
|
||||
|
||||
select(item) {
|
||||
this.treeview.onSelection(item);
|
||||
select(item, value) {
|
||||
this.treeview.onSelection(item, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,72 +20,10 @@ export default class Treeview extends Component {
|
|||
refresh() {
|
||||
this.model.refresh().then(() => {
|
||||
this.data = this.model.data;
|
||||
console.log(this.data);
|
||||
this.repaintAll();
|
||||
});
|
||||
}
|
||||
|
||||
repaintAll() {
|
||||
let oldData = this.data;
|
||||
oldData.forEach(node => {
|
||||
this.repaintAsc(node);
|
||||
this.repaintDesc(node);
|
||||
});
|
||||
}
|
||||
|
||||
repaintNode(node) {
|
||||
this.repaintAsc(node);
|
||||
this.repaintDesc(node);
|
||||
}
|
||||
|
||||
repaintAsc(node) {
|
||||
if (!node.parent) return;
|
||||
|
||||
const parent = node.parent;
|
||||
if ((node.selected || node.included) && !parent.selected) {
|
||||
parent.included = true;
|
||||
parent.hasCheckedChilds = true;
|
||||
} else if (!this.hasCheckedChilds(parent) && !this.hasCheckedParents(node))
|
||||
parent.included = false;
|
||||
|
||||
// FIXME - Propagate hasCheckedCHilds
|
||||
if (!node.selected && this.hasCheckedParents(node)) {
|
||||
node.included = true;
|
||||
parent.hasCheckedChilds = false;
|
||||
}
|
||||
|
||||
if (!this.hasCheckedChilds(node))
|
||||
node.hasCheckedChilds = false;
|
||||
|
||||
this.repaintAsc(parent);
|
||||
}
|
||||
|
||||
repaintDesc(node) {
|
||||
/* if (node.hasCheckedChilds)
|
||||
node.included = false; */
|
||||
|
||||
if (!node.selected && this.hasCheckedChilds(node)) {
|
||||
node.hasCheckedChilds = true;
|
||||
node.included = true;
|
||||
} else if (!node.selected && node.childs && !this.hasCheckedChilds(node))
|
||||
node.hasCheckedChilds = false;
|
||||
|
||||
|
||||
const childs = node.childs || [];
|
||||
for (let i = 0; i < childs.length; i++) {
|
||||
childs[i].included = false;
|
||||
|
||||
if (((node.selected || node.included && this.hasCheckedParents(childs[i])) && !childs[i].selected) && !node.excluded)
|
||||
childs[i].included = true;
|
||||
|
||||
this.repaintDesc(childs[i]);
|
||||
}
|
||||
|
||||
if (!node.selected && node.hasCheckedChilds)
|
||||
node.included = true;
|
||||
}
|
||||
|
||||
hasCheckedChilds(node) {
|
||||
/* hasCheckedChilds(node) {
|
||||
if (!node.childs) return false;
|
||||
|
||||
const childs = node.childs;
|
||||
|
@ -105,44 +43,41 @@ export default class Treeview extends Component {
|
|||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
} */
|
||||
|
||||
onSelection(item) {
|
||||
let canBeExcluded = this.hasCheckedChilds(item) || this.hasCheckedParents(item);
|
||||
|
||||
if (!item.selected && item.included && canBeExcluded)
|
||||
item.excluded = true;
|
||||
else
|
||||
item.excluded = false;
|
||||
|
||||
item.selected = !item.selected;
|
||||
|
||||
if (item.selected && item.included)
|
||||
item.included = false;
|
||||
|
||||
if (this.hasCheckedChilds(item))
|
||||
item.hasCheckedChilds = true;
|
||||
else if (this.childs)
|
||||
item.hasCheckedChilds = false;
|
||||
|
||||
this.emit('selection', {item});
|
||||
onSelection(item, value) {
|
||||
this.emit('selection', {item, value});
|
||||
}
|
||||
|
||||
onToggle(item) {
|
||||
if (item.childs && item.childs.length == 0)
|
||||
return;
|
||||
|
||||
if (item.childs)
|
||||
if (item.active)
|
||||
item.childs = undefined;
|
||||
else {
|
||||
this.model.applyFilter({}, {parentFk: item.id}).then(() => {
|
||||
item.childs = this.model.data;
|
||||
item.childs.forEach(child => {
|
||||
child.parent = item;
|
||||
const newData = this.model.data;
|
||||
|
||||
if (item.childs) {
|
||||
let childs = item.childs;
|
||||
childs.forEach(child => {
|
||||
let index = newData.findIndex(newChild => {
|
||||
return newChild.id == child.id;
|
||||
});
|
||||
this.repaintNode(item);
|
||||
newData[index] = child;
|
||||
});
|
||||
}
|
||||
|
||||
item.childs = newData.sort((a, b) => {
|
||||
let priority = (b.isIncluded - a.isIncluded) - 1;
|
||||
|
||||
if (b.name > a.name)
|
||||
priority++;
|
||||
|
||||
return priority;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
item.active = !item.active;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,19 +2,21 @@
|
|||
|
||||
vn-treeview {
|
||||
ul {
|
||||
margin: 0;
|
||||
line-height: 24px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
|
||||
.actions {
|
||||
padding: 0.5em;
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
.description {
|
||||
padding: 0.5em
|
||||
padding-left: 5px
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,27 +24,41 @@ vn-treeview {
|
|||
padding: 0 1.8em;
|
||||
}
|
||||
|
||||
li > vn-horizontal {
|
||||
padding: 5px
|
||||
}
|
||||
|
||||
li > vn-horizontal:hover {
|
||||
background-color: $color-hover-cd
|
||||
}
|
||||
|
||||
li.selected > vn-horizontal > .description .text,
|
||||
li.included > vn-horizontal > .description .text {
|
||||
font-weight: bold;
|
||||
color: $color-main;
|
||||
li.expanded > vn-horizontal > .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
transition: all 0.2s;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
li.collapsed > vn-horizontal > .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
transition: all 0.2s;
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
li.included {
|
||||
& > vn-horizontal > .description > vn-horizontal > vn-check {
|
||||
.mdl-checkbox .mdl-checkbox__box-outline, {
|
||||
border: 2px solid $color-main-medium;
|
||||
& > vn-horizontal > .description {
|
||||
color: $color-notice;
|
||||
font-weight: bold;
|
||||
|
||||
& > vn-check .md-icon {
|
||||
background-color: $color-notice
|
||||
}
|
||||
fieldset[disabled] .mdl-checkbox .mdl-checkbox__box-outline, .mdl-checkbox.is-disabled .mdl-checkbox__box-outline {
|
||||
border: 2px solid rgba(0,0,0,.26);
|
||||
}
|
||||
.mdl-checkbox .mdl-checkbox__tick-outline {
|
||||
background: $color-main-medium;
|
||||
|
||||
}
|
||||
|
||||
li.excluded {
|
||||
& > vn-horizontal > .description {
|
||||
color: $color-alert;
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div style="position: relative;">
|
||||
<div style="position: absolute; top: 0; left: 0; padding: .5em; z-index: 1">
|
||||
<div style="position: absolute; top: 0; left: 0; padding: .3em; z-index: 1">
|
||||
<vn-icon-button
|
||||
icon="menu"
|
||||
style="font-size: .4em;"
|
||||
|
@ -15,14 +15,16 @@
|
|||
<div pad-medium>
|
||||
<vn-horizontal ng-repeat="field in fields">
|
||||
<vn-check
|
||||
vn-one label="{{field}}"
|
||||
vn-one label="{{titles[field]}}"
|
||||
field="tableConfiguration.configuration[field]">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-button
|
||||
label="Save"
|
||||
ng-click="$ctrl.saveConfiguration(tableConfiguration)">
|
||||
</vn-button>
|
||||
</vn-horizontal>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ngModule from '../module';
|
||||
import template from './uvc.html';
|
||||
import './uvc.scss';
|
||||
|
||||
directive.$inject = ['$http', '$compile', 'vnApp', '$translate'];
|
||||
export function directive($http, $compile, vnApp, $translate) {
|
||||
|
@ -7,12 +8,16 @@ export function directive($http, $compile, vnApp, $translate) {
|
|||
let allHeaders = $element[0].querySelectorAll(`vn-th[field], vn-th[th-id]`);
|
||||
let headerList = Array.from(allHeaders);
|
||||
let ids = [];
|
||||
let titles = {};
|
||||
|
||||
headerList.forEach(header => {
|
||||
ids.push(header.getAttribute('th-id') || header.getAttribute('field'));
|
||||
let id = header.getAttribute('th-id') || header.getAttribute('field');
|
||||
ids.push(id);
|
||||
titles[id] = header.innerText || id.charAt(0).toUpperCase() + id.slice(1);
|
||||
});
|
||||
|
||||
$scope.fields = ids;
|
||||
$scope.titles = titles;
|
||||
|
||||
return headerList;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
vn-table vn-dialog[vn-id="uvc"]{
|
||||
& > div {
|
||||
min-width: 18em;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
|
||||
vn-button[label="Save"] {
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
|
@ -2,3 +2,5 @@ import './module';
|
|||
import './routes';
|
||||
import './components';
|
||||
import './styles';
|
||||
|
||||
// XXX: Pull request: Test 2
|
||||
|
|
|
@ -58,7 +58,7 @@ function backWatch(done) {
|
|||
|
||||
nodemon({
|
||||
exec: commands.join(' && '),
|
||||
ext: 'js html css',
|
||||
ext: 'js html css json',
|
||||
args: ['backOnly'],
|
||||
watch: backSources,
|
||||
done: done
|
||||
|
|
|
@ -6,12 +6,6 @@ module.exports = Self => {
|
|||
description: 'Returns the first shipped and landed possible for params',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'zoneFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
|
@ -21,6 +15,12 @@ module.exports = Self => {
|
|||
type: 'Number',
|
||||
default: 1,
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
|
@ -32,64 +32,120 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getLeaves = async(filter, zoneFk, parentFk = 1) => {
|
||||
Self.getLeaves = async(zoneFk, parentFk = 1, filter) => {
|
||||
let conn = Self.dataSource.connector;
|
||||
let stmts = [];
|
||||
|
||||
stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.checkedChilds`);
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`SELECT lft, rgt, depth + 1 INTO @lft, @rgt, @depth
|
||||
FROM zoneGeo WHERE id = ?`, [parentFk]));
|
||||
`CREATE TEMPORARY TABLE tmp.checkedChilds (
|
||||
id INT,
|
||||
name VARCHAR(100),
|
||||
lft INT,
|
||||
rgt INT,
|
||||
depth BIGINT(22),
|
||||
sons DECIMAL(10, 0),
|
||||
isIncluded TINYINT
|
||||
) ENGINE = MEMORY`));
|
||||
|
||||
stmts.push(`DROP TEMPORARY TABLE IF EXISTS tChilds`);
|
||||
|
||||
let stmt = new ParameterizedSQL(
|
||||
`CREATE TEMPORARY TABLE tChilds
|
||||
ENGINE = MEMORY
|
||||
SELECT id, lft, rgt
|
||||
FROM zoneGeo pt`);
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
if (!filter.where) {
|
||||
stmt.merge(`WHERE pt.lft > @lft AND pt.rgt < @rgt
|
||||
AND pt.depth = @depth`);
|
||||
if (parentFk === 1) {
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`INSERT INTO tmp.checkedChilds
|
||||
SELECT
|
||||
zg.id,
|
||||
zg.name,
|
||||
zg.lft,
|
||||
zg.rgt,
|
||||
zg.depth,
|
||||
zg.sons,
|
||||
zi.isIncluded
|
||||
FROM zoneGeo zg
|
||||
JOIN zoneIncluded zi ON zi.geoFk = zg.id
|
||||
AND zoneFk = ?`, [zoneFk]));
|
||||
}
|
||||
|
||||
stmts.push(stmt);
|
||||
let stmt = new ParameterizedSQL(
|
||||
`SELECT * FROM (
|
||||
SELECT
|
||||
zg.id,
|
||||
zg.name,
|
||||
zg.lft,
|
||||
zg.rgt,
|
||||
zg.depth,
|
||||
zg.sons,
|
||||
IF(ch.id = zg.id, isIncluded, null) isIncluded
|
||||
FROM zoneGeo zg
|
||||
JOIN tmp.checkedChilds ch
|
||||
ON zg.lft <= ch.lft AND zg.rgt >= ch.rgt
|
||||
AND zg.depth > 0
|
||||
UNION ALL
|
||||
SELECT
|
||||
child.id,
|
||||
child.name,
|
||||
child.lft,
|
||||
child.rgt,
|
||||
child.depth,
|
||||
child.sons,
|
||||
zi.isIncluded
|
||||
FROM zoneGeo parent
|
||||
JOIN zoneGeo child ON child.lft > parent.lft
|
||||
AND child.rgt < parent.rgt
|
||||
AND child.depth = parent.depth + 1
|
||||
LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id
|
||||
AND zoneFk = ?
|
||||
WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]);
|
||||
|
||||
stmts.push(`DROP TEMPORARY TABLE IF EXISTS tZones`);
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CREATE TEMPORARY TABLE tZones
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id
|
||||
FROM tChilds t
|
||||
JOIN zoneGeo zt
|
||||
ON zt.lft > t.lft AND zt.rgt < t.rgt
|
||||
JOIN zoneIncluded zi
|
||||
ON zi.geoFk = zt.id AND zi.zoneFk = ?
|
||||
GROUP BY t.id`, [zoneFk]));
|
||||
// Get nodes from depth greather than Origin
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
stmt.merge('GROUP BY nst.id');
|
||||
|
||||
const resultIndex = stmts.push(new ParameterizedSQL(
|
||||
`SELECT
|
||||
pt.id,
|
||||
pt.name,
|
||||
pt.lft,
|
||||
pt.rgt,
|
||||
pt.depth,
|
||||
pt.sons,
|
||||
ti.id IS NOT NULL hasCheckedChilds,
|
||||
zi.geoFk IS NOT NULL AS selected,
|
||||
zi.isIncluded AS excluded
|
||||
FROM zoneGeo pt
|
||||
LEFT JOIN vn.zoneIncluded zi
|
||||
ON zi.geoFk = pt.id AND zi.zoneFk = ?
|
||||
JOIN tChilds c ON c.id = pt.id
|
||||
LEFT JOIN tZones ti ON ti.id = pt.id
|
||||
ORDER BY selected DESC, name`, [zoneFk])) - 1;
|
||||
const resultIndex = stmts.push(stmt) - 1;
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await Self.rawStmt(sql);
|
||||
const nodes = result[resultIndex];
|
||||
|
||||
return result[resultIndex];
|
||||
if (nodes.length == 0)
|
||||
return nodes;
|
||||
|
||||
// Get parent nodes
|
||||
const minorDepth = nodes.reduce((a, b) => {
|
||||
return b < a ? b : a;
|
||||
}).depth;
|
||||
|
||||
const parentNodes = nodes.filter(element => {
|
||||
return element.depth === minorDepth;
|
||||
});
|
||||
|
||||
const sortedLeaves = parentNodes.sort((a, b) => {
|
||||
let priority = (b.isIncluded - a.isIncluded) - 1;
|
||||
|
||||
if (b.name > a.name)
|
||||
priority++;
|
||||
|
||||
return priority;
|
||||
});
|
||||
const leaves = Object.assign([], sortedLeaves);
|
||||
|
||||
nestLeaves(leaves);
|
||||
|
||||
function nestLeaves(elements) {
|
||||
elements.forEach(element => {
|
||||
element.childs = Object.assign([], getLeaves(element));
|
||||
|
||||
nestLeaves(element.childs);
|
||||
});
|
||||
}
|
||||
|
||||
function getLeaves(parent) {
|
||||
let elements = nodes.filter(element => {
|
||||
return element.lft > parent.lft && element.rgt < parent.rgt
|
||||
&& element.depth === parent.depth + 1;
|
||||
});
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
return leaves;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,8 +8,8 @@ module.exports = Self => {
|
|||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'geoFk',
|
||||
type: 'Number',
|
||||
arg: 'item',
|
||||
type: 'Object',
|
||||
required: true,
|
||||
}],
|
||||
returns: {
|
||||
|
@ -22,31 +22,15 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.toggleIsIncluded = async(zoneFk, geoFk) => {
|
||||
const models = Self.app.models;
|
||||
const geo = await models.ZoneGeo.findById(geoFk);
|
||||
const isIncluded = await Self.findOne({
|
||||
where: {zoneFk, geoFk}
|
||||
Self.toggleIsIncluded = async(zoneFk, item) => {
|
||||
if (item.isIncluded === null)
|
||||
return Self.destroyAll({zoneFk, geoFk: item.id});
|
||||
else {
|
||||
return Self.upsert({
|
||||
zoneFk: zoneFk,
|
||||
geoFk: item.id,
|
||||
isIncluded: item.isIncluded
|
||||
});
|
||||
|
||||
const hasCheckedParents = await Self.rawSql(
|
||||
`SELECT id
|
||||
FROM vn.zoneGeo zt
|
||||
JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id
|
||||
WHERE zt.lft < ? AND zt.rgt > ?`, [geo.lft, geo.rgt]
|
||||
);
|
||||
const hasCheckedChilds = await Self.rawSql(
|
||||
`SELECT id
|
||||
FROM vn.zoneGeo zt
|
||||
JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id
|
||||
WHERE zt.lft > ? AND zt.rgt < ?`, [geo.lft, geo.rgt]
|
||||
);
|
||||
|
||||
const isExcluded = hasCheckedParents.length || hasCheckedChilds.length;
|
||||
|
||||
if (isIncluded)
|
||||
return Self.destroyAll({zoneFk, geoFk});
|
||||
else
|
||||
return Self.upsert({zoneFk, geoFk, isIncluded: isExcluded});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ class Controller {
|
|||
res.data.forEach(holiday => {
|
||||
events.push({
|
||||
date: holiday.dated,
|
||||
color: 'blue-circle',
|
||||
color: 'red',
|
||||
title: holiday.description || holiday.name,
|
||||
isRemovable: false
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
vn-id="model"
|
||||
url="/agency/api/ZoneGeos/getLeaves"
|
||||
filter="::$ctrl.filter"
|
||||
params="{zoneFk: $ctrl.$stateParams.id, parentFk: 1}">
|
||||
params="{zoneFk: $ctrl.$stateParams.id}" auto-load="false">
|
||||
</vn-crud-model>
|
||||
<div class="main-with-right-menu">
|
||||
<vn-card compact pad-large>
|
||||
|
@ -13,7 +13,7 @@
|
|||
vn-focus>
|
||||
</vn-searchbar>
|
||||
<vn-treeview vn-id="treeview" model="model"
|
||||
on-selection="$ctrl.onSelection(item)">
|
||||
on-selection="$ctrl.onSelection(item, value)">
|
||||
</vn-treeview>
|
||||
</vn-card>
|
||||
<vn-side-menu side="right">
|
||||
|
|
|
@ -22,11 +22,12 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
onSelection(item) {
|
||||
onSelection(item, isIncluded) {
|
||||
item.isIncluded = isIncluded;
|
||||
const path = '/agency/api/ZoneIncludeds/toggleIsIncluded';
|
||||
const params = {geoFk: item.id, zoneFk: this.zone.id};
|
||||
const params = {zoneFk: this.zone.id, item};
|
||||
this.$http.post(path, params).then(() => {
|
||||
this.$scope.treeview.repaintNode(item);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,8 +119,7 @@ class Controller {
|
|||
} else
|
||||
offsetTop = onPreparationLine.offsetTop - headerHeight;
|
||||
|
||||
body.querySelector('ui-view').scrollTop = offsetTop;
|
||||
|
||||
this.$window.scrollTo(0, offsetTop);
|
||||
|
||||
this.ticketFk = null;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::item.density}}</vn-td>
|
||||
<vn-td number>{{::item.density}}</vn-td>
|
||||
<vn-td>{{::item.taxClass}}</vn-td>
|
||||
<vn-td>
|
||||
<vn-check
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
picture: Foto
|
|
@ -96,7 +96,8 @@
|
|||
<vn-check
|
||||
vn-one
|
||||
label="My team"
|
||||
field="filter.myTeam">
|
||||
field="filter.myTeam"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal margin-large-top>
|
||||
|
|
|
@ -25,6 +25,13 @@ class Controller {
|
|||
}, {
|
||||
relation: 'sip',
|
||||
scope: {fields: ['extension']}
|
||||
}, {
|
||||
relation: 'department',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'department'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
</vn-horizontal>
|
||||
<div class="body">
|
||||
<div class="attributes">
|
||||
<h5>{{$ctrl.worker.firstName}} {{$ctrl.worker.name}}</h5>
|
||||
<h5 title="{{$ctrl.worker.firstName}} {{$ctrl.worker.name}}">
|
||||
{{$ctrl.worker.firstName}} {{$ctrl.worker.name}}
|
||||
</h5>
|
||||
<vn-label-value label="Id"
|
||||
value="{{$ctrl.worker.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="User"
|
||||
value="{{$ctrl.worker.user.name}}">
|
||||
value="{{$ctrl.worker.user.name}}"
|
||||
title="{{$ctrl.worker.firstName}} {{$ctrl.worker.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Email"
|
||||
value="{{$ctrl.worker.user.email}}">
|
||||
|
@ -24,13 +27,13 @@
|
|||
value="{{$ctrl.worker.client.fi}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Department"
|
||||
value="{{$ctrl.worker.department.department}}">
|
||||
value="{{$ctrl.worker.department.department.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Phone"
|
||||
value="{{$ctrl.worker.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Extension"
|
||||
value="{{$ctrl.worker.sip.phone}}">
|
||||
value="{{$ctrl.worker.sip.extension}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
Workers: Trabajadores
|
||||
Last name: Apellidos
|
||||
User data: Datos de usuario
|
||||
Fiscal identifier: Identificador fiscal
|
||||
Email: Correo electrónico
|
||||
Fiscal identifier: NIF
|
||||
Email: E-mail
|
||||
Department: Departamento
|
||||
User id: Id de usuario
|
||||
Role: Rol
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
value="{{worker.user.email}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Department"
|
||||
value="{{worker.department.department}}">
|
||||
value="{{worker.department.department.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Phone"
|
||||
value="{{worker.phone}}">
|
||||
|
@ -25,13 +25,14 @@
|
|||
value="{{worker.userFk}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="User"
|
||||
value="{{worker.user.name}}">
|
||||
value="{{worker.user.name}}"
|
||||
title="{{worker.firstName}} {{worker.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Role"
|
||||
value="{{worker.user.role.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Extension"
|
||||
value="{{worker.sip.phone}}">
|
||||
value="{{worker.sip.extension}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -35,6 +35,13 @@ class Controller {
|
|||
}, {
|
||||
relation: 'sip',
|
||||
scope: {fields: ['extension']}
|
||||
}, {
|
||||
relation: 'department',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'department'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
|
@ -11,13 +11,13 @@
|
|||
"dependencies": {
|
||||
"compression": "^1.7.3",
|
||||
"fs-extra": "^5.0.0",
|
||||
"helmet": "^3.15.0",
|
||||
"helmet": "^3.15.1",
|
||||
"i18n": "^0.8.3",
|
||||
"loopback": "^3.24.0",
|
||||
"loopback": "^3.25.0",
|
||||
"loopback-boot": "^2.27.1",
|
||||
"loopback-component-explorer": "^6.3.1",
|
||||
"loopback-connector-mysql": "^5.3.1",
|
||||
"loopback-connector-remote": "^3.4.0",
|
||||
"loopback-connector-remote": "^3.4.1",
|
||||
"loopback-context": "^3.4.0",
|
||||
"md5": "^2.2.1",
|
||||
"object-diff": "0.0.4",
|
||||
|
@ -29,16 +29,16 @@
|
|||
"vn-loopback": "file:./loopback"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/core": "^7.3.3",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/polyfill": "^7.2.5",
|
||||
"@babel/preset-env": "^7.2.0",
|
||||
"@babel/preset-env": "^7.3.1",
|
||||
"@babel/register": "^7.0.0",
|
||||
"angular-mocks": "^1.7.4",
|
||||
"angular-mocks": "^1.7.7",
|
||||
"babel-loader": "^8.0.5",
|
||||
"css-loader": "^2.1.0",
|
||||
"del": "^2.2.2",
|
||||
"eslint": "^5.12.0",
|
||||
"eslint": "^5.14.0",
|
||||
"eslint-config-google": "^0.11.0",
|
||||
"eslint-plugin-jasmine": "^2.10.1",
|
||||
"fancy-log": "^1.3.2",
|
||||
|
@ -68,16 +68,16 @@
|
|||
"karma-webpack": "^3.0.5",
|
||||
"merge-stream": "^1.0.1",
|
||||
"minimist": "^1.2.0",
|
||||
"mysql2": "^1.6.1",
|
||||
"mysql2": "^1.6.5",
|
||||
"nightmare": "^3.0.1",
|
||||
"node-sass": "^4.9.3",
|
||||
"nodemon": "^1.18.5",
|
||||
"nodemon": "^1.18.10",
|
||||
"plugin-error": "^1.0.1",
|
||||
"raw-loader": "^1.0.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"webpack": "^4.28.3",
|
||||
"webpack-cli": "^3.2.1",
|
||||
"webpack": "^4.29.5",
|
||||
"webpack-cli": "^3.2.3",
|
||||
"webpack-dev-server": "^3.1.14",
|
||||
"webpack-merge": "^4.2.1",
|
||||
"yaml-loader": "^0.5.0"
|
||||
|
|
|
@ -1055,7 +1055,7 @@ INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
|||
(1, 2, 69),
|
||||
(5, 1, 442),
|
||||
(9, 1, 442),
|
||||
(18, 3, 791);
|
||||
(18, 3, 567);
|
||||
|
||||
INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`)
|
||||
VALUES
|
||||
|
|
Loading…
Reference in New Issue