Skip to content

Commit f77309f

Browse files
committed
dead end
1 parent 4835635 commit f77309f

File tree

9 files changed

+492
-141
lines changed

9 files changed

+492
-141
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ desktop-old/
1818
reference-*
1919

2020
*.tgz
21+
22+
TODO.md

package-lock.json

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"to-markdown-cli": "^0.4.4",
141141
"tributejs": "^5.0.1",
142142
"turndown": "^7.0.0"
143+
},
144+
"dependencies": {
145+
"ssb-crut": "^4.6.0"
143146
}
144147
}

ui/core/components/daisyui/Form.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const m = require("mithril")
33
const Form = {
44
view: vnode => {
55
let onSave = vnode.attrs.onSave
6-
let onCancel = vnode.attrs?.onCancel ? vnode.attrs.onCancel : onCancelDefault
76

87
const onSubmit = ev => {
98
ev.preventDefault()
@@ -13,7 +12,9 @@ const Form = {
1312
const onCancelDefault = ev => {
1413
ev.preventDefault
1514
}
16-
15+
16+
let onCancel = vnode.attrs?.onCancel ? vnode.attrs.onCancel : onCancelDefault
17+
1718
return m("form.form", {onsubmit: onSubmit},[
1819
...vnode.children,
1920
m("div.flex", [
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const m = require("mithril")
2+
const Scuttle = require("scuttle-gathering")
3+
const Form = require("../../core/components/daisyui/Form.js")
4+
const TextInput = require("../../core/components/daisyui/TextInput.js")
5+
const TextArea = require("../../core/components/daisyui/TextArea.js")
6+
7+
8+
9+
const gathering = Scuttle(ssb.sbot)
10+
const sbot = ssb.sbot
11+
12+
const GatheringEdit = {
13+
oninit: vnode => {
14+
vnode.state.gatheringId = vnode.attrs.gatheringId || false
15+
},
16+
view: vnode => {
17+
let gatheringId = vnode.state.gatheringId
18+
19+
let title = vnode.state.title
20+
let startDateTime = vnode.state.startDateTime
21+
let description = vnode.state.description
22+
let location = vnode.state.location
23+
let image = vnode.state.image
24+
25+
const createOrUpdateGathering = () => {
26+
let opts = {
27+
title,
28+
startDateTime,
29+
description,
30+
location,
31+
image,
32+
}
33+
34+
const cb = (err, data) => {
35+
if (err) {
36+
// vnode.state.error = err
37+
throw err
38+
} else {
39+
// vnode.state.data = data
40+
if (data.key) {
41+
patchfox.go("calendar", "view", {msgid: data.key})
42+
}
43+
}
44+
}
45+
46+
if (gatheringId) {
47+
gathering.put(gatheringId, opts, cb)
48+
} else {
49+
gathering.post(opts, cb)
50+
}
51+
}
52+
53+
const setField = field => {
54+
const eventHandler = ev => {
55+
vnode.state[field] = ev.target.value
56+
}
57+
return eventHandler
58+
}
59+
60+
const makeInput = field => {
61+
return m(TextInput, {
62+
label: field,
63+
onchange: setField(field),
64+
value: vnode.state[field]
65+
})
66+
}
67+
68+
return m(Form, {
69+
onSave: createOrUpdateGathering
70+
}, [
71+
makeInput("title"),
72+
makeInput("startDateTime"),
73+
makeInput("location"),
74+
])
75+
76+
}
77+
}
78+
79+
module.exports = GatheringEdit

ui/packages/calendar/calendar.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const GatheringCard = require("./GatheringCard.js")
22
const GatheringView = require("./GatheringView.js")
3-
const TimelineView = require("./TimelineView.js");
4-
const ExportView = require("./ExportView.js");
5-
const GatheringActionCard = require("./GatheringActionCard.js");
3+
const TimelineView = require("./TimelineView.js")
4+
const ExportView = require("./ExportView.js")
5+
const GatheringActionCard = require("./GatheringActionCard.js")
6+
const GatheringEdit = require("./GatheringEdit.js")
67
const { isGathering, isUpdate, isAttendee } = require("ssb-gathering-schema")
78

89
patchfox.package({
@@ -24,10 +25,19 @@ patchfox.package({
2425
gathering: GatheringView,
2526
timeline: TimelineView,
2627
export: ExportView,
28+
edit: GatheringEdit,
2729
menu: {
2830
group: "Calendar",
2931
label: "Gatherings",
3032
items: [
33+
{
34+
label: "Create Gathering",
35+
event: "package:go",
36+
data: {
37+
pkg: "calendar",
38+
view: "edit"
39+
}
40+
},
3141
{
3242
label: "Future Events",
3343
event: "package:go",

ui/packages/hub/Thread.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ const ThreadView = {
5454
<a href="?thread=${thread}#/thread">${thread}</a>
5555
: ${vnode.state.error}
5656
`)),
57-
m("button.btn.btn-primary.mt-2", {
58-
onclick: () => history.back()
59-
}, "Go back")
57+
m("button.btn.btn-primary.mt-2", {
58+
onclick: () => history.back()
59+
}, "Go back")
6060
]
6161

6262
const messagesOrSpinner =

ui/packages/system/TestArea.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const m = require("mithril")
2+
const Crut = require("ssb-crut")
3+
const Overwrite = require("@tangle/overwrite")
4+
const SimpleSet = require("@tangle/simple-set")
5+
6+
const sbot = ssb.sbot
7+
8+
const TestArea = {
9+
oninit: (vnode) => {
10+
const spec = {
11+
type: "bookDistribution",
12+
props: {
13+
title: Overwrite(),
14+
links: SimpleSet()
15+
}
16+
}
17+
18+
const crut = new Crut(ssb, spec) // ssb = an ssb server
19+
20+
crut.create(
21+
{
22+
title: "Four Decentralization Protocols",
23+
24+
links: { add: ["https://leanpub.com/four-decentralisation-protocols"] },
25+
26+
},
27+
(err, msgId) => {
28+
//
29+
console.log(err)
30+
console.log(msgId)
31+
sbot.get(msgId, (err2, data) => {
32+
console.log(err2)
33+
console.log(data)
34+
})
35+
}
36+
)
37+
},
38+
view: (vnode) => {
39+
return m("p", "check logs")
40+
41+
},
42+
}
43+
44+
module.exports = TestArea

ui/packages/system/system.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const JoinPub = require("./JoinPub.js")
33
const JoinRoom = require("./JoinRoom.js")
44
const Status = require("./Status.js")
55
const HttpAuth = require("./httpAuth.js")
6+
const TestArea = require("./TestArea.js")
67

78
patchfox.package({
89
name: "system",
@@ -12,6 +13,7 @@ patchfox.package({
1213
joinRoom: JoinRoom,
1314
status: Status,
1415
httpAuth: HttpAuth,
16+
testArea: TestArea,
1517
menu: [
1618
{
1719
group: "Application",
@@ -40,6 +42,14 @@ patchfox.package({
4042
pkg: "system",
4143
view: "peers"
4244
}
45+
},
46+
{
47+
label: "test",
48+
event: "package:go",
49+
data: {
50+
pkg: "system",
51+
view: "testArea"
52+
}
4353
}
4454
]
4555
}

0 commit comments

Comments
 (0)