0
0
Fork 0

fix: refs #7909 rollback scroll

This commit is contained in:
Jorge Penadés 2024-09-09 13:38:27 +02:00
parent 132501e4a4
commit 803c02b80d
1 changed files with 245 additions and 276 deletions

View File

@ -14,7 +14,6 @@ import VnJsonValue from '../common/VnJsonValue.vue';
import FetchData from '../FetchData.vue'; import FetchData from '../FetchData.vue';
import VnSelect from './VnSelect.vue'; import VnSelect from './VnSelect.vue';
import VnUserLink from '../ui/VnUserLink.vue'; import VnUserLink from '../ui/VnUserLink.vue';
import VnPaginate from '../ui/VnPaginate.vue';
const stateStore = useStateStore(); const stateStore = useStateStore();
const validationsStore = useValidator(); const validationsStore = useValidator();
@ -69,7 +68,7 @@ const filter = {
], ],
}; };
const paginate = ref(); const workers = ref();
const actions = ref(); const actions = ref();
const changeInput = ref(); const changeInput = ref();
const searchInput = ref(); const searchInput = ref();
@ -236,8 +235,9 @@ async function openPointRecord(id, modelLog) {
const locale = validations[modelLog.model]?.locale || {}; const locale = validations[modelLog.model]?.locale || {};
pointRecord.value = parseProps(propNames, locale, data); pointRecord.value = parseProps(propNames, locale, data);
} }
async function setLogTree(data) { async function setLogTree() {
filter.where = { and: [{ originFk: route.params.id }] }; filter.where = { and: [{ originFk: route.params.id }] };
const { data } = await getLogs(filter);
logTree.value = getLogTree(data); logTree.value = getLogTree(data);
} }
@ -266,7 +266,15 @@ async function applyFilter() {
filter.where.and.push(selectedFilters.value); filter.where.and.push(selectedFilters.value);
} }
paginate.value.fetch(filter); const { data } = await getLogs(filter);
logTree.value = getLogTree(data);
}
async function getLogs(filter) {
return axios.get(props.url ?? `${props.model}Logs`, {
params: { filter: JSON.stringify(filter) },
});
} }
function setDate(type) { function setDate(type) {
@ -369,6 +377,8 @@ async function clearFilter() {
await applyFilter(); await applyFilter();
} }
setLogTree();
onUnmounted(() => { onUnmounted(() => {
stateStore.rightDrawer = false; stateStore.rightDrawer = false;
}); });
@ -381,6 +391,16 @@ watch(
); );
</script> </script>
<template> <template>
<FetchData
:url="`${props.model}Logs/${route.params.id}/editors`"
:filter="{
fields: ['id', 'nickname', 'name', 'image'],
order: 'nickname',
limit: 30,
}"
@on-fetch="(data) => (workers = data)"
auto-load
/>
<FetchData <FetchData
:url="`${props.model}Logs/${route.params.id}/models`" :url="`${props.model}Logs/${route.params.id}/models`"
:filter="{ order: ['changedModel'] }" :filter="{ order: ['changedModel'] }"
@ -398,16 +418,6 @@ watch(
" "
auto-load auto-load
/> />
<VnPaginate
ref="paginate"
:data-key="`${model}Log`"
:url="`${model}Logs`"
:filter="filter"
:skeleton="false"
auto-load
@on-fetch="setLogTree"
>
<template #body>
<div <div
class="column items-center logs origin-log q-mt-md" class="column items-center logs origin-log q-mt-md"
v-for="(originLog, originLogIndex) in logTree" v-for="(originLog, originLogIndex) in logTree"
@ -455,10 +465,8 @@ watch(
size="md" size="md"
class="model-name q-mr-xs text-white" class="model-name q-mr-xs text-white"
v-if=" v-if="
!( !(modelLog.changedModel && modelLog.changedModelId) &&
modelLog.changedModel && modelLog.model
modelLog.changedModelId
) && modelLog.model
" "
:style="{ :style="{
backgroundColor: useColor(modelLog.model), backgroundColor: useColor(modelLog.model),
@ -532,9 +540,7 @@ watch(
> >
{{ modelLog.modelI18n }} {{ modelLog.modelI18n }}
<span v-if="modelLog.id" <span v-if="modelLog.id"
>#{{ >#{{ modelLog.id }}</span
modelLog.id
}}</span
> >
</div> </div>
<QCardSection <QCardSection
@ -549,18 +555,12 @@ watch(
> >
<span <span
class="json-field q-mr-xs text-grey" class="json-field q-mr-xs text-grey"
:title=" :title="value.name"
value.name
"
> >
{{ {{ value.nameI18n }}:
value.nameI18n
}}:
</span> </span>
<VnJsonValue <VnJsonValue
:value=" :value="value.val.val"
value.val.val
"
/> />
</QItem> </QItem>
</QCardSection> </QCardSection>
@ -572,11 +572,7 @@ watch(
:class="actionsClass[log.action]" :class="actionsClass[log.action]"
:name="actionsIcon[log.action]" :name="actionsIcon[log.action]"
:title=" :title="
t( t(`actions.${actionsText[log.action]}`)
`actions.${
actionsText[log.action]
}`
)
" "
/> />
</div> </div>
@ -596,27 +592,17 @@ watch(
@click="log.expand = !log.expand" @click="log.expand = !log.expand"
/> />
<span v-if="log.props.length" class="attributes"> <span v-if="log.props.length" class="attributes">
<span <span v-if="!log.expand" class="q-pa-none text-grey">
v-if="!log.expand"
class="q-pa-none text-grey"
>
<span <span
v-for="(prop, propIndex) in log.props" v-for="(prop, propIndex) in log.props"
:key="propIndex" :key="propIndex"
class="basic-json" class="basic-json"
> >
<span <span class="json-field" :title="prop.name">
class="json-field"
:title="prop.name"
>
{{ prop.nameI18n }}: {{ prop.nameI18n }}:
</span> </span>
<VnJsonValue :value="prop.val.val" /> <VnJsonValue :value="prop.val.val" />
<span <span v-if="propIndex < log.props.length - 1"
v-if="
propIndex <
log.props.length - 1
"
>,&nbsp; >,&nbsp;
</span> </span>
</span> </span>
@ -626,44 +612,28 @@ watch(
class="expanded-json column q-pa-none" class="expanded-json column q-pa-none"
> >
<div <div
v-for="( v-for="(prop, prop2Index) in log.props"
prop, prop2Index
) in log.props"
:key="prop2Index" :key="prop2Index"
class="q-pa-none text-grey" class="q-pa-none text-grey"
> >
<span <span class="json-field" :title="prop.name">
class="json-field"
:title="prop.name"
>
{{ prop.nameI18n }}: {{ prop.nameI18n }}:
</span> </span>
<VnJsonValue :value="prop.val.val" /> <VnJsonValue :value="prop.val.val" />
<span <span v-if="prop.val.id" class="id-value">
v-if="prop.val.id"
class="id-value"
>
#{{ prop.val.id }} #{{ prop.val.id }}
</span> </span>
<span v-if="log.action == 'update'"> <span v-if="log.action == 'update'">
<VnJsonValue <VnJsonValue :value="prop.old.val" />
:value="prop.old.val" <span v-if="prop.old.id" class="id-value">
/>
<span
v-if="prop.old.id"
class="id-value"
>
#{{ prop.old.id }} #{{ prop.old.id }}
</span> </span>
</span> </span>
</div> </div>
</span> </span>
</span> </span>
<span <span v-if="!log.props.length" class="description">
v-if="!log.props.length"
class="description"
>
{{ log.description }} {{ log.description }}
</span> </span>
</QCardSection> </QCardSection>
@ -673,8 +643,6 @@ watch(
</QList> </QList>
</div> </div>
</div> </div>
</template>
</VnPaginate>
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()"> <Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
<QList dense> <QList dense>
<QSeparator /> <QSeparator />
@ -723,16 +691,17 @@ watch(
</QOptionGroup> </QOptionGroup>
</QItem> </QItem>
<QItem class="q-mt-sm"> <QItem class="q-mt-sm">
<QItemSection v-if="userRadio !== null"> <QItemSection v-if="!workers">
<QSkeleton type="QInput" class="full-width" />
</QItemSection>
<QItemSection v-if="workers && userRadio !== null">
<VnSelect <VnSelect
class="full-width" class="full-width"
:label="t('globals.user')" :label="t('globals.user')"
v-model="userSelect" v-model="userSelect"
option-label="name" option-label="name"
option-value="id" option-value="id"
:url="`${model}Logs/${$route.params.id}/editors`" :options="workers"
:fields="['id', 'nickname', 'name', 'image']"
sort-by="nickname"
@update:model-value="selectFilter('userSelect')" @update:model-value="selectFilter('userSelect')"
hide-selected hide-selected
> >