Skip to content

Commit bc5e8fd

Browse files
dfallingclaude
andauthored
Allow editing elements (#18)
* Allow editing an element's name, completed, and description Element details was read-only. Add an Edit button that opens a form for the three most-commonly-changed fields. The updateElement mutation is a full replace (name/description/uri/completed/icon are non-null), so the edit screen round-trips the untouched fields (uri, icon, location, schedule, labels, trips) to avoid clearing them on save. The detail query was expanded with the fields needed to reconstruct that input. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Make element icon and URL editable Round out the edit form with the remaining identity fields. The URL is validated against an http(s) pattern so a malformed value can't be saved. The icon uses an emoji picker rather than free text: the system keyboard's emoji panel can't be opened programmatically, and a single tap-to-replace picker guarantees the field is always exactly one emoji, which is what the icon is meant to be. Adds rn-emoji-keyboard (pure JS, no native deps). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3338cd7 commit bc5e8fd

9 files changed

Lines changed: 494 additions & 3 deletions

File tree

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"react-native": "0.85.3",
2424
"react-native-encrypted-storage": "^4.0.3",
2525
"react-native-safe-area-context": "^5.5.2",
26-
"react-native-screens": "^4.25.2"
26+
"react-native-screens": "^4.25.2",
27+
"rn-emoji-keyboard": "^1.7.0"
2728
},
2829
"devDependencies": {
2930
"@babel/core": "^7.25.2",

src/graphql/__generated__/types.ts

Lines changed: 81 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graphql/queries/elementDetail.graphql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ query ElementDetail($id: String!) {
55
icon
66
description
77
completed
8+
uri
89
labels
10+
trips {
11+
id
12+
}
913
location {
1014
id
1115
address
1216
latitude
1317
longitude
18+
placeId
1419
}
1520
photos {
1621
id
@@ -25,6 +30,8 @@ query ElementDetail($id: String!) {
2530
endDate
2631
startTime
2732
endTime
33+
startTz
34+
endTz
2835
}
2936
}
3037
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
mutation UpdateElement($input: ElementInput!) {
2+
updateElement(input: $input) {
3+
id
4+
name
5+
icon
6+
description
7+
completed
8+
uri
9+
labels
10+
trips {
11+
id
12+
}
13+
location {
14+
id
15+
address
16+
latitude
17+
longitude
18+
placeId
19+
}
20+
photos {
21+
id
22+
thumbnail
23+
regular
24+
description
25+
}
26+
schedule {
27+
id
28+
allDay
29+
startDate
30+
endDate
31+
startTime
32+
endTime
33+
startTz
34+
endTz
35+
}
36+
}
37+
}

src/map/ElementDetailScreen.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function ElementDetailScreen({route, navigation}: Props) {
2929
element={data?.element ?? null}
3030
loading={loading}
3131
onClose={() => navigation.goBack()}
32+
onEdit={() => navigation.navigate('ElementEdit', {elementId})}
3233
/>
3334
</View>
3435
);
@@ -38,10 +39,12 @@ function ModalContents({
3839
element,
3940
loading,
4041
onClose,
42+
onEdit,
4143
}: {
4244
element: ElementDetail | null;
4345
loading: boolean;
4446
onClose: () => void;
47+
onEdit: () => void;
4548
}) {
4649
const safeAreaInsets = useSafeAreaInsets();
4750

@@ -59,6 +62,16 @@ function ModalContents({
5962
<Text style={styles.headerTitle} numberOfLines={1}>
6063
{element?.name ?? (loading ? 'Loading…' : ' ')}
6164
</Text>
65+
{element ? (
66+
<Pressable
67+
accessibilityRole="button"
68+
accessibilityLabel="Edit element"
69+
hitSlop={10}
70+
onPress={onEdit}
71+
style={styles.editButton}>
72+
<Text style={styles.editButtonText}>Edit</Text>
73+
</Pressable>
74+
) : null}
6275
</View>
6376

6477
{element ? (
@@ -199,6 +212,15 @@ const styles = StyleSheet.create({
199212
fontWeight: '600',
200213
color: '#111',
201214
},
215+
editButton: {
216+
marginLeft: 12,
217+
paddingHorizontal: 4,
218+
},
219+
editButtonText: {
220+
fontSize: 16,
221+
color: '#0a7ea4',
222+
fontWeight: '600',
223+
},
202224
scrollContent: {
203225
padding: 16,
204226
},

0 commit comments

Comments
 (0)