feat+fix: Add option to set default download/share file type, fix typo in filter to query string, disable unused options in document filter

This commit is contained in:
Anton Stubenbord
2023-04-28 20:45:47 +02:00
parent 14c850ece6
commit bea0ab94be
20 changed files with 337 additions and 197 deletions

View File

@@ -15,6 +15,7 @@ class FullscreenLabelForm<T extends Label> extends StatefulWidget {
final Widget leadingIcon;
final String? addNewLabelText;
final bool autofocus;
final bool allowSelectUnassigned;
FullscreenLabelForm({
super.key,
@@ -27,6 +28,7 @@ class FullscreenLabelForm<T extends Label> extends StatefulWidget {
required this.leadingIcon,
this.addNewLabelText,
this.autofocus = true,
this.allowSelectUnassigned = true,
}) : assert(
!(initialValue?.isOnlyAssigned() ?? false) || showAnyAssignedOption,
),
@@ -248,16 +250,26 @@ class _FullscreenLabelFormState<T extends Label> extends State<FullscreenLabelFo
);
}
final title = option.whenOrNull(
notAssigned: () => S.of(context)!.notAssigned,
anyAssigned: () => S.of(context)!.anyAssigned,
fromId: (id) => widget.options[id]!.name,
return option.whenOrNull(
notAssigned: () => ListTile(
selected: highlight,
selectedTileColor: Theme.of(context).focusColor,
title: Text(S.of(context)!.notAssigned),
onTap: onTap,
),
anyAssigned: () => ListTile(
selected: highlight,
selectedTileColor: Theme.of(context).focusColor,
title: Text(S.of(context)!.anyAssigned),
onTap: onTap,
),
fromId: (id) => ListTile(
selected: highlight,
selectedTileColor: Theme.of(context).focusColor,
title: Text(widget.options[id]!.name),
onTap: onTap,
enabled: widget.allowSelectUnassigned ? true : widget.options[id]!.documentCount == 0,
),
)!; // Never null, since we already return on unset before
return ListTile(
selected: highlight,
selectedTileColor: Theme.of(context).focusColor,
title: Text(title),
onTap: onTap,
);
}
}

View File

@@ -27,6 +27,7 @@ class LabelFormField<T extends Label> extends StatelessWidget {
final bool showAnyAssignedOption;
final List<T> suggestions;
final String? addLabelText;
final bool allowSelectUnassigned;
const LabelFormField({
Key? key,
@@ -42,6 +43,7 @@ class LabelFormField<T extends Label> extends StatelessWidget {
this.showAnyAssignedOption = true,
this.suggestions = const [],
this.addLabelText,
required this.allowSelectUnassigned,
}) : super(key: key);
String _buildText(BuildContext context, IdQueryParameter? value) {
@@ -100,6 +102,7 @@ class LabelFormField<T extends Label> extends StatelessWidget {
),
),
openBuilder: (context, closeForm) => FullscreenLabelForm<T>(
allowSelectUnassigned: allowSelectUnassigned,
addNewLabelText: addLabelText,
leadingIcon: prefixIcon,
onCreateNewLabel: addLabelPageBuilder != null