Add latitude and longitude columns to departments table with edit functionality.

This commit is contained in:
Jeppe Bundgaard
2025-08-26 16:49:06 +02:00
parent 9ccc0927c0
commit d34d6958cf
2 changed files with 46 additions and 0 deletions
@@ -36,6 +36,8 @@ const redirect = (path) => {
<th>{{ SessionUser.objects.departments.columns.name.label }}</th>
<th>{{ SessionUser.objects.departments.columns.description.label }}</th>
<th>{{ SessionUser.objects.departments.columns.economic_department_id.label }}</th>
<th>{{ SessionUser.objects.departments.columns.latitude.label }}</th>
<th>{{ SessionUser.objects.departments.columns.longitude.label }}</th>
<th>Handlinger</th>
</tr>
</thead>
@@ -61,6 +63,18 @@ const redirect = (path) => {
:edit-function="SessionUser.objects.departments.showEditObjectFieldForm"
:parse-function="SessionUser.objects.economic_departments.functions.getEconomicDepartmentName"
/>
<EditableTableColumn
:object="department"
:loadList="loadList"
column="latitude"
:edit-function="SessionUser.objects.departments.showEditObjectFieldForm"
/>
<EditableTableColumn
:object="department"
:loadList="loadList"
column="longitude"
:edit-function="SessionUser.objects.departments.showEditObjectFieldForm"
/>
<td>
<div class="buttons">
<button class="button is-small is-dark" @click="showEditDepartmentForm(department.id, department.name, department.description, department.economic_department_id)">Rediger</button>
@@ -94,6 +94,22 @@ export const getDepartmentName = async (id) => {
required: false
}
},
longitude: {
label: "Longitude",
type: "number",
sortable: true,
creation: {
required: false
}
},
latitude: {
label: "Latitude",
type: "number",
sortable: true,
creation: {
required: false
}
}
},
add: async (name, economic_department_id) => {
return ObjectsGlobal.add.object(
@@ -144,6 +160,22 @@ export const getDepartmentName = async (id) => {
"dimension",
parseInt(dimension)
)
},
longitude: async (id, longitude) => {
return ObjectsGlobal.set.column(
Departments.meta.endpoint,
id,
"longitude",
parseFloat(longitude)
)
},
latitude: async (id, latitude) => {
return ObjectsGlobal.set.column(
Departments.meta.endpoint,
id,
"latitude",
parseFloat(latitude)
)
}
},
get: {