Compare commits
	
		
			2 commits
		
	
	
		
			ccdb6d7463
			...
			7693b062ab
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 7693b062ab | |||
| 905dee7e33 | 
					 3 changed files with 46 additions and 37 deletions
				
			
		| 
						 | 
				
			
			@ -25,16 +25,10 @@
 | 
			
		|||
 | 
			
		||||
<%def name="make_b_autocomplete_component()">
 | 
			
		||||
  <script type="text/x-template" id="b-autocomplete-template">
 | 
			
		||||
    <o-autocomplete v-model="orugaValue"
 | 
			
		||||
                    :data="data"
 | 
			
		||||
                    :field="field"
 | 
			
		||||
                    :open-on-focus="openOnFocus"
 | 
			
		||||
                    :keep-first="keepFirst"
 | 
			
		||||
                    :clearable="clearable"
 | 
			
		||||
                    :clear-on-select="clearOnSelect"
 | 
			
		||||
                    :formatter="customFormatter"
 | 
			
		||||
                    :placeholder="placeholder"
 | 
			
		||||
                    @update:model-value="orugaValueUpdated"
 | 
			
		||||
    <o-autocomplete v-model:input="orugaValue"
 | 
			
		||||
                    :options="options"
 | 
			
		||||
                    clear-icon="circle-xmark"
 | 
			
		||||
                    @update:input="orugaValueUpdated"
 | 
			
		||||
                    ref="autocomplete">
 | 
			
		||||
    </o-autocomplete>
 | 
			
		||||
  </script>
 | 
			
		||||
| 
						 | 
				
			
			@ -45,12 +39,7 @@
 | 
			
		|||
            modelValue: String,
 | 
			
		||||
            data: Array,
 | 
			
		||||
            field: String,
 | 
			
		||||
            openOnFocus: Boolean,
 | 
			
		||||
            keepFirst: Boolean,
 | 
			
		||||
            clearable: Boolean,
 | 
			
		||||
            clearOnSelect: Boolean,
 | 
			
		||||
            customFormatter: null,
 | 
			
		||||
            placeholder: String,
 | 
			
		||||
        },
 | 
			
		||||
        data() {
 | 
			
		||||
            return {
 | 
			
		||||
| 
						 | 
				
			
			@ -64,13 +53,33 @@
 | 
			
		|||
                }
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        computed: {
 | 
			
		||||
            options() {
 | 
			
		||||
                const options = []
 | 
			
		||||
                const field = this.field || 'label'
 | 
			
		||||
                for (let opt of this.data) {
 | 
			
		||||
                    const newOpt = {
 | 
			
		||||
                        label: opt[field],
 | 
			
		||||
                        value: opt,
 | 
			
		||||
                    }
 | 
			
		||||
                    if (this.customFormatter) {
 | 
			
		||||
                        newOpt.label = this.customFormatter(opt)
 | 
			
		||||
                    }
 | 
			
		||||
                    options.push(newOpt)
 | 
			
		||||
                }
 | 
			
		||||
                return options
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        methods: {
 | 
			
		||||
            focus() {
 | 
			
		||||
                const input = this.$refs.autocomplete.$el.querySelector('input')
 | 
			
		||||
                input.focus()
 | 
			
		||||
            },
 | 
			
		||||
            orugaValueUpdated(value) {
 | 
			
		||||
                this.$emit('update:modelValue', value)
 | 
			
		||||
                if (this.field) {
 | 
			
		||||
                    value = value[this.field]
 | 
			
		||||
                }
 | 
			
		||||
                this.$emit('update:modelValue', value || '')
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -247,27 +247,27 @@ def get_libver(
 | 
			
		|||
 | 
			
		||||
    elif key == 'bb_vue':
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '3.4.31'
 | 
			
		||||
            return '3.5.18'
 | 
			
		||||
 | 
			
		||||
    elif key == 'bb_oruga':
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '0.8.12'
 | 
			
		||||
            return '0.11.4'
 | 
			
		||||
 | 
			
		||||
    elif key in ('bb_oruga_bulma', 'bb_oruga_bulma_css'):
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '0.3.0'
 | 
			
		||||
            return '0.7.3'
 | 
			
		||||
 | 
			
		||||
    elif key == 'bb_fontawesome_svg_core':
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '6.5.2'
 | 
			
		||||
            return '7.0.0'
 | 
			
		||||
 | 
			
		||||
    elif key == 'bb_free_solid_svg_icons':
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '6.5.2'
 | 
			
		||||
            return '7.0.0'
 | 
			
		||||
 | 
			
		||||
    elif key == 'bb_vue_fontawesome':
 | 
			
		||||
        if not configured_only:
 | 
			
		||||
            return '3.0.6'
 | 
			
		||||
            return '3.1.1'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_liburl(
 | 
			
		||||
| 
						 | 
				
			
			@ -419,7 +419,7 @@ def get_liburl(
 | 
			
		|||
    elif key == 'bb_oruga_bulma':
 | 
			
		||||
        if static and hasattr(static, 'bb_oruga_bulma_js'):
 | 
			
		||||
            return liburl + static.bb_oruga_bulma_js.relpath
 | 
			
		||||
        return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.mjs'
 | 
			
		||||
        return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.js'
 | 
			
		||||
 | 
			
		||||
    elif key == 'bb_oruga_bulma_css':
 | 
			
		||||
        if static and hasattr(static, 'bb_oruga_bulma_css'):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -161,7 +161,7 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_vue_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_vue')
 | 
			
		||||
        self.assertEqual(version, '3.4.31')
 | 
			
		||||
        self.assertEqual(version, '3.5.18')
 | 
			
		||||
 | 
			
		||||
    def test_bb_vue_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_vue', '3.4.30')
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +170,7 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_oruga_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_oruga')
 | 
			
		||||
        self.assertEqual(version, '0.8.12')
 | 
			
		||||
        self.assertEqual(version, '0.11.4')
 | 
			
		||||
 | 
			
		||||
    def test_bb_oruga_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_oruga', '0.8.11')
 | 
			
		||||
| 
						 | 
				
			
			@ -179,9 +179,9 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_oruga_bulma_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_oruga_bulma')
 | 
			
		||||
        self.assertEqual(version, '0.3.0')
 | 
			
		||||
        self.assertEqual(version, '0.7.3')
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_oruga_bulma_css')
 | 
			
		||||
        self.assertEqual(version, '0.3.0')
 | 
			
		||||
        self.assertEqual(version, '0.7.3')
 | 
			
		||||
 | 
			
		||||
    def test_bb_oruga_bulma_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_oruga_bulma', '0.2.11')
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_fontawesome_svg_core_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_fontawesome_svg_core')
 | 
			
		||||
        self.assertEqual(version, '6.5.2')
 | 
			
		||||
        self.assertEqual(version, '7.0.0')
 | 
			
		||||
 | 
			
		||||
    def test_bb_fontawesome_svg_core_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_fontawesome_svg_core', '6.5.1')
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +199,7 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_free_solid_svg_icons_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_free_solid_svg_icons')
 | 
			
		||||
        self.assertEqual(version, '6.5.2')
 | 
			
		||||
        self.assertEqual(version, '7.0.0')
 | 
			
		||||
 | 
			
		||||
    def test_bb_free_solid_svg_icons_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_free_solid_svg_icons', '6.5.1')
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ class TestGetLibVer(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_vue_fontawesome_default(self):
 | 
			
		||||
        version = mod.get_libver(self.request, 'bb_vue_fontawesome')
 | 
			
		||||
        self.assertEqual(version, '3.0.6')
 | 
			
		||||
        self.assertEqual(version, '3.1.1')
 | 
			
		||||
 | 
			
		||||
    def test_bb_vue_fontawesome_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.libver.bb_vue_fontawesome', '3.0.8')
 | 
			
		||||
| 
						 | 
				
			
			@ -344,7 +344,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_vue_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_vue')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/vue@3.4.31/dist/vue.esm-browser.prod.js')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/vue@3.5.18/dist/vue.esm-browser.prod.js')
 | 
			
		||||
 | 
			
		||||
    def test_bb_vue_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_vue', '/lib/vue.js')
 | 
			
		||||
| 
						 | 
				
			
			@ -358,7 +358,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_oruga_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_oruga')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/oruga-next@0.8.12/dist/oruga.mjs')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/oruga-next@0.11.4/dist/oruga.mjs')
 | 
			
		||||
 | 
			
		||||
    def test_bb_oruga_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_oruga', '/lib/oruga.js')
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +372,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_oruga_bulma_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_oruga_bulma')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/theme-bulma@0.3.0/dist/bulma.mjs')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/theme-bulma@0.7.3/dist/bulma.js')
 | 
			
		||||
 | 
			
		||||
    def test_bb_oruga_bulma_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_oruga_bulma', '/lib/oruga_bulma.js')
 | 
			
		||||
| 
						 | 
				
			
			@ -386,7 +386,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_oruga_bulma_css_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_oruga_bulma_css')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/theme-bulma@0.3.0/dist/bulma.css')
 | 
			
		||||
        self.assertEqual(url, 'https://unpkg.com/@oruga-ui/theme-bulma@0.7.3/dist/bulma.css')
 | 
			
		||||
 | 
			
		||||
    def test_bb_oruga_bulma_css_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_oruga_bulma_css', '/lib/oruga-bulma.css')
 | 
			
		||||
| 
						 | 
				
			
			@ -400,7 +400,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_fontawesome_svg_core_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_fontawesome_svg_core')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-svg-core@6.5.2/+esm')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-svg-core@7.0.0/+esm')
 | 
			
		||||
 | 
			
		||||
    def test_bb_fontawesome_svg_core_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_fontawesome_svg_core', '/lib/fontawesome-svg-core.js')
 | 
			
		||||
| 
						 | 
				
			
			@ -414,7 +414,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_free_solid_svg_icons_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_free_solid_svg_icons')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/free-solid-svg-icons@6.5.2/+esm')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/free-solid-svg-icons@7.0.0/+esm')
 | 
			
		||||
 | 
			
		||||
    def test_bb_free_solid_svg_icons_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_free_solid_svg_icons', '/lib/free-solid-svg-icons.js')
 | 
			
		||||
| 
						 | 
				
			
			@ -428,7 +428,7 @@ class TestGetLibUrl(TestCase):
 | 
			
		|||
 | 
			
		||||
    def test_bb_vue_fontawesome_default(self):
 | 
			
		||||
        url = mod.get_liburl(self.request, 'bb_vue_fontawesome')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/vue-fontawesome@3.0.6/+esm')
 | 
			
		||||
        self.assertEqual(url, 'https://cdn.jsdelivr.net/npm/@fortawesome/vue-fontawesome@3.1.1/+esm')
 | 
			
		||||
 | 
			
		||||
    def test_bb_vue_fontawesome_custom(self):
 | 
			
		||||
        self.config.setdefault('wuttaweb.liburl.bb_vue_fontawesome', '/lib/vue-fontawesome.js')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue