-
{setVisibleOnItem(e.target.checked, selected_product); emit('update')}" v-if="selected_product && !preview_mode" :checked="!isHidden">
+
{setListState(props.questionnaire.items, selected_product, e.target.checked); emit('update')}" v-if="selected_product && !preview_mode" :checked="!isHidden">
{{ props.questionnaire.internal_name }}
@@ -152,61 +157,10 @@ const isEditable = computed(() => props.selected_product && props.questionnaire.
-
-
-
-
-
-
+
+
+
+
= 400)
+ if (response.status === 204)
+ return {}
+ else if (response.status >= 400)
throw new APIError(await response.json());
else
return await response.json()
@@ -61,6 +63,10 @@ export async function createQuestionnaire(data) {
return await api_json_request(`organizers/${organizer_slug}/events/${event_slug}/questionnaires/`, 'POST', data);
}
+export async function deleteQuestionnaire(id) {
+ return await api_json_request(`organizers/${organizer_slug}/events/${event_slug}/questionnaires/${id}/`, 'DELETE', {});
+}
+
export async function getItems() {
using pb = ProgressBar.show('loading product list')
return await api_get_all- (`organizers/${organizer_slug}/events/${event_slug}/items/`);
@@ -72,7 +78,7 @@ export async function getCategories() {
}
export async function getSalesChannels() {
- return await api_get_all(`organizers/${organizer_slug}/saleschannels/`);
+ return await api_get_all(`organizers/${organizer_slug}/saleschannels/`);
}
export function getEventLocales() {
diff --git a/src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.js b/src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.ts
similarity index 88%
rename from src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.js
rename to src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.ts
index 2ff48460e7..c94babdaa7 100644
--- a/src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.js
+++ b/src/pretix/static/pretixcontrol/js/ui/questionnaires/helper.ts
@@ -37,7 +37,7 @@ export function sort (array, ...orderBy) {
return 0
})
}
-export function *groupBy (array, key) {
+export function *groupBy (array: V[], key: (v: V) => K): Generator<[K, V[]]> {
let lastKey, lastArray
for (const x of array) {
const k = key(x)
@@ -55,6 +55,15 @@ export function *groupBy (array, key) {
}
}
+export function setListState(list, state, identifier) {
+ const i = list.indexOf(identifier)
+ if (i === -1) {
+ if (state) list.push(identifier)
+ } else {
+ if (!state) list.splice(i, 1)
+ }
+}
+
export function fromJsonScript (id) {
return JSON.parse(document.getElementById(id).textContent)
}
diff --git a/src/pretix/static/pretixcontrol/js/ui/questionnaires/model.ts b/src/pretix/static/pretixcontrol/js/ui/questionnaires/model.ts
index fbbf9cb7cd..2a55be2f58 100644
--- a/src/pretix/static/pretixcontrol/js/ui/questionnaires/model.ts
+++ b/src/pretix/static/pretixcontrol/js/ui/questionnaires/model.ts
@@ -70,3 +70,12 @@ export type Category = {
name: I18nString,
internal_name: string | null,
}
+
+export type SalesChannel = {
+ identifier: string,
+ type: string,
+ label: I18nString,
+ position: number,
+}
+
+export type GroupedItems = [Category, Item[]][];