Add order_priority field to departments

- Introduce `order_priority` property in `departments_o.php`.
- Update `departmentsRoute.php` to handle `order_priority` in input and output.
- Adjust object initialization and serialization for the new field.
This commit is contained in:
Jeppe Bundgaard
2026-01-26 13:53:25 +01:00
parent 16f041600c
commit 9b9713ecc1
2 changed files with 8 additions and 1 deletions
@@ -23,6 +23,7 @@ class departments_o extends db
public object_property $branding; // The branding of the department public object_property $branding; // The branding of the department
public object_property $longitude; // The longitude of the department (Can be null) public object_property $longitude; // The longitude of the department (Can be null)
public object_property $latitude; // The latitude of the department (Can be null) public object_property $latitude; // The latitude of the department (Can be null)
public object_property $order_priority; // The order priority of the department (Lower number = higher priority)
public object_property $created_at; public object_property $created_at;
public object_property $updated_at; public object_property $updated_at;
@@ -91,6 +92,7 @@ class departments_o extends db
$this->visible = new object_property($this->table, $this->id, 'visible', 'int', false); $this->visible = new object_property($this->table, $this->id, 'visible', 'int', false);
$this->longitude = new object_property($this->table, $this->id, 'longitude', 'float', false); $this->longitude = new object_property($this->table, $this->id, 'longitude', 'float', false);
$this->latitude = new object_property($this->table, $this->id, 'latitude', 'float', false); $this->latitude = new object_property($this->table, $this->id, 'latitude', 'float', false);
$this->order_priority = new object_property($this->table, $this->id, 'order_priority', 'int', false);
$this->created_at = new object_property($this->table, $this->id, 'created_at', 'string', false); $this->created_at = new object_property($this->table, $this->id, 'created_at', 'string', false);
$this->updated_at = new object_property($this->table, $this->id, 'updated_at', 'string', false); $this->updated_at = new object_property($this->table, $this->id, 'updated_at', 'string', false);
} }
@@ -311,6 +313,7 @@ class departments_o extends db
'branding' => (int)$this->branding->value(), 'branding' => (int)$this->branding->value(),
'longitude' => (float)$this->longitude->value(), 'longitude' => (float)$this->longitude->value(),
'latitude' => (float)$this->latitude->value(), 'latitude' => (float)$this->latitude->value(),
'order_priority' => (int)$this->order_priority->value(),
'created_at' => (string)$this->created_at->value(), 'created_at' => (string)$this->created_at->value(),
'updated_at' => (string)$this->updated_at->value(), 'updated_at' => (string)$this->updated_at->value(),
]; ];
@@ -62,7 +62,8 @@ class departmentsRoute
'dimension' => (int)$department['dimension'], 'dimension' => (int)$department['dimension'],
'branding' => (int)$department['branding'], 'branding' => (int)$department['branding'],
'longitude' => (float)$department['longitude'], 'longitude' => (float)$department['longitude'],
'latitude' => (float)$department['latitude'] 'latitude' => (float)$department['latitude'],
'order_priority' => (int)$department['order_priority'],
]; ];
// If the user has the permission to view the slack webhook, add it to the response // If the user has the permission to view the slack webhook, add it to the response
if ($user->hasPermission('view_slack_webhook')) { if ($user->hasPermission('view_slack_webhook')) {
@@ -154,6 +155,9 @@ class departmentsRoute
if (self::isParametersSet(['longitude'])) { if (self::isParametersSet(['longitude'])) {
$department->longitude->set(self::getParameter('longitude')); $department->longitude->set(self::getParameter('longitude'));
} }
if (self::isParametersSet(['order_priority'])) {
$department->order_priority->set((int)self::getParameter('order_priority'));
}
// Log the incident // Log the incident
(new logs_o())->add('departments', (int)self::getParameter('id'), 1, $user->id, 'EDIT_DEPARTMENT', 'Successfully edited a department'); (new logs_o())->add('departments', (int)self::getParameter('id'), 1, $user->id, 'EDIT_DEPARTMENT', 'Successfully edited a department');
// Return a success message // Return a success message