/* This file is part of inventur. * inventur is a simple web app using rocket to help maintain inventory data. * Copyright (C) 2024 Johannes Randerath * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ //! Submodule holding structs relevant to handle form data. use rocket::serde::{Serialize, Deserialize}; //use inventur_db::ShareCard; #[derive(FromForm)] pub struct DeleteColumn { pub tblid: i32, pub id_in_table: i32, } #[derive(FromForm)] pub struct EditColumn { pub tblid: i32, pub id_in_table: i32, pub name: String, pub column_type: isize, } #[derive(FromForm)] pub struct NewColumn { pub tblid: i32, pub name: String, pub column_type: isize, } #[derive(FromForm)] pub struct NewEntry { pub tblid: i32, pub cells: Vec, } #[derive(FromForm)] pub struct EditEntry { pub tblid: i32, pub cells: Vec, pub row_pos: i32, } #[derive(FromForm)] pub struct DeleteEntry { pub tblid: i32, pub row_pos: i32, } /// Edit a table's name #[derive(FromForm)] pub struct EditTname { pub tblid: i32, pub new_name: String, } #[derive(FromForm)] pub struct NewTable { pub name: String, pub field_names: Vec, pub field_types: Vec, } #[derive(Deserialize)] #[serde(crate = "rocket::serde")] pub struct ImportTable { pub name: String, pub columns: Vec, pub rows: Vec>, } #[derive(FromForm)] pub struct DeleteTable { pub tblid: i32, } #[derive(Serialize, Clone)] #[serde(crate = "rocket::serde")] pub struct Sharee { id: i32, username: String, readonly: bool, } impl From for Sharee { fn from(sharecard: inventur_db::ShareCard) -> Self { Sharee { id: sharecard.sharee_id, username: sharecard.sharee_name, readonly: sharecard.readonly} } } #[derive(FromForm, Debug)] pub struct EditShare { pub sharees: Vec, pub readonly: Vec, pub delete: Vec, pub tblid: i32, pub new_user: Option, } #[derive(Serialize, Clone, Debug)] #[serde(crate = "rocket::serde")] pub struct UserQueryResult { pub id: i32, pub username: String, } #[derive(FromForm, Debug)] pub struct SearchString { pub query: String, }