This commit is contained in:
parent
ec4b76a0f8
commit
f6bfec1377
|
@ -29,7 +29,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<span ng-class="{'link': log.user.worker.id, 'value': !log.user.worker.id}"
|
<span ng-class="{'link': log.user.worker.id, 'value': !log.user.worker.id}"
|
||||||
ng-click="$ctrl.showWorkerDescriptor($event, log.user.worker.id)"
|
ng-click="$ctrl.showDescriptor('Worker', $event, log.user.worker.id)"
|
||||||
translate>{{::log.user.name || 'System' | translate}}
|
translate>{{::log.user.name || 'System' | translate}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="prop in ::log.props">
|
<tr ng-repeat="prop in ::log.props">
|
||||||
<td class="field">{{prop.name}}</td>
|
<td class="field">{{prop.name}}</td>
|
||||||
<td class="before">{{prop.old}}</td>
|
<td class="before"><span ng-class="{'link': prop.descriptor}" ng-click="$ctrl.showDescriptor(prop.descriptor, $event, prop.old)">{{prop.old}}</span></td>
|
||||||
<td class="after">{{prop.new}}</td>
|
<td class="after"><span ng-class="{'link': prop.descriptor}" ng-click="$ctrl.showDescriptor(prop.descriptor, $event, prop.new)">{{prop.new}}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -69,5 +69,11 @@
|
||||||
<vn-pagination model="model"></vn-pagination>
|
<vn-pagination model="model"></vn-pagination>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<vn-worker-descriptor-popover vn-id="workerDescriptor">
|
|
||||||
|
<!-- DESCRIPTORS -->
|
||||||
|
<vn-worker-descriptor-popover vn-id="Worker">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
<vn-item-descriptor-popover vn-id="Item">
|
||||||
|
</vn-item-descriptor-popover>
|
||||||
|
<vn-ticket-descriptor-popover vn-id="Ticket">
|
||||||
|
</vn-ticket-descriptor-popover>
|
||||||
|
|
|
@ -7,6 +7,7 @@ const validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
this.descriptors = new Map();
|
||||||
this.actionsText = {
|
this.actionsText = {
|
||||||
insert: 'Creates',
|
insert: 'Creates',
|
||||||
update: 'Updates',
|
update: 'Updates',
|
||||||
|
@ -39,24 +40,37 @@ export default class Controller extends Section {
|
||||||
const empty = {};
|
const empty = {};
|
||||||
const validations = window.validations;
|
const validations = window.validations;
|
||||||
for (const log of value) {
|
for (const log of value) {
|
||||||
|
if(log.changedModel && !this.descriptors.get(log.changedModel))
|
||||||
|
this.fillDescriptorsMap(log.changedModel);
|
||||||
|
|
||||||
const oldValues = log.oldInstance || empty;
|
const oldValues = log.oldInstance || empty;
|
||||||
const newValues = log.newInstance || empty;
|
const newValues = log.newInstance || empty;
|
||||||
const locale = validations[log.changedModel]?.locale || empty;
|
const locale = validations[log.changedModel]?.locale || empty;
|
||||||
|
|
||||||
let props = Object.keys(oldValues).concat(Object.keys(newValues));
|
let props = Object.keys(oldValues).concat(Object.keys(newValues));
|
||||||
props = [...new Set(props)];
|
props = [...new Set(props)];
|
||||||
|
|
||||||
log.props = [];
|
log.props = [];
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
|
const descriptor = this.descriptors.get(log.changedModel).get(prop);
|
||||||
log.props.push({
|
log.props.push({
|
||||||
name: locale[prop] || prop,
|
name: locale[prop] || prop,
|
||||||
old: this.formatValue(oldValues[prop]),
|
old: this.formatValue(oldValues[prop]),
|
||||||
new: this.formatValue(newValues[prop])
|
new: this.formatValue(newValues[prop]),
|
||||||
|
descriptor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fillDescriptorsMap(changedModel) {
|
||||||
|
const relations = new Map();
|
||||||
|
Object.values(window.validations[changedModel].relations).forEach(relation => {
|
||||||
|
if(relation.type == "belongsTo")
|
||||||
|
relations.set(relation.keyFrom, relation.modelTo);
|
||||||
|
});
|
||||||
|
this.descriptors.set(changedModel, relations);
|
||||||
|
}
|
||||||
|
|
||||||
get showModelName() {
|
get showModelName() {
|
||||||
return !(this.changedModel && this.changedModelId);
|
return !(this.changedModel && this.changedModelId);
|
||||||
}
|
}
|
||||||
|
@ -88,9 +102,9 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showWorkerDescriptor(event, workerId) {
|
showDescriptor(descriptor, event, id) {
|
||||||
if (!workerId) return;
|
if (!descriptor || !this.$[descriptor]) return;
|
||||||
this.$.workerDescriptor.show(event.target, workerId);
|
this.$[descriptor].show(event.target, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
json[modelName] = {
|
json[modelName] = {
|
||||||
properties: model.definition.rawProperties,
|
properties: model.definition.rawProperties,
|
||||||
|
relations: model.relations,
|
||||||
validations: jsonValidations,
|
validations: jsonValidations,
|
||||||
locale
|
locale
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue