<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import PopupLayout from "@/layouts/PopupLayout.vue";
import ctxRef from "@/utils/ctx_ref.js"
import Context from "./updateGroupPopup.js"
import PostForm from "@/components/form/PostForm.vue";
import TInputText from "@/components/ui/TInputText.vue";
import MoreOptionsIndicator from "@/components/common/MoreOptionsIndicator.vue";
import TCheckboxBinary from "@/components/ui/TCheckboxBinary.vue";
import TTextarea from "@/components/ui/TTextarea.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<PopupLayout>
		<header>修改分组</header>

		<PostForm action="$" @success="ctx.success">
			<input type="hidden" name="groupId" :value="ctx.group.id"/>
			<DefinitionTable>
				<tbody>
				<tr>
					<td class="title">分组名称 *</td>
					<td>
						<TInputText name="name" maxlength="100" autofocus v-model="ctx.group.name" class="w-full"/>
						<p class="comment">给分组起一个容易识别的名称</p>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<MoreOptionsIndicator></MoreOptionsIndicator>
					</td>
				</tr>
				</tbody>
				<tbody v-show="ctx.moreOptionsVisible">
				<tr>
					<td>分组描述</td>
					<td>
						<TTextarea name="description" maxlength="200" rows="3" v-model="ctx.group.description" class="w-full"></TTextarea>
					</td>
				</tr>
				<tr>
					<td>启用当前分组</td>
					<td>
						<TCheckboxBinary name="isOn" value="1" v-model="ctx.group.isOn"/>
					</td>
				</tr>
				</tbody>
			</DefinitionTable>

			<SubmitButton></SubmitButton>
		</PostForm>
	</PopupLayout>
</template>

<style lang="postcss" scoped>
</style>