Add question_condition support to SelfServeQuestions with dynamic filtering and table integration
- Introduced `question_condition` field for conditional question handling. - Enhanced question filtering logic using `department_id` and `product_id`. - Added default "Ingen" option for `question_condition`. - Updated `SelfServeQuestionsTable` to include editable `question_condition` column. - Removed deprecated `image` and `vehicle_type` column handlers. - Added `question_condition` handling in the backend update logic.
This commit is contained in:
+5143
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,7 @@ const onDrop = async (event, newIndex) => {
|
||||
<tr>
|
||||
<th v-if="SessionUser.canAccessAdmin()" style="width: 40px;"></th>
|
||||
<th>{{ SessionUser.objects.self_serve_questions.columns.order_priority.label }}</th>
|
||||
<th>{{ SessionUser.objects.self_serve_questions.columns.question_condition.label }}</th>
|
||||
<th>{{ SessionUser.objects.self_serve_questions.columns.question.label }}</th>
|
||||
<th>{{ SessionUser.objects.self_serve_questions.columns.description.label }}</th>
|
||||
<th>{{ SessionUser.objects.self_serve_questions.columns.lane.label }}</th>
|
||||
@@ -108,6 +109,14 @@ const onDrop = async (event, newIndex) => {
|
||||
:edit-function="SessionUser.objects.self_serve_questions.showEditObjectFieldForm"
|
||||
:permission-check-function="SessionUser.canAccessAdmin"
|
||||
/>
|
||||
<EditableTableColumn
|
||||
:object="object"
|
||||
:loadList="loadList"
|
||||
column="question_condition"
|
||||
:edit-function="SessionUser.objects.self_serve_questions.showEditObjectFieldForm"
|
||||
:parse-function="SessionUser.objects.self_serve_questions.columns.question_condition.parse"
|
||||
:permission-check-function="SessionUser.canAccessAdmin"
|
||||
/>
|
||||
<EditableTableColumn
|
||||
:object="object"
|
||||
:loadList="loadList"
|
||||
|
||||
@@ -96,12 +96,39 @@ export const SelfServeQuestions = {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
image: {
|
||||
label: "Billede",
|
||||
type: "number",
|
||||
question_condition: {
|
||||
label: "Betingelse (Hvis)",
|
||||
type: "select",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
required: true
|
||||
},
|
||||
options: async (lockedValues = {}) => {
|
||||
let questions = await SessionUser.objects.self_serve_questions.get.all();
|
||||
const departmentId = lockedValues.department || lockedValues.department_id;
|
||||
const productId = lockedValues.product || lockedValues.vehicle_type || lockedValues.product_id;
|
||||
|
||||
if (departmentId) {
|
||||
questions = questions.filter(q => parseInt(q.department) === parseInt(departmentId));
|
||||
}
|
||||
if (productId) {
|
||||
questions = questions.filter(q => parseInt(q.product) === parseInt(productId));
|
||||
}
|
||||
|
||||
let options = questions.map(q => ({
|
||||
...q,
|
||||
name: q.question
|
||||
}));
|
||||
|
||||
options.unshift({
|
||||
id: 0,
|
||||
name: "Ingen"
|
||||
});
|
||||
|
||||
return options;
|
||||
},
|
||||
parse: (id) => {
|
||||
return SessionUser.objects.self_serve_questions.functions.getQuestionText(id);
|
||||
}
|
||||
},
|
||||
order_priority: {
|
||||
@@ -113,7 +140,7 @@ export const SelfServeQuestions = {
|
||||
}
|
||||
},
|
||||
},
|
||||
add: async (department, lane, product, question, description, order_priority) => {
|
||||
add: async (department, lane, product, question, description, question_condition, order_priority) => {
|
||||
return ObjectsGlobal.add.object(
|
||||
SelfServeQuestions.meta.endpoint,
|
||||
{
|
||||
@@ -122,6 +149,7 @@ export const SelfServeQuestions = {
|
||||
product: parseInt(product),
|
||||
question: question,
|
||||
description: description,
|
||||
question_condition: (question_condition && parseInt(question_condition) !== 0) ? parseInt(question_condition) : null,
|
||||
order_priority: parseInt(order_priority),
|
||||
}
|
||||
);
|
||||
@@ -151,20 +179,12 @@ export const SelfServeQuestions = {
|
||||
parseInt(order_priority)
|
||||
)
|
||||
},
|
||||
image: async (id, image) => {
|
||||
question_condition: async (id, question_condition) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
SelfServeQuestions.meta.endpoint,
|
||||
id,
|
||||
"image",
|
||||
parseInt(image)
|
||||
)
|
||||
},
|
||||
vehicle_type: async (id, vehicle_type) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
SelfServeQuestions.meta.endpoint,
|
||||
id,
|
||||
"vehicle_type",
|
||||
parseInt(vehicle_type)
|
||||
"question_condition",
|
||||
(question_condition && parseInt(question_condition) !== 0) ? parseInt(question_condition) : null
|
||||
)
|
||||
},
|
||||
product: async (id, product) => {
|
||||
|
||||
Reference in New Issue
Block a user