0
0
Fork 0

fix: refs #7909 rollback scroll

This commit is contained in:
Jorge Penadés 2024-09-09 13:17:38 +02:00
parent 132501e4a4
commit 9506ed695b
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,283 +418,231 @@ watch(
" "
auto-load auto-load
/> />
<VnPaginate <div
ref="paginate" class="column items-center logs origin-log q-mt-md"
:data-key="`${model}Log`" v-for="(originLog, originLogIndex) in logTree"
:url="`${model}Logs`" :key="originLogIndex"
:filter="filter"
:skeleton="false"
auto-load
@on-fetch="setLogTree"
> >
<template #body> <QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1">
<div <h6 class="origin-id text-grey">
class="column items-center logs origin-log q-mt-md" {{ useCapitalize(validations[props.model].locale.name) }}
v-for="(originLog, originLogIndex) in logTree" #{{ originLog.originFk }}
:key="originLogIndex" </h6>
> <div class="line bg-grey"></div>
<QItem class="origin-info items-center q-my-md" v-if="logTree.length > 1"> </QItem>
<h6 class="origin-id text-grey"> <div
{{ useCapitalize(validations[props.model].locale.name) }} class="user-log q-mb-sm"
#{{ originLog.originFk }} v-for="(userLog, userIndex) in originLog.logs"
</h6> :key="userIndex"
<div class="line bg-grey"></div> >
</QItem> <div class="timeline">
<div <div class="user-avatar">
class="user-log q-mb-sm" <VnUserLink :worker-id="userLog?.user?.id">
v-for="(userLog, userIndex) in originLog.logs" <template #link>
:key="userIndex" <VnAvatar
:class="{ 'cursor-pointer': userLog?.user?.id }"
:worker-id="userLog?.user?.id"
:title="userLog?.user?.nickname"
:show-letter="!userLog?.user"
size="lg"
/>
</template>
</VnUserLink>
</div>
<div class="arrow bg-panel" v-if="byRecord"></div>
<div class="line"></div>
</div>
<QList class="user-changes" v-if="userLog">
<QItem
class="model-log column q-px-none q-py-xs"
v-for="(modelLog, modelLogIndex) in userLog.logs"
:key="modelLogIndex"
> >
<div class="timeline"> <QItemSection>
<div class="user-avatar"> <QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
<VnUserLink :worker-id="userLog?.user?.id"> <QChip
<template #link> dense
<VnAvatar size="md"
:class="{ 'cursor-pointer': userLog?.user?.id }" class="model-name q-mr-xs text-white"
:worker-id="userLog?.user?.id" v-if="
:title="userLog?.user?.nickname" !(modelLog.changedModel && modelLog.changedModelId) &&
:show-letter="!userLog?.user" modelLog.model
size="lg" "
/> :style="{
</template> backgroundColor: useColor(modelLog.model),
</VnUserLink> }"
</div> :title="`${modelLog.model} #${modelLog.id}`"
<div class="arrow bg-panel" v-if="byRecord"></div> >
<div class="line"></div> {{ t(modelLog.modelI18n) }}
</div> </QChip>
<QList class="user-changes" v-if="userLog">
<QItem
class="model-log column q-px-none q-py-xs"
v-for="(modelLog, modelLogIndex) in userLog.logs"
:key="modelLogIndex"
>
<QItemSection>
<QItemLabel class="model-info q-mb-xs" v-if="!byRecord">
<QChip
dense
size="md"
class="model-name q-mr-xs text-white"
v-if="
!(
modelLog.changedModel &&
modelLog.changedModelId
) && modelLog.model
"
:style="{
backgroundColor: useColor(modelLog.model),
}"
:title="`${modelLog.model} #${modelLog.id}`"
>
{{ t(modelLog.modelI18n) }}
</QChip>
<span <span
class="model-id q-mr-xs" class="model-id q-mr-xs"
v-if="modelLog.summaryId" v-if="modelLog.summaryId"
v-text="`#${modelLog.summaryId}`" v-text="`#${modelLog.summaryId}`"
/> />
<span <span
class="model-value" class="model-value"
:title="modelLog.showValue" :title="modelLog.showValue"
v-text="modelLog.showValue" v-text="modelLog.showValue"
/> />
<QBtn <QBtn
flat flat
round round
color="grey" color="grey"
class="q-mr-xs q-ml-auto" class="q-mr-xs q-ml-auto"
size="sm" size="sm"
icon="filter_alt" icon="filter_alt"
:title="t('recordChanges')" :title="t('recordChanges')"
@click.stop="filterByRecord(modelLog)" @click.stop="filterByRecord(modelLog)"
/> />
</QItemLabel> </QItemLabel>
</QItemSection> </QItemSection>
<QItemSection> <QItemSection>
<QCard <QCard
class="changes-log q-py-none q-mb-xs" class="changes-log q-py-none q-mb-xs"
v-for="(log, logIndex) in modelLog.logs" v-for="(log, logIndex) in modelLog.logs"
:key="logIndex" :key="logIndex"
>
<QCardSection class="change-info q-pa-none">
<QItem
class="q-px-sm q-py-xs justify-between items-center"
> >
<QCardSection class="change-info q-pa-none"> <div
<QItem class="date text-grey text-caption q-mr-sm"
class="q-px-sm q-py-xs justify-between items-center" :title="
> date.formatDate(
<div log.creationDate,
class="date text-grey text-caption q-mr-sm" 'DD/MM/YYYY hh:mm:ss'
:title=" ) ?? `date:'dd/MM/yyyy HH:mm:ss'`
date.formatDate( "
log.creationDate,
'DD/MM/YYYY hh:mm:ss'
) ?? `date:'dd/MM/yyyy HH:mm:ss'`
"
>
{{ toRelativeDate(log.creationDate) }}
</div>
<div>
<QBtn
color="grey"
class="pit"
icon="preview"
flat
round
:title="t('pointRecord')"
padding="none"
v-if="log.action != 'insert'"
@click.stop="
openPointRecord(log.id, modelLog)
"
>
<QPopupProxy>
<QCard v-if="pointRecord">
<div
class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
>
{{ modelLog.modelI18n }}
<span v-if="modelLog.id"
>#{{
modelLog.id
}}</span
>
</div>
<QCardSection
class="change-detail q-pa-sm"
>
<QItem
v-for="(
value, index
) in pointRecord"
:key="index"
class="q-pa-none"
>
<span
class="json-field q-mr-xs text-grey"
:title="
value.name
"
>
{{
value.nameI18n
}}:
</span>
<VnJsonValue
:value="
value.val.val
"
/>
</QItem>
</QCardSection>
</QCard>
</QPopupProxy>
</QBtn>
<QIcon
class="action q-ml-xs"
:class="actionsClass[log.action]"
:name="actionsIcon[log.action]"
:title="
t(
`actions.${
actionsText[log.action]
}`
)
"
/>
</div>
</QItem>
</QCardSection>
<QCardSection
class="change-detail q-px-sm q-py-xs"
:class="{ expanded: log.expand }"
v-if="log.props.length || log.description"
> >
<QIcon {{ toRelativeDate(log.creationDate) }}
class="cursor-pointer q-mr-md" </div>
<div>
<QBtn
color="grey" color="grey"
name="expand_more" class="pit"
:title="t('globals.details')" icon="preview"
size="sm" flat
@click="log.expand = !log.expand" round
/> :title="t('pointRecord')"
<span v-if="log.props.length" class="attributes"> padding="none"
<span v-if="log.action != 'insert'"
v-if="!log.expand" @click.stop="
class="q-pa-none text-grey" openPointRecord(log.id, modelLog)
> "
<span >
v-for="(prop, propIndex) in log.props" <QPopupProxy>
:key="propIndex" <QCard v-if="pointRecord">
class="basic-json" <div
> class="header q-px-sm q-py-xs q-ma-none text-white text-bold bg-primary"
<span
class="json-field"
:title="prop.name"
> >
{{ prop.nameI18n }}: {{ modelLog.modelI18n }}
</span> <span v-if="modelLog.id"
<VnJsonValue :value="prop.val.val" /> >#{{ modelLog.id }}</span
<span >
v-if=" </div>
propIndex < <QCardSection
log.props.length - 1 class="change-detail q-pa-sm"
" >
>,&nbsp; <QItem
</span> v-for="(
value, index
) in pointRecord"
:key="index"
class="q-pa-none"
>
<span
class="json-field q-mr-xs text-grey"
:title="value.name"
>
{{ value.nameI18n }}:
</span>
<VnJsonValue
:value="value.val.val"
/>
</QItem>
</QCardSection>
</QCard>
</QPopupProxy>
</QBtn>
<QIcon
class="action q-ml-xs"
:class="actionsClass[log.action]"
:name="actionsIcon[log.action]"
:title="
t(`actions.${actionsText[log.action]}`)
"
/>
</div>
</QItem>
</QCardSection>
<QCardSection
class="change-detail q-px-sm q-py-xs"
:class="{ expanded: log.expand }"
v-if="log.props.length || log.description"
>
<QIcon
class="cursor-pointer q-mr-md"
color="grey"
name="expand_more"
:title="t('globals.details')"
size="sm"
@click="log.expand = !log.expand"
/>
<span v-if="log.props.length" class="attributes">
<span v-if="!log.expand" class="q-pa-none text-grey">
<span
v-for="(prop, propIndex) in log.props"
:key="propIndex"
class="basic-json"
>
<span class="json-field" :title="prop.name">
{{ prop.nameI18n }}:
</span>
<VnJsonValue :value="prop.val.val" />
<span v-if="propIndex < log.props.length - 1"
>,&nbsp;
</span>
</span>
</span>
<span
v-if="log.expand"
class="expanded-json column q-pa-none"
>
<div
v-for="(prop, prop2Index) in log.props"
:key="prop2Index"
class="q-pa-none text-grey"
>
<span class="json-field" :title="prop.name">
{{ prop.nameI18n }}:
</span>
<VnJsonValue :value="prop.val.val" />
<span v-if="prop.val.id" class="id-value">
#{{ prop.val.id }}
</span>
<span v-if="log.action == 'update'">
<VnJsonValue :value="prop.old.val" />
<span v-if="prop.old.id" class="id-value">
#{{ prop.old.id }}
</span> </span>
</span> </span>
<span </div>
v-if="log.expand" </span>
class="expanded-json column q-pa-none" </span>
> <span v-if="!log.props.length" class="description">
<div {{ log.description }}
v-for="( </span>
prop, prop2Index </QCardSection>
) in log.props" </QCard>
:key="prop2Index" </QItemSection>
class="q-pa-none text-grey" </QItem>
> </QList>
<span </div>
class="json-field" </div>
:title="prop.name"
>
{{ prop.nameI18n }}:
</span>
<VnJsonValue :value="prop.val.val" />
<span
v-if="prop.val.id"
class="id-value"
>
#{{ prop.val.id }}
</span>
<span v-if="log.action == 'update'">
<VnJsonValue
:value="prop.old.val"
/>
<span
v-if="prop.old.id"
class="id-value"
>
#{{ prop.old.id }}
</span>
</span>
</div>
</span>
</span>
<span
v-if="!log.props.length"
class="description"
>
{{ log.description }}
</span>
</QCardSection>
</QCard>
</QItemSection>
</QItem>
</QList>
</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
> >