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}}">
|
<span class="json-field" title="{{::prop.name}}">
|
||||||
{{::prop.nameI18n}}:
|
{{::prop.nameI18n}}:
|
||||||
</span>
|
</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>
|
</span>
|
||||||
<div ng-if="log.expand" class="expanded-json">
|
<div ng-if="log.expand" class="expanded-json">
|
||||||
<div ng-repeat="prop in ::log.props">
|
<div ng-repeat="prop in ::log.props">
|
||||||
<span class="json-field" title="{{::prop.name}}">
|
<span class="json-field" title="{{::prop.name}}">
|
||||||
{{::prop.nameI18n}}:
|
{{::prop.nameI18n}}:
|
||||||
</span>
|
</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'">
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -64,29 +64,47 @@ export default class Controller extends Section {
|
||||||
set logs(value) {
|
set logs(value) {
|
||||||
this._logs = value;
|
this._logs = value;
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
const empty = {};
|
const empty = {};
|
||||||
const validations = window.validations;
|
const validations = window.validations;
|
||||||
|
const castJsonValue = this.castJsonValue;
|
||||||
|
|
||||||
for (const log of value) {
|
for (const log of value) {
|
||||||
const oldValues = log.oldInstance || empty;
|
const notDelete = log.action != 'delete';
|
||||||
const newValues = log.newInstance || empty;
|
const olds = (notDelete ? log.oldInstance : null) || empty;
|
||||||
|
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
|
||||||
const locale = validations[log.changedModel]?.locale || empty;
|
const locale = validations[log.changedModel]?.locale || empty;
|
||||||
log.changedModelI18n = firstUpper(locale.name) || log.changedModel;
|
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)];
|
props = [...new Set(props)];
|
||||||
|
|
||||||
log.props = [];
|
log.props = [];
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
|
if (prop.endsWith('$')) continue;
|
||||||
log.props.push({
|
log.props.push({
|
||||||
name: prop,
|
name: prop,
|
||||||
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
||||||
old: this.castJsonValue(oldValues[prop]),
|
old: getVal(olds, prop),
|
||||||
new: this.castJsonValue(newValues[prop])
|
val: getVal(vals, prop)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
log.props.sort(
|
log.props.sort(
|
||||||
(a, b) => a.nameI18n.localeCompare(b.nameI18n));
|
(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() {
|
get models() {
|
||||||
|
@ -113,10 +131,6 @@ export default class Controller extends Section {
|
||||||
: value;
|
: value;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainVal(prop, action) {
|
|
||||||
return action == 'delete' ? prop.old : prop.new;
|
|
||||||
}
|
|
||||||
|
|
||||||
relativeDate(dateVal) {
|
relativeDate(dateVal) {
|
||||||
if (dateVal == null) return '';
|
if (dateVal == null) return '';
|
||||||
const date = new Date(dateVal);
|
const date = new Date(dateVal);
|
||||||
|
@ -238,3 +252,12 @@ ngModule.vnComponent('vnLog', {
|
||||||
url: '@'
|
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
|
name: subrole
|
||||||
columns:
|
columns:
|
||||||
|
id: id
|
||||||
role: rol
|
role: rol
|
||||||
inheritsFrom: inherits
|
inheritsFrom: inherits
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
name: subrol
|
name: subrol
|
||||||
columns:
|
columns:
|
||||||
|
id: id
|
||||||
role: rol
|
role: rol
|
||||||
inheritsFrom: hereda
|
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