mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Initialize selectpicker via stimulus controller.
This commit is contained in:
parent
f1ea25cad2
commit
f276c436ae
16 changed files with 31 additions and 32 deletions
12
assets/controllers/elements/selectpicker_controller.js
Normal file
12
assets/controllers/elements/selectpicker_controller.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import {Controller} from "@hotwired/stimulus";
|
||||||
|
import "bootstrap-select";
|
||||||
|
import 'bootstrap-select/dist/css/bootstrap-select.css'
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
$(this.element).selectpicker({
|
||||||
|
dropdownAlignRight: 'auto',
|
||||||
|
container: '#content',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,6 +45,9 @@ import "./datatables";
|
||||||
//import "./tab_remember";
|
//import "./tab_remember";
|
||||||
import "./register_events";
|
import "./register_events";
|
||||||
|
|
||||||
|
//Define jquery globally
|
||||||
|
window.$ = window.jQuery = require("jquery")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
require('bootstrap-select');
|
require('bootstrap-select');
|
||||||
|
@ -52,8 +55,7 @@ require('jquery-form');
|
||||||
require('corejs-typeahead/dist/typeahead.bundle.min');
|
require('corejs-typeahead/dist/typeahead.bundle.min');
|
||||||
window.Bloodhound = require('corejs-typeahead/dist/bloodhound.js');
|
window.Bloodhound = require('corejs-typeahead/dist/bloodhound.js');
|
||||||
|
|
||||||
//Define jquery globally
|
;
|
||||||
window.$ = window.jQuery = require("jquery");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
//CSS
|
//CSS
|
||||||
import 'bootstrap-select/dist/css/bootstrap-select.css'
|
|
||||||
import "bootstrap-fileinput/css/fileinput.css"
|
import "bootstrap-fileinput/css/fileinput.css"
|
||||||
|
|
||||||
//JS
|
//JS
|
||||||
import "bootstrap-select";
|
|
||||||
import "./lib/jquery.tristate"
|
import "./lib/jquery.tristate"
|
||||||
import "bootstrap-fileinput";
|
import "bootstrap-fileinput";
|
||||||
|
|
||||||
|
@ -24,8 +23,6 @@ const RegisterEventHelper = class {
|
||||||
|
|
||||||
this.registerTriStateCheckboxes();
|
this.registerTriStateCheckboxes();
|
||||||
|
|
||||||
this.registerBootstrapSelectPicker();
|
|
||||||
|
|
||||||
this.registerSpecialCharInput();
|
this.registerSpecialCharInput();
|
||||||
this.registerHoverPics();
|
this.registerHoverPics();
|
||||||
|
|
||||||
|
@ -100,15 +97,6 @@ const RegisterEventHelper = class {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
registerBootstrapSelectPicker() {
|
|
||||||
this.registerLoadHandler(() => {
|
|
||||||
$(".selectpicker").selectpicker({
|
|
||||||
dropdownAlignRight: 'auto',
|
|
||||||
container: '#content',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
registerAutocompleteTagsinput() {
|
registerAutocompleteTagsinput() {
|
||||||
this.registerLoadHandler(() => {
|
this.registerLoadHandler(() => {
|
||||||
$('input.tagsinput').each(function() {
|
$('input.tagsinput').each(function() {
|
||||||
|
|
|
@ -69,6 +69,7 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
||||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
|
|
|
@ -95,6 +95,7 @@ class LabelOptionsType extends AbstractType
|
||||||
},
|
},
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
|
|
|
@ -82,6 +82,7 @@ class PartLotType extends AbstractType
|
||||||
'disable_not_selectable' => true,
|
'disable_not_selectable' => true,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker form-control-sm',
|
'class' => 'selectpicker form-control-sm',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
|
|
|
@ -63,6 +63,7 @@ class MasterPictureAttachmentType extends AbstractType
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
],
|
],
|
||||||
'choice_attr' => static function (Options $options) {
|
'choice_attr' => static function (Options $options) {
|
||||||
|
|
|
@ -117,6 +117,7 @@ class StructuralEntityType extends AbstractType
|
||||||
$resolver->setDefault('attr', static function (Options $options) {
|
$resolver->setDefault('attr', static function (Options $options) {
|
||||||
$tmp = [
|
$tmp = [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
];
|
];
|
||||||
|
|
|
@ -150,6 +150,7 @@ class UserAdminForm extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
|
@ -162,6 +163,7 @@ class UserAdminForm extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
|
@ -178,6 +180,7 @@ class UserAdminForm extends AbstractType
|
||||||
},
|
},
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'title' => 'selectpicker.nothing_selected',
|
'title' => 'selectpicker.nothing_selected',
|
||||||
],
|
],
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
|
|
|
@ -99,6 +99,7 @@ class UserSettingsType extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
'placeholder' => 'user_settings.language.placeholder',
|
'placeholder' => 'user_settings.language.placeholder',
|
||||||
|
@ -110,6 +111,7 @@ class UserSettingsType extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
'data-live-search' => true,
|
'data-live-search' => true,
|
||||||
],
|
],
|
||||||
'placeholder' => 'user_settings.timezone.placeholder',
|
'placeholder' => 'user_settings.timezone.placeholder',
|
||||||
|
@ -121,6 +123,7 @@ class UserSettingsType extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
|
'data-controller' => 'elements--selectpicker',
|
||||||
],
|
],
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
'choices' => User::AVAILABLE_THEMES,
|
'choices' => User::AVAILABLE_THEMES,
|
||||||
|
|
|
@ -107,7 +107,6 @@
|
||||||
$holder.append($newFormRow);
|
$holder.append($newFormRow);
|
||||||
|
|
||||||
//Reinit the selectpickers
|
//Reinit the selectpickers
|
||||||
$(".selectpicker").selectpicker();
|
|
||||||
$(".file").fileinput();
|
$(".file").fileinput();
|
||||||
|
|
||||||
//Reinit typeahead:
|
//Reinit typeahead:
|
||||||
|
|
|
@ -104,8 +104,6 @@
|
||||||
|
|
||||||
$holder.append($newFormRow);
|
$holder.append($newFormRow);
|
||||||
|
|
||||||
//Reinit the selectpickers
|
|
||||||
$(".selectpicker").selectpicker();
|
|
||||||
$(".file").fileinput();
|
$(".file").fileinput();
|
||||||
|
|
||||||
//Reinit typeahead:
|
//Reinit typeahead:
|
||||||
|
|
|
@ -55,8 +55,5 @@
|
||||||
|
|
||||||
$holder.append($newFormRow);
|
$holder.append($newFormRow);
|
||||||
|
|
||||||
//Reinit the selectpickers
|
|
||||||
$(".selectpicker").selectpicker();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -52,10 +52,6 @@
|
||||||
$("#" + min_discount_id).val(new_min_amount);
|
$("#" + min_discount_id).val(new_min_amount);
|
||||||
$("#" + price_related_id).val("1");
|
$("#" + price_related_id).val("1");
|
||||||
|
|
||||||
|
|
||||||
//Reinit the selectpickers
|
|
||||||
$(".selectpicker").selectpicker();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_orderdetail_entry(btn) {
|
function delete_orderdetail_entry(btn) {
|
||||||
|
@ -77,9 +73,5 @@
|
||||||
newForm = newForm.replace(/__name__/g, index);
|
newForm = newForm.replace(/__name__/g, index);
|
||||||
|
|
||||||
$holder.children("tbody").append(newForm);
|
$holder.children("tbody").append(newForm);
|
||||||
|
|
||||||
//Reinit the selectpickers
|
|
||||||
$(".selectpicker").selectpicker();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
{{ form_widget(form.price) }}
|
{{ form_widget(form.price) }}
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
{{ form_widget(form.currency, {'attr': {'class': 'selectpicker form-control-sm'}}) }}
|
{{ form_widget(form.currency, {'attr': {'class': 'selectpicker form-control-sm', 'data-controller': 'elements--selectpicker'}}) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ form_errors(form.price) }}
|
{{ form_errors(form.price) }}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{# <span id="select_count"></span> #}
|
{# <span id="select_count"></span> #}
|
||||||
<span class="badge badge-secondary">{% trans with {'%count%': '<span id="select_count"></span>'} %}part_list.action.part_count{% endtrans %}</span>
|
<span class="badge badge-secondary">{% trans with {'%count%': '<span id="select_count"></span>'} %}part_list.action.part_count{% endtrans %}</span>
|
||||||
|
|
||||||
<select class="selectpicker" name="action" id="select_action"
|
<select class="selectpicker" name="action" id="select_action" data-controller="elements--selectpicker"
|
||||||
title="{% trans %}part_list.action.action.title{% endtrans %}" onchange="updateTargetSelect()" required>
|
title="{% trans %}part_list.action.action.title{% endtrans %}" onchange="updateTargetSelect()" required>
|
||||||
<optgroup label="{% trans %}part_list.action.action.group.favorite{% endtrans %}">
|
<optgroup label="{% trans %}part_list.action.action.group.favorite{% endtrans %}">
|
||||||
<option {% if not is_granted('@parts.edit') %}disabled{% endif %} value="favorite">{% trans %}part_list.action.action.favorite{% endtrans %}</option>
|
<option {% if not is_granted('@parts.edit') %}disabled{% endif %} value="favorite">{% trans %}part_list.action.action.favorite{% endtrans %}</option>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue