Merge branch 'dev'
This commit is contained in:
commit
64a8f6a812
|
@ -19,4 +19,4 @@ rules:
|
||||||
no-eq-null: 0
|
no-eq-null: 0
|
||||||
no-console: 0
|
no-console: 0
|
||||||
no-warning-comments: 0
|
no-warning-comments: 0
|
||||||
no-empty: 0
|
no-empty: [error, allowEmptyCatch: true]
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
margin-medium-left
|
margin-medium-left
|
||||||
orange
|
orange
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
ng-if = "observation.showAddIcon"
|
ng-if = "observation.showAddIcon && observationsTypes.model.length > $ctrl.observations.length"
|
||||||
ng-click="$ctrl.addObservation()"
|
ng-click="$ctrl.addObservation()"
|
||||||
></vn-icon>
|
></vn-icon>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default class Controller {
|
||||||
id: parseInt($state.params.addressId)
|
id: parseInt($state.params.addressId)
|
||||||
};
|
};
|
||||||
this.observations = [];
|
this.observations = [];
|
||||||
this.observationsDictionary = {};
|
this.observationsOld = {};
|
||||||
this.observationsRemoved = [];
|
this.observationsRemoved = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +60,16 @@ export default class Controller {
|
||||||
return this.$http.post(`/client/api/AddressObservations/crudAddressObservations`, objectObservations);
|
return this.$http.post(`/client/api/AddressObservations/crudAddressObservations`, objectObservations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_observationsEquals(ob1, ob2) {
|
||||||
|
return ob1.observationTypeFk === ob2.observationTypeFk && ob1.description === ob2.description;
|
||||||
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
this._unsetDirtyForm();
|
this._unsetDirtyForm();
|
||||||
let submitWatcher = this.$scope.watcher.dataChanged();
|
let submitWatcher = this.$scope.watcher.dataChanged();
|
||||||
let submitObservations;
|
let submitObservations;
|
||||||
let repeatedTypes = false;
|
let repeatedTypes = false;
|
||||||
|
let types = [];
|
||||||
let observationsObj = {
|
let observationsObj = {
|
||||||
delete: this.observationsRemoved,
|
delete: this.observationsRemoved,
|
||||||
create: [],
|
create: [],
|
||||||
|
@ -73,31 +78,27 @@ export default class Controller {
|
||||||
|
|
||||||
for (let i = 0; i < this.observations.length; i++) {
|
for (let i = 0; i < this.observations.length; i++) {
|
||||||
let observation = this.observations[i];
|
let observation = this.observations[i];
|
||||||
// only one observation is allowed for each of its types
|
let isNewObservation = observation.id === undefined;
|
||||||
if (this.observationsDictionary[observation.observationTypeFk] !== undefined && // IF the dictionary contains the type
|
|
||||||
(
|
if (types.indexOf(observation.observationTypeFk) !== -1) {
|
||||||
// AND (is a new Observation OR is old but with distinct Id) --> repeated
|
|
||||||
!observation.id || (observation.id && this.observationsDictionary[observation.observationTypeFk].id !== observation.id)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
repeatedTypes = true;
|
repeatedTypes = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!observation.id && observation.observationTypeFk && observation.description) {
|
types.push(observation.observationTypeFk);
|
||||||
|
|
||||||
|
if (isNewObservation && observation.observationTypeFk && observation.description) {
|
||||||
observationsObj.create.push(observation);
|
observationsObj.create.push(observation);
|
||||||
} else if (observation.id && this.observationsDictionary[observation.observationTypeFk].description !== observation.description) {
|
} else if (!isNewObservation && !this._observationsEquals(this.observationsOld[observation.id], observation)) {
|
||||||
observationsObj.update.push(observation);
|
observationsObj.update.push(observation);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.observationsDictionary[observation.observationTypeFk] = observation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submitObservations = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
submitObservations = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||||
|
|
||||||
if (repeatedTypes) {
|
if (repeatedTypes) {
|
||||||
this.vnApp.showMessage(
|
this.vnApp.showMessage(
|
||||||
this.$translate.instant('you can not repeat the types of observations')
|
this.$translate.instant('The observation type must be unique')
|
||||||
);
|
);
|
||||||
} else if (submitWatcher && !submitObservations) {
|
} else if (submitWatcher && !submitObservations) {
|
||||||
this.$scope.watcher.submit().then(() => {
|
this.$scope.watcher.submit().then(() => {
|
||||||
|
@ -126,7 +127,7 @@ export default class Controller {
|
||||||
this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => {
|
this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => {
|
||||||
this.observations = res.data;
|
this.observations = res.data;
|
||||||
res.data.forEach(item => {
|
res.data.forEach(item => {
|
||||||
this.observationsDictionary[item.observationTypeFk] = Object.assign({}, item);
|
this.observationsOld[item.id] = Object.assign({}, item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
Enabled: Activo
|
Enabled: Activo
|
||||||
Is equalizated: Recargo de equivalencia
|
Is equalizated: Recargo de equivalencia
|
||||||
|
Observation type: Tipo de observación
|
||||||
|
Description: Descripción
|
||||||
|
The observation type must be unique: El tipo de observación ha de ser único
|
|
@ -1,5 +1,4 @@
|
||||||
<mg-ajax path="/item/api/items/1/getLog"></mg-ajax>
|
<mg-ajax path="/item/api/Items/getLog" options="vnIndex"></mg-ajax>
|
||||||
<!-- <mg-ajax path="/item/api/history/{{edit.params.id}}/sumAmount" options="mgEdit"></mg-ajax> -->
|
|
||||||
<vn-card pad-medium>
|
<vn-card pad-medium>
|
||||||
<vn-vertical pad-medium>
|
<vn-vertical pad-medium>
|
||||||
<vn-title vn-one margin-large-bottom>Item history</vn-title>
|
<vn-title vn-one margin-large-bottom>Item history</vn-title>
|
||||||
|
@ -22,12 +21,10 @@
|
||||||
<vn-one pad-medium-h>{{::itemLog.description}}</vn-one>
|
<vn-one pad-medium-h>{{::itemLog.description}}</vn-one>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
|
|
||||||
<vn-horizontal vn-one class="list list-footer text-center">
|
<vn-horizontal vn-one class="list list-footer text-center">
|
||||||
<vn-one pad-medium-h></vn-one>
|
<vn-one pad-medium-h></vn-one>
|
||||||
<vn-two pad-medium-h></vn-two>
|
<vn-two pad-medium-h></vn-two>
|
||||||
<vn-one pad-medium-h></vn-one>
|
<vn-one pad-medium-h></vn-one>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
|
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
41
gulpfile.js
41
gulpfile.js
|
@ -1,16 +1,12 @@
|
||||||
require('require-yaml');
|
require('require-yaml');
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const gutil = require('gulp-util');
|
const gutil = require('gulp-util');
|
||||||
const wrap = require('gulp-wrap');
|
|
||||||
const concat = require('gulp-concat');
|
|
||||||
const merge = require('merge-stream');
|
|
||||||
const print = require('gulp-print');
|
const print = require('gulp-print');
|
||||||
const runSequence = require('run-sequence');
|
const runSequence = require('run-sequence');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const WebpackDevServer = require('webpack-dev-server');
|
const WebpackDevServer = require('webpack-dev-server');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
|
@ -81,9 +77,17 @@ gulp.task('e2e-run', () => {
|
||||||
|
|
||||||
gulp.task('clean', () => {
|
gulp.task('clean', () => {
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true});
|
const files = [
|
||||||
|
`${buildDir}/*`,
|
||||||
|
`!${buildDir}/templates`,
|
||||||
|
`!${buildDir}/images`,
|
||||||
|
`docker-compose.yml`
|
||||||
|
];
|
||||||
|
return del(files, {force: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('i', ['install']);
|
||||||
|
|
||||||
gulp.task('install', () => {
|
gulp.task('install', () => {
|
||||||
const install = require('gulp-install');
|
const install = require('gulp-install');
|
||||||
let jsonFile = [];
|
let jsonFile = [];
|
||||||
|
@ -101,9 +105,6 @@ gulp.task('install', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Gulp install alias
|
|
||||||
gulp.task('i', ['install']);
|
|
||||||
|
|
||||||
// Deployment
|
// Deployment
|
||||||
|
|
||||||
gulp.task('build', ['clean'], () => {
|
gulp.task('build', ['clean'], () => {
|
||||||
|
@ -111,9 +112,8 @@ gulp.task('build', ['clean'], () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('docker-compose', async () => {
|
gulp.task('docker-compose', async () => {
|
||||||
let compose = await fs.readFile('./docker-compose.tpl.yml', 'utf8');
|
|
||||||
|
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
let compose = await fs.readFile('./docker-compose.tpl.yml', 'utf8');
|
||||||
let composeYml = yaml.safeLoad(compose);
|
let composeYml = yaml.safeLoad(compose);
|
||||||
let services = await getServices();
|
let services = await getServices();
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ gulp.task('nginx-stop', ['nginx-conf'], async () => {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exec(command, err => {
|
exec(command, err => {
|
||||||
if (err) return reject(err);
|
if (err && err.code != 1) return reject(err);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -191,6 +191,9 @@ gulp.task('nginx-stop', ['nginx-conf'], async () => {
|
||||||
gulp.task('nginx-conf', async () => {
|
gulp.task('nginx-conf', async () => {
|
||||||
const mustache = require('mustache');
|
const mustache = require('mustache');
|
||||||
|
|
||||||
|
if (!await fs.exists(nginxTemp))
|
||||||
|
await fs.mkdir(nginxTemp);
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
services: await getServices(),
|
services: await getServices(),
|
||||||
defaultService: defaultService,
|
defaultService: defaultService,
|
||||||
|
@ -208,19 +211,16 @@ gulp.task('nginx-conf', async () => {
|
||||||
let template = await fs.readFile(confFile, 'utf8');
|
let template = await fs.readFile(confFile, 'utf8');
|
||||||
let nginxConf = mustache.render(template, params);
|
let nginxConf = mustache.render(template, params);
|
||||||
|
|
||||||
await fs.writeFile(`${nginxDir}/temp/nginx.conf`, nginxConf);
|
await fs.writeFile(`${nginxTemp}/nginx.conf`, nginxConf);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('nginx-clean', () => {
|
gulp.task('nginx-clean', () => {
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
return del([`${nginxDir}/temp/*`], {force: true});
|
return del([`${nginxTemp}/*`], {force: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
let services;
|
|
||||||
|
|
||||||
async function getServices() {
|
async function getServices() {
|
||||||
if (services) return services;
|
let services;
|
||||||
|
|
||||||
let startPort = defaultPort + 1;
|
let startPort = defaultPort + 1;
|
||||||
services = [];
|
services = [];
|
||||||
|
|
||||||
|
@ -286,11 +286,13 @@ gulp.task('webpack-dev-server', function() {
|
||||||
|
|
||||||
// Locale
|
// Locale
|
||||||
|
|
||||||
let localeFiles = `${srcDir}/**/locale/*.json`;
|
let localeFiles = `${srcDir}/**/locale/*.yml`;
|
||||||
|
|
||||||
gulp.task('locales', function() {
|
gulp.task('locales', function() {
|
||||||
const extend = require('gulp-extend');
|
const extend = require('gulp-extend');
|
||||||
const yaml = require('gulp-yaml');
|
const yaml = require('gulp-yaml');
|
||||||
|
const merge = require('merge-stream');
|
||||||
|
|
||||||
let streams = [];
|
let streams = [];
|
||||||
|
|
||||||
for (let mod in modules)
|
for (let mod in modules)
|
||||||
|
@ -310,6 +312,9 @@ gulp.task('locales', function() {
|
||||||
let routeFiles = `${srcDir}/**/routes.json`;
|
let routeFiles = `${srcDir}/**/routes.json`;
|
||||||
|
|
||||||
gulp.task('routes', function() {
|
gulp.task('routes', function() {
|
||||||
|
const concat = require('gulp-concat');
|
||||||
|
const wrap = require('gulp-wrap');
|
||||||
|
|
||||||
return gulp.src(routeFiles)
|
return gulp.src(routeFiles)
|
||||||
.pipe(concat('routes.js', {newLine: ','}))
|
.pipe(concat('routes.js', {newLine: ','}))
|
||||||
.pipe(wrap('var routes = [<%=contents%>\n];'))
|
.pipe(wrap('var routes = [<%=contents%>\n];'))
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
"angular": {
|
"angular": {
|
||||||
"version": "1.6.8",
|
"version": "1.6.8",
|
||||||
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz",
|
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz",
|
||||||
"integrity": "sha1-W+N4pYvpGlSJ54tZxFGM2f0nP/s="
|
"integrity": "sha512-9WErZIOw1Cu1V5Yxdvxz/6YpND8ntdP71fdPpufPFJvZodZXqCjQBYrHqEoMZreO5i84O3D/Jw/vepoFt68Azw=="
|
||||||
},
|
},
|
||||||
"angular-cookies": {
|
"angular-cookies": {
|
||||||
"version": "1.6.4",
|
"version": "1.6.4",
|
||||||
|
@ -1119,7 +1119,7 @@
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.5.1",
|
"version": "3.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||||
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=",
|
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
|
@ -9909,7 +9909,7 @@
|
||||||
"jasmine-spec-reporter": {
|
"jasmine-spec-reporter": {
|
||||||
"version": "4.2.1",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
|
||||||
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
|
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"colors": "1.1.2"
|
"colors": "1.1.2"
|
||||||
|
@ -10051,7 +10051,7 @@
|
||||||
"karma": {
|
"karma": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
|
||||||
"integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=",
|
"integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bluebird": "3.5.1",
|
"bluebird": "3.5.1",
|
||||||
|
@ -10103,7 +10103,7 @@
|
||||||
"karma-chrome-launcher": {
|
"karma-chrome-launcher": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
||||||
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
|
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs-access": "1.0.1",
|
"fs-access": "1.0.1",
|
||||||
|
@ -10113,7 +10113,7 @@
|
||||||
"karma-firefox-launcher": {
|
"karma-firefox-launcher": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
|
||||||
"integrity": "sha1-LEcDBFLwRTHrfRPU/HZpYwu5Mzk=",
|
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"karma-jasmine": {
|
"karma-jasmine": {
|
||||||
|
@ -10134,7 +10134,7 @@
|
||||||
"karma-webpack": {
|
"karma-webpack": {
|
||||||
"version": "2.0.9",
|
"version": "2.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz",
|
||||||
"integrity": "sha1-YciAkffdkQY1E0wDKyZqRlr/tX8=",
|
"integrity": "sha512-F1j3IG/XhiMzcunAXbWXH95uizjzr3WdTzmVWlta8xqxcCtAu9FByCb4sccIMxaVFAefpgnUW9KlCo0oLvIX6A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "0.9.2",
|
"async": "0.9.2",
|
||||||
|
@ -14654,7 +14654,7 @@
|
||||||
"useragent": {
|
"useragent": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
|
||||||
"integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=",
|
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "4.1.1",
|
"lru-cache": "4.1.1",
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
DROP PROCEDURE IF EXISTS mysql.truncateAll;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE mysql.truncateAll()
|
||||||
|
BEGIN
|
||||||
|
DECLARE vSchema VARCHAR(255);
|
||||||
|
DECLARE vTable VARCHAR(255);
|
||||||
|
DECLARE vDone BOOL;
|
||||||
|
|
||||||
|
DECLARE cTables CURSOR FOR
|
||||||
|
SELECT `TABLE_SCHEMA`, `TABLE_NAME`
|
||||||
|
FROM `information_schema`.`TABLES`
|
||||||
|
WHERE `TABLE_TYPE` = 'BASE TABLE'
|
||||||
|
AND `TABLE_ROWS` > 0
|
||||||
|
AND `TABLE_SCHEMA` NOT IN ('information_schema', 'mysql', 'performance_schema');
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = FALSE;
|
||||||
|
OPEN cTables;
|
||||||
|
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH cTables INTO vSchema, vTable;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET @stmt = CONCAT('TRUNCATE TABLE `', vSchema, '`.`', vTable, '`');
|
||||||
|
PREPARE stmt FROM @stmt;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
CLOSE cTables;
|
||||||
|
SET FOREIGN_KEY_CHECKS = TRUE;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -390,16 +390,16 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
||||||
|
|
||||||
INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `defaultAgencyFk`, `longitude`, `latitude`, `isEqualizated`)
|
INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `defaultAgencyFk`, `longitude`, `latitude`, `isEqualizated`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
|
(101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
|
||||||
(2, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0),
|
(102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0),
|
||||||
(3, 'Clark Kenn', 'The phone box', 'Silla', 46460, 1, NULL, NULL, 1, 1, 3, 2, NULL, NULL, 0),
|
(103, 'Clark Kenn', 'The phone box', 'Silla', 46460, 1, NULL, NULL, 1, 1, 3, 2, NULL, NULL, 0),
|
||||||
(4, 'Tony Stark', 'Stark tower', 'Silla', 46460, 1, NULL, NULL, 1, 1, 4, 2, NULL, NULL, 0),
|
(104, 'Tony Stark', 'Stark tower', 'Silla', 46460, 1, NULL, NULL, 1, 1, 4, 2, NULL, NULL, 0),
|
||||||
(5, 'Max Eisenhardt', 'The plastic cell', 'Silla', 46460, 1, NULL, NULL, 1, 1, 5, 2, NULL, NULL, 0),
|
(105, 'Max Eisenhardt', 'The plastic cell', 'Silla', 46460, 1, NULL, NULL, 1, 1, 5, 2, NULL, NULL, 0),
|
||||||
(6, 'David Charles Haller', 'Many places', 'Silla', 46460, 1, NULL, NULL, 1, 1, 6, 2, NULL, NULL, 0),
|
(106, 'David Charles Haller', 'Many places', 'Silla', 46460, 1, NULL, NULL, 1, 1, 6, 2, NULL, NULL, 0),
|
||||||
(7, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0),
|
(107, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0),
|
||||||
(8, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0),
|
(108, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0),
|
||||||
(9, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0),
|
(109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0),
|
||||||
(10,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0);
|
(1010,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0);
|
||||||
|
|
||||||
INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `created`)
|
INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
CREATE OR REPLACE
|
||||||
|
ALGORITHM = UNDEFINED
|
||||||
|
DEFINER = `root`@`%`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn`.`agencyMode` AS
|
||||||
|
SELECT
|
||||||
|
`a`.`Id_Agencia` AS `id`,
|
||||||
|
`a`.`Agencia` AS `name`,
|
||||||
|
`a`.`description` AS `description`,
|
||||||
|
`a`.`Vista` AS `deliveryMethodFk`,
|
||||||
|
`a`.`Vista` AS `__deliveryMethod`,
|
||||||
|
`a`.`Vista` AS `__view`,
|
||||||
|
`a`.`m3` AS `m3`,
|
||||||
|
`a`.`cod71` AS `cod71`,
|
||||||
|
`a`.`web` AS `web`,
|
||||||
|
`a`.`agency_id` AS `agencyFk`,
|
||||||
|
`a`.`agency_id` AS `__agency`,
|
||||||
|
`a`.`agency_service_id` AS `agencyServiceFk`,
|
||||||
|
`a`.`agency_service_id` AS `__agencyService`,
|
||||||
|
`a`.`inflacion` AS `inflation`,
|
||||||
|
`a`.`inflacion` AS `__inflacion`,
|
||||||
|
`a`.`is_volumetric` AS `isVolumetric`,
|
||||||
|
`a`.`send_mail` AS `reportMail`
|
||||||
|
FROM
|
||||||
|
`vn2008`.`Agencias` `a`
|
|
@ -0,0 +1,18 @@
|
||||||
|
CREATE OR REPLACE
|
||||||
|
ALGORITHM = UNDEFINED
|
||||||
|
DEFINER = `root`@`%`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn`.`agencyHour` AS
|
||||||
|
SELECT
|
||||||
|
`h`.`agency_hour_id` AS `id`,
|
||||||
|
`h`.`agency_id` AS `agencyFk`,
|
||||||
|
`h`.`agency_id` AS `__agency`,
|
||||||
|
`h`.`week_day` AS `weekDay`,
|
||||||
|
`h`.`warehouse_id` AS `warehouseFk`,
|
||||||
|
`h`.`warehouse_id` AS `__warehouse`,
|
||||||
|
`h`.`province_id` AS `provinceFk`,
|
||||||
|
`h`.`province_id` AS `__province`,
|
||||||
|
`h`.`subtract_day` AS `substractDay`,
|
||||||
|
`h`.`max_hour` AS `maxHour`
|
||||||
|
FROM
|
||||||
|
`vn2008`.`agency_hour` `h`
|
|
@ -0,0 +1,24 @@
|
||||||
|
CREATE OR REPLACE
|
||||||
|
ALGORITHM = UNDEFINED
|
||||||
|
DEFINER = `root`@`%`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn`.`address` AS
|
||||||
|
SELECT
|
||||||
|
`t`.`id_consigna` AS `id`,
|
||||||
|
`t`.`Id_cliente` AS `clientFk`,
|
||||||
|
`t`.`domicilio` AS `street`,
|
||||||
|
`t`.`poblacion` AS `city`,
|
||||||
|
`t`.`codPostal` AS `postalCode`,
|
||||||
|
`t`.`province_id` AS `provinceFk`,
|
||||||
|
`t`.`telefono` AS `phone`,
|
||||||
|
`t`.`movil` AS `mobile`,
|
||||||
|
`t`.`consignatario` AS `nickname`,
|
||||||
|
`t`.`predeterminada` AS `isDefaultAddress`,
|
||||||
|
`t`.`longitude` AS `longitude`,
|
||||||
|
`t`.`latitude` AS `latitude`,
|
||||||
|
`t`.`warehouse_id` AS `warehouseFk`,
|
||||||
|
`t`.`Id_Agencia` AS `agencyFk`,
|
||||||
|
`t`.`isEqualizated` AS `isEqualizated`,
|
||||||
|
`t`.`active` AS `isActive`
|
||||||
|
FROM
|
||||||
|
`vn2008`.`Consignatarios` `t`
|
|
@ -0,0 +1,36 @@
|
||||||
|
USE `account`;
|
||||||
|
CREATE
|
||||||
|
OR REPLACE ALGORITHM = UNDEFINED
|
||||||
|
DEFINER = `root`@`%`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `account`.`__userRole` AS
|
||||||
|
SELECT
|
||||||
|
`r`.`inheritsFrom` AS `id`
|
||||||
|
FROM
|
||||||
|
(`account`.`roleRole` `r`
|
||||||
|
JOIN `account`.`user` `u` ON ((`u`.`role` = `r`.`role`)))
|
||||||
|
WHERE
|
||||||
|
(`u`.`id` = USERGETID());
|
||||||
|
|
||||||
|
DROP VIEW `account`.`userRole`;
|
||||||
|
|
||||||
|
CREATE TABLE `account`.`userRole` (
|
||||||
|
`userFk` INT(10) UNSIGNED NOT NULL,
|
||||||
|
`roleFk` INT(10) UNSIGNED NOT NULL,
|
||||||
|
PRIMARY KEY (`userFk`, `roleFk`));
|
||||||
|
|
||||||
|
ALTER TABLE `account`.`userRole`
|
||||||
|
ADD INDEX `user` (`userFk` ASC),
|
||||||
|
ADD INDEX `role` (`roleFk` ASC);
|
||||||
|
|
||||||
|
ALTER TABLE `account`.`userRole`
|
||||||
|
ADD CONSTRAINT `user`
|
||||||
|
FOREIGN KEY (`userFk`)
|
||||||
|
REFERENCES `account`.`user` (`id`)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE,
|
||||||
|
ADD CONSTRAINT `role`
|
||||||
|
FOREIGN KEY (`roleFk`)
|
||||||
|
REFERENCES `account`.`role` (`id`)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE;
|
|
@ -0,0 +1,31 @@
|
||||||
|
DROP function IF EXISTS `userHasRoleId`;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` FUNCTION `account`.`userHasRoleId`(vRoleId INT) RETURNS tinyint(1)
|
||||||
|
DETERMINISTIC
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba si el usuario actual tiene asociado un rol.
|
||||||
|
*
|
||||||
|
* @param vRoleId Identificador del rol a comprobar
|
||||||
|
* @return %TRUE si tiene el rol, %FALSE en caso contrario
|
||||||
|
*/
|
||||||
|
DECLARE vHasRole BOOL DEFAULT FALSE;
|
||||||
|
|
||||||
|
SELECT COUNT(*) > 0 INTO vHasRole
|
||||||
|
FROM user u
|
||||||
|
JOIN roleRole r ON r.role = u.role
|
||||||
|
WHERE u.id = userGetId()
|
||||||
|
AND r.inheritsFrom = vRoleId;
|
||||||
|
|
||||||
|
IF NOT vHasRole
|
||||||
|
THEN
|
||||||
|
SELECT COUNT(*) > 0 INTO vHasRole
|
||||||
|
FROM userRole
|
||||||
|
WHERE userFk = userGetId()
|
||||||
|
AND roleFk = vRoleId;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN vHasRole;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
|
@ -1,27 +1,13 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('itemLog', {
|
Self.installMethod('getLog', filterParams);
|
||||||
description: 'Returns the item changes log',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'id',
|
|
||||||
type: 'number',
|
|
||||||
required: true,
|
|
||||||
description: 'The item id',
|
|
||||||
http: {source: 'path'}
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
arg: 'data',
|
|
||||||
type: ['Object'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/:id/itemLog`,
|
|
||||||
verb: 'get'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.itemLog = itemFk => {
|
function filterParams(params) {
|
||||||
let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`;
|
return {
|
||||||
return Self.rawSql(query, [itemFk]);
|
where: {
|
||||||
};
|
itemFk: params.itemFk
|
||||||
|
},
|
||||||
|
skip: (params.page - 1) * params.size,
|
||||||
|
limit: params.size
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = function(Self) {
|
||||||
|
require('../methods/item/getLog.js')(Self);
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"name": "ItemLog",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "itemLog",
|
||||||
|
"database": "vn"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "Number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"creationDate": {
|
||||||
|
"type": "Date"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"originFk": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Origin",
|
||||||
|
"foreignKey": "originFk"
|
||||||
|
},
|
||||||
|
"userFk": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "User",
|
||||||
|
"foreignKey": "userFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,5 +34,8 @@
|
||||||
},
|
},
|
||||||
"Tag": {
|
"Tag": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"ItemLog": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,3 @@ jasmine.addReporter(new SpecReporter({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jasmine.execute();
|
jasmine.execute();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue