Replace question_condition with condition_id across department_selfserve_questions logic, routes, OpenAPI spec, and related methods for improved consistency and clarity.

This commit is contained in:
Jeppe Bundgaard
2026-01-09 13:53:03 +01:00
parent d576a4741b
commit 97d2786ff1
3 changed files with 15 additions and 15 deletions
+3 -3
View File
@@ -1344,7 +1344,7 @@ paths:
type: string type: string
description: description:
type: string type: string
question_condition: condition_id:
type: integer type: integer
nullable: true nullable: true
order_priority: order_priority:
@@ -1391,7 +1391,7 @@ paths:
type: string type: string
description: description:
type: string type: string
question_condition: condition_id:
type: integer type: integer
nullable: true nullable: true
order_priority: order_priority:
@@ -4997,7 +4997,7 @@ components:
product: product:
type: integer type: integer
description: Product ID description: Product ID
question_condition: condition_id:
type: integer type: integer
description: Question condition object ID description: Question condition object ID
nullable: true nullable: true
@@ -16,7 +16,7 @@ class department_selfserve_questions_o extends db
public object_property $department; // The department id public object_property $department; // The department id
public object_property $lane; // The lane id public object_property $lane; // The lane id
public object_property $product; // The product id public object_property $product; // The product id
public object_property $question_condition; // The question condition object id (if applicable) public object_property $condition_id; // The question condition object id (if applicable)
public object_property $question; // The question text public object_property $question; // The question text
public object_property $description; // The question description public object_property $description; // The question description
public object_property $order_priority; // The order priority of the question (lower numbers are shown first) public object_property $order_priority; // The order priority of the question (lower numbers are shown first)
@@ -37,12 +37,12 @@ class department_selfserve_questions_o extends db
* @param int $product The product id * @param int $product The product id
* @param string $question The question text * @param string $question The question text
* @param string $description The question description * @param string $description The question description
* @param int|null $question_condition The question question_condition (if applicable) * @param int|null $condition_id The question condition_id (if applicable)
* @param int $order_priority The order priority of the question (lower numbers are shown first) * @param int $order_priority The order priority of the question (lower numbers are shown first)
* @return department_selfserve_questions_o * @return department_selfserve_questions_o
* @throws Exception If the object was not created successfully * @throws Exception If the object was not created successfully
*/ */
public function add(int $department, int $lane, int $product, string $question, string $description, int $question_condition = null, int $order_priority = 0): department_selfserve_questions_o public function add(int $department, int $lane, int $product, string $question, string $description, int $condition_id = null, int $order_priority = 0): department_selfserve_questions_o
{ {
global /** @var db $db */ global /** @var db $db */
$db; $db;
@@ -52,8 +52,8 @@ class department_selfserve_questions_o extends db
$product = (int)$product; $product = (int)$product;
$question = $db->escape_string($question); $question = $db->escape_string($question);
$description = $db->escape_string($description); $description = $db->escape_string($description);
if (!is_null($question_condition)) { if (!is_null($condition_id)) {
$question_condition = (int)$question_condition; $condition_id = (int)$condition_id;
} }
$order_priority = (int)$order_priority; $order_priority = (int)$order_priority;
// Add the object // Add the object
@@ -63,7 +63,7 @@ class department_selfserve_questions_o extends db
'product' => $product, 'product' => $product,
'question' => $question, 'question' => $question,
'description' => $description, 'description' => $description,
...(!is_null($question_condition) ? ['question_condition' => $question_condition] : []), // If the question_condition is null, it will be set to null in the database ...(!is_null($condition_id) ? ['condition_id' => $condition_id] : []), // If the condition_id is null, it will be set to null in the database
'order_priority' => $order_priority, 'order_priority' => $order_priority,
]); ]);
$this->id = $tmp_id; $this->id = $tmp_id;
@@ -77,7 +77,7 @@ class department_selfserve_questions_o extends db
$this->department = new object_property($this->table, $this->id, 'department', 'int', false); $this->department = new object_property($this->table, $this->id, 'department', 'int', false);
$this->lane = new object_property($this->table, $this->id, 'lane', 'int', false); $this->lane = new object_property($this->table, $this->id, 'lane', 'int', false);
$this->product = new object_property($this->table, $this->id, 'product', 'int', false); $this->product = new object_property($this->table, $this->id, 'product', 'int', false);
$this->question_condition = new object_property($this->table, $this->id, 'question_condition', 'int', false); $this->condition_id = new object_property($this->table, $this->id, 'condition_id', 'int', false);
$this->question = new object_property($this->table, $this->id, 'question', 'string', false); $this->question = new object_property($this->table, $this->id, 'question', 'string', false);
$this->description = new object_property($this->table, $this->id, 'description', 'string', false); $this->description = new object_property($this->table, $this->id, 'description', 'string', false);
$this->order_priority = new object_property($this->table, $this->id, 'order_priority', 'int', false); $this->order_priority = new object_property($this->table, $this->id, 'order_priority', 'int', false);
@@ -108,7 +108,7 @@ class department_selfserve_questions_o extends db
'department' => (int)$this->department->value(), 'department' => (int)$this->department->value(),
'lane' => (int)$this->lane->value(), 'lane' => (int)$this->lane->value(),
'product' => (int)$this->product->value(), 'product' => (int)$this->product->value(),
'question_condition' => is_null($this->question_condition->value()) ? null : (int)$this->question_condition->value(), 'condition_id' => is_null($this->condition_id->value()) ? null : (int)$this->condition_id->value(),
'question' => (string)$this->question->value(), 'question' => (string)$this->question->value(),
'description' => (string)$this->description->value(), 'description' => (string)$this->description->value(),
'order_priority' => (int)$this->order_priority->value(), 'order_priority' => (int)$this->order_priority->value(),
@@ -90,7 +90,7 @@ class departmentSelfserveQuestionsRoute
$product = (int)$response->getRequestParameter('product'); $product = (int)$response->getRequestParameter('product');
$question = (string)$response->getRequestParameter('question'); $question = (string)$response->getRequestParameter('question');
$description = (string)$response->getRequestParameter('description'); $description = (string)$response->getRequestParameter('description');
$question_condition = $response->isRequestParameterSet('question_condition') ? (int)$response->getRequestParameter('question_condition') : null; $condition_id = $response->isRequestParameterSet('condition_id') ? (int)$response->getRequestParameter('condition_id') : null;
$order_priority = (int)($response->getRequestParameter('order_priority') ?? 0); $order_priority = (int)($response->getRequestParameter('order_priority') ?? 0);
if (!$department || !$lane || !$product || !$question || !$description) { if (!$department || !$lane || !$product || !$question || !$description) {
@@ -109,7 +109,7 @@ class departmentSelfserveQuestionsRoute
$product, $product,
$question, $question,
$description, $description,
$question_condition, $condition_id,
$order_priority $order_priority
); );
(new logs_o())->add('department_selfserve_questions', 'global', 1, $user->id, 'ADD_QUESTION', 'User added a department self-serve question: ' . $question); (new logs_o())->add('department_selfserve_questions', 'global', 1, $user->id, 'ADD_QUESTION', 'User added a department self-serve question: ' . $question);
@@ -165,8 +165,8 @@ class departmentSelfserveQuestionsRoute
if (self::isParametersSet(['description'])) { if (self::isParametersSet(['description'])) {
$question_o->description->set((string)self::getParameter('description')); $question_o->description->set((string)self::getParameter('description'));
} }
if (self::isParametersSet(['question_condition'])) { if (self::isParametersSet(['condition_id'])) {
$question_o->question_condition->set(self::getParameter('question_condition') === null ? null : (int)self::getParameter('question_condition')); $question_o->condition_id->set(self::getParameter('condition_id') === null ? null : (int)self::getParameter('condition_id'));
} }
if (self::isParametersSet(['order_priority'])) { if (self::isParametersSet(['order_priority'])) {
$question_o->order_priority->set((int)self::getParameter('order_priority')); $question_o->order_priority->set((int)self::getParameter('order_priority'));