From 06e282b8398fb88e6d25bcf9c3efe0667dd66a68 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 16 Feb 2021 16:46:16 +0100 Subject: [PATCH] supprime select2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit select2 n'est plus utilisé. Il est remplacé par ComboMultipleDropdownList --- app/assets/stylesheets/add_instructeur.scss | 30 ------- app/assets/stylesheets/application.scss | 1 - app/assets/stylesheets/buttons.scss | 16 ---- app/assets/stylesheets/forms.scss | 38 +-------- .../stylesheets/personnes_impliquees.scss | 5 -- app/javascript/new_design/select2.js | 80 ------------------- app/javascript/packs/application.js | 1 - 7 files changed, 1 insertion(+), 170 deletions(-) delete mode 100644 app/javascript/new_design/select2.js diff --git a/app/assets/stylesheets/add_instructeur.scss b/app/assets/stylesheets/add_instructeur.scss index 8e446e281..ba7d7b3cf 100644 --- a/app/assets/stylesheets/add_instructeur.scss +++ b/app/assets/stylesheets/add_instructeur.scss @@ -5,34 +5,4 @@ .select-instructeurs { width: 100%; } - - .select2-container--default { - .select2-selection--multiple { - border: solid 1px $border-grey; - - .select2-selection__choice, // scss-lint:disable SelectorFormat - .select2-search--inline { - padding: $default-spacer; - } - } - - &.select2-container--focus { - .select2-selection--multiple { - border: 1px solid $blue; - box-shadow: 0px 0px 2px 1px $blue; - } - } - - .select2-results__option { // scss-lint:disable SelectorFormat - padding: $default-spacer; - } - - .custom-select2-option { - .icon { - margin-right: $default-spacer; - } - } - } } - - diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index af88e9f77..eaf0c0b98 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,6 +4,5 @@ // = require ./utils // = require ./fonts // = require leaflet -// = require select2 // = require_tree . // = stub ./print.scss diff --git a/app/assets/stylesheets/buttons.scss b/app/assets/stylesheets/buttons.scss index f7bfe4ea1..4e399e8ef 100644 --- a/app/assets/stylesheets/buttons.scss +++ b/app/assets/stylesheets/buttons.scss @@ -281,18 +281,6 @@ .dropdown-form { padding: 2 * $default-spacer; - .select2-container { - margin-bottom: 2 * $default-spacer; - } - - .select2-selection { - border: 1px solid $border-grey; - - &.select2-selection--multiple { - border: 1px solid $border-grey; - } - } - &.large { width: 340px; } @@ -310,10 +298,6 @@ } } -.select2-dropdown { - border: 1px solid $border-grey; -} - .link { color: $blue; } diff --git a/app/assets/stylesheets/forms.scss b/app/assets/stylesheets/forms.scss index d37c4c8df..c473aca8d 100644 --- a/app/assets/stylesheets/forms.scss +++ b/app/assets/stylesheets/forms.scss @@ -260,8 +260,7 @@ max-width: 180px; } - select, - .select2-selection { + select { // hack found here: https://stackoverflow.com/questions/1895476/how-to-style-a-select-dropdown-with-css-only-without-javascript -webkit-appearance: none; -moz-appearance: none; @@ -327,41 +326,6 @@ color: $white; } - .select2 { - min-width: 50%; - } - - .select2-container { - display: block; - margin-bottom: $default-fields-spacer; - - &.select2-container--focus { - .select2-selection { - border-color: $border-grey; - } - } - - .select2-selection--single { - min-height: 62px; - - // scss-lint:disable SelectorFormat - .select2-selection__arrow { - display: none; - } - // scss-lint:enable - } - - // scss-lint:disable SelectorFormat - .select2-selection__rendered { - padding: $default-padding; - } - - .select2-selection__choice { - background-color: #FFFFFF; - } - // scss-lint:enable - } - .editable-champ { &:not(.editable-champ-carte) .algolia-autocomplete { margin-bottom: 2 * $default-padding; diff --git a/app/assets/stylesheets/personnes_impliquees.scss b/app/assets/stylesheets/personnes_impliquees.scss index 829abbf38..381886823 100644 --- a/app/assets/stylesheets/personnes_impliquees.scss +++ b/app/assets/stylesheets/personnes_impliquees.scss @@ -9,11 +9,6 @@ margin-left: 16px; } - // scss-lint:disable SelectorFormat - .form .select2-container .select2-selection__rendered { - padding: 12px; - } - // scss-lint:enable [data-react-class="ComboMultipleDropdownList"] { margin-bottom: $default-fields-spacer; diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js deleted file mode 100644 index e69e1c92e..000000000 --- a/app/javascript/new_design/select2.js +++ /dev/null @@ -1,80 +0,0 @@ -import $ from 'jquery'; -import 'select2'; - -const language = { - errorLoading: function () { - return 'Les résultats ne peuvent pas être chargés.'; - }, - inputTooLong: function (args) { - var overChars = args.input.length - args.maximum; - - return 'Supprimez ' + overChars + ' caractère' + (overChars > 1 ? 's' : ''); - }, - inputTooShort: function (args) { - var remainingChars = args.minimum - args.input.length; - - return ( - 'Saisissez au moins ' + - remainingChars + - ' caractère' + - (remainingChars > 1 ? 's' : '') - ); - }, - loadingMore: function () { - return 'Chargement de résultats supplémentaires…'; - }, - maximumSelected: function (args) { - return ( - 'Vous pouvez seulement sélectionner ' + - args.maximum + - ' élément' + - (args.maximum > 1 ? 's' : '') - ); - }, - noResults: function () { - return 'Aucun résultat trouvé'; - }, - searching: function () { - return 'Recherche en cours…'; - }, - removeAllItems: function () { - return 'Supprimer tous les éléments'; - } -}; - -const baseOptions = { - language, - width: '100%' -}; - -const templateOption = ({ text }) => - $( - `${text}` - ); - -addEventListener('ds:page:update', () => { - $('select.select2').select2(baseOptions); - - $('.columns-form select.select2-limited').select2({ - width: '300px', - placeholder: 'Sélectionnez des colonnes', - maximumSelectionLength: '5' - }); - - $('.recipients-form select.select2-limited').select2({ - language, - width: '300px', - placeholder: 'Sélectionnez des instructeurs', - maximumSelectionLength: '30' - }); - - $('select.select2-limited.select-instructeurs').select2({ - language, - dropdownParent: $('.instructeur-wrapper'), - placeholder: 'Saisir l’adresse email de l’instructeur', - tags: true, - tokenSeparators: [',', ' '], - templateResult: templateOption, - templateSelection: templateOption - }); -}); diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 4cf6989f0..940713e7b 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -17,7 +17,6 @@ import '../new_design/dropdown'; import '../new_design/form-validation'; import '../new_design/procedure-context'; import '../new_design/procedure-form'; -import '../new_design/select2'; import '../new_design/spinner'; import '../new_design/support'; import '../new_design/dossiers/auto-save';