Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into test
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
commit
a15f6e2573
|
@ -51,7 +51,12 @@
|
||||||
"type": "hasOne",
|
"type": "hasOne",
|
||||||
"model": "EmailUser",
|
"model": "EmailUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
},
|
||||||
|
"worker": {
|
||||||
|
"type": "hasOne",
|
||||||
|
"model": "Worker",
|
||||||
|
"foreignKey": "userFk"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1 @@
|
||||||
<vn-crud-model
|
<vn-log url="/api/ClientLogs" origin-id="$ctrl.$stateParams.id"></vn-log>
|
||||||
vn-id="model"
|
|
||||||
url="/client/api/ClientLogs"
|
|
||||||
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>
|
|
|
@ -4,44 +4,6 @@ class Controller {
|
||||||
constructor($scope, $stateParams) {
|
constructor($scope, $stateParams) {
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$stateParams = $stateParams;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Client', () => {
|
|
||||||
describe('Component vnClientLog', () => {
|
|
||||||
let $componentController;
|
|
||||||
let $scope;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('client'));
|
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
||||||
$componentController = _$componentController_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
controller = $componentController('vnClientLog', {$scope: $scope});
|
|
||||||
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('logs setter', () => {
|
|
||||||
it('should call the function getInstance() twice', () => {
|
|
||||||
spyOn(controller, 'getInstance');
|
|
||||||
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
|
||||||
|
|
||||||
expect(controller.getInstance.calls.count()).toBe(2);
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 2});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getInstance(instance)', () => {
|
|
||||||
it('should transform the object given in to an array', () => {
|
|
||||||
let newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance);
|
|
||||||
|
|
||||||
expect(newInstance).toEqual([{key: 'id', value: 1}]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,9 +1 @@
|
||||||
<vn-crud-model
|
<vn-log url="/api/ItemLogs" origin-id="$ctrl.$stateParams.id"></vn-log>
|
||||||
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>
|
|
|
@ -4,44 +4,6 @@ class Controller {
|
||||||
constructor($scope, $stateParams) {
|
constructor($scope, $stateParams) {
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$stateParams = $stateParams;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1 @@
|
||||||
<vn-crud-model
|
<vn-log url="/api/RouteLogs" origin-id="$ctrl.$stateParams.id"></vn-log>
|
||||||
vn-id="model"
|
|
||||||
url="/api/RouteLogs"
|
|
||||||
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>
|
|
|
@ -4,44 +4,6 @@ class Controller {
|
||||||
constructor($scope, $stateParams) {
|
constructor($scope, $stateParams) {
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$stateParams = $stateParams;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Route', () => {
|
|
||||||
describe('Component vnRouteLog', () => {
|
|
||||||
let $componentController;
|
|
||||||
let $scope;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('route'));
|
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
||||||
$componentController = _$componentController_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
controller = $componentController('vnRouteLog', {$scope: $scope});
|
|
||||||
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('logs setter', () => {
|
|
||||||
it('should call the function getInstance() twice', () => {
|
|
||||||
spyOn(controller, 'getInstance');
|
|
||||||
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
|
||||||
|
|
||||||
expect(controller.getInstance.calls.count()).toBe(2);
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 2});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getInstance(instance)', () => {
|
|
||||||
it('should transform the object given in to an array', () => {
|
|
||||||
let newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance);
|
|
||||||
|
|
||||||
expect(newInstance).toEqual([{key: 'id', value: 1}]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,9 +1 @@
|
||||||
<vn-crud-model auto-load="false"
|
<vn-log url="/api/TicketLogs" origin-id="$ctrl.$stateParams.id"></vn-log>
|
||||||
vn-id="model"
|
|
||||||
url="/ticket/api/TicketLogs"
|
|
||||||
link="{originFk: $ctrl.$stateParams.id}"
|
|
||||||
filter="$ctrl.filter"
|
|
||||||
limit="20"
|
|
||||||
data="$ctrl.logs">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-log model="model"></vn-log>
|
|
|
@ -4,45 +4,6 @@ class Controller {
|
||||||
constructor($scope, $stateParams) {
|
constructor($scope, $stateParams) {
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$stateParams = $stateParams;
|
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) {
|
|
||||||
const properties = [];
|
|
||||||
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)?$/;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Ticket', () => {
|
|
||||||
describe('Component vnTicketLog', () => {
|
|
||||||
let $componentController;
|
|
||||||
let $scope;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('ticket'));
|
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
||||||
$componentController = _$componentController_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
controller = $componentController('vnTicketLog', {$scope: $scope});
|
|
||||||
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('logs setter', () => {
|
|
||||||
it('should call the function getInstance() twice', () => {
|
|
||||||
spyOn(controller, 'getInstance');
|
|
||||||
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
|
||||||
|
|
||||||
expect(controller.getInstance.calls.count()).toBe(2);
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
|
||||||
expect(controller.getInstance).toHaveBeenCalledWith({id: 2});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getInstance(instance)', () => {
|
|
||||||
it('should transform the object given in to an array', () => {
|
|
||||||
const newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance);
|
|
||||||
|
|
||||||
expect(newInstance).toEqual([{key: 'id', value: 1}]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,8 +1,17 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="{{$ctrl.url}}"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
link="{originFk: $ctrl.originId}"
|
||||||
|
data="$ctrl.logs"
|
||||||
|
limit="20"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-title>History</vn-title>
|
<vn-title>History</vn-title>
|
||||||
<vn-table model="$ctrl.model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="creationDate">Date</vn-th>
|
<vn-th field="creationDate">Date</vn-th>
|
||||||
|
@ -15,7 +24,7 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="log in $ctrl.model.data">
|
<vn-tr ng-repeat="log in $ctrl.logs">
|
||||||
<vn-td>
|
<vn-td>
|
||||||
{{::log.creationDate | dateTime:'dd/MM/yyyy HH:mm'}}
|
{{::log.creationDate | dateTime:'dd/MM/yyyy HH:mm'}}
|
||||||
<div class="changes">
|
<div class="changes">
|
||||||
|
@ -23,7 +32,7 @@
|
||||||
<span translate class="label">Changed by</span><span class="label">: </span>
|
<span translate class="label">Changed by</span><span class="label">: </span>
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="$ctrl.showWorkerDescriptor($event, log.user.id)"
|
ng-click="$ctrl.showWorkerDescriptor($event, log.user.worker.id)"
|
||||||
translate
|
translate
|
||||||
class="value">{{::log.user.name | dashIfEmpty}}
|
class="value">{{::log.user.name | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -45,7 +54,7 @@
|
||||||
<vn-td class="expendable">
|
<vn-td class="expendable">
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="$ctrl.showWorkerDescriptor($event, log.user.id)"
|
ng-click="$ctrl.showWorkerDescriptor($event, log.user.worker.id)"
|
||||||
translate
|
translate
|
||||||
class="value">{{::log.user.name | dashIfEmpty}}
|
class="value">{{::log.user.name | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -89,7 +98,7 @@
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
<vn-pagination model="$ctrl.model"></vn-pagination>
|
<vn-pagination model="model"></vn-pagination>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
|
|
|
@ -10,6 +10,35 @@ export default class Controller {
|
||||||
'delete': 'Deletes',
|
'delete': 'Deletes',
|
||||||
'select': 'Views'
|
'select': 'Views'
|
||||||
};
|
};
|
||||||
|
this.filter = {
|
||||||
|
include: [{
|
||||||
|
relation: 'user',
|
||||||
|
scope: {
|
||||||
|
fields: ['name'],
|
||||||
|
include: {
|
||||||
|
relation: 'worker',
|
||||||
|
scope: {
|
||||||
|
fields: ['id']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showWorkerDescriptor(event, workerFk) {
|
showWorkerDescriptor(event, workerFk) {
|
||||||
|
@ -22,6 +51,22 @@ export default class Controller {
|
||||||
this.$.workerDescriptor.parent = event.target;
|
this.$.workerDescriptor.parent = event.target;
|
||||||
this.$.workerDescriptor.show();
|
this.$.workerDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getInstance(instance) {
|
||||||
|
const properties = [];
|
||||||
|
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)?$/;
|
||||||
|
|
||||||
|
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'];
|
Controller.$inject = ['$scope'];
|
||||||
|
@ -30,6 +75,8 @@ ngModule.component('vnLog', {
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
bindings: {
|
bindings: {
|
||||||
model: '<'
|
model: '<',
|
||||||
|
originId: '<',
|
||||||
|
url: '@'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue