전역 구조 리팩터링 및 테스트 확장
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:superport_v2/core/constants/app_sections.dart';
|
||||
import 'package:superport_v2/widgets/app_layout.dart';
|
||||
import 'package:superport_v2/widgets/components/filter_bar.dart';
|
||||
import 'package:superport_v2/widgets/components/superport_dialog.dart';
|
||||
|
||||
import '../../../../../core/config/environment.dart';
|
||||
import '../../../../../widgets/spec_page.dart';
|
||||
@@ -167,7 +168,8 @@ class _GroupPermissionEnabledPageState
|
||||
? false
|
||||
: (result.page * result.pageSize) < result.total;
|
||||
|
||||
final showReset = _searchController.text.isNotEmpty ||
|
||||
final showReset =
|
||||
_searchController.text.isNotEmpty ||
|
||||
_controller.groupFilter != null ||
|
||||
_controller.menuFilter != null ||
|
||||
_controller.statusFilter != GroupPermissionStatusFilter.all ||
|
||||
@@ -191,6 +193,29 @@ class _GroupPermissionEnabledPageState
|
||||
),
|
||||
],
|
||||
toolbar: FilterBar(
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
onPressed: _controller.isLoading ? null : _applyFilters,
|
||||
child: const Text('검색 적용'),
|
||||
),
|
||||
if (showReset)
|
||||
ShadButton.ghost(
|
||||
onPressed: _controller.isLoading
|
||||
? null
|
||||
: () {
|
||||
_searchController.clear();
|
||||
_searchFocus.requestFocus();
|
||||
_controller.updateGroupFilter(null);
|
||||
_controller.updateMenuFilter(null);
|
||||
_controller.updateIncludeDeleted(false);
|
||||
_controller.updateStatusFilter(
|
||||
GroupPermissionStatusFilter.all,
|
||||
);
|
||||
_controller.fetch(page: 1);
|
||||
},
|
||||
child: const Text('초기화'),
|
||||
),
|
||||
],
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 260,
|
||||
@@ -208,16 +233,12 @@ class _GroupPermissionEnabledPageState
|
||||
key: ValueKey(_controller.groupFilter),
|
||||
initialValue: _controller.groupFilter,
|
||||
placeholder: Text(
|
||||
_controller.groups.isEmpty
|
||||
? '그룹 로딩중...'
|
||||
: '그룹 전체',
|
||||
_controller.groups.isEmpty ? '그룹 로딩중...' : '그룹 전체',
|
||||
),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return Text(
|
||||
_controller.groups.isEmpty
|
||||
? '그룹 로딩중...'
|
||||
: '그룹 전체',
|
||||
_controller.groups.isEmpty ? '그룹 로딩중...' : '그룹 전체',
|
||||
);
|
||||
}
|
||||
final group = _controller.groups.firstWhere(
|
||||
@@ -230,10 +251,7 @@ class _GroupPermissionEnabledPageState
|
||||
_controller.updateGroupFilter(value);
|
||||
},
|
||||
options: [
|
||||
const ShadOption<int?>(
|
||||
value: null,
|
||||
child: Text('그룹 전체'),
|
||||
),
|
||||
const ShadOption<int?>(value: null, child: Text('그룹 전체')),
|
||||
..._controller.groups.map(
|
||||
(group) => ShadOption<int?>(
|
||||
value: group.id,
|
||||
@@ -249,25 +267,18 @@ class _GroupPermissionEnabledPageState
|
||||
key: ValueKey(_controller.menuFilter),
|
||||
initialValue: _controller.menuFilter,
|
||||
placeholder: Text(
|
||||
_controller.menus.isEmpty
|
||||
? '메뉴 로딩중...'
|
||||
: '메뉴 전체',
|
||||
_controller.menus.isEmpty ? '메뉴 로딩중...' : '메뉴 전체',
|
||||
),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return Text(
|
||||
_controller.menus.isEmpty
|
||||
? '메뉴 로딩중...'
|
||||
: '메뉴 전체',
|
||||
_controller.menus.isEmpty ? '메뉴 로딩중...' : '메뉴 전체',
|
||||
);
|
||||
}
|
||||
final menuItem = _controller.menus.firstWhere(
|
||||
(m) => m.id == value,
|
||||
orElse: () => MenuItem(
|
||||
id: value,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
orElse: () =>
|
||||
MenuItem(id: value, menuCode: '', menuName: ''),
|
||||
);
|
||||
return Text(menuItem.menuName);
|
||||
},
|
||||
@@ -275,10 +286,7 @@ class _GroupPermissionEnabledPageState
|
||||
_controller.updateMenuFilter(value);
|
||||
},
|
||||
options: [
|
||||
const ShadOption<int?>(
|
||||
value: null,
|
||||
child: Text('메뉴 전체'),
|
||||
),
|
||||
const ShadOption<int?>(value: null, child: Text('메뉴 전체')),
|
||||
..._controller.menus.map(
|
||||
(menuItem) => ShadOption<int?>(
|
||||
value: menuItem.id,
|
||||
@@ -322,24 +330,6 @@ class _GroupPermissionEnabledPageState
|
||||
const Text('삭제 포함'),
|
||||
],
|
||||
),
|
||||
ShadButton.outline(
|
||||
onPressed: _controller.isLoading ? null : _applyFilters,
|
||||
child: const Text('검색 적용'),
|
||||
),
|
||||
if (showReset)
|
||||
ShadButton.ghost(
|
||||
onPressed: _controller.isLoading
|
||||
? null
|
||||
: () {
|
||||
_searchController.clear();
|
||||
_searchFocus.requestFocus();
|
||||
_controller.updateGroupFilter(null);
|
||||
_controller.updateMenuFilter(null);
|
||||
_controller.updateIncludeDeleted(false);
|
||||
_controller.fetch(page: 1);
|
||||
},
|
||||
child: const Text('초기화'),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ShadCard(
|
||||
@@ -384,27 +374,27 @@ class _GroupPermissionEnabledPageState
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: permissions.isEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'조건에 맞는 권한이 없습니다.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
)
|
||||
: _PermissionTable(
|
||||
permissions: permissions,
|
||||
dateFormat: _dateFormat,
|
||||
onEdit: _controller.isSubmitting
|
||||
? null
|
||||
: (permission) =>
|
||||
_openPermissionForm(context, permission: permission),
|
||||
onDelete: _controller.isSubmitting
|
||||
? null
|
||||
: _confirmDelete,
|
||||
onRestore: _controller.isSubmitting
|
||||
? null
|
||||
: _restorePermission,
|
||||
),
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'조건에 맞는 권한이 없습니다.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
)
|
||||
: _PermissionTable(
|
||||
permissions: permissions,
|
||||
dateFormat: _dateFormat,
|
||||
onEdit: _controller.isSubmitting
|
||||
? null
|
||||
: (permission) => _openPermissionForm(
|
||||
context,
|
||||
permission: permission,
|
||||
),
|
||||
onDelete: _controller.isSubmitting ? null : _confirmDelete,
|
||||
onRestore: _controller.isSubmitting
|
||||
? null
|
||||
: _restorePermission,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -430,311 +420,302 @@ class _GroupPermissionEnabledPageState
|
||||
BuildContext context, {
|
||||
GroupPermission? permission,
|
||||
}) async {
|
||||
final isEdit = permission != null;
|
||||
final permissionId = permission?.id;
|
||||
final existingPermission = permission;
|
||||
final isEdit = existingPermission != null;
|
||||
final permissionId = existingPermission?.id;
|
||||
if (isEdit && permissionId == null) {
|
||||
_showSnack('ID 정보가 없어 수정할 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
final groupNotifier = ValueNotifier<int?>(permission?.group.id);
|
||||
final menuNotifier = ValueNotifier<int?>(permission?.menu.id);
|
||||
final createNotifier = ValueNotifier<bool>(permission?.canCreate ?? false);
|
||||
final readNotifier = ValueNotifier<bool>(permission?.canRead ?? true);
|
||||
final updateNotifier = ValueNotifier<bool>(permission?.canUpdate ?? false);
|
||||
final deleteNotifier = ValueNotifier<bool>(permission?.canDelete ?? false);
|
||||
final activeNotifier = ValueNotifier<bool>(permission?.isActive ?? true);
|
||||
final noteController = TextEditingController(text: permission?.note ?? '');
|
||||
final groupNotifier = ValueNotifier<int?>(existingPermission?.group.id);
|
||||
final menuNotifier = ValueNotifier<int?>(existingPermission?.menu.id);
|
||||
final createNotifier = ValueNotifier<bool>(
|
||||
existingPermission?.canCreate ?? false,
|
||||
);
|
||||
final readNotifier = ValueNotifier<bool>(
|
||||
existingPermission?.canRead ?? true,
|
||||
);
|
||||
final updateNotifier = ValueNotifier<bool>(
|
||||
existingPermission?.canUpdate ?? false,
|
||||
);
|
||||
final deleteNotifier = ValueNotifier<bool>(
|
||||
existingPermission?.canDelete ?? false,
|
||||
);
|
||||
final activeNotifier = ValueNotifier<bool>(
|
||||
existingPermission?.isActive ?? true,
|
||||
);
|
||||
final noteController = TextEditingController(
|
||||
text: existingPermission?.note ?? '',
|
||||
);
|
||||
final saving = ValueNotifier<bool>(false);
|
||||
final groupError = ValueNotifier<String?>(null);
|
||||
final menuError = ValueNotifier<String?>(null);
|
||||
|
||||
await showDialog<bool>(
|
||||
await SuperportDialog.show<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
final theme = ShadTheme.of(dialogContext);
|
||||
final materialTheme = Theme.of(dialogContext);
|
||||
final navigator = Navigator.of(dialogContext);
|
||||
return Dialog(
|
||||
insetPadding: const EdgeInsets.all(24),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
child: ShadCard(
|
||||
title: Text(
|
||||
isEdit ? '권한 수정' : '권한 등록',
|
||||
style: theme.textTheme.h3,
|
||||
),
|
||||
description: Text(
|
||||
'그룹과 메뉴의 권한을 ${isEdit ? '수정' : '등록'}하세요.',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
footer: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (_, isSaving, __) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: isSaving ? null : () => navigator.pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ShadButton(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () async {
|
||||
final groupId = groupNotifier.value;
|
||||
final menuId = menuNotifier.value;
|
||||
groupError.value = groupId == null
|
||||
? '그룹을 선택하세요.'
|
||||
: null;
|
||||
menuError.value = menuId == null
|
||||
? '메뉴를 선택하세요.'
|
||||
: null;
|
||||
if (groupError.value != null ||
|
||||
menuError.value != null) {
|
||||
return;
|
||||
}
|
||||
dialog: SuperportDialog(
|
||||
title: isEdit ? '권한 수정' : '권한 등록',
|
||||
description: '그룹과 메뉴의 권한을 ${isEdit ? '수정' : '등록'}하세요.',
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
secondaryAction: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton.ghost(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('취소'),
|
||||
);
|
||||
},
|
||||
),
|
||||
primaryAction: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () async {
|
||||
final groupId = groupNotifier.value;
|
||||
final menuId = menuNotifier.value;
|
||||
groupError.value = groupId == null ? '그룹을 선택하세요.' : null;
|
||||
menuError.value = menuId == null ? '메뉴를 선택하세요.' : null;
|
||||
if (groupError.value != null || menuError.value != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
saving.value = true;
|
||||
final input = GroupPermissionInput(
|
||||
groupId: groupId!,
|
||||
menuId: menuId!,
|
||||
canCreate: createNotifier.value,
|
||||
canRead: readNotifier.value,
|
||||
canUpdate: updateNotifier.value,
|
||||
canDelete: deleteNotifier.value,
|
||||
isActive: activeNotifier.value,
|
||||
note: noteController.text.trim().isEmpty
|
||||
? null
|
||||
: noteController.text.trim(),
|
||||
);
|
||||
final response = isEdit
|
||||
? await _controller.update(
|
||||
permissionId!,
|
||||
input,
|
||||
)
|
||||
: await _controller.create(input);
|
||||
saving.value = false;
|
||||
if (response != null) {
|
||||
if (!navigator.mounted) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
_showSnack(
|
||||
isEdit ? '권한을 수정했습니다.' : '권한을 등록했습니다.',
|
||||
);
|
||||
}
|
||||
navigator.pop(true);
|
||||
saving.value = true;
|
||||
final trimmedNote = noteController.text.trim();
|
||||
final input = GroupPermissionInput(
|
||||
groupId: groupId!,
|
||||
menuId: menuId!,
|
||||
canCreate: createNotifier.value,
|
||||
canRead: readNotifier.value,
|
||||
canUpdate: updateNotifier.value,
|
||||
canDelete: deleteNotifier.value,
|
||||
isActive: activeNotifier.value,
|
||||
note: trimmedNote.isEmpty ? null : trimmedNote,
|
||||
);
|
||||
final navigator = Navigator.of(dialogContext);
|
||||
final response = isEdit
|
||||
? await _controller.update(permissionId!, input)
|
||||
: await _controller.create(input);
|
||||
saving.value = false;
|
||||
if (response != null) {
|
||||
if (!navigator.mounted) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
_showSnack(isEdit ? '권한을 수정했습니다.' : '권한을 등록했습니다.');
|
||||
}
|
||||
navigator.pop(true);
|
||||
}
|
||||
},
|
||||
child: Text(isEdit ? '저장' : '등록'),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
final theme = ShadTheme.of(dialogContext);
|
||||
final materialTheme = Theme.of(dialogContext);
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: groupError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '그룹',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadSelect<int?>(
|
||||
initialValue: groupNotifier.value,
|
||||
placeholder: const Text('그룹을 선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return const Text('그룹을 선택하세요');
|
||||
}
|
||||
final groupId = value;
|
||||
final group = _controller.groups.firstWhere(
|
||||
(g) => g.id == groupId,
|
||||
orElse: () =>
|
||||
Group(id: groupId, groupName: ''),
|
||||
);
|
||||
return Text(
|
||||
group.groupName.isEmpty
|
||||
? '그룹을 선택하세요'
|
||||
: group.groupName,
|
||||
);
|
||||
},
|
||||
child: Text(isEdit ? '저장' : '등록'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: groupError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '그룹',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadSelect<int?>(
|
||||
initialValue: groupNotifier.value,
|
||||
placeholder: const Text('그룹을 선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return const Text('그룹을 선택하세요');
|
||||
}
|
||||
final groupId = value;
|
||||
final group = _controller.groups.firstWhere(
|
||||
(g) => g.id == groupId,
|
||||
orElse: () =>
|
||||
Group(id: groupId, groupName: ''),
|
||||
);
|
||||
return Text(
|
||||
group.groupName.isEmpty
|
||||
? '그룹을 선택하세요'
|
||||
: group.groupName,
|
||||
);
|
||||
},
|
||||
onChanged: saving.value || isEdit
|
||||
? null
|
||||
: (value) {
|
||||
groupNotifier.value = value;
|
||||
if (value != null) {
|
||||
groupError.value = null;
|
||||
}
|
||||
},
|
||||
options: [
|
||||
..._controller.groups.map(
|
||||
(group) => ShadOption<int?>(
|
||||
value: group.id,
|
||||
child: Text(group.groupName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
onChanged: isSaving || isEdit
|
||||
? null
|
||||
: (value) {
|
||||
groupNotifier.value = value;
|
||||
if (value != null) {
|
||||
groupError.value = null;
|
||||
}
|
||||
},
|
||||
options: [
|
||||
..._controller.groups.map(
|
||||
(group) => ShadOption<int?>(
|
||||
value: group.id,
|
||||
child: Text(group.groupName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: menuError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadSelect<int?>(
|
||||
initialValue: menuNotifier.value,
|
||||
placeholder: const Text('메뉴를 선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return const Text('메뉴를 선택하세요');
|
||||
}
|
||||
final menuId = value;
|
||||
final menu = _controller.menus.firstWhere(
|
||||
(m) => m.id == menuId,
|
||||
orElse: () => MenuItem(
|
||||
id: menuId,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
);
|
||||
return Text(
|
||||
menu.menuName.isEmpty
|
||||
? '메뉴를 선택하세요'
|
||||
: menu.menuName,
|
||||
);
|
||||
},
|
||||
onChanged: saving.value || isEdit
|
||||
? null
|
||||
: (value) {
|
||||
menuNotifier.value = value;
|
||||
if (value != null) {
|
||||
menuError.value = null;
|
||||
}
|
||||
},
|
||||
options: [
|
||||
..._controller.menus.map(
|
||||
(menu) => ShadOption<int?>(
|
||||
value: menu.id,
|
||||
child: Text(menu.menuName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_PermissionToggleRow(
|
||||
label: '생성권한',
|
||||
notifier: createNotifier,
|
||||
enabled: !saving.value,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '조회권한',
|
||||
notifier: readNotifier,
|
||||
enabled: !saving.value,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '수정권한',
|
||||
notifier: updateNotifier,
|
||||
enabled: !saving.value,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '삭제권한',
|
||||
notifier: deleteNotifier,
|
||||
enabled: !saving.value,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: activeNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '사용여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: saving.value
|
||||
? null
|
||||
: (next) => activeNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '사용' : '미사용'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '비고',
|
||||
child: ShadTextarea(controller: noteController),
|
||||
),
|
||||
if (isEdit) ...[
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'생성일시: ${_formatDateTime(permission.createdAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'수정일시: ${_formatDateTime(permission.updatedAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: menuError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '메뉴',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadSelect<int?>(
|
||||
initialValue: menuNotifier.value,
|
||||
placeholder: const Text('메뉴를 선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
if (value == null) {
|
||||
return const Text('메뉴를 선택하세요');
|
||||
}
|
||||
final menuId = value;
|
||||
final menu = _controller.menus.firstWhere(
|
||||
(m) => m.id == menuId,
|
||||
orElse: () => MenuItem(
|
||||
id: menuId,
|
||||
menuCode: '',
|
||||
menuName: '',
|
||||
),
|
||||
);
|
||||
return Text(
|
||||
menu.menuName.isEmpty
|
||||
? '메뉴를 선택하세요'
|
||||
: menu.menuName,
|
||||
);
|
||||
},
|
||||
onChanged: isSaving || isEdit
|
||||
? null
|
||||
: (value) {
|
||||
menuNotifier.value = value;
|
||||
if (value != null) {
|
||||
menuError.value = null;
|
||||
}
|
||||
},
|
||||
options: [
|
||||
..._controller.menus.map(
|
||||
(menu) => ShadOption<int?>(
|
||||
value: menu.id,
|
||||
child: Text(menu.menuName),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
errorText,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_PermissionToggleRow(
|
||||
label: '생성권한',
|
||||
notifier: createNotifier,
|
||||
enabled: !isSaving,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '조회권한',
|
||||
notifier: readNotifier,
|
||||
enabled: !isSaving,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '수정권한',
|
||||
notifier: updateNotifier,
|
||||
enabled: !isSaving,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_PermissionToggleRow(
|
||||
label: '삭제권한',
|
||||
notifier: deleteNotifier,
|
||||
enabled: !isSaving,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: activeNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '사용여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: isSaving
|
||||
? null
|
||||
: (next) => activeNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '사용' : '미사용'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '비고',
|
||||
child: ShadTextarea(controller: noteController),
|
||||
),
|
||||
if (existingPermission != null) ...[
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'생성일시: ${_formatDateTime(existingPermission.createdAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'수정일시: ${_formatDateTime(existingPermission.updatedAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
groupNotifier.dispose();
|
||||
@@ -751,26 +732,29 @@ class _GroupPermissionEnabledPageState
|
||||
}
|
||||
|
||||
Future<void> _confirmDelete(GroupPermission permission) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
final confirmed = await SuperportDialog.show<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
title: const Text('권한 삭제'),
|
||||
content: Text(
|
||||
dialog: SuperportDialog(
|
||||
title: '권한 삭제',
|
||||
description:
|
||||
'"${permission.group.groupName}" → "${permission.menu.menuName}" 권한을 삭제하시겠습니까?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
secondaryAction: Builder(
|
||||
builder: (dialogContext) {
|
||||
return ShadButton.ghost(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
TextButton(
|
||||
);
|
||||
},
|
||||
),
|
||||
primaryAction: Builder(
|
||||
builder: (dialogContext) {
|
||||
return ShadButton.destructive(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true && permission.id != null) {
|
||||
|
||||
Reference in New Issue
Block a user