fix: remove and replace old form functions

This commit is contained in:
James Cole 2023-06-04 10:09:45 +02:00
parent a4f9a6fd42
commit 0438fb5a2e
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
15 changed files with 40 additions and 230 deletions

View File

@ -9,7 +9,8 @@
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
</script>
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal" enctype="multipart/form-data">
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal"
enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="objectType" value="{{ objectType }}"/>
<input type="hidden" name="active" value="1"/>
@ -58,7 +59,6 @@
{# only correct way to do active checkbox #}
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
{{ ExpandedForm.location('location', null, {locations: locations}) }}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>
</div>
@ -89,13 +89,16 @@
var iOwe = '{{ 'i_owe_amount'|_|escape('js') }}';
</script>
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"
nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/accounts/create.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
{% block styles %}
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}">
{% endblock %}

View File

@ -73,7 +73,6 @@
{{ ExpandedForm.checkbox('active', 1) }}
{# only correct way to do active checkbox #}
{{ ExpandedForm.location('location', null, {locations: locations}) }}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>

View File

@ -1,7 +1,7 @@
<div class="{{ classes }}" id="{{ name }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('number', name, value, options) }}
{{ Html.input('number', name, value).class('form-control').attribute('step','any').attribute('autocomplete','off').attribute('spellcheck','false') }}
{% include 'form.help' %}
{% include 'form.feedback' %}
</div>

View File

@ -1,24 +1 @@
<div class="input-group">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu">
{% for currency in currencies %}
<li>
<a href="#"
class="currency-option"
data-id="{{ currency.id }}"
data-name="{{ name }}"
data-currency="{{ currency.code }}"
data-symbol="{{ currency.symbol|raw }}">{{ currency.name }}</a></li>
{% endfor %}
</ul>
</div>
{{ Form.input('number', name, value, options) }}
</div>
<input type="hidden" name="amount_currency_id_{{ name }}" value="{{ defaultCurrency.id }}"/>
TODO REPLACE ME

View File

@ -1,33 +1 @@
<div class="{{ classes }}" id="{{ name }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu">
{% for currency in currencies %}
<li>
<a href="#"
class="currency-option"
data-id="{{ currency.id }}"
data-name="{{ name }}"
data-currency="{{ currency.code }}"
data-symbol="{{ currency.symbol|raw }}">{{ currency.name }}</a></li>
{% endfor %}
</ul>
</div>
{{ Form.input('number', name, value, options) }}
</div>
{% include 'form.feedback' %}
</div>
<!-- Going to put in this value: {{ defaultCurrency.id }} -->
<input type="hidden" name="amount_currency_id_{{ name }}" value="{{ defaultCurrency.id }}" data-backup="{{ defaultCurrency.id }}"/>
</div>
TODO REPLACE ME

View File

@ -3,14 +3,14 @@
<div class="col-sm-8">
{% for groupName, accounts in grouped %}
<strong>{{ groupName }}</strong><br />
<strong>{{ groupName }}</strong><br/>
{% for id, account in accounts %}
<div class="checkbox" style="margin-left:2em;">
<label>
{% if account in selected or (selected|length == 0 and options.select_all == true) %}
{{ Form.checkbox(name~'[]', id, true, options) }}
{{ Html.checkbox(name~'[]',true).id(id) }}
{% else %}
{{ Form.checkbox(name~'[]', id, false, options) }}
{{ Form.checkbox(name~'[]',false).id(id) }}
{% endif %}
{{ account|escape }}
</label>

View File

@ -1,33 +1 @@
<div class="{{ classes }}" id="{{ name }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu">
{% for currency in currencies %}
<li>
<a href="#"
class="currency-option"
data-id="{{ currency.id }}"
data-name="{{ name }}"
data-currency="{{ currency.code }}"
data-symbol="{{ currency.symbol|raw }}">{{ currency.name }}</a></li>
{% endfor %}
</ul>
</div>
{{ Form.input('number', name, value, options) }}
</div>
{% include 'form.feedback' %}
</div>
<input type="hidden" name="amount_currency_id_{{ name }}" value="{{ defaultCurrency.id }}"/>
</div>
TODO REMOVE ME

View File

@ -10,7 +10,7 @@
<div class="{% if options.small %}col-sm-4{% else %}col-sm-8{% endif %}">
<div class="checkbox">
<label>
{{ Form.checkbox(name, value, options.checked, options) }}
{{ Html.checkbox(name, options.checked, value) }}
</label>
</div>
{% include 'form.help' %}

View File

@ -6,7 +6,7 @@
<div class="input-group-addon">
<span class="fa fa-calendar"></span>
</div>
{{ Form.input('date', name, value, options) }}
{{ Html.input('date', name, value).class('form-control').attribute('autocomplete','off').attribute('spellcheck','false') }}
</div>
{% include 'form.help' %}
{% include 'form.feedback' %}

View File

@ -2,7 +2,7 @@
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.file(name, options) }}
{{ Html.input('file',name).attribute('multiple','multiple').class('form-control') }}
{% include 'form.help' %}
{% include 'form.feedback' %}
</div>

View File

@ -2,7 +2,7 @@
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('number', name, value, options) }}
{{ Html.input('number', name, value).attribute('step',options.step).attribute('autocomplete','off').attribute('spellcheck', 'false').class('form-control') }}
{% include 'form.help' %}
{% include 'form.feedback' %}
</div>

View File

@ -1,114 +1 @@
<div class="{{ classes }}" id="{{ name }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{% if config('firefly.mapbox_api_key') == '' %}
<p class="text-danger">
{{ trans('firefly.mapbox_api_key')|raw }}
</p>
{% else %}
<div id="{{ name }}_map" style="width:100%;height:300px;"></div>
<div id="{{ name }}_map_canvas"></div>
<p class="help-block">
{{ 'press_object_location'|_ }}
<button class="btn btn-default btn-xs" type="button" id="{{ name }}_clear_location">{{ 'clear_location'|_ }}</button>
</p>
{# latitude #}
<input type="hidden" name="{{ name }}_latitude" value="{{ options.locations[name].latitude|default('52.3167') }}"/>
{# longitude #}
<input type="hidden" name="{{ name }}_longitude" value="{{ options.locations[name].longitude|default('5.5500') }}"/>
{# zoomlevel #}
<input type="hidden" name="{{ name }}_zoom_level" value="{{ options.locations[name].zoom_level|default('6') }}"/>
{# has location set? #}
<input type="hidden" name="{{ name }}_has_location" value="{{ options.locations[name].has_location|default('false') }}"/>
{% include 'form.feedback' %}
{% endif %}
</div>
</div>
{% if config('firefly.mapbox_api_key') != '' %}
{% set latitudevar = name~'_latitude' %}
{% set longitudevar = name~'_longitude' %}
{% set zoomlevelvar = name~'_zoom_level' %}
{% set haslocationvar = name~'_has_location' %}
{% set clearvar = name~'_clear_location' %}
<script type="text/javascript" nonce="{{ JS_NONCE }}">
var mymap;
var marker;
if (typeof locations.{{ name }}.latitude === 'undefined') {
locations.{{ name }}.latitude = '52.3167';
}
if (typeof locations.{{ name }}.longitude === 'undefined') {
locations.{{ name }}.longitude = '5.5500';
}
if (typeof locations.{{ name }}.zoom_level === 'undefined') {
locations.{{ name }}.zoom_level = '6';
}
if (typeof mapboxToken === 'undefined') {
var mapboxToken = 'invalid';
}
window.onload = function () {
document.getElementById('{{ clearvar }}').addEventListener('click', function () {
if (typeof marker !== 'undefined') {
marker.remove();
$('input[name="{{ haslocationvar }}"]').val('false');
$('input[name="{{ latitudevar }}"]').val('');
$('input[name="{{ longitudevar }}"]').val('');
$('input[name="{{ zoomlevelvar }}"]').val('');
}
});
};
// set location thing:
function setObjectLocation(e) {
if (typeof e.latlng !== 'undefined') {
console.log('Set object location: lat(' + e.latlng.lat + '), long(' + e.latlng.lng + '), zoom (' + mymap.getZoom() + ')');
$('input[name="{{ latitudevar }}"]').val(e.latlng.lat);
$('input[name="{{ longitudevar }}"]').val(e.latlng.lng);
$('input[name="{{ haslocationvar }}"]').val('true');
}
if (typeof e.latlng === 'undefined') {
console.log('Set object zoom level to ' + mymap.getZoom());
}
$('input[name="{{ zoomlevelvar }}"]').val(mymap.getZoom());
// remove existing marker:
if (typeof marker !== 'undefined' && typeof e.latlng !== 'undefined') {
marker.remove();
}
if (typeof e.latlng !== 'undefined') {
// new marker
marker = L.marker({lat: e.latlng.lat, lng: e.latlng.lng}).addTo(mymap);
}
}
document.addEventListener("DOMContentLoaded", function () {
"use strict";
// make map:
mymap = L.map('{{ name }}_map').setView({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}, locations.{{ name }}.zoom_level);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: mapboxToken
}).addTo(mymap);
mymap.on('contextmenu', setObjectLocation);
mymap.on('zoomend', setObjectLocation);
// add marker
if (typeof locations.{{ name }}.has_location !== 'undefined' && locations.{{ name }}.has_location === true) {
marker = L.marker({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}).addTo(mymap);
}
});
</script>
{% endif %}
TODO REMOVE ME

View File

@ -6,7 +6,8 @@
{% block content %}
<form method="POST" action="{{ route('rule-groups.execute', ruleGroup.id) }}" accept-charset="UTF-8" class="form-horizontal" id="execute-rule-group">
<form method="POST" action="{{ route('rule-groups.execute', ruleGroup.id) }}" accept-charset="UTF-8"
class="form-horizontal" id="execute-rule-group">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<div class="row">
@ -31,7 +32,8 @@
</div>
</div>
<div class="box-footer">
<input type="submit" name="submit" value="{{ 'execute'|_ }}" id="do-execute-button" class="btn btn-success pull-right"/>
<input type="submit" name="submit" value="{{ 'execute'|_ }}" id="do-execute-button"
class="btn btn-success pull-right"/>
</div>
</div>
</div>
@ -39,12 +41,16 @@
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"
nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/rules/select-transactions.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/rules/select-transactions.js?v={{ FF_VERSION }}"
nonce="{{ JS_NONCE }}"></script>
{% endblock %}
{% block styles %}
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
{% endblock %}

View File

@ -10,7 +10,8 @@
var locations = {{ locations|json_encode|raw }};
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
</script>
<form method="POST" action="{{ route('tags.store') }}" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
<form method="POST" action="{{ route('tags.store') }}" accept-charset="UTF-8" class="form-horizontal" id="store"
enctype="multipart/form-data">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-12">
@ -33,7 +34,6 @@
<div class="box-body">
{{ ExpandedForm.date('date') }}
{{ ExpandedForm.textarea('description') }}
{{ ExpandedForm.location('location', null, {locations: locations}) }}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>
</div>
@ -62,12 +62,15 @@
{% endblock %}
{% block scripts %}
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"
nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script src="v1/js/ff/tags/create-edit.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet"
media="all" nonce="{{ JS_NONCE }}">
{% endblock %}

View File

@ -38,7 +38,6 @@
<div class="box-body">
{{ ExpandedForm.date('date', tag.date.format('Y-m-d')) }}
{{ ExpandedForm.textarea('description', tag.description) }}
{{ ExpandedForm.location('location', null, {locations: locations}) }}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>
</div>