Skip to content

Commit

Permalink
App Datenmanagement: Erweiterungen Batch-Zuweisungen
Browse files Browse the repository at this point in the history
  • Loading branch information
gdmhrogut committed Nov 10, 2023
1 parent b53d5d3 commit cb9f624
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"createFilterObject": true,
"currMap": true,
"customMapFilters": true,
"disableActionsControls": true,
"enableActionsControls": true,
"enableAddressReferenceButton": true,
"enableMapLocate": true,
"featureGeometry": true,
Expand Down
73 changes: 72 additions & 1 deletion datenmanagement/models/models_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,12 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'field': 'bewirtschafter',
'type': 'foreignkey'
},
{
'action_name': 'hydranten-feuerloeschgeeignet',
'action_title': 'ausgewählten Datensätzen feuerlöschgeeignet (ja/nein) direkt zuweisen',
'field': 'feuerloeschgeeignet',
'type': 'boolean'
},
{
'action_name': 'hydranten-betriebszeit',
'action_title': 'ausgewählten Datensätzen Betriebszeit direkt zuweisen',
Expand Down Expand Up @@ -3724,6 +3730,32 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'verbund': 'verbund',
'betriebsart': 'betriebsart'
}
list_actions_assign = [
{
'action_name': 'ladestationen_elektrofahrzeuge-geplant',
'action_title': 'ausgewählten Datensätzen geplant (ja/nein) direkt zuweisen',
'field': 'geplant',
'type': 'boolean'
},
{
'action_name': 'ladestationen_elektrofahrzeuge-betreiber',
'action_title': 'ausgewählten Datensätzen Betreiber direkt zuweisen',
'field': 'betreiber',
'type': 'foreignkey'
},
{
'action_name': 'ladestationen_elektrofahrzeuge-verbund',
'action_title': 'ausgewählten Datensätzen Verbund direkt zuweisen',
'field': 'verbund',
'type': 'foreignkey'
},
{
'action_name': 'ladestationen_elektrofahrzeuge-betriebsart',
'action_title': 'ausgewählten Datensätzen Betriebsart direkt zuweisen',
'field': 'betriebsart',
'type': 'foreignkey'
}
]
map_feature_tooltip_field = 'bezeichnung'
map_filter_fields = {
'geplant': 'geplant?',
Expand Down Expand Up @@ -3906,6 +3938,21 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'art': 'art',
'gebaeudeart': 'bezeichnung'
}
list_actions_assign = [
{
'action_name': 'meldedienst_punkthaft-gebaeudeart',
'action_title': 'ausgewählten Datensätzen Gebäudeart direkt zuweisen',
'field': 'gebaeudeart',
'type': 'foreignkey'
},
{
'action_name': 'meldedienst_punkthaft-datum',
'action_title': 'ausgewählten Datensätzen Datum direkt zuweisen',
'field': 'datum',
'type': 'date',
'value_required': True
}
]
heavy_load_limit = 600
map_feature_tooltip_field = 'art'
map_filter_fields = {
Expand Down Expand Up @@ -4385,6 +4432,14 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'hersteller': 'bezeichnung',
'typ': 'typ'
}
list_actions_assign = [
{
'action_name': 'poller-status',
'action_title': 'ausgewählten Datensätzen Status direkt zuweisen',
'field': 'status',
'type': 'foreignkey'
}
]
map_feature_tooltip_field = 'bezeichnung'
map_filter_fields = {
'art': 'Art',
Expand Down Expand Up @@ -4576,6 +4631,14 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'adresse': 'adresse',
'traeger': 'bezeichnung'
}
list_actions_assign = [
{
'action_name': 'rettungswachen-traeger',
'action_title': 'ausgewählten Datensätzen Träger direkt zuweisen',
'field': 'traeger',
'type': 'foreignkey'
}
]
map_feature_tooltip_field = 'bezeichnung'
map_filter_fields = {
'bezeichnung': 'Bezeichnung',
Expand Down Expand Up @@ -4771,6 +4834,7 @@ class Meta(SimpleModel.Meta):
class BasemodelMeta(SimpleModel.BasemodelMeta):
description = 'Schutzzäune gegen Tierseuchen in der Hanse- und Universitätsstadt Rostock'
as_overlay = True
readonly_fields = ['laenge']
geometry_type = 'MultiLineString'
list_fields = {
'aktiv': 'aktiv?',
Expand All @@ -4783,7 +4847,14 @@ class BasemodelMeta(SimpleModel.BasemodelMeta):
'tierseuche': 'bezeichnung',
'zustand': 'zustand'
}
readonly_fields = ['laenge']
list_actions_assign = [
{
'action_name': 'schutzzaeune_tierseuchen-zustand',
'action_title': 'ausgewählten Datensätzen Zustand direkt zuweisen',
'field': 'zustand',
'type': 'foreignkey'
}
]
map_feature_tooltip_field = 'zustand'
map_filter_fields = {
'tierseuche': 'Tierseuche',
Expand Down
32 changes: 28 additions & 4 deletions datenmanagement/static/datenmanagement/js/list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* @function
* @name disableActionsControls
*
* disables action controls
*
*/
function disableActionsControls() {
$('#action-count').text('kein Datensatz ausgewählt');
$('#action-select').prop('selectedIndex', 0);
$('#action-select').prop('disabled', true);
$('#action-button').prop('disabled', true);
}

/**
* @function
* @name downloadFile
Expand All @@ -20,6 +34,18 @@ function downloadFile(file, fileName = 'file') {
a.remove();
}

/**
* @function
* @name enableActionsControls
*
* enables action controls
*
*/
function enableActionsControls() {
$('#action-select').prop('disabled', false);
$('#action-button').prop('disabled', false);
}

/**
* @function
* @name formatData
Expand Down Expand Up @@ -171,15 +197,13 @@ function initDataTable(dataUrl, languageUrl, numberOfColumns) {
* @function
* @name reloadDataTable
*
* reloads data table and resets action controls
* reloads data table and disables action controls
*
* @param {Object} dataTable - data table
*/
function reloadDataTable(dataTable) {
setTimeout(function() {
dataTable.ajax.reload();
$('#action-count').text('kein Datensatz ausgewählt');
$('#action-select').prop('selectedIndex', 0);
$('#action-button').prop('disabled', true);
disableActionsControls();
}, 1000);
}
10 changes: 4 additions & 6 deletions datenmanagement/templates/datenmanagement/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h4 class="mt-3">
<div class="d-grid mt-2 mb-3">
<div class="input-group">
<label hidden for="action-select" class="form-label"></label>
<select class="form-select" id="action-select" name="action">
<select class="form-select" id="action-select" name="action" disabled>
<option selected>Aktion wählen…</option>
{% for action_assign in actions_assign %}
<option value="assign-selected-{{ action_assign.action_name }}">{{ action_assign.action_title }}</option>
Expand Down Expand Up @@ -232,15 +232,13 @@ <h4 class="mt-3">
let actionCheckboxes = $('.action-checkbox').filter(':checked');
// enable or disable button for executing selected action
if (actionCheckboxes.length > 0)
$('#action-button').prop('disabled', false);
enableActionsControls();
else
$('#action-button').prop('disabled', true);
disableActionsControls();
// adjust information texts accordingly
if (actionCheckboxes.length === 1)
$('#action-count').text('1 Datensatz ausgewählt');
else if (actionCheckboxes.length === 0)
$('#action-count').text('kein Datensatz ausgewählt');
else
else if (actionCheckboxes.length > 1)
$('#action-count').text(actionCheckboxes.length + ' Datensätze ausgewählt');
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ <h5 id="confirmexport-modal-title" class="modal-title">Wert für Direktzuweisung
</div>
<div id="action-assign-{{ modal_name }}-modal-body" class="modal-body">
<form class="form needs-validation text-center" action="">
{% if type == 'foreignkey' %}
{% if type == 'boolean' or type == 'foreignkey' %}
<label hidden for="action-assign-{{ modal_name }}-modal-input-field" class="form-label"></label>
<select class="form-select" id="action-assign-{{ modal_name }}-modal-input-field" name="{{ field_name }}">
{% for select_value in select_values %}
<option value{% if select_value.pk %}="{{ select_value.pk }}"{% endif %}>{% if select_value.text %}{{ select_value.text }}{% else %}---------{% endif %}</option>
<option value{% if select_value.value %}="{{ select_value.value }}"{% endif %}>{% if select_value.text %}{{ select_value.text }}{% else %}{% if type == 'boolean' %}unbekannt{% else %}---------{% endif %}{% endif %}</option>
{% endfor %}
</select>
{% else %}
Expand Down
Loading

0 comments on commit cb9f624

Please sign in to comment.