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