50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
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) {
|
|
const properties = [];
|
|
if (typeof instance == 'object' && instance != null) {
|
|
Object.keys(instance).forEach(property => {
|
|
properties.push({key: property, value: instance[property]});
|
|
});
|
|
return properties;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope', '$stateParams'];
|
|
|
|
ngModule.component('vnTicketLog', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
});
|