Investigation on send filter expiration

This commit is contained in:
oguzhankoral 2024-05-07 20:17:30 +03:00
Родитель 730c844cc6
Коммит 19161fa2ae
3 изменённых файлов: 44 добавлений и 6 удалений

Просмотреть файл

@ -5,11 +5,17 @@
<FormButton
size="sm"
full-width
color="card"
class="flex items-center justify-center"
:color="'card'"
class="flex items-center justify-center border"
@click="sendOrCancel"
>
{{ modelCard.progress ? 'Cancel' : 'Publish' }}
{{
modelCard.progress
? 'Cancel'
: modelCard.sendFilter?.expired
? 'Update Filter'
: 'Publish'
}}
</FormButton>
</div>
<div
@ -18,9 +24,9 @@
<FormButton
v-tippy="'Edit what gets published'"
:icon-left="CubeIcon"
link
full-width
size="sm"
color="card"
:color="modelCard.sendFilter?.expired ? 'warning' : 'card'"
class="flex min-w-0 transition hover:text-primary py-1"
:disabled="!!modelCard.progress"
@click="openFilterDialog = true"

Просмотреть файл

@ -11,6 +11,7 @@ export interface ISendFilter extends IDiscriminatedObject {
name: string
summary: string
isDefault: boolean
expired: boolean
}
export interface IDirectSelectionSendFilter extends ISendFilter {

Просмотреть файл

@ -5,7 +5,11 @@ import {
import { IModelCard, ModelCardProgress } from 'lib/models/card'
import { useMixpanel } from '~/lib/core/composables/mixpanel'
import { IReceiverModelCard } from 'lib/models/card/receiver'
import { ISendFilter, ISenderModelCard } from 'lib/models/card/send'
import {
IDirectSelectionSendFilter,
ISendFilter,
ISenderModelCard
} from 'lib/models/card/send'
export type ProjectModelGroup = {
projectId: string
@ -297,6 +301,33 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
const refreshSendFilters = async () =>
(sendFilters.value = await app.$sendBinding?.getSendFilters())
app.$selectionBinding?.on('setSelection', (selInfo) => {
const senders = documentModelStore.value.models.filter((model) =>
model.typeDiscriminator.toLowerCase().includes('sender')
) as ISenderModelCard[]
const sendersWithSelectionFilter = senders.filter(
(model) => model.sendFilter?.name === 'Selection'
)
sendersWithSelectionFilter.forEach((model) => {
const filter = model.sendFilter as IDirectSelectionSendFilter
if (selInfo.selectedObjectIds.length === 0) {
// make not expired always if selection empty
filter.expired = false
patchModel(model.modelCardId, { sendFilter: filter })
return
}
const sameSelection = filter.selectedObjectIds
.slice()
.sort()
.every(
(value, index) =>
value === (selInfo.selectedObjectIds as string[]).slice().sort()[index]
)
filter.expired = !sameSelection
patchModel(model.modelCardId, { sendFilter: filter })
})
})
app.$baseBinding.on(
'documentChanged',
() =>