Add condition_id support to SelfServeConditions, SelfServeConditionRules, and related components

- Renamed `question_condition` to `condition_id` for consistency across `SelfServeConditions`, `SelfServeTasks`, and `SelfServeQuestions`.
- Introduced CRUD operations for `SelfServeConditionRules` with logic for managing condition rules.
- Enhanced existing components to support `condition_id`, including dynamic filtering and table parsing.
- Updated UI elements to reflect changes, including new rule creation options and improved field handling for `condition_id`.
This commit is contained in:
Jeppe Bundgaard
2026-01-09 14:08:53 +01:00
parent aaa0298bae
commit 1c13e2c80d
4 changed files with 435 additions and 12 deletions
+406 -10
View File
@@ -1344,7 +1344,7 @@ paths:
type: string
description:
type: string
question_condition:
condition_id:
type: integer
nullable: true
order_priority:
@@ -1391,7 +1391,7 @@ paths:
type: string
description:
type: string
question_condition:
condition_id:
type: integer
nullable: true
order_priority:
@@ -1434,12 +1434,345 @@ paths:
'404':
$ref: '#/components/responses/NotFound'
/department/selfserve/conditions:
get:
tags:
- Self-Serve
summary: List self-serve conditions
description: Retrieve a list of self-serve conditions for a department, lane, or product.
operationId: listSelfserveConditions
parameters:
- name: id
in: query
description: Filter by condition ID
schema:
type: integer
- name: department
in: query
description: Filter by department ID
schema:
type: integer
- name: lane
in: query
description: Filter by lane ID
schema:
type: integer
- name: product
in: query
description: Filter by product ID
schema:
type: integer
- name: condition_id
in: query
description: Filter by condition ID
schema:
type: integer
- $ref: '#/components/parameters/PageParam'
- $ref: '#/components/parameters/PerPageParam'
- $ref: '#/components/parameters/SearchParam'
- $ref: '#/components/parameters/FiltersParam'
responses:
'200':
description: Successfully retrieved conditions
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DepartmentSelfserveCondition'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
post:
tags:
- Self-Serve
summary: Add self-serve condition
description: Add a new self-serve condition.
operationId: addSelfserveCondition
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- department
- lane
- product
- name
- description
properties:
department:
type: integer
lane:
type: integer
product:
type: integer
condition_id:
type: integer
nullable: true
name:
type: string
description:
type: string
responses:
'200':
description: Successfully added condition
content:
application/json:
schema:
$ref: '#/components/schemas/DepartmentSelfserveCondition'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
put:
tags:
- Self-Serve
summary: Update self-serve condition
description: Update an existing self-serve condition.
operationId: updateSelfserveCondition
parameters:
- name: id
in: query
required: true
description: Condition ID
schema:
type: integer
requestBody:
content:
application/json:
schema:
type: object
properties:
department:
type: integer
lane:
type: integer
product:
type: integer
condition_id:
type: integer
nullable: true
name:
type: string
description:
type: string
responses:
'200':
description: Successfully updated condition
content:
application/json:
schema:
$ref: '#/components/schemas/DepartmentSelfserveCondition'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
delete:
tags:
- Self-Serve
summary: Delete self-serve condition
description: Delete a self-serve condition.
operationId: deleteSelfserveCondition
parameters:
- name: id
in: query
required: true
description: Condition ID
schema:
type: integer
responses:
'200':
description: Successfully deleted condition
content:
application/json:
schema:
type: string
example: Condition deleted
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
/department/selfserve/condition/rules:
get:
tags:
- Self-Serve
summary: List self-serve condition rules
description: Retrieve a list of self-serve condition rules.
operationId: listSelfserveConditionRules
parameters:
- name: id
in: query
description: Filter by rule ID
schema:
type: integer
- name: condition_id
in: query
description: Filter by condition ID
schema:
type: integer
- name: type
in: query
description: Filter by rule type
schema:
type: string
- name: object_type
in: query
description: Filter by object type
schema:
type: string
- name: object_id
in: query
description: Filter by object ID
schema:
type: integer
- $ref: '#/components/parameters/PageParam'
- $ref: '#/components/parameters/PerPageParam'
- $ref: '#/components/parameters/SearchParam'
- $ref: '#/components/parameters/FiltersParam'
responses:
'200':
description: Successfully retrieved condition rules
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DepartmentSelfserveConditionRule'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
post:
tags:
- Self-Serve
summary: Add self-serve condition rule
description: Add a new self-serve condition rule.
operationId: addSelfserveConditionRule
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- condition_id
- type
- object_type
- object_id
- name
- description
properties:
condition_id:
type: integer
type:
type: string
object_type:
type: string
object_id:
type: integer
name:
type: string
description:
type: string
responses:
'200':
description: Successfully added condition rule
content:
application/json:
schema:
$ref: '#/components/schemas/DepartmentSelfserveConditionRule'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
put:
tags:
- Self-Serve
summary: Update self-serve condition rule
description: Update an existing self-serve condition rule.
operationId: updateSelfserveConditionRule
parameters:
- name: id
in: query
required: true
description: Rule ID
schema:
type: integer
requestBody:
content:
application/json:
schema:
type: object
properties:
condition_id:
type: integer
type:
type: string
object_type:
type: string
object_id:
type: integer
name:
type: string
description:
type: string
responses:
'200':
description: Successfully updated condition rule
content:
application/json:
schema:
$ref: '#/components/schemas/DepartmentSelfserveConditionRule'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
delete:
tags:
- Self-Serve
summary: Delete self-serve condition rule
description: Delete a self-serve condition rule.
operationId: deleteSelfserveConditionRule
parameters:
- name: id
in: query
required: true
description: Rule ID
schema:
type: integer
responses:
'200':
description: Successfully deleted condition rule
content:
application/json:
schema:
type: string
example: Rule deleted
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
/department/selfserve/tasks:
get:
tags:
- Self-Serve
summary: List self-serve tasks
description: Retrieve a list of self-serve tasks for a department, lane, product, or question.
description: Retrieve a list of self-serve tasks for a department, lane, product, or condition_id.
operationId: listSelfserveTasks
parameters:
- name: id
@@ -1462,9 +1795,9 @@ paths:
description: Filter by product ID
schema:
type: integer
- name: question
- name: condition_id
in: query
description: Filter by question ID
description: Filter by condition ID
schema:
type: integer
- $ref: '#/components/parameters/PageParam'
@@ -1510,7 +1843,7 @@ paths:
type: integer
product:
type: integer
question:
condition_id:
type: integer
nullable: true
task:
@@ -1557,7 +1890,7 @@ paths:
type: integer
product:
type: integer
question:
condition_id:
type: integer
nullable: true
task:
@@ -4664,7 +4997,7 @@ components:
product:
type: integer
description: Product ID
question_condition:
condition_id:
type: integer
description: Question condition object ID
nullable: true
@@ -4699,9 +5032,9 @@ components:
product:
type: integer
description: Product ID
question:
condition_id:
type: integer
description: Question ID (if conditional task)
description: Condition ID (if conditional task)
nullable: true
task:
type: string
@@ -4719,6 +5052,69 @@ components:
type: string
format: date-time
DepartmentSelfserveCondition:
type: object
properties:
id:
type: integer
description: Condition ID
department:
type: integer
description: Department ID
lane:
type: integer
description: Lane ID
product:
type: integer
description: Product ID
condition_id:
type: integer
description: Optional condition ID
nullable: true
name:
type: string
description: Condition name
description:
type: string
description: Condition description
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
DepartmentSelfserveConditionRule:
type: object
properties:
id:
type: integer
description: Rule ID
condition_id:
type: integer
description: Condition object ID
type:
type: string
description: Condition type (e.g., IS_TRUE, IS_FALSE)
object_type:
type: string
description: The object type to which the condition applies (e.g., question, task, etc.)
object_id:
type: integer
description: The object id to which the condition applies
name:
type: string
description: Condition name
description:
type: string
description: Condition description
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
OrderCreate:
type: object
required:
@@ -62,6 +62,8 @@ const props = defineProps({
return SessionUser.objects.self_serve_questions.functions.getQuestionText(id);
} else if (object.object_type === 'task') {
return SessionUser.objects.self_serve_tasks.functions.getTaskText(id);
} else if (object.object_type === 'condition') {
return SessionUser.objects.self_serve_conditions.functions.getConditionName(id);
}
return id;
}"
@@ -50,7 +50,7 @@ export const SelfServeConditionRules = {
}
},
condition_id: {
label: "Betingelse",
label: "Betingelse (parent)",
type: "select",
sortable: true,
creation: {
@@ -88,6 +88,7 @@ export const SelfServeConditionRules = {
return [
{ id: "question", name: "Spørgsmål" },
{ id: "task", name: "Opgave" },
{ id: "condition", name: "Betingelse" },
];
}
},
@@ -115,6 +116,13 @@ export const SelfServeConditionRules = {
setFieldValue('name', task.task);
setFieldValue('description', task.description || '');
}
} else if (objectType === 'condition') {
const conditions = await SessionUser.objects.self_serve_conditions.get.all();
const condition = conditions.find(c => c.id === objectId);
if (condition) {
setFieldValue('name', condition.name);
setFieldValue('description', condition.description || '');
}
}
}
},
@@ -126,12 +134,17 @@ export const SelfServeConditionRules = {
} else if (objectType === 'task') {
const tasks = await SessionUser.objects.self_serve_tasks.get.all();
return tasks.map(t => ({ id: t.id, name: t.task }));
} else if (objectType === 'condition') {
const conditions = await SessionUser.objects.self_serve_conditions.get.all();
return conditions.map(c => ({ id: c.id, name: c.name }));
} else {
const questions = await SessionUser.objects.self_serve_questions.get.all();
const tasks = await SessionUser.objects.self_serve_tasks.get.all();
const conditions = await SessionUser.objects.self_serve_conditions.get.all();
return [
...questions.map(q => ({ id: q.id, name: `[Spørgsmål] ${q.question}` })),
...tasks.map(t => ({ id: t.id, name: `[Opgave] ${t.task}` }))
...tasks.map(t => ({ id: t.id, name: `[Opgave] ${t.task}` })),
...conditions.map(c => ({ id: c.id, name: `[Betingelse] ${c.name}` }))
];
}
}
@@ -49,6 +49,18 @@ const conditionId = route.query.condition_id;
</span>
<span>Tilføj opgaveregel</span>
</button>
<button
class="button is-primary"
@click="SessionUser.objects.self_serve_condition_rules.showCreateObjectForm({
condition_id: conditionId,
object_type: 'condition'
}, loadList)"
>
<span class="icon">
<i class="fas fa-filter"></i>
</span>
<span>Tilføj betingelsesregel</span>
</button>
<router-link :to="{ name: 'selfserveconditions', params: { departmentId: departmentId } }" class="button is-link is-light">
<span class="icon">
<i class="fas fa-filter"></i>