Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add generic menu action. #48

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 15 additions & 55 deletions src/models/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ impl Default for MenuResponse {
}
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct MenuAction {
pub internal_id: Option<i32>,
pub id: Option<String>,
pub uuid: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Menu {
pub uuid: Option<String>,
Expand All @@ -46,11 +56,11 @@ pub struct Menu {
pub action: Option<String>,
pub action_id: Option<i32>,
pub action_uuid: Option<String>,
pub window: Option<Window>,
pub process: Option<Process>,
pub form: Option<Form>,
pub browser: Option<Browser>,
pub workflow: Option<Workflow>,
pub window: Option<MenuAction>,
pub process: Option<MenuAction>,
pub form: Option<MenuAction>,
pub browser: Option<MenuAction>,
pub workflow: Option<MenuAction>,
// Tree menu childs
pub children: Option<Vec<Menu>>
}
Expand Down Expand Up @@ -117,56 +127,6 @@ impl Menu {
}
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Window {
pub uuid: Option<String>,
pub internal_id: Option<i32>,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>,
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Process {
pub uuid: Option<String>,
pub internal_id: Option<i32>,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>,
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Form {
pub uuid: Option<String>,
pub internal_id: Option<i32>,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>,
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Browser {
pub uuid: Option<String>,
pub internal_id: Option<i32>,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>,
}

#[derive(Deserialize, Serialize, Extractible, Debug, Clone)]
pub struct Workflow {
pub uuid: Option<String>,
pub internal_id: Option<i32>,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub help: Option<String>,
}

pub async fn allowed_menu(_language: Option<&String>, _client_id: Option<&String>, _role_id: Option<&String>, _dictionary_code: Option<&String>) -> Result<MenuListResponse, std::io::Error> {
let _expected_role = role_from_id(_role_id, _client_id, _dictionary_code).await;
let _role = match _expected_role {
Expand Down
22 changes: 11 additions & 11 deletions src/models/menu_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{io::ErrorKind, io::Error};

use crate::controller::opensearch::{find_from_dsl_body, IndexDocument};

use super::{get_index_name, menu::{Browser, Form, Process, Window, Workflow}, role::Role};
use super::{get_index_name, menu::MenuAction, role::Role};

#[derive(Deserialize, Extractible, Debug, Clone)]
#[salvo(extract(default_source(from = "body")))]
Expand Down Expand Up @@ -53,11 +53,11 @@ pub struct MenuItem {
pub action: Option<String>,
pub action_id: Option<i32>,
pub action_uuid: Option<String>,
pub window: Option<Window>,
pub process: Option<Process>,
pub form: Option<Form>,
pub browser: Option<Browser>,
pub workflow: Option<Workflow>
pub window: Option<MenuAction>,
pub process: Option<MenuAction>,
pub form: Option<MenuAction>,
pub browser: Option<MenuAction>,
pub workflow: Option<MenuAction>
}

impl Default for MenuItem {
Expand All @@ -83,11 +83,11 @@ impl Default for MenuItem {
action: None,
action_id: None,
action_uuid: None,
window: None,
process: None,
form: None,
browser: None,
workflow: None
window: None,
process: None,
form: None,
browser: None,
workflow: None
}
}
}
Expand Down