231801_test_to_master #1519

Merged
alexm merged 490 commits from 231801_test_to_master into master 2023-05-12 06:29:59 +00:00
3 changed files with 79 additions and 36 deletions
Showing only changes of commit 6e3e2cf798 - Show all commits

View File

@ -166,7 +166,7 @@ export default class Field extends FormInput {
if (event.defaultPrevented) return;
event.preventDefault();
this.field = null;
this.input.dispatchEvent(new Event('change'));
this.element.dispatchEvent(new Event('change'));
}
buildInput(type) {

View File

@ -6,8 +6,7 @@
where="{changedModel: $ctrl.changedModel, changedModelId: $ctrl.changedModelId}"
data="$ctrl.logs"
order="creationDate DESC, id DESC"
limit="20"
auto-load="true">
limit="20">
</vn-crud-model>
<vn-crud-model
url="{{$ctrl.url}}/{{$ctrl.originId}}/models"
@ -122,21 +121,37 @@
</vn-data-viewer>
<vn-side-menu side="right">
<form vn-vertical
ng-submit="$ctrl.applyFilter(filter)"
ng-model-options="{updateOn: 'change blur'}"
class="vn-pa-md filter">
<vn-autocomplete
label="Model"
ng-model="filter.changedModel"
value-field="changedModel"
show-field="changedModel"
data="models">
</vn-autocomplete>
<h6
class="text-secondary vn-mb-md"
style="font-weight: normal;"
translate>
Filter
</h6>
<vn-textfield
label="Id"
ng-model="filter.changedModelId">
label="Name"
ng-model="filter.changedModelValue">
</vn-textfield>
<vn-vertical>
<vn-radio
label="All"
val="all"
ng-model="filter.who">
</vn-radio>
<vn-radio
label="User"
val="user"
ng-model="filter.who">
</vn-radio>
<vn-radio
label="System"
val="system"
ng-model="filter.who">
</vn-radio>
</div>
<vn-autocomplete
ng-show="filter.who != 'system'"
label="User"
ng-model="filter.userFk"
value-field="id"
@ -150,30 +165,37 @@
<div class="text-secondary text-caption">{{name}}</div>
</tpl-item>
</vn-autocomplete>
<div vn-vertical>
<vn-autocomplete
label="Model"
ng-model="filter.changedModel"
value-field="changedModel"
show-field="changedModel"
data="models">
</vn-autocomplete>
<vn-textfield
label="Id"
ng-model="filter.changedModelId">
</vn-textfield>
<vn-vertical>
<vn-check
label="Creates"
val="insert"
ng-model="filter.actions.insert">
</vn-check>
<vn-check
label="Updates"
val="update"
ng-model="filter.actions.update">
</vn-check>
<vn-check
label="Deletes"
val="delete"
ng-model="filter.actions.delete">
</vn-check>
<vn-check
label="Views"
val="select"
ng-model="filter.actions.select">
</vn-check>
</div>
<vn-date-picker
label="From"
label="Date"
ng-model="filter.from">
</vn-date-picker>
<vn-date-picker
@ -181,11 +203,14 @@
ng-model="filter.to">
</vn-date-picker>
<vn-button-bar vn-vertical class="vn-mt-sm">
<vn-submit label="Filter"></vn-submit>
<vn-button
label="Filter"
ng-click="$ctrl.applyFilter(filter)">
</vn-button>
<vn-button
label="Reset"
class="flat"
ng-click="$ctrl.removeFilter()"
ng-click="$ctrl.resetFilter()"
ng-if="model.userFilter">
</vn-button>
</vn-button-bar>

View File

@ -19,8 +19,6 @@ export default class Controller extends Section {
delete: 'alert',
select: 'notice'
};
$.filter = {};
this.filter = {
include: [{
relation: 'user',
@ -42,21 +40,23 @@ export default class Controller extends Section {
this.today.setHours(0, 0, 0, 0);
}
$onInit() {
$postLink() {
this.resetFilter();
const {$} = this;
$.$watch(
() => [
$.filter.actions,
$.filter.changedModelValue,
$.filter.who,
$.filter.changedModel,
$.filter.userFk
$.filter.changedModelId,
$.filter.userFk,
$.filter.actions,
$.filter.from,
$.filter.to
],
() => this.applyFilter(),
true
);
$.$watch(
() => $.filter.from,
() => $.filter.to = $.filter.from
);
}
get logs() {
@ -135,12 +135,27 @@ export default class Controller extends Section {
this.$.workerDescriptor.show(event.target, workerId);
}
resetFilter() {
this.$.filter = {who: 'all'};
}
applyFilter() {
const filter = this.$.filter;
function getParam(prop, value) {
if (value == null || value == '') return null;
switch (prop) {
case 'changedModelValue':
return {[prop]: {like: `%${value}%`}};
case 'who':
switch (value) {
case 'all':
return null;
case 'user':
return {userFk: {neq: null}};
case 'system':
return {userFk: null};
}
case 'actions':
const inq = [];
for (const action in value) {
@ -149,7 +164,13 @@ export default class Controller extends Section {
}
return inq.length ? {action: {inq}} : null;
case 'from':
return {creationDate: {gte: value}};
if (filter.to) {
return {creationDate: {gte: value}};
} else {
const to = new Date(value);
to.setHours(23, 59, 59, 999);
return {creationDate: {between: [value, to]}};
}
case 'to':
const to = new Date(value);
to.setHours(23, 59, 59, 999);
@ -164,12 +185,9 @@ export default class Controller extends Section {
const param = getParam(prop, filter[prop]);
if (param) and.push(param);
}
this.$.model.applyFilter(and.length ? {where: {and}} : null);
}
removeFilter() {
this.$.filter = {};
this.applyFilter();
const lbFilter = and.length ? {where: {and}} : null;
return this.$.model.applyFilter(lbFilter);
}
searchUser(search) {