mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(jobs): Opt-in lock so a job type can refuse a cancel after its commit * feat(create-user-template): Create a user template and list it in "Your templates" * fix(create-user-template): Address review feedback - Only the owner can open a user template; the slug endpoint returns 404 otherwise and includes `type`. - List templates through `/api/templates/?view=flat` instead of `/own/`. - Rename the job's copy to `template_workspace`, renumber the migration to 0132 after develop's core migrations, guard it like 0128, and move revision fields and metadata to the update PR. - Clear references outside the selection instead of failing the import, lock the owner row against a concurrent delete, and keep leftovers tracked until they're deleted. - Load workspace permissions only for the wizard, handle instances without categories, restore a running job before a failed one, and open the default template again in the template modal. - Reuse existing export, cancel and serializer code, keep one icon list, remove overlapping tests, and give template fixtures a unique slug.
83 lines
1.9 KiB
Vue
83 lines
1.9 KiB
Vue
<template>
|
|
<Context ref="contextRef" class="template-icon-select-context" @shown="shown">
|
|
<SelectSearch
|
|
ref="searchRef"
|
|
v-model="search"
|
|
:placeholder="$t('templateIconSelectContext.search')"
|
|
/>
|
|
<div
|
|
v-if="icons.length > 0"
|
|
v-auto-overflow-scroll
|
|
class="template-icon-select-context__icons"
|
|
>
|
|
<button
|
|
v-for="icon in icons"
|
|
:key="icon"
|
|
type="button"
|
|
class="template-icon-select-context__icon"
|
|
:class="{
|
|
'template-icon-select-context__icon--active': icon === active,
|
|
}"
|
|
:title="getIconName(icon)"
|
|
@click="select(icon)"
|
|
>
|
|
<i :class="icon"></i>
|
|
</button>
|
|
</div>
|
|
<div v-else class="template-icon-select-context__empty">
|
|
{{ $t('templateIconSelectContext.noResults') }}
|
|
</div>
|
|
</Context>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, nextTick, ref } from 'vue'
|
|
|
|
import { TEMPLATE_ICONS } from '@baserow/modules/core/utils/templateIcons'
|
|
|
|
defineProps({
|
|
// The icon that is currently picked.
|
|
active: {
|
|
type: String,
|
|
default: null,
|
|
},
|
|
})
|
|
|
|
const emit = defineEmits(['selected'])
|
|
|
|
const contextRef = ref(null)
|
|
const searchRef = ref(null)
|
|
const search = ref('')
|
|
|
|
// The name of `iconoir-light-bulb-on` is `light bulb on`.
|
|
function getIconName(icon) {
|
|
return icon.replace(/^iconoir-/, '').replaceAll('-', ' ')
|
|
}
|
|
|
|
const icons = computed(() => {
|
|
const query = search.value.trim().toLowerCase()
|
|
return TEMPLATE_ICONS.filter((icon) => getIconName(icon).includes(query))
|
|
})
|
|
|
|
async function shown() {
|
|
search.value = ''
|
|
await nextTick()
|
|
searchRef.value?.$el.querySelector('input')?.focus()
|
|
}
|
|
|
|
function select(icon) {
|
|
emit('selected', icon)
|
|
contextRef.value.hide()
|
|
}
|
|
|
|
function toggle(...args) {
|
|
contextRef.value.toggle(...args)
|
|
}
|
|
|
|
function hide() {
|
|
contextRef.value.hide()
|
|
}
|
|
|
|
defineExpose({ toggle, hide })
|
|
</script>
|