Fixes to channel modal

This commit is contained in:
Nassim Jahnke 2022-04-06 15:15:11 +02:00
parent dd49201756
commit 8c956ece9c
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 16 additions and 3 deletions

View File

@ -27,8 +27,8 @@ const ctx = useContext();
const validation = reactive({
nameErrors: [] as string[],
colorErrors: [] as string[],
nameValid: false,
colorValid: false,
nameValid: props.edit,
colorValid: props.edit,
});
const form = reactive<ProjectChannel>({
name: "",
@ -62,9 +62,22 @@ const isValid = computed(() => {
watch(name, (newVal) => checkName(newVal));
watch(color, (newVal) => checkColor(newVal));
let lastNameEdit = -1;
function checkName(name: string) {
validation.nameValid = false;
validation.nameErrors = [];
// Don't immediately/constantly spam checks
const now = Date.now();
lastNameEdit = now;
setTimeout(() => {
if (lastNameEdit === now) {
checkName0(name);
}
}, 250);
}
function checkName0(name: string) {
if (name.length === 0) {
return;
}

View File

@ -178,7 +178,7 @@ function getNonChannelTags(version: Version): ApiTag[] {
<div class="inline-flex w-full flex-cols space-between">
<InputCheckbox v-model="filter.allChecked.channels" class="flex-right" @change="checkAllChannels" />
<span class="flex-grow">{{ i18n.t("version.channels") }}</span>
<Link :to="`/${project.owner.name}/${project.name}/channels`">
<Link v-if="hasPerms(NamedPermission.EDIT_TAGS)" :to="`/${project.owner.name}/${project.name}/channels`">
<Button size="small" class="ml-2 text-sm"> <IconMdiPencil /> </Button
></Link>
</div>