#1775 travel.log crear sección historial

This commit is contained in:
Bernat 2019-10-25 13:28:12 +02:00
parent 5547193a31
commit 9fd0ab0bd3
7 changed files with 100 additions and 5 deletions

View File

@ -0,0 +1,18 @@
CREATE TABLE `vn`.`travelLog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`originFk` int(10) unsigned 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,
`changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`oldInstance` text COLLATE utf8_unicode_ci,
`newInstance` text COLLATE utf8_unicode_ci,
`changedModelId` int(11) DEFAULT NULL,
`changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `originFk` (`originFk`),
KEY `userFk` (`userFk`),
CONSTRAINT `travelLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelLog_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

@ -3,5 +3,7 @@
"dataSource": "vn"
},"Entry": {
"dataSource": "vn"
},"TravelLog": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,58 @@
{
"name": "TravelLog",
"base": "VnModel",
"options": {
"mysql": {
"table": "travelLog"
}
},
"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": "Number"
},
"changedModelValue": {
"type": "String"
},
"description": {
"type": "String"
}
},
"relations": {
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
}
},
"scope": {
"order": ["creationDate DESC", "id DESC"]
}
}

View File

@ -10,4 +10,5 @@ Travel id: Id envío
Search travels by id: Buscar envios por identificador
# Sections
Travels: Envíos
Travels: Envíos
Log: Historial

View File

@ -0,0 +1 @@
<vn-log url="api/TravelLogs" origin-id="$ctrl.$stateParams.id"></vn-log>

View File

@ -0,0 +1,15 @@
import ngModule from '../module';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTravelLog', {
template: require('./index.html'),
controller: Controller,
});

View File

@ -19,8 +19,8 @@
<vn-th field="changedModel" class="expendable">Model</vn-th>
<vn-th field="action" class="expendable">Action</vn-th>
<vn-th field="changedModelValue" class="expendable">Name</vn-th>
<vn-th>Before</vn-th>
<vn-th>After</vn-th>
<vn-th expand>Before</vn-th>
<vn-th expand>After</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
@ -66,7 +66,7 @@
<vn-td class="expendable">
{{::log.changedModelValue}}
</vn-td>
<vn-td class="before">
<vn-td expand class="before">
<vn-one ng-repeat="old in log.oldProperties">
<div>
<span translate class="label">{{::old.key}}</span><span class="label">: </span>
@ -74,7 +74,7 @@
</div>
</vn-one>
</vn-td>
<vn-td class="after">
<vn-td expand class="after">
<vn-one
ng-repeat="new in log.newProperties"
ng-if="!log.description"