This commit is contained in:
parent
df48041444
commit
fb75ff0eae
|
@ -0,0 +1,4 @@
|
|||
USE `vn`;
|
||||
|
||||
ALTER TABLE vn.itemLog MODIFY COLUMN userFk int(10) unsigned NULL;
|
||||
ALTER TABLE vn.itemLog MODIFY COLUMN id int(11) NOT NULL AUTO_INCREMENT;
|
|
@ -4,7 +4,12 @@ describe('item new()', () => {
|
|||
let item;
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.Item.destroyById(item.id);
|
||||
let sql = 'DELETE FROM vn.itemLog WHERE originFk = ?';
|
||||
await app.models.Item.rawSql(sql, [item.id]);
|
||||
|
||||
sql = 'DELETE FROM vn.item WHERE id = ?';
|
||||
await app.models.Item.rawSql(sql, [item.id]);
|
||||
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = Self => {
|
|||
if (!tax.taxClassFk)
|
||||
throw new UserError('Tax class cannot be blank');
|
||||
|
||||
promises.push(Self.app.models.ItemTaxCountry.updateAll(
|
||||
promises.push(Self.app.models.ItemTaxCountry.update(
|
||||
{id: tax.id},
|
||||
{taxClassFk: tax.taxClassFk}
|
||||
));
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{
|
||||
"name": "ItemBarcode",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ItemLog",
|
||||
"relation": "item",
|
||||
"changedModelValue": "code"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemBarcode"
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{
|
||||
"name": "ItemBotanical",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ItemLog",
|
||||
"relation": "item",
|
||||
"changedModelValue": "botanical"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemBotanical"
|
||||
|
|
|
@ -8,38 +8,48 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
"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"
|
||||
},
|
||||
"description": {
|
||||
"changedModelId": {
|
||||
"type": "Number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "String"
|
||||
},
|
||||
"action": {
|
||||
"description": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"item": {
|
||||
"type": "belongsTo",
|
||||
"model": "Item",
|
||||
"foreignKey": "originFk"
|
||||
},
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{
|
||||
"name": "ItemNiche",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ItemLog",
|
||||
"relation": "item",
|
||||
"changedModelValue": "code"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemPlacement"
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{
|
||||
"name": "ItemTag",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ItemLog",
|
||||
"relation": "item",
|
||||
"changedModelValue": "value"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemTag"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "Item",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"ItemLog"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "item"
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/item/api/ItemLogs"
|
||||
filter="::$ctrl.filter"
|
||||
link="{originFk: $ctrl.$stateParams.id}"
|
||||
limit="20"
|
||||
data="logs" auto-load="false">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="description">Description</vn-th>
|
||||
<vn-th field="action">Action</vn-th>
|
||||
<vn-th field="userFk">Changed by</vn-th>
|
||||
<vn-th field="creationDate" default-order="DESC">Date</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="itemLog in logs">
|
||||
<vn-td>{{::itemLog.description}}</vn-td>
|
||||
<vn-td>{{::itemLog.action}}</vn-td>
|
||||
<vn-td>{{::itemLog.user.name}}</vn-td>
|
||||
<vn-td>{{::itemLog.creationDate | dateTime:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-vertical>
|
||||
<vn-pagination model="model"></vn-pagination>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
|
@ -1,25 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams) {
|
||||
this.$stateParams = $stateParams;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: "item"
|
||||
},
|
||||
{
|
||||
relation: "user",
|
||||
scope: {
|
||||
fields: ["name"]
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$stateParams'];
|
||||
|
||||
ngModule.component('vnItemHistory', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -11,7 +11,7 @@ import './data';
|
|||
import './fetched-tags';
|
||||
import './tags';
|
||||
import './tax';
|
||||
// import './history';
|
||||
import './log';
|
||||
import './last-entries';
|
||||
import './niche';
|
||||
import './botanical';
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/api/ItemLogs"
|
||||
link="{originFk: $ctrl.$stateParams.id}"
|
||||
filter="$ctrl.filter"
|
||||
limit="20"
|
||||
data="$ctrl.logs" auto-load="false">
|
||||
</vn-crud-model>
|
||||
<vn-log model="model"></vn-log>
|
|
@ -0,0 +1,53 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $stateParams) {
|
||||
this.$scope = $scope;
|
||||
this.$stateParams = $stateParams;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
get logs() {
|
||||
return this._logs;
|
||||
}
|
||||
|
||||
set logs(value) {
|
||||
this._logs = value;
|
||||
|
||||
if (this.logs) {
|
||||
this.logs.forEach(log => {
|
||||
log.oldProperties = this.getInstance(log.oldInstance);
|
||||
log.newProperties = this.getInstance(log.newInstance);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getInstance(instance) {
|
||||
let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
|
||||
const properties = [];
|
||||
if (typeof instance == 'object' && instance != null) {
|
||||
Object.keys(instance).forEach(property => {
|
||||
if (validDate.test(instance[property]))
|
||||
instance[property] = new Date(instance[property]).toLocaleString('es-ES');
|
||||
|
||||
properties.push({key: property, value: instance[property]});
|
||||
});
|
||||
return properties;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$stateParams'];
|
||||
|
||||
ngModule.component('vnItemLog', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
});
|
|
@ -12,7 +12,8 @@
|
|||
{"state": "item.card.botanical", "icon": "local_florist"},
|
||||
{"state": "item.card.itemBarcode", "icon": "icon-barcode"},
|
||||
{"state": "item.card.diary", "icon": "icon-transaction"},
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"}
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"},
|
||||
{"state": "item.card.log", "icon": "history"}
|
||||
],
|
||||
"keybindings": [
|
||||
{"key": "a", "state": "item.index"}
|
||||
|
@ -116,6 +117,11 @@
|
|||
"item": "$ctrl.item"
|
||||
},
|
||||
"acl": ["employee"]
|
||||
}, {
|
||||
"url" : "/log",
|
||||
"state": "item.card.log",
|
||||
"component": "vn-item-log",
|
||||
"description": "Log"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue