Mountain/IPC/WindServiceHandlers/UI/
QuickInputShowInputBox.rs1#![allow(unused_variables)]
2
3use std::sync::Arc;
6
7use serde_json::{Value, json};
8
9use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
10
11pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
12 use CommonLibrary::UserInterface::{
13 DTO::InputBoxOptionsDTO::InputBoxOptionsDTO,
14 UserInterfaceProvider::UserInterfaceProvider,
15 };
16
17 let Opts = Arguments.first();
18
19 let Options = InputBoxOptionsDTO {
20 Prompt:Opts
21 .and_then(|V| V.get("prompt"))
22 .and_then(|P| P.as_str())
23 .map(|S| S.to_string()),
24
25 PlaceHolder:Opts
26 .and_then(|V| V.get("placeholder"))
27 .and_then(|P| P.as_str())
28 .map(|S| S.to_string()),
29
30 IsPassword:Some(Opts.and_then(|V| V.get("password")).and_then(|B| B.as_bool()).unwrap_or(false)),
31
32 Value:Opts
33 .and_then(|V| V.get("value"))
34 .and_then(|V| V.as_str())
35 .map(|S| S.to_string()),
36
37 Title:Opts
38 .and_then(|V| V.get("title"))
39 .and_then(|T| T.as_str())
40 .map(|S| S.to_string()),
41
42 IgnoreFocusOut:None,
43 };
44
45 let Result = RunTime
46 .Environment
47 .ShowInputBox(Some(Options))
48 .await
49 .map_err(|Error| format!("quickInput:showInputBox failed: {}", Error))?;
50
51 Ok(Result.map(|S| json!(S)).unwrap_or(Value::Null))
52}