Improved checkboxes and file input on import dialog.

This commit is contained in:
Jan Böhmer 2019-04-13 18:24:53 +02:00
parent 68aa750e00
commit fbfb0269d3
9 changed files with 72 additions and 16 deletions

View file

@ -614,7 +614,7 @@ BS 4 overrides
}
}
label:not(.form-check-label) {
label:not(.form-check-label, custom-control-label) {
font-weight: bold;
}

View file

@ -26,6 +26,8 @@ import 'awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css'
import "patternfly-bootstrap-treeview/src/css/bootstrap-treeview.css"
import "bootstrap-fileinput/css/fileinput.css"
//require( 'jszip' );
//#require( 'pdfmake' );
require( 'datatables.net-bs4' );
@ -42,7 +44,9 @@ require('jquery-form');
//Define jquery globally
window.$ = window.jQuery = require("jquery");
require('patternfly-bootstrap-treeview/src/js/bootstrap-treeview')
require('patternfly-bootstrap-treeview/src/js/bootstrap-treeview');
require('bootstrap-fileinput');
require('./datatables.js');

View file

@ -212,6 +212,11 @@ $(document).on("ajaxUI:start ajaxUI:reload", function() {
});
});
//Re initialize fileinputs on reload
$(document).on("ajaxUI:reload", function () {
//@ts-ignore
$(".file").fileinput();
});
/**
* Register the button, to jump to the top of the page.

View file

@ -2,7 +2,7 @@ twig:
default_path: '%kernel.project_dir%/templates'
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes: ['bootstrap_4_horizontal_layout.html.twig']
form_themes: ['bootstrap_4_horizontal_layout.html.twig', 'Form/extendedBootstrap4_layout.html.twig' ]
globals:
partdb_title: '%partdb_title%'

View file

@ -25,6 +25,7 @@
"@types/js-cookie": "^2.2.1",
"awesome-bootstrap-checkbox": "^1.0.1",
"bootbox": "^5.1.0",
"bootstrap-fileinput": "^5.0.1",
"bootstrap-select": "^1.13.8",
"datatables.net-bs4": "^1.10.19",
"datatables.net-buttons-bs4": "^1.5.4",

View file

@ -51,13 +51,17 @@ class ImportType extends AbstractType
$builder
->add('format', ChoiceType::class, ['choices' =>
['JSON' => 'json', 'XML' => 'xml','CSV'=>'csv' ,'YAML' => 'yaml']])
->add('csv_separator', TextType::class, ['data' => ';'])
['JSON' => 'json', 'XML' => 'xml','CSV'=>'csv' ,'YAML' => 'yaml'], 'label' => 'export.format'])
->add('csv_separator', TextType::class, ['data' => ';', 'label' => 'import.csv_separator'])
->add('parent', EntityType::class, ['class' => $data['entity_class'], 'choice_label' => 'full_path',
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false, 'label' => 'parent.label',
])
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false])
->add('file', FileType::class)
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false, 'label' => 'parent.label'])
->add('file', FileType::class, ['label' => 'import.file',
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false']])
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false,
'label' => 'import.preserve_children', 'label_attr'=> ['class' => 'checkbox-custom']])
->add('abort_on_validation_error', CheckboxType::class, ['data' => true, 'required' => false,
'label' => 'import.abort_on_validation', 'help'=> 'import.abort_on_validation.help', 'label_attr'=> ['class' => 'checkbox-custom']])
//Buttons
->add('import', SubmitType::class, ['label' => 'import.btn']);

View file

@ -129,9 +129,9 @@
<div class="form-row mt-2">
<div class="offset-2 col">
<div class="form-check abc-checkbox">
<input class="form-check-input" name="include_children" id="include_children" type="checkbox" checked>
<label class="form-check-label" for="include_children">
<div class="custom-control custom-checkbox">
<input class="form-check-input custom-control-input" name="include_children" id="include_children" type="checkbox" checked>
<label class="form-check-label custom-control-label" for="include_children">
{% trans %}export.include_children{% endtrans %}
</label>
</div>
@ -182,9 +182,9 @@
<div class="form-row mt-2">
<div class="offset-2 col">
<div class="form-check abc-checkbox">
<input class="form-check-input" name="include_children" id="include_children" type="checkbox" checked>
<label class="form-check-label" for="include_children">
<div class="custom-control custom-checkbox">
<input class="form-check-input custom-control-input" name="include_children" id="include_children" type="checkbox" checked>
<label class="form-check-label custom-control-label" for="include_children">
{% trans %}export.include_children{% endtrans %}
</label>
</div>

View file

@ -0,0 +1,29 @@
{% extends 'bootstrap_4_horizontal_layout.html.twig' %}
{% block file_widget -%}
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
{% endblock %}
{% block checkbox_widget %}
{# {% set parent_label_class=(parent_label_class|default(label_attr.class|default(''))) ~ ' checkbox-custom' %} #}
{{ parent() }}
{% endblock %}
{#
{% block checkbox_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{%- if 'checkbox-custom' in parent_label_class -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
<div class="custom-control custom-checkbox{{ 'checkbox-inline' in parent_label_class ? ' custom-control-inline' }}">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{%- else -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%}
<div class="form-check abc-checkbox {{ 'checkbox-inline' in parent_label_class ? ' form-check-inline' }}">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{%- endif -%}
{%- endblock checkbox_widget %}
#}

View file

@ -1244,6 +1244,14 @@ bootbox@^5.1.0:
bootstrap ">=3.0.0"
jquery ">=1.9.1"
bootstrap-fileinput@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/bootstrap-fileinput/-/bootstrap-fileinput-5.0.1.tgz#4762fb736cef0a21ec93e4f95c43d93626238e0d"
integrity sha512-JLOVCcs7Dw0u+bWe3MwkgSz++8lolUJjgnKQ19vf8disS6Zmxmzp771dFjmRDCZDuGDPG5knGCOohqLDPjUQ9Q==
dependencies:
bootstrap ">= 3.4.1"
jquery ">= 1.9.0"
bootstrap-select@^1.13.8:
version "1.13.8"
resolved "https://registry.yarnpkg.com/bootstrap-select/-/bootstrap-select-1.13.8.tgz#c47047410511f6d8a8917a7738d1b03c95717d5d"
@ -1254,7 +1262,7 @@ bootstrap@3.4.x:
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.4.1.tgz#c3a347d419e289ad11f4033e3c4132b87c081d72"
integrity sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==
bootstrap@>=3.0.0, bootstrap@^4.3.1:
"bootstrap@>= 3.4.1", bootstrap@>=3.0.0, bootstrap@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac"
integrity sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==
@ -3680,6 +3688,11 @@ jquery-form@^4.2.2:
dependencies:
jquery ">=1.7.2"
"jquery@>= 1.9.0":
version "3.4.0"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.0.tgz#8de513fa0fa4b2c7d2e48a530e26f0596936efdf"
integrity sha512-ggRCXln9zEqv6OqAGXFEcshF5dSBvCkzj6Gm2gzuR5fWawaX8t7cxKVkkygKODrDAzKdoYw3l/e3pm3vlT4IbQ==
"jquery@>= 2.1.x", jquery@>=1.7, jquery@>=1.7.2, jquery@>=1.9.1, jquery@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"