From 79262264d9ab1b08990628b07fcceabd09874e51 Mon Sep 17 00:00:00 2001 From: Daniel Wilkowski Date: Thu, 17 Oct 2024 13:45:38 +0200 Subject: [PATCH] Add icon search to icon editor --- resources/views/adm/icons.twig | 64 +++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/resources/views/adm/icons.twig b/resources/views/adm/icons.twig index 35870c283..4d251d93c 100644 --- a/resources/views/adm/icons.twig +++ b/resources/views/adm/icons.twig @@ -3,34 +3,49 @@ {% block card %} {{ form_open({url: route('adm.icons.save'), method: 'post', id: 'app'}) }} -
+

- - + + + + +
umiejscowienieikona FontAwesome + + + + +
+ +
+
+ + + + - + @@ -55,21 +70,36 @@ delimiters: ['${', '}'], data() { return { - editorIcons, + editorIcons: Object + .entries(editorIcons) + .map(([location, [defaultIcon, currentIcon]]) => { + return {location, defaultIcon, currentIcon}; + }), + searchName: '', + searchIcon: '', }; }, - computed: { - icons() { - return Object.entries(this.$data.editorIcons).map(([location, [defaultIcon, currentIcon]]) => { - return {location, defaultIcon, currentIcon}; - }); - }, - }, methods: { - reset(event) { - event.currentTarget.parentElement.parentElement.querySelector('input[name]').value = ''; + visible({location, defaultIcon, currentIcon}) { + currentIcon = currentIcon.trim(); + if (this.$data.searchName) { + if (!containsCaseInsensitive(location, this.$data.searchName)) { + return false; + } + } + if (this.$data.searchIcon) { + const effectiveIcon = currentIcon === '' ? defaultIcon : currentIcon; + if (!containsCaseInsensitive(effectiveIcon, this.$data.searchIcon)) { + return false; + } + } + return true; }, }, }); + + function containsCaseInsensitive(string, substring) { + return string.toLowerCase().includes(substring.toLocaleString()); + } {% endblock %}
Umiejscowienieikona font-awesome