CI / go (Server) (push) Failing after 4m38s
CI / go (Web-App) (push) Successful in 12m18s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / frontend (push) Failing after 7m49s
CI / desktop (ubuntu-latest) (push) Successful in 1h25m30s
CI / mobile (push) Failing after 5m14s
CI / docker (push) Successful in 39m26s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Databases (ADR-13 follow-ups):
- Relation properties link records to another database, on the same page
or on any page the reader can open (read live and read-only, like synced
pages). Cells list the linked titles; clicking one opens the record.
- Rollup properties work out counts, sums, averages, medians, min/max,
ranges, earliest/latest dates and checked counts over related records.
Neither is stored: views compute them before drawing (linked.ts), so they
follow both databases live, and rollups sort and filter as numbers.
- Exports (Markdown, HTML, PDF, Word) resolve them for same-page databases.
- A record opens as a full page at /p/<page>/r/<database>/<record>, with
"Open as full page" on the side panel and "Back to the page".
Edgeless mode (ADR-14 follow-ups):
- History previews show a version's canvas and count canvas changes.
- Comments can be anchored to canvas elements (anchor {element}); elements
with open threads show a badge that opens the thread.
- Workspaces choose how new pages open (workspaces.default_page_mode); the
per-device choice now defaults to following the workspace.
- Phones edit the canvas once a page is opened for editing; the page note
shows the page title.
Languages:
- The admin panel speaks English, Polish, German, French and Spanish, with
a picker sharing the web app's setting and a key parity test.
- The phone app speaks the same five, follows the phone's language (and
Android's per-app language setting), and has its own parity test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
164 lines
4.8 KiB
Dart
164 lines
4.8 KiB
Dart
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../api/docwell_api.dart';
|
|
import '../app.dart';
|
|
import 'page_screen.dart';
|
|
import 'widgets.dart';
|
|
import '../l10n.dart';
|
|
|
|
/// One page of the tree with how deep it sits.
|
|
typedef TreeRow = ({PageNode page, int depth});
|
|
|
|
/// The space's pages in tree order with their depth. The server lists them
|
|
/// depth-first; a page whose parent isn't listed sits at the top.
|
|
List<TreeRow> treeRows(List<PageNode> pages) {
|
|
final depth = <String, int>{};
|
|
return [
|
|
for (final p in pages)
|
|
(
|
|
page: p,
|
|
depth: depth[p.id] = p.parent.isEmpty ? 0 : (depth[p.parent] ?? -1) + 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
/// A space's page tree. Branches start folded; tap the arrow to open them.
|
|
class SpaceScreen extends StatefulWidget {
|
|
const SpaceScreen({super.key, required this.session, required this.space});
|
|
|
|
final AppSession session;
|
|
final Space space;
|
|
|
|
@override
|
|
State<SpaceScreen> createState() => _SpaceScreenState();
|
|
}
|
|
|
|
class _SpaceScreenState extends State<SpaceScreen> {
|
|
List<PageNode>? _pages;
|
|
final _open = <String>{};
|
|
String? _error;
|
|
bool _offline = false;
|
|
|
|
bool get _canEdit =>
|
|
widget.space.role == SpaceCallerRole.admin ||
|
|
widget.space.role == SpaceCallerRole.editor;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
Future<void> _load() async {
|
|
final api = widget.session.api;
|
|
try {
|
|
final pages = await api.pages(widget.space.id);
|
|
if (mounted) {
|
|
setState(() {
|
|
_pages = pages;
|
|
_offline = api.offline;
|
|
_error = null;
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) setState(() => _error = describeError(e));
|
|
}
|
|
}
|
|
|
|
Future<void> _openPage(String id, {bool edit = false}) async {
|
|
await Navigator.of(context).push(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) =>
|
|
PageScreen(session: widget.session, pageId: id, startEditing: edit),
|
|
),
|
|
);
|
|
_load();
|
|
}
|
|
|
|
Future<void> _newPage() async {
|
|
try {
|
|
final p = await widget.session.api.createPage(widget.space.id);
|
|
await _openPage(p.id, edit: true);
|
|
} catch (e) {
|
|
if (mounted) {
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(SnackBar(content: Text(describeError(e))));
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final pages = _pages;
|
|
final rows = pages == null ? <TreeRow>[] : treeRows(pages);
|
|
final hasChildren = {for (final p in pages ?? <PageNode>[]) p.parent};
|
|
// A row shows when every ancestor is open.
|
|
final visible = <TreeRow>[];
|
|
final shown = <String>{''};
|
|
for (final r in rows) {
|
|
if (shown.contains(r.page.parent) &&
|
|
(r.page.parent.isEmpty || _open.contains(r.page.parent))) {
|
|
visible.add(r);
|
|
shown.add(r.page.id);
|
|
}
|
|
}
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(widget.space.name)),
|
|
floatingActionButton: _canEdit && !_offline
|
|
? FloatingActionButton(
|
|
tooltip: tr('newPage'),
|
|
onPressed: _newPage,
|
|
child: const Icon(Icons.add),
|
|
)
|
|
: null,
|
|
body: RefreshIndicator(
|
|
onRefresh: _load,
|
|
child: ListView(
|
|
children: [
|
|
if (_offline) const OfflineBanner(),
|
|
if (_error != null)
|
|
ErrorTile(message: _error!, onRetry: _load)
|
|
else if (pages == null)
|
|
const Padding(
|
|
padding: EdgeInsets.all(32),
|
|
child: Center(child: CircularProgressIndicator()),
|
|
)
|
|
else if (pages.isEmpty)
|
|
ListTile(title: Text(tr('noPages'))),
|
|
for (final r in visible)
|
|
ListTile(
|
|
key: Key('page-${r.page.id}'),
|
|
contentPadding: EdgeInsets.only(
|
|
left: 8.0 + r.depth * 20,
|
|
right: 16,
|
|
),
|
|
leading: hasChildren.contains(r.page.id)
|
|
? IconButton(
|
|
tooltip: _open.contains(r.page.id)
|
|
? tr('fold')
|
|
: tr('unfold'),
|
|
icon: Icon(
|
|
_open.contains(r.page.id)
|
|
? Icons.expand_more
|
|
: Icons.chevron_right,
|
|
),
|
|
onPressed: () => setState(() {
|
|
if (!_open.remove(r.page.id)) _open.add(r.page.id);
|
|
}),
|
|
)
|
|
: SizedBox(width: 48, child: PageIcon(r.page.icon)),
|
|
title: Text(
|
|
r.page.title.isEmpty ? tr('untitled') : r.page.title,
|
|
),
|
|
onTap: () => _openPage(r.page.id),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|