foldkit-cms 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -133,11 +133,19 @@ like any other; the view is the form's own.
133
133
 
134
134
  ```ts
135
135
  const Editor = Cms.editor('PostEditor', { content: Posts })
136
- const Slot = Bundle.declare(Editor.bundle, 'editor') // its Model and its Messages, in yours
136
+ const Base = Bundle.compose({ remote: Remote.Model }).pipe(
137
+ Bundle.withMessages(Remote.messages),
138
+ Bundle.withChild('editor', Editor.bundle), // its Model and its Messages, in yours
139
+ )
140
+ // App = Surface.application(Base), and Data = Remote.make({ model: App.model.remote, ... })
137
141
 
138
142
  const PostEditor = Editor.at({ data: Data, model: App.model.editor })
139
- const Placed = Page.at(Slot, { onOut: PostEditor.onOut })
140
- const update = PostEditor.after(Page.assemble(Placed).update(yourUpdate))
143
+ const Page = Base.pipe(
144
+ Bundle.withServices<RemoteClient>(),
145
+ Bundle.configure('editor', { onOut: PostEditor.onOut }), // made from Data, so given now
146
+ )
147
+ const Placed = Page.children.editor
148
+ const update = PostEditor.after(Page.placements.update(yourUpdate))
141
149
 
142
150
  Data.subscriptions({ ...yourSurfaces, ...PostEditor.actives })
143
151
 
@@ -147,14 +155,29 @@ Editor.Message.PublishAsked() // also: ScheduleAsked({ at }), UnscheduleAsked, D
147
155
  // RestoreAsked({ revision }), UnpublishAsked, ArchiveAsked, UnarchiveAsked, ReloadAsked, OverwriteAsked
148
156
 
149
157
  PostEditor.status(model) // Opened | Editing | Saving | Saved | Conflict | Publishing | Published | ...
150
- PostEditor.state(model) // the entry's lifecycle state, as the server last derived it
151
- PostEditor.pageId(model) // the row's id, or the entry's until there is a row: what a preview shows under
158
+ PostEditor.state(model) // Option: the entry's lifecycle state, as the server last derived it
159
+ PostEditor.may(model, 'publish') // whether the server's `allow` lets this principal ask it; false until read
160
+ PostEditor.pageId(model) // Option: the row's id, or the entry's until there is a row: what a preview shows under
161
+ PostEditor.storedEntry(model) // Option: the entry the server knows, none until something new is first saved
152
162
  ```
153
163
 
154
164
  - **Saving is automatic and is not publishing.** Each edit starts a rest (`rest`,
155
165
  one second by default), and the edit that is still the last one when its rest
156
166
  ends saves the form as it stands, valid or not. There is no Save button to
157
167
  forget, and a validation error never costs an author their work.
168
+ - **A publish the form's own checks stop is `Incomplete`**, not whatever the
169
+ last save said: nothing was sent, the failing fields say why, and the next
170
+ edit clears it. One waiting for a check still running (an address being
171
+ looked up) is `Publishing` until the check answers.
172
+ - **What counts as an edit is the form's answer, not a Message tag.** The editor
173
+ asks `form.authoredChanged(before, after)`, so a blur, a refusal, or a repeated
174
+ value starts no rest, while a control the editor has never heard of — a
175
+ stateful or Bundle-backed one — autosaves exactly like a text field.
176
+ - **A form control backed by a Bundle keeps running inside the editor.** Its
177
+ Subscriptions and Resources (see
178
+ [`Input.bundle`](../form/README.md#a-control-with-a-model-of-its-own)) run
179
+ while an entry is open and stop when the editor closes. A runtime that runs
180
+ the editor provides their Resources, as for any Bundle that has some.
158
181
  - **`Editing` means there are edits that are not saved yet**, and `Opened` means
159
182
  the form is as it was found. A draft the editor filled the form from is on the
160
183
  server already, so it reads `Saved`.
@@ -219,15 +242,29 @@ EntryTable({ page, renderers: Cms.displayRenderers() }, h)
219
242
 
220
243
  | Kind | What it is |
221
244
  | --- | --- |
222
- | `Cms.Input.Slug` | Text shown after the address it completes. `Cms.slug(from, { prefix?, through? })` makes one that follows `from` through `Cms.slugify`. A form filled with a published slug does not follow: an address must not move because its title did. |
245
+ | `Cms.Input.Slug` | Text shown after the address it completes. `Cms.slug(from, { prefix?, through? })` makes one that follows `from` through `Cms.slugify`. A form filled with a published slug does not follow: an address must not move because its title did. Drawn as the prefix in `FieldSlots.affix` and the input in `text`, together in `group`. |
223
246
  | `Cms.Input.DateTime` | A moment. Text that is none is `Invalid`, not submitted. |
224
- | `Cms.Display.State` | An entry's state as words: `Changed, scheduled`, `New, overdue`. `of({ words })` takes yours. Its renderer is a `span` with `data-cms-state` and `data-cms-schedule` to style. |
247
+ | `Cms.Display.State` | An entry's state as words: `Changed, scheduled`, `New, overdue`. `of({ words })` takes yours, text with blanks as every words object is: each state, `scheduled`, `overdue`, and `withSchedule` (`'{state}, {schedule}'`). Its renderer is a `span` with `data-cms-state` and `data-cms-schedule` to style. |
225
248
  | `Cms.Display.Moment` | A time. `of({ now })` reads relative to that clock (`3 days ago`), and you decide how often it moves; without one it is the date and time. Its renderer is a `time`. |
226
249
 
227
250
  `Cms.Entities` already say how they are shown: an entry's `state` is a `State`,
228
251
  and its times are `Moment`s, so a `Crud.list` over `Cms.Entries` needs only the
229
252
  renderers.
230
253
 
254
+ Entry-level views live beside the kinds: `Cms.stateBadge` for the state,
255
+ `Cms.revisionsOf` for the open entry's published revisions, `Cms.historyCard`
256
+ for the timeline, `Cms.moreCard` for the rest of what can happen to it. They
257
+ draw on your own slot builders, so you keep your slots and styles; who
258
+ published and the archive button's icon are yours to name:
259
+
260
+ ```ts
261
+ Cms.historyCard(slots, h, Cms.revisionsOf(model, history), {
262
+ state,
263
+ restore: revision => Message.RestoreAsked({ revision }),
264
+ authorName: name => directoryName(name),
265
+ })
266
+ ```
267
+
231
268
  ## Entities and operations
232
269
 
233
270
  `Cms.Entities` is `Entry`, `Draft` and `Revision`, related: an entry has one