Improve ajax-select style

This commit is contained in:
Antoine Bartuccio 2024-10-20 17:37:51 +02:00
parent be5ce414ba
commit 45441c351d
3 changed files with 19 additions and 23 deletions

View File

@ -1,10 +1,4 @@
/* This also requires ajax-select-index.css */ /* This also requires ajax-select-index.css */
.tomselected {
.select2-container--default {
color: black;
}
}
.ts-dropdown { .ts-dropdown {
.select-item { .select-item {
@ -22,20 +16,22 @@
} }
} }
.ts-control { .ts-wrapper.plugin-remove_button:not(.rtl) .item .remove {
border-left: 1px solid black;
.item { }
cursor: pointer;
background-color: #e4e4e4;
border: 1px solid #aaa;
border-radius: 4px;
display: inline-block;
margin-left: 5px;
margin-top: 5px;
margin-bottom: 5px;
padding-right: 10px;
padding-left: 10px;
}
.ts-wrapper.multi .ts-control [data-value] {
background-image: none;
cursor: pointer;
background-color: #e4e4e4;
border: 1px solid #aaa;
border-radius: 4px;
display: inline-block;
margin-left: 5px;
margin-top: 5px;
margin-bottom: 5px;
padding-right: 10px;
padding-left: 10px;
text-shadow: none;
box-shadow: none;
} }

View File

@ -1,4 +1,4 @@
import "tom-select/dist/css/tom-select.css"; import "tom-select/dist/css/tom-select.default.css";
import { inheritHtmlElement, registerComponent } from "#core:utils/web-components"; import { inheritHtmlElement, registerComponent } from "#core:utils/web-components";
import TomSelect from "tom-select"; import TomSelect from "tom-select";
import type { import type {
@ -71,7 +71,6 @@ class AutocompleteSelect extends inheritHtmlElement("select") {
} }
protected shouldLoad(query: string) { protected shouldLoad(query: string) {
console.log(this);
return query.length >= this.minCharNumberForSearch; // Avoid launching search with less than setup number of characters return query.length >= this.minCharNumberForSearch; // Avoid launching search with less than setup number of characters
} }

View File

@ -39,6 +39,7 @@ class AutoCompleteSelectMixin:
def get_context(self, name, value, attrs): def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs) context = super().get_context(name, value, attrs)
context["widget"]["attrs"]["autocomplete"] = "off"
context["component"] = self.component_name context["component"] = self.component_name
context["statics"] = { context["statics"] = {
"js": [staticfiles_storage.url(file) for file in self.js], "js": [staticfiles_storage.url(file) for file in self.js],