Mountain/RPC/CocoonService/GenericRequest/WindowDialogs/
ShowInputBox.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::{Value, json};
4use tonic::Response;
5use CommonLibrary::UserInterface::UserInterfaceProvider::UserInterfaceProvider;
6
7use crate::{Environment::MountainEnvironment::MountainEnvironment, Vine::Generated::GenericResponse};
8
9pub async fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
10 use CommonLibrary::UserInterface::DTO::InputBoxOptionsDTO::InputBoxOptionsDTO;
11
12 let Opts = Params.get(0);
13
14 let Options = InputBoxOptionsDTO {
15 Prompt:Opts
16 .and_then(|V| V.get("prompt"))
17 .and_then(|P| P.as_str())
18 .map(|S| S.to_string()),
19
20 PlaceHolder:Opts
21 .and_then(|V| V.get("placeHolder"))
22 .and_then(|P| P.as_str())
23 .map(|S| S.to_string()),
24
25 IsPassword:Some(Opts.and_then(|V| V.get("password")).and_then(|B| B.as_bool()).unwrap_or(false)),
26
27 Value:Opts
28 .and_then(|V| V.get("value"))
29 .and_then(|V| V.as_str())
30 .map(|S| S.to_string()),
31
32 Title:None,
33
34 IgnoreFocusOut:None,
35 };
36
37 match Env.ShowInputBox(Some(Options)).await {
38 Ok(Some(Text)) => super::super::FileSystem::OkResponse(RequestId, &json!(Text)),
39
40 Ok(None) => super::super::FileSystem::OkResponse(RequestId, &Value::Null),
41
42 Err(Error) => super::super::FileSystem::ErrResponse(RequestId, -32000, Error.to_string()),
43 }
44}