Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2689-add_id_in_typeTransaction_client_and_supplier
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Padawan 2020-12-30 10:49:58 +01:00
commit f2742b88a2
12 changed files with 123 additions and 11 deletions

View File

@ -0,0 +1,18 @@
CREATE TABLE `vn`.`zoneLog` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`originFk` int(10) NOT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8 DEFAULT NULL,
`changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`oldInstance` text COLLATE utf8_unicode_ci DEFAULT NULL,
`newInstance` text COLLATE utf8_unicode_ci DEFAULT NULL,
`changedModelId` int(11) DEFAULT NULL,
`changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `originFk` (`originFk`),
KEY `userFk` (`userFk`),
CONSTRAINT `zoneLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `zoneLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

View File

@ -145,9 +145,15 @@ module.exports = function(Self) {
rewriteDbError(replaceErrFunc) {
function replaceErr(err, replaceErrFunc) {
if (Array.isArray(err)) {
const errors = err.filter(error => {
return error != undefined && error != null;
});
let errs = [];
for (let e of err)
errs.push(replaceErrFunc(e));
for (let e of errors) {
if (!(e instanceof UserError))
errs.push(replaceErrFunc(e));
else errs.push(e);
}
return errs;
}
return replaceErrFunc(err);

View File

@ -31,5 +31,8 @@
},
"ZoneEstimatedDelivery": {
"dataSource": "vn"
},
"ZoneLog": {
"dataSource": "vn"
}
}

View File

@ -1,6 +1,10 @@
{
"name": "ZoneEvent",
"base": "VnModel",
"base": "Loggable",
"log": {
"model":"ZoneLog",
"relation": "zone"
},
"options": {
"mysql": {
"table": "zoneEvent"

View File

@ -1,6 +1,11 @@
{
"name": "ZoneIncluded",
"base": "VnModel",
"base": "Loggable",
"log": {
"model": "ZoneLog",
"relation": "zone",
"showField": "isIncluded"
},
"options": {
"mysql": {
"table": "zoneIncluded"

View File

@ -0,0 +1,58 @@
{
"name": "ZoneLog",
"base": "VnModel",
"options": {
"mysql": {
"table": "zoneLog"
}
},
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"originFk": {
"type": "Number",
"required": true
},
"userFk": {
"type": "Number"
},
"action": {
"type": "String",
"required": true
},
"changedModel": {
"type": "String"
},
"oldInstance": {
"type": "Object"
},
"newInstance": {
"type": "Object"
},
"creationDate": {
"type": "Date"
},
"changedModelId": {
"type": "String"
},
"changedModelValue": {
"type": "String"
},
"description": {
"type": "String"
}
},
"relations": {
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
}
},
"scope": {
"order": ["creationDate DESC", "id DESC"]
}
}

View File

@ -1,6 +1,10 @@
{
"name": "ZoneWarehouse",
"base": "VnModel",
"base": "Loggable",
"log": {
"model":"ZoneLog",
"relation": "zone"
},
"options": {
"mysql": {
"table": "zoneWarehouse"

View File

@ -1,6 +1,10 @@
{
"name": "Zone",
"base": "VnModel",
"base": "Loggable",
"log": {
"model":"ZoneLog",
"showField": "name"
},
"options": {
"mysql": {
"table": "zone"
@ -39,11 +43,6 @@
}
},
"relations": {
"geolocations": {
"type": "hasMany",
"model": "ZoneGeo",
"foreignKey": "zoneFk"
},
"agencyMode": {
"type": "belongsTo",
"model": "AgencyMode",

View File

@ -16,3 +16,4 @@ import './calendar';
import './location';
import './calendar';
import './upcoming-deliveries';
import './log';

View File

@ -0,0 +1 @@
<vn-log url="ZoneLogs" origin-id="$ctrl.$params.id"></vn-log>

View File

@ -0,0 +1,7 @@
import ngModule from '../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnZoneLog', {
template: require('./index.html'),
controller: Section,
});

View File

@ -14,6 +14,7 @@
{"state": "zone.card.basicData", "icon": "settings"},
{"state": "zone.card.location", "icon": "my_location"},
{"state": "zone.card.warehouses", "icon": "home"},
{"state": "zone.card.log", "icon": "history"},
{"state": "zone.card.events", "icon": "today"}
]
},
@ -84,6 +85,11 @@
"params": {
"zone": "$ctrl.zone"
}
}, {
"url" : "/log",
"state": "zone.card.log",
"component": "vn-zone-log",
"description": "Log"
}
]
}