support custom fields in timesheet batch update (#2043)

This commit is contained in:
Kevin Papst
2020-10-21 17:10:11 +02:00
committed by GitHub
parent 167a826f50
commit 6ed7ee76e7
25 changed files with 392 additions and 105 deletions

View File

@@ -21,18 +21,23 @@
{% endblock daterange_widget %}
{% block datetime_widget -%}
{%- if widget == 'single_text' -%}
<div class="input-group">
<div class="input-group-addon">
<a href="#" onclick="$('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).trigger('change')"><i class="fa fa-calendar-alt"></i></a>
</div>
{{ block('form_widget_simple') }}
<div class="input-group">
<div class="input-group-addon">
<a href="#" onclick="if (!$('#{{ id }}').is(':disabled')) { $('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
</div>
{%- else -%}
{{ block('form_widget_simple') }}
{%- endif -%}
</div>
{%- endblock datetime_widget %}
{% block date_widget -%}
<div class="input-group">
<div class="input-group-addon">
<a href="#" onclick="if (!$('#{{ id }}').is(':disabled')) { $('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
</div>
{{ block('form_widget_simple') }}
</div>
{%- endblock date_widget %}
{% block text_widget -%}
{% if icon is not empty %}
<div class="input-group">

View File

@@ -8,6 +8,120 @@
'form': form,
} %}
{% embed formEditTemplate with formOptions %}
{% block form_body %}
<fieldset>
<div class="row">
<div class="col-md-4">
{{ form_row(form.customer) }}
</div>
<div class="col-md-4">
{{ form_row(form.project) }}
</div>
<div class="col-md-4">
{{ form_row(form.activity) }}
</div>
</div>
</fieldset>
<fieldset>
{{ form_row(form.replaceTags) }}
{{ form_row(form.tags) }}
</fieldset>
{% if form.user is defined %}
<fieldset>
{{ form_row(form.user) }}
</fieldset>
{% endif %}
{% if form.exported is defined %}
<fieldset>
{{ form_row(form.exported) }}
</fieldset>
{% endif %}
{% if form.recalculateRates is defined %}
<fieldset>
{{ form_row(form.recalculateRates) }}
<div class="row">
<div class="col-md-6">
{{ form_row(form.fixedRate) }}
</div>
<div class="col-md-6">
{{ form_row(form.hourlyRate) }}
</div>
</div>
</fieldset>
{% endif %}
{% if form.metaFields is defined %}
<fieldset>
<div class="row">
<div class="col-md-6">
{{ form_row(form.updateMeta) }}
</div>
<div class="col-md-6">
{{ form_row(form.metaFields) }}
</div>
</div>
</fieldset>
{% endif %}
{% endblock %}
{% endembed %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
window.addEventListener('load', function() {
{% if form.recalculateRates is defined %}
document.getElementById('{{ form.recalculateRates.vars.id }}').onchange = function() {
if (this.checked) {
document.getElementById('{{ form.fixedRate.vars.id }}').setAttribute('disabled', 'disabled');
document.getElementById('{{ form.hourlyRate.vars.id }}').setAttribute('disabled', 'disabled');
} else {
document.getElementById('{{ form.fixedRate.vars.id }}').removeAttribute('disabled');
document.getElementById('{{ form.hourlyRate.vars.id }}').removeAttribute('disabled');
}
};
{% endif %}
{% if form.metaFields is defined %}
var allElements = document.getElementsByName('{{ form.vars.name }}')[0].elements;
for (var i = 0; i < allElements.length; ++i) {
var el = allElements[i];
var elAttr = el.getAttribute('name');
if (elAttr === null) {
continue;
}
if (elAttr.indexOf('{{ form.metaFields.vars.full_name }}') !== -1) {
{# disable all custom fields, each one has to be activated before it can be used #}
el.setAttribute('disabled', 'disabled');
} else if (elAttr.indexOf('{{ form.updateMeta.vars.full_name }}') !== -1) {
el.checked = false;
el.onclick = function() {
var searchElements = document.getElementsByName('{{ form.vars.name }}')[0].elements;
var metaCheckbox = this;
var metaName = metaCheckbox.value;
for (var s = 0; s < searchElements.length; ++s) {
var current = searchElements[s];
var currentAttr = current.getAttribute('name');
if (currentAttr === null) {
continue;
}
if (currentAttr.indexOf('{{ form.metaFields.vars.full_name }}') === -1) {
continue;
}
if (current.dataset.name === undefined || current.dataset.name !== metaName) {
continue;
}
if (metaCheckbox.checked) {
current.removeAttribute('disabled');
} else {
current.setAttribute('disabled', 'disabled');
}
}
};
}
}
{% endif %}
});
</script>
{% endblock %}