Merge pull request 'master' (!1592) from master into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1592
This commit is contained in:
commit
47fe77efde
|
@ -75,16 +75,16 @@
|
|||
<span class="json-field" title="{{::prop.name}}">
|
||||
{{::prop.nameI18n}}:
|
||||
</span>
|
||||
<vn-json-value value="::$ctrl.mainVal(prop, log.action)"></vn-json-value><span ng-if="::!$last">,</span>
|
||||
<vn-json-value value="::prop.val.val"></vn-json-value><span ng-if="::!$last">,</span>
|
||||
</span>
|
||||
<div ng-if="log.expand" class="expanded-json">
|
||||
<div ng-repeat="prop in ::log.props">
|
||||
<span class="json-field" title="{{::prop.name}}">
|
||||
{{::prop.nameI18n}}:
|
||||
</span>
|
||||
<vn-json-value value="::$ctrl.mainVal(prop, log.action)"></vn-json-value>
|
||||
<vn-log-value val="::prop.val"></vn-log-value>
|
||||
<span ng-if="::log.action == 'update'">
|
||||
← <vn-json-value value="::prop.old"></vn-json-value>
|
||||
← <vn-log-value val="::prop.old"></vn-log-value>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -64,29 +64,47 @@ export default class Controller extends Section {
|
|||
set logs(value) {
|
||||
this._logs = value;
|
||||
if (!value) return;
|
||||
|
||||
const empty = {};
|
||||
const validations = window.validations;
|
||||
const castJsonValue = this.castJsonValue;
|
||||
|
||||
for (const log of value) {
|
||||
const oldValues = log.oldInstance || empty;
|
||||
const newValues = log.newInstance || empty;
|
||||
const notDelete = log.action != 'delete';
|
||||
const olds = (notDelete ? log.oldInstance : null) || empty;
|
||||
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
|
||||
const locale = validations[log.changedModel]?.locale || empty;
|
||||
log.changedModelI18n = firstUpper(locale.name) || log.changedModel;
|
||||
|
||||
let props = Object.keys(oldValues).concat(Object.keys(newValues));
|
||||
let props = Object.keys(olds).concat(Object.keys(vals));
|
||||
props = [...new Set(props)];
|
||||
|
||||
log.props = [];
|
||||
for (const prop of props) {
|
||||
if (prop.endsWith('$')) continue;
|
||||
log.props.push({
|
||||
name: prop,
|
||||
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
||||
old: this.castJsonValue(oldValues[prop]),
|
||||
new: this.castJsonValue(newValues[prop])
|
||||
old: getVal(olds, prop),
|
||||
val: getVal(vals, prop)
|
||||
});
|
||||
}
|
||||
log.props.sort(
|
||||
(a, b) => a.nameI18n.localeCompare(b.nameI18n));
|
||||
}
|
||||
|
||||
function getVal(vals, prop) {
|
||||
let val, id;
|
||||
const showProp = `${prop}$`;
|
||||
|
||||
if (vals[showProp] != null) {
|
||||
val = vals[showProp];
|
||||
id = vals[prop];
|
||||
} else
|
||||
val = vals[prop];
|
||||
|
||||
return {val: castJsonValue(val), id};
|
||||
}
|
||||
}
|
||||
|
||||
get models() {
|
||||
|
@ -113,10 +131,6 @@ export default class Controller extends Section {
|
|||
: value;
|
||||
}
|
||||
|
||||
mainVal(prop, action) {
|
||||
return action == 'delete' ? prop.old : prop.new;
|
||||
}
|
||||
|
||||
relativeDate(dateVal) {
|
||||
if (dateVal == null) return '';
|
||||
const date = new Date(dateVal);
|
||||
|
@ -238,3 +252,12 @@ ngModule.vnComponent('vnLog', {
|
|||
url: '@'
|
||||
}
|
||||
});
|
||||
|
||||
ngModule.component('vnLogValue', {
|
||||
template:
|
||||
'<vn-json-value value="::$ctrl.val.val"></vn-json-value>' +
|
||||
'<span ng-if="::$ctrl.val.id" class="id-value"> #{{::$ctrl.val.id}}</span>',
|
||||
bindings: {
|
||||
val: '<?',
|
||||
}
|
||||
});
|
||||
|
|
|
@ -144,3 +144,7 @@ vn-log {
|
|||
}
|
||||
}
|
||||
}
|
||||
vn-log-value > .id-value {
|
||||
font-size: .9rem;
|
||||
color: $color-font-secondary;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
name: subrole
|
||||
columns:
|
||||
id: id
|
||||
role: rol
|
||||
inheritsFrom: inherits
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
name: subrol
|
||||
columns:
|
||||
id: id
|
||||
role: rol
|
||||
inheritsFrom: hereda
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
name: SMS
|
||||
columns:
|
||||
id: id
|
||||
senderFk: sender
|
||||
sender: sender number
|
||||
destination: destination
|
||||
message: message
|
||||
statusCode: status code
|
||||
status: status
|
||||
created: created
|
|
@ -0,0 +1,10 @@
|
|||
name: SMS
|
||||
columns:
|
||||
id: id
|
||||
senderFk: remitente
|
||||
sender: número remitente
|
||||
destination: destinatario
|
||||
message: mensaje
|
||||
statusCode: código estado
|
||||
status: estado
|
||||
created: creado
|
Loading…
Reference in New Issue