feat(dialog): 상세 팝업 SuperportDetailDialog 통합
- SuperportDetailDialog 위젯과 showSuperportDetailDialog 헬퍼를 추가하고 metadata/섹션 패턴을 표준화 - 결재/재고/마스터 각 상세 다이얼로그를 dialogs 디렉터리에 신설하고 기존 페이지를 신규 팝업으로 전환 - SuperportTable 행 선택과 우편번호 검색 다이얼로그 onRowTap 보정을 통해 헤더 오프셋 버그를 제거 - 상세 다이얼로그 및 트랜잭션/상세 뷰 전용 위젯 테스트와 tester_extensions 유틸을 추가하여 회귀를 방지 - detail_dialog_unification_plan.md로 작업 배경과 필드 통합 계획을 문서화
This commit is contained in:
@@ -5,13 +5,14 @@ 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 'package:superport_v2/widgets/components/superport_pagination_controls.dart';
|
||||
import 'package:superport_v2/widgets/components/superport_table.dart';
|
||||
|
||||
import '../../../../../core/config/environment.dart';
|
||||
import '../../../../../widgets/spec_page.dart';
|
||||
import '../../domain/entities/group.dart';
|
||||
import '../../domain/repositories/group_repository.dart';
|
||||
import '../dialogs/group_detail_dialog.dart';
|
||||
import '../controllers/group_controller.dart';
|
||||
|
||||
/// 권한 그룹 관리 페이지. 기능 플래그에 따라 사양 화면 또는 실제 목록을 보여준다.
|
||||
@@ -151,7 +152,7 @@ class _GroupEnabledPageState extends State<_GroupEnabledPage> {
|
||||
leading: const Icon(LucideIcons.plus, size: 16),
|
||||
onPressed: _controller.isSubmitting
|
||||
? null
|
||||
: () => _openGroupForm(context),
|
||||
: _openGroupCreateDialog,
|
||||
child: const Text('신규 등록'),
|
||||
),
|
||||
],
|
||||
@@ -274,11 +275,9 @@ class _GroupEnabledPageState extends State<_GroupEnabledPage> {
|
||||
: _GroupTable(
|
||||
groups: groups,
|
||||
dateFormat: _dateFormat,
|
||||
onEdit: _controller.isSubmitting
|
||||
onRowTap: _controller.isSubmitting
|
||||
? null
|
||||
: (group) => _openGroupForm(context, group: group),
|
||||
onDelete: _controller.isSubmitting ? null : _confirmDelete,
|
||||
onRestore: _controller.isSubmitting ? null : _restoreGroup,
|
||||
: _openGroupDetailDialog,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -313,265 +312,37 @@ class _GroupEnabledPageState extends State<_GroupEnabledPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openGroupForm(BuildContext context, {Group? group}) async {
|
||||
final existingGroup = group;
|
||||
final isEdit = existingGroup != null;
|
||||
final groupId = existingGroup?.id;
|
||||
if (isEdit && groupId == null) {
|
||||
_showSnack('ID 정보가 없어 수정할 수 없습니다.');
|
||||
Future<void> _openGroupCreateDialog() async {
|
||||
final result = await showGroupDetailDialog(
|
||||
context: context,
|
||||
dateFormat: _dateFormat,
|
||||
onCreate: _controller.create,
|
||||
onUpdate: _controller.update,
|
||||
onDelete: _controller.delete,
|
||||
onRestore: _controller.restore,
|
||||
);
|
||||
if (result != null && mounted) {
|
||||
_showSnack(result.message);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openGroupDetailDialog(Group group) async {
|
||||
final groupId = group.id;
|
||||
if (groupId == null) {
|
||||
_showSnack('ID 정보가 없어 상세를 열 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
final nameController = TextEditingController(
|
||||
text: existingGroup?.groupName ?? '',
|
||||
);
|
||||
final descriptionController = TextEditingController(
|
||||
text: existingGroup?.description ?? '',
|
||||
);
|
||||
final noteController = TextEditingController(
|
||||
text: existingGroup?.note ?? '',
|
||||
);
|
||||
final isDefaultNotifier = ValueNotifier<bool>(
|
||||
existingGroup?.isDefault ?? false,
|
||||
);
|
||||
final isActiveNotifier = ValueNotifier<bool>(
|
||||
existingGroup?.isActive ?? true,
|
||||
);
|
||||
final saving = ValueNotifier<bool>(false);
|
||||
final nameError = ValueNotifier<String?>(null);
|
||||
|
||||
await SuperportDialog.show<void>(
|
||||
final result = await showGroupDetailDialog(
|
||||
context: context,
|
||||
dialog: SuperportDialog(
|
||||
title: isEdit ? '그룹 수정' : '그룹 등록',
|
||||
description: '그룹 정보를 ${isEdit ? '수정' : '입력'}하세요.',
|
||||
constraints: const BoxConstraints(maxWidth: 540),
|
||||
actions: [
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton.ghost(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () => Navigator.of(
|
||||
dialogContext,
|
||||
rootNavigator: true,
|
||||
).pop(),
|
||||
child: const Text('취소'),
|
||||
);
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: saving,
|
||||
builder: (dialogContext, isSaving, __) {
|
||||
return ShadButton(
|
||||
onPressed: isSaving
|
||||
? null
|
||||
: () async {
|
||||
final name = nameController.text.trim();
|
||||
final description = descriptionController.text.trim();
|
||||
final note = noteController.text.trim();
|
||||
|
||||
nameError.value = name.isEmpty ? '그룹명을 입력하세요.' : null;
|
||||
|
||||
if (nameError.value != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
saving.value = true;
|
||||
final input = GroupInput(
|
||||
groupName: name,
|
||||
description: description.isEmpty ? null : description,
|
||||
isDefault: isDefaultNotifier.value,
|
||||
isActive: isActiveNotifier.value,
|
||||
note: note.isEmpty ? null : note,
|
||||
);
|
||||
final navigator = Navigator.of(
|
||||
dialogContext,
|
||||
rootNavigator: true,
|
||||
);
|
||||
final response = isEdit
|
||||
? await _controller.update(groupId!, input)
|
||||
: await _controller.create(input);
|
||||
saving.value = false;
|
||||
if (response != null) {
|
||||
if (!navigator.mounted) {
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
_showSnack(isEdit ? '그룹을 수정했습니다.' : '그룹을 등록했습니다.');
|
||||
}
|
||||
navigator.pop();
|
||||
}
|
||||
},
|
||||
child: Text(isEdit ? '저장' : '등록'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
child: StatefulBuilder(
|
||||
builder: (dialogContext, _) {
|
||||
final theme = ShadTheme.of(dialogContext);
|
||||
final materialTheme = Theme.of(dialogContext);
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ValueListenableBuilder<String?>(
|
||||
valueListenable: nameError,
|
||||
builder: (_, errorText, __) {
|
||||
return _FormField(
|
||||
label: '그룹명',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShadInput(
|
||||
controller: nameController,
|
||||
readOnly: isEdit,
|
||||
onChanged: (_) {
|
||||
if (nameController.text.trim().isNotEmpty) {
|
||||
nameError.value = null;
|
||||
}
|
||||
},
|
||||
),
|
||||
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: 16),
|
||||
_FormField(
|
||||
label: '설명',
|
||||
child: ShadTextarea(controller: descriptionController),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: isDefaultNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '기본여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: saving.value
|
||||
? null
|
||||
: (next) => isDefaultNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '기본 그룹' : '일반 그룹'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: isActiveNotifier,
|
||||
builder: (_, value, __) {
|
||||
return _FormField(
|
||||
label: '사용여부',
|
||||
child: Row(
|
||||
children: [
|
||||
ShadSwitch(
|
||||
value: value,
|
||||
onChanged: saving.value
|
||||
? null
|
||||
: (next) => isActiveNotifier.value = next,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(value ? '사용' : '미사용'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_FormField(
|
||||
label: '비고',
|
||||
child: ShadTextarea(controller: noteController),
|
||||
),
|
||||
if (existingGroup != null) ...[
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'생성일시: ${_formatDateTime(existingGroup.createdAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'수정일시: ${_formatDateTime(existingGroup.updatedAt)}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
dateFormat: _dateFormat,
|
||||
group: group,
|
||||
onCreate: _controller.create,
|
||||
onUpdate: _controller.update,
|
||||
onDelete: _controller.delete,
|
||||
onRestore: _controller.restore,
|
||||
);
|
||||
|
||||
nameController.dispose();
|
||||
descriptionController.dispose();
|
||||
noteController.dispose();
|
||||
isDefaultNotifier.dispose();
|
||||
isActiveNotifier.dispose();
|
||||
saving.dispose();
|
||||
nameError.dispose();
|
||||
}
|
||||
|
||||
Future<void> _confirmDelete(Group group) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
title: const Text('그룹 삭제'),
|
||||
content: Text('"${group.groupName}" 그룹을 삭제하시겠습니까?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(dialogContext, rootNavigator: true).pop(false),
|
||||
child: const Text('취소'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(dialogContext, rootNavigator: true).pop(true),
|
||||
child: const Text('삭제'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed == true && group.id != null) {
|
||||
final success = await _controller.delete(group.id!);
|
||||
if (success && mounted) {
|
||||
_showSnack('그룹을 삭제했습니다.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _restoreGroup(Group group) async {
|
||||
if (group.id == null) return;
|
||||
final restored = await _controller.restore(group.id!);
|
||||
if (restored != null && mounted) {
|
||||
_showSnack('그룹을 복구했습니다.');
|
||||
if (result != null && mounted) {
|
||||
_showSnack(result.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,129 +356,70 @@ class _GroupEnabledPageState extends State<_GroupEnabledPage> {
|
||||
}
|
||||
messenger.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
String _formatDateTime(DateTime? value) {
|
||||
if (value == null) {
|
||||
return '-';
|
||||
}
|
||||
return _dateFormat.format(value.toLocal());
|
||||
}
|
||||
}
|
||||
|
||||
class _GroupTable extends StatelessWidget {
|
||||
const _GroupTable({
|
||||
required this.groups,
|
||||
required this.onEdit,
|
||||
required this.onDelete,
|
||||
required this.onRestore,
|
||||
required this.dateFormat,
|
||||
required this.onRowTap,
|
||||
});
|
||||
|
||||
final List<Group> groups;
|
||||
final void Function(Group group)? onEdit;
|
||||
final void Function(Group group)? onDelete;
|
||||
final void Function(Group group)? onRestore;
|
||||
final DateFormat dateFormat;
|
||||
final void Function(Group group)? onRowTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final header = [
|
||||
'ID',
|
||||
'그룹명',
|
||||
'설명',
|
||||
'기본',
|
||||
'사용',
|
||||
'삭제',
|
||||
'비고',
|
||||
'변경일시',
|
||||
'동작',
|
||||
].map((text) => ShadTableCell.header(child: Text(text))).toList();
|
||||
final columns = const [
|
||||
Text('ID'),
|
||||
Text('그룹명'),
|
||||
Text('설명'),
|
||||
Text('기본'),
|
||||
Text('사용'),
|
||||
Text('삭제'),
|
||||
Text('비고'),
|
||||
Text('변경일시'),
|
||||
];
|
||||
|
||||
final rows = groups.map((group) {
|
||||
final cells = [
|
||||
group.id?.toString() ?? '-',
|
||||
group.groupName,
|
||||
(group.description?.isEmpty ?? true) ? '-' : group.description!,
|
||||
group.isDefault ? 'Y' : 'N',
|
||||
group.isActive ? 'Y' : 'N',
|
||||
group.isDeleted ? 'Y' : '-',
|
||||
(group.note?.isEmpty ?? true) ? '-' : group.note!,
|
||||
group.updatedAt == null
|
||||
? '-'
|
||||
: dateFormat.format(group.updatedAt!.toLocal()),
|
||||
].map((text) => ShadTableCell(child: Text(text))).toList();
|
||||
final rows = groups
|
||||
.map(
|
||||
(group) => <Widget>[
|
||||
Text(group.id?.toString() ?? '-'),
|
||||
Text(group.groupName),
|
||||
Text(group.description?.isEmpty ?? true ? '-' : group.description!),
|
||||
Text(group.isDefault ? 'Y' : 'N'),
|
||||
Text(group.isActive ? 'Y' : 'N'),
|
||||
Text(group.isDeleted ? 'Y' : '-'),
|
||||
Text(group.note?.isEmpty ?? true ? '-' : group.note!),
|
||||
Text(
|
||||
group.updatedAt == null
|
||||
? '-'
|
||||
: dateFormat.format(group.updatedAt!.toLocal()),
|
||||
),
|
||||
],
|
||||
)
|
||||
.toList();
|
||||
|
||||
cells.add(
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: onEdit == null ? null : () => onEdit!(group),
|
||||
child: const Icon(LucideIcons.pencil, size: 16),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
group.isDeleted
|
||||
? ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: onRestore == null
|
||||
? null
|
||||
: () => onRestore!(group),
|
||||
child: const Icon(LucideIcons.history, size: 16),
|
||||
)
|
||||
: ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: onDelete == null
|
||||
? null
|
||||
: () => onDelete!(group),
|
||||
child: const Icon(LucideIcons.trash2, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
return cells;
|
||||
}).toList();
|
||||
|
||||
return SizedBox(
|
||||
height: 56.0 * (groups.length + 1),
|
||||
child: ShadTable.list(
|
||||
header: header,
|
||||
children: rows,
|
||||
columnSpanExtent: (index) {
|
||||
if (index == 8) {
|
||||
return const FixedTableSpanExtent(160);
|
||||
}
|
||||
if (index == 2) {
|
||||
return const FixedTableSpanExtent(220);
|
||||
}
|
||||
if (index == 6) {
|
||||
return const FixedTableSpanExtent(200);
|
||||
}
|
||||
return const FixedTableSpanExtent(120);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FormField extends StatelessWidget {
|
||||
const _FormField({required this.label, required this.child});
|
||||
|
||||
final String label;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: theme.textTheme.small),
|
||||
const SizedBox(height: 6),
|
||||
child,
|
||||
],
|
||||
return SuperportTable(
|
||||
columns: columns,
|
||||
rows: rows,
|
||||
rowHeight: 56,
|
||||
maxHeight: 56.0 * (groups.length + 1),
|
||||
onRowTap: onRowTap == null
|
||||
? null
|
||||
: (index) {
|
||||
if (index < 0 || index >= groups.length) {
|
||||
return;
|
||||
}
|
||||
onRowTap!(groups[index]);
|
||||
},
|
||||
columnSpanExtent: (index) => switch (index) {
|
||||
2 => const FixedTableSpanExtent(220),
|
||||
6 => const FixedTableSpanExtent(200),
|
||||
7 => const FixedTableSpanExtent(160),
|
||||
_ => const FixedTableSpanExtent(120),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user