mirror of
https://github.com/pretix/pretix.git
synced 2026-06-11 01:25:13 +00:00
Don't show warning if inactive products are used in checkin-rules (Z#23236197) (#6242)
This commit is contained in:
@@ -401,13 +401,14 @@ class CheckinListUpdate(EventPermissionRequiredMixin, UpdateView):
|
|||||||
{
|
{
|
||||||
'id': i.pk,
|
'id': i.pk,
|
||||||
'name': str(i),
|
'name': str(i),
|
||||||
|
'active': i.active,
|
||||||
'variations': [
|
'variations': [
|
||||||
{
|
{
|
||||||
'id': v.pk,
|
'id': v.pk,
|
||||||
'name': str(v.value)
|
'name': str(v.value)
|
||||||
} for v in i.variations.all()
|
} for v in i.variations.all()
|
||||||
]
|
]
|
||||||
} for i in self.request.event.items.filter(active=True).prefetch_related('variations')
|
} for i in self.request.event.items.prefetch_related('variations')
|
||||||
],
|
],
|
||||||
**super().get_context_data(),
|
**super().get_context_data(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { rules as rawRules, items, allProducts, limitProducts } from './django-interop'
|
import { rules as rawRules, allItems, activeItems, allProducts, limitProducts } from './django-interop'
|
||||||
import { convertToDNF } from './jsonlogic-boolalg'
|
import { convertToDNF } from './jsonlogic-boolalg'
|
||||||
|
|
||||||
import RulesEditor from './checkin-rules-editor.vue'
|
import RulesEditor from './checkin-rules-editor.vue'
|
||||||
@@ -53,7 +53,7 @@ const missingItems = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let missing = []
|
let missing = []
|
||||||
for (const item of items.value) {
|
for (const item of activeItems.value) {
|
||||||
if (productsSeen[item.id]) continue
|
if (productsSeen[item.id]) continue
|
||||||
if (!allProducts.value && !limitProducts.value.includes(item.id)) continue
|
if (!allProducts.value && !limitProducts.value.includes(item.id)) continue
|
||||||
if (item.variations.length > 0) {
|
if (item.variations.length > 0) {
|
||||||
@@ -87,7 +87,7 @@ const missingItems = computed(() => {
|
|||||||
|
|
||||||
//- Tab panes
|
//- Tab panes
|
||||||
.tab-content
|
.tab-content
|
||||||
#rules-edit.tab-pane.active(v-if="items", role="tabpanel")
|
#rules-edit.tab-pane.active(v-if="allItems", role="tabpanel")
|
||||||
RulesEditor
|
RulesEditor
|
||||||
#rules-viz.tab-pane(role="tabpanel")
|
#rules-viz.tab-pane(role="tabpanel")
|
||||||
RulesVisualization
|
RulesVisualization
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ watch(rules, (newVal) => {
|
|||||||
rulesInput.value = JSON.stringify(newVal)
|
rulesInput.value = JSON.stringify(newVal)
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
||||||
export const items = ref<any[]>([])
|
export const activeItems = ref<any[]>([])
|
||||||
|
export const allItems = ref<any[]>([])
|
||||||
|
|
||||||
const itemsEl = document.querySelector('#items')
|
const itemsEl = document.querySelector('#items')
|
||||||
if (itemsEl?.textContent) {
|
if (itemsEl?.textContent) {
|
||||||
items.value = JSON.parse(itemsEl.textContent || '[]')
|
allItems.value = JSON.parse(itemsEl.textContent || '[]')
|
||||||
|
activeItems.value = allItems.value.filter(item => item.active)
|
||||||
|
|
||||||
function checkForInvalidIds (validProducts: Record<string, string>, validVariations: Record<string, string>, rule: any) {
|
function checkForInvalidIds (validProducts: Record<string, string>, validVariations: Record<string, string>, rule: any) {
|
||||||
if (rule['and']) {
|
if (rule['and']) {
|
||||||
@@ -57,8 +59,8 @@ if (itemsEl?.textContent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkForInvalidIds(
|
checkForInvalidIds(
|
||||||
Object.fromEntries(items.value.map(p => [p.id, p.name])),
|
Object.fromEntries(allItems.value.map(p => [p.id, p.name])),
|
||||||
Object.fromEntries(items.value.flatMap(p => p.variations?.map(v => [v.id, p.name + ' – ' + v.name]) ?? [])),
|
Object.fromEntries(allItems.value.flatMap(p => p.variations?.map(v => [v.id, p.name + ' – ' + v.name]) ?? [])),
|
||||||
rules.value
|
rules.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user