pub struct Session(/* private fields */);Expand description
What the screens of a running application share: the frame, the current form, and what has to happen next. A handle.
Implementations§
Source§impl Session
impl Session
Sourcepub fn list_records(&self, view: &ViewInfo) -> Vec<Object>
pub fn list_records(&self, view: &ViewInfo) -> Vec<Object>
The records of a list, the way it chose to see them, as this person can read them.
Sourcepub fn list_table(&self, view: &ViewInfo) -> Option<GridTable>
pub fn list_table(&self, view: &ViewInfo) -> Option<GridTable>
A list as it stands: the columns showing and every record the way it chose to see them, as a table to make a report or a file from.
Source§impl Session
impl Session
Sourcepub fn embedded<S: ObjectSpace + 'static>(
application: Application,
space: impl Fn() -> S + 'static,
words: Words,
) -> Self
pub fn embedded<S: ObjectSpace + 'static>( application: Application, space: impl Fn() -> S + 'static, words: Words, ) -> Self
A session for lists and actions inside a screen an application made itself, with no window
around them. Showing a view is up to it, with show_list.
Sourcepub fn show_list(&self, id: &str)
pub fn show_list(&self, id: &str)
Shows this view of the model in the frame, without asking anything.
Sourcepub fn confirmations(&self) -> ConfirmDialog
pub fn confirmations(&self) -> ConfirmDialog
What asks before actions run, for a screen with no window of the framework around it.
Sourcepub fn toaster(&self) -> Toaster
pub fn toaster(&self) -> Toaster
What shows messages, for a screen with no window of the framework around it.
Sourcepub fn show_message(&self, message: Message)
pub fn show_message(&self, message: Message)
Tells people something, which goes away by itself.
Sourcepub fn use_records(
&self,
entity: impl Into<String>,
source: impl Fn() -> Vec<Object> + 'static,
)
pub fn use_records( &self, entity: impl Into<String>, source: impl Fn() -> Vec<Object> + 'static, )
Gives the records of an entity no storage keeps, for its list and its forms.
Sourcepub fn use_collection(
&self,
entity: impl Into<String>,
field: impl Into<String>,
source: impl Fn(&Object) -> Vec<Object> + 'static,
)
pub fn use_collection( &self, entity: impl Into<String>, field: impl Into<String>, source: impl Fn(&Object) -> Vec<Object> + 'static, )
Gives the records of a list no storage keeps, inside a form of this entity.
Sourcepub fn export_captions(&self) -> String
pub fn export_captions(&self) -> String
What people see in the model, as CSV with an empty column for its translation.
Sourcepub fn import_captions(&self, language: &str, csv: &str) -> Result<(), String>
pub fn import_captions(&self, language: &str, csv: &str) -> Result<(), String>
Takes the CSV of export_captions, filled in, as the model in this
language, which set_language picks.
Sourcepub fn register_control(
&self,
name: impl Into<String>,
control: impl Fn() -> AnyView + 'static,
)
pub fn register_control( &self, name: impl Into<String>, control: impl Fn() -> AnyView + 'static, )
Registers a control by name, for a dashboard to show.
Sourcepub fn set_model_setting(
&self,
path: &[&str],
name: &str,
value: &str,
) -> Result<(), String>
pub fn set_model_setting( &self, path: &[&str], name: &str, value: &str, ) -> Result<(), String>
Changes a setting of the model in the person’s own layer, if they may, and keeps it.
Sourcepub fn restore_model_settings(&self) -> Result<(), String>
pub fn restore_model_settings(&self) -> Result<(), String>
Throws away the person’s own changes to the model, if they may.
Sourcepub fn show_full(&self, content: impl Fn() -> AnyView + 'static)
pub fn show_full(&self, content: impl Fn() -> AnyView + 'static)
Shows this in place of the view, with the navigation still around it, until
close_full or going anywhere else.
Sourcepub fn close_full(&self)
pub fn close_full(&self)
Goes back to the view from what show_full showed.
Sourcepub fn close_presented(&self)
pub fn close_presented(&self)
Closes what present showed.
Sourcepub fn present(
&self,
title: impl Into<String>,
content: impl Fn() -> AnyView + 'static,
)
pub fn present( &self, title: impl Into<String>, content: impl Fn() -> AnyView + 'static, )
Shows this in a window over the screens, until it is closed.
Sourcepub fn set_form_caption(&self, caption: FormCaption)
pub fn set_form_caption(&self, caption: FormCaption)
Says what a field of a form is called when that depends on the record.
Sourcepub fn form_record(&self) -> Option<Object>
pub fn form_record(&self) -> Option<Object>
The record on the form as it stands, following its fields.
Sourcepub fn use_model_store(&self, store: Rc<dyn ModelStore>) -> Result<(), String>
pub fn use_model_store(&self, store: Rc<dyn ModelStore>) -> Result<(), String>
Keeps the person’s own layer of the model there, and reads what is there now.
Sourcepub fn set_language(&self, language: &str) -> Result<(), String>
pub fn set_language(&self, language: &str) -> Result<(), String>
Shows the model in this language, from the translations given.
Sourcepub fn register_list_editor(
&self,
name: impl Into<String>,
editor: impl Fn(&ListEditorRequest) -> AnyView + 'static,
)
pub fn register_list_editor( &self, name: impl Into<String>, editor: impl Fn(&ListEditorRequest) -> AnyView + 'static, )
Registers how a list can be shown, for a view’s EditorType in the model to pick by name,
or DefaultListEditor on Views for all of them.
Sourcepub fn choose_list_editor(&self, view: &str, editor: &str) -> Result<(), String>
pub fn choose_list_editor(&self, view: &str, editor: &str) -> Result<(), String>
Shows this list with the editor of this name, which stays in the person’s own layer.
Sourcepub fn use_attachment_store(&self, store: Rc<dyn AttachmentStore>)
pub fn use_attachment_store(&self, store: Rc<dyn AttachmentStore>)
Keeps the content of attached files there, apart from the records. Without it, a file stays inside its record’s field.
Sourcepub fn user_settings(&self) -> Option<String>
pub fn user_settings(&self) -> Option<String>
What the person changed in the model, to keep between runs.
Sourcepub fn set_form_value(&self, field: &str, value: Value)
pub fn set_form_value(&self, field: &str, value: Value)
Changes a field of the form, as a screen of its own around the form would.
Sourcepub fn of(cx: &ActionContext) -> Option<Self>
pub fn of(cx: &ActionContext) -> Option<Self>
The session an action is running in.
Sourcepub fn texts(&self) -> Texts
pub fn texts(&self) -> Texts
Every text of the application in its language, with what it added over the ones that come with the framework, for words of its own by key.
Sourcepub fn use_texts(&self, texts: Texts)
pub fn use_texts(&self, texts: Texts)
The texts texts gives, for this session and the ones inside it.
Sourcepub fn records_changed(&self)
pub fn records_changed(&self)
Tells lists to read again, after something changed the records from outside.
Sourcepub fn entity(&self, name: &str) -> Option<EntityInfo>
pub fn entity(&self, name: &str) -> Option<EntityInfo>
An entity by name.
Sourcepub fn announcer(&self) -> &Announcer
pub fn announcer(&self) -> &Announcer
Where screen readers hear what changed: saving, deleting, the screen that opened. Its region is in the window; an application says more with it.
Sourcepub fn set_access_words(&self, words: AccessWords)
pub fn set_access_words(&self, words: AccessWords)
The words of what screen readers hear, from the language of the application unless given.
Sourcepub fn access_words(&self) -> AccessWords
pub fn access_words(&self) -> AccessWords
The words of what screen readers hear.
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Goes up whenever records may have changed; reading it builds again when they do.
Sourcepub fn violations_of(&self, record: &Object, context: &str) -> Vec<Violation>
pub fn violations_of(&self, record: &Object, context: &str) -> Vec<Violation>
What this record fails in this context.
Sourcepub fn hand_file(&self, name: String, bytes: Vec<u8>, picker: &FilePicker)
pub fn hand_file(&self, name: String, bytes: Vec<u8>, picker: &FilePicker)
Hands a file over to whoever asked for them, or else to the person.
Sourcepub fn has_unsaved_changes(&self) -> bool
pub fn has_unsaved_changes(&self) -> bool
Whether there is a form with changes that were not kept.
Sourcepub fn open_detail(&self, entity_name: &str, key: &Value)
pub fn open_detail(&self, entity_name: &str, key: &Value)
Opens the form of a record, in a unit of work of its own.
Sourcepub fn run_action(&self, action: &Action, input: ActionInput)
pub fn run_action(&self, action: &Action, input: ActionInput)
Runs an action from a screen: asks its question first, and does what it asks for next.