CRUD / foldkit-crud
Deleting
A remover is a mutation with a yes in between. Like the editor it is a Bundle, because which id is being asked about is state.
ts
const Remover = Crud.remover('PostRemover', {
mutation: DeletePostMutation,
input: id => ({ id }), // the mutation's input for an id
})
// In the page: Bundle.withChild('remover', Remover.bundle), beside the editor.
const PostRemover = Remover.at({ data: Data, model: App.model.remover })
// With the editor's: Bundle.configure('remover', { onOut: PostRemover.onOut })
const RemoveForm = Page.children.removerRemoveForm.helpers.ask(id)asks; nothing is deleted yet.dismiss()clears it.Remover.Message.Confirmed()andCancelled()are the yes and the no. A yes with nothing asked does nothing.PostRemover.status(model)isIdle,Confirming,Deleting,DeletedorDeleteFailed;target(model)is the id, for the confirmation's words, anderror(model)says why a delete failed.
The server's mutation says what is gone, with deleted in its outcome, and
names no list. Remote then knows the record absent: it leaves every list and
relation it was in with no refetch, a detail of it reads NotFound, and an
editor open on it reports NotFound.
Detail
One record through a Selection, for a page that shows it. Like a list it holds no state.
ts
const PostDetail = Crud.detail('PostDetail', { selection: PostPage }).at({
data: Data,
id: model => Option.fromNullOr(model.shownPostId), // none while none is shown
})
PostDetail.value(model) // RemoteData of the Selection's valueCrud.detail(...).fields lists the selected members with their labels, as a
list's columns does. PostDetail.active makes the value a requirement while
an id is shown, and PostDetail.refresh(model) asks for it again.