diff --git a/src-tauri/src/apps/contractapp/filters.rs b/src-tauri/src/apps/contractapp/filters.rs index 5c19e2f..a6c7554 100644 --- a/src-tauri/src/apps/contractapp/filters.rs +++ b/src-tauri/src/apps/contractapp/filters.rs @@ -5,9 +5,9 @@ use super::models::{Contract, ContractApplicationFile, ContractCategory, Counter static CONTRACTAPP_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").remote("name_of_product"), Filter::exact("number"), - Filter::contains("number"), + Filter::contains("number").remote("number"), Filter::exact("date"), Filter::exact("status"), Filter::exact("status_name"), @@ -16,50 +16,50 @@ static CONTRACTAPP_FILTERS: &[Filter] = &[ Filter::contains("contract_type"), Filter::exact("category"), Filter::contains("category"), - Filter::exact("category_id"), + Filter::exact("category_id").remote("category"), Filter::contains("counterparty_name"), - Filter::contains("name_of_product"), - Filter::exact("counterparty_id"), - Filter::exact("project_id"), - Filter::exact("frc_id"), - Filter::exact("employee_id"), + Filter::contains("name_of_product").remote("name_of_product"), + Filter::exact("counterparty_id").remote("company"), + Filter::exact("project_id").remote("project"), + Filter::exact("frc_id").remote("frc"), + Filter::exact("employee_id").remote("employee"), ]; static CONTRACT_CATEGORY_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").local_only(), Filter::exact("name_group"), - Filter::contains("name_group"), + Filter::contains("name_group").local_only(), ]; static COUNTERPARTY_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").remote("search"), ]; static CONTRACT_APPLICATION_FILE_FILTERS: &[Filter] = &[ Filter::exact("id"), - Filter::exact("contract_id"), + Filter::exact("contract_id").remote("contract"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").remote("search"), Filter::exact("file_type"), Filter::exact("status"), ]; pub fn contractapp_filterset() -> FilterSet { - FilterSet::new(CONTRACTAPP_FILTERS) + FilterSet::new(CONTRACTAPP_FILTERS).remote_ordering("order_by") } pub fn contract_category_filterset() -> FilterSet { - FilterSet::new(CONTRACT_CATEGORY_FILTERS) + FilterSet::new(CONTRACT_CATEGORY_FILTERS).remote_ordering("order_by") } pub fn counterparty_filterset() -> FilterSet { - FilterSet::new(COUNTERPARTY_FILTERS) + FilterSet::new(COUNTERPARTY_FILTERS).remote_ordering("order_by") } pub fn contract_application_file_filterset() -> FilterSet { - FilterSet::new(CONTRACT_APPLICATION_FILE_FILTERS) + FilterSet::new(CONTRACT_APPLICATION_FILE_FILTERS).remote_ordering("order_by") } diff --git a/src-tauri/src/apps/contractapp/mod.rs b/src-tauri/src/apps/contractapp/mod.rs index 580c16a..ce5265b 100644 --- a/src-tauri/src/apps/contractapp/mod.rs +++ b/src-tauri/src/apps/contractapp/mod.rs @@ -16,23 +16,27 @@ impl AppModule for ContractappModule { } fn init(&self, ctx: &mut ModuleContext) { - ctx.resource::( + ctx.mapped_remote_resource::( "contract", + "/api/contract/", serializers::contractapp_serializer(), filters::contractapp_filterset(), ); - ctx.resource::( + ctx.mapped_remote_resource::( "contract_category", + "/api/cont/category/", serializers::contract_category_serializer(), filters::contract_category_filterset(), ); - ctx.resource::( + ctx.mapped_remote_resource::( "counterparty", + "/api/catalog/company/", serializers::counterparty_serializer(), filters::counterparty_filterset(), ); - ctx.resource::( + ctx.mapped_remote_resource::( "contract_application_file", + "/api/cont/appfile/", serializers::contract_application_file_serializer(), filters::contract_application_file_filterset(), ); diff --git a/src-tauri/src/apps/contractapp/serializers.rs b/src-tauri/src/apps/contractapp/serializers.rs index e179024..40d77a1 100644 --- a/src-tauri/src/apps/contractapp/serializers.rs +++ b/src-tauri/src/apps/contractapp/serializers.rs @@ -12,19 +12,19 @@ static CONTRACT_FIELDS: &[Field] = &[ Field::new("id").read_only(), Field::new("name"), Field::new("number"), - Field::new("absolute_url"), - Field::new("contract_type"), - Field::new("category"), + Field::new("absolute_url").source("get_absolute_url"), + Field::new("contract_type").source("get_type"), + Field::new("category").source("get_category"), Field::new("category_id").required(false).nullable(), - Field::new("amount_total_display"), - Field::new("amount_by_ds"), + Field::new("amount_total_display").source("get_amount_total"), + Field::new("amount_by_ds").source("get_amount_by_ds"), Field::new("comment"), Field::new("date"), - Field::new("status_name"), + Field::new("status_name").source("get_status"), Field::new("status"), Field::new("nds"), Field::new("name_of_product"), - Field::new("counterparty_name"), + Field::new("counterparty_name").source("counterparty"), Field::new("amount"), Field::new("month_pay").required(false).nullable(), Field::new("avans_pay"), @@ -35,15 +35,27 @@ static CONTRACT_FIELDS: &[Field] = &[ Field::new("bill_paid_sum").required(false).nullable(), Field::new("income_total"), Field::new("arrears"), - Field::new("counterparty_id").required(false).nullable(), - Field::new("project_id").required(false).nullable(), - Field::new("frc_id").required(false).nullable(), - Field::new("employee_id").required(false).nullable(), + Field::new("counterparty_id") + .source("company") + .required(false) + .nullable(), + Field::new("project_id") + .source("project") + .required(false) + .nullable(), + Field::new("frc_id") + .source("frc") + .required(false) + .nullable(), + Field::new("employee_id") + .source("get_employee") + .required(false) + .nullable(), Field::related("category_ref", "category_id", &CATEGORY_RELATION), - Field::related("counterparty", "counterparty_id", &COUNTERPARTY_RELATION), - Field::related("project", "project_id", &PROJECT_RELATION), - Field::related("frc", "frc_id", &FRC_RELATION), - Field::related("employee", "employee_id", &EMPLOYEE_RELATION), + Field::related("counterparty", "company", &COUNTERPARTY_RELATION), + Field::related("project", "project", &PROJECT_RELATION), + Field::related("frc", "frc", &FRC_RELATION), + Field::related("employee", "get_employee", &EMPLOYEE_RELATION), ]; static CONTRACT_CATEGORY_FIELDS: &[Field] = &[ @@ -58,16 +70,16 @@ static CONTRACT_CATEGORY_FIELDS: &[Field] = &[ static COUNTERPARTY_FIELDS: &[Field] = &[Field::new("id").read_only(), Field::new("name")]; static CONTRACT_APPLICATION_FILE_FIELDS: &[Field] = &[ Field::new("id").read_only(), - Field::new("contract_id"), + Field::new("contract_id").source("contract"), Field::new("name"), Field::new("file_type"), - Field::new("file_type_display"), + Field::new("file_type_display").source("get_file_type_display"), Field::new("status"), - Field::new("status_display"), - Field::new("absolute_url"), - Field::new("scan_name"), - Field::new("scan_url"), - Field::new("local_path"), + Field::new("status_display").source("get_status_display"), + Field::new("absolute_url").source("get_absolute_url"), + Field::new("scan_name").source("get_scan"), + Field::new("scan_url").source("scan"), + Field::new("local_path").default(empty_string), Field::new("comment"), Field::new("bill_total"), Field::new("bill_cost_total"), @@ -83,6 +95,10 @@ static PROJECT_RELATION: RelatedModel = RelatedModel::new(project_seria static FRC_RELATION: RelatedModel = RelatedModel::new(frc_serializer); static EMPLOYEE_RELATION: RelatedModel = RelatedModel::new(employee_serializer); +fn empty_string() -> serde_json::Value { + serde_json::Value::String(String::new()) +} + pub fn contractapp_serializer() -> ModelSerializer { ModelSerializer::new(CONTRACT_FIELDS) } diff --git a/src-tauri/src/apps/frcapp/filters.rs b/src-tauri/src/apps/frcapp/filters.rs index 5f26a25..914d879 100644 --- a/src-tauri/src/apps/frcapp/filters.rs +++ b/src-tauri/src/apps/frcapp/filters.rs @@ -5,9 +5,9 @@ use super::models::Frc; static FRC_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").local_only(), ]; pub fn frc_filterset() -> FilterSet { - FilterSet::new(FRC_FILTERS) + FilterSet::new(FRC_FILTERS).remote_ordering("order_by") } diff --git a/src-tauri/src/apps/frcapp/mod.rs b/src-tauri/src/apps/frcapp/mod.rs index 81ccdae..bc6670e 100644 --- a/src-tauri/src/apps/frcapp/mod.rs +++ b/src-tauri/src/apps/frcapp/mod.rs @@ -16,8 +16,9 @@ impl AppModule for FrcModule { } fn init(&self, ctx: &mut ModuleContext) { - ctx.resource::( + ctx.mapped_remote_resource::( "frc", + "/api/frc/frc/", serializers::frc_serializer(), filters::frc_filterset(), ); diff --git a/src-tauri/src/apps/frcapp/serializers.rs b/src-tauri/src/apps/frcapp/serializers.rs index 28fb796..e9be7f3 100644 --- a/src-tauri/src/apps/frcapp/serializers.rs +++ b/src-tauri/src/apps/frcapp/serializers.rs @@ -6,7 +6,7 @@ static FRC_FIELDS: &[Field] = &[ Field::new("id").read_only(), Field::new("name"), Field::new("icon"), - Field::new("balance"), + Field::new("balance").source("get_balance"), ]; pub fn frc_serializer() -> ModelSerializer { diff --git a/src-tauri/src/apps/personemanagment/filters.rs b/src-tauri/src/apps/personemanagment/filters.rs index 37683b7..49dc39e 100644 --- a/src-tauri/src/apps/personemanagment/filters.rs +++ b/src-tauri/src/apps/personemanagment/filters.rs @@ -5,17 +5,21 @@ use super::models::{Employee, Message, Task, TaskTransfer}; static EMPLOYEE_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").remote("name"), Filter::exact("short_name"), - Filter::contains("short_name"), + Filter::contains("short_name").remote("name"), ]; static TASK_FILTERS: &[Filter] = &[ Filter::exact("id"), - Filter::exact("name"), - Filter::contains("name"), - Filter::exact("author_id"), - Filter::exact("responsible_id"), + Filter::contains("text"), + Filter::remote_only("doer"), + Filter::remote_only("author"), + Filter::exact("archive"), + Filter::exact("typ"), + Filter::exact("status"), + Filter::remote_only("q"), + Filter::remote_only("incomplete"), ]; static MESSAGE_FILTERS: &[Filter] = &[ @@ -26,18 +30,18 @@ static MESSAGE_FILTERS: &[Filter] = &[ static TASK_TRANSFER_FILTERS: &[Filter] = &[ Filter::exact("id"), - Filter::exact("employee_from_id"), - Filter::exact("employee_to_id"), + Filter::remote_only("employee_from"), + Filter::remote_only("employee_to"), Filter::exact("status"), Filter::exact("typ"), ]; pub fn employee_filterset() -> FilterSet { - FilterSet::new(EMPLOYEE_FILTERS) + FilterSet::new(EMPLOYEE_FILTERS).remote_ordering("order_by") } pub fn task_filterset() -> FilterSet { - FilterSet::new(TASK_FILTERS) + FilterSet::new(TASK_FILTERS).remote_ordering("order_by") } pub fn message_filterset() -> FilterSet { @@ -45,5 +49,5 @@ pub fn message_filterset() -> FilterSet { } pub fn task_transfer_filterset() -> FilterSet { - FilterSet::new(TASK_TRANSFER_FILTERS) + FilterSet::new(TASK_TRANSFER_FILTERS).remote_ordering("order_by") } diff --git a/src-tauri/src/apps/personemanagment/mod.rs b/src-tauri/src/apps/personemanagment/mod.rs index d5dfbb3..32ee862 100644 --- a/src-tauri/src/apps/personemanagment/mod.rs +++ b/src-tauri/src/apps/personemanagment/mod.rs @@ -16,20 +16,21 @@ impl AppModule for TaskModule { } fn init(&self, ctx: &mut ModuleContext) { - ctx.resource::( + ctx.mapped_remote_resource::( "employee", + "/api/persone/employee/", serializers::employee_serializer(), filters::employee_filterset(), ); - ctx.remote_resource::( + ctx.mapped_remote_resource::( "task", - "/api/persone/task", + "/api/persone/task/", serializers::task_serializer(), filters::task_filterset(), ); - ctx.remote_resource::( + ctx.mapped_remote_resource::( "task_transfer", - "/api/persone/task_transfer", + "/api/persone/task_transfer/", serializers::task_transfer_serializer(), filters::task_transfer_filterset(), ); diff --git a/src-tauri/src/apps/personemanagment/models.rs b/src-tauri/src/apps/personemanagment/models.rs index 3fcdce3..c28fcba 100644 --- a/src-tauri/src/apps/personemanagment/models.rs +++ b/src-tauri/src/apps/personemanagment/models.rs @@ -19,13 +19,73 @@ pub struct Task { #[field(primary_key)] pub id: i64, - pub name: String, - - #[field(foreign_key = Employee)] - pub author_id: Option, - - #[field(foreign_key = Employee)] - pub responsible_id: Option, + pub project: Option, + pub doer: Option, + pub doer_name: String, + pub author: Option, + pub memo_full: Option, + pub bill_full: Option, + pub contract_full: Option, + pub contract_application_full: Option, + pub outgoing_letter_full: Option, + pub entry_letter_full: Option, + pub protocolitem_full: Option, + pub decree_full: Option, + pub delivery_full: Option, + pub get_status: String, + pub get_status_class: String, + pub get_scan_url: Option, + pub get_last_day: String, + pub frc_icon: String, + pub uploadfile_set: Option, + pub deadline: String, + pub request_new_deadline: Option, + pub plan_date: Option, + pub date: String, + pub message_set: Option, + pub responsible: Option, + pub counterparty: Option, + pub get_deadline_history: Option, + pub duration: Option, + pub bid_full: Option, + pub price_agreement_full: Option, + pub transfer: Option, + pub text: String, + pub status: String, + pub result: String, + pub complit_date: Option, + pub comment: String, + pub note: String, + pub approve: bool, + pub archive: bool, + pub approve_date: Option, + pub approve_required: bool, + pub progress_status: String, + pub start_date: Option, + pub end_date: Option, + pub order_number: Option, + pub priority: Option, + pub typ: String, + pub stage: Option, + pub contract: Option, + pub questionnair: Option, + pub contract_application: Option, + pub entry_letter: Option, + pub outgoing_letter: Option, + pub protocol: Option, + pub bill: Option, + pub decree: Option, + pub court_case: Option, + pub bill_register: Option, + pub price_agreement: Option, + pub bid: Option, + pub delivery: Option, + pub scheduled_task: Option, + pub report: Option, + pub memo: Option, + pub protocolitem: Option, + pub related_note: Option, + pub task: Option, } #[derive(Debug, Clone, Model)] @@ -49,14 +109,14 @@ pub struct TaskTransfer { #[field(primary_key)] pub id: i64, - #[field(foreign_key = Employee)] - pub employee_from_id: Option, + pub employee_from: Option, - #[field(foreign_key = Employee)] - pub employee_to_id: Option, + pub employee_to: Option, pub date_create: String, + pub task: Option, + pub status: String, pub typ: String, diff --git a/src-tauri/src/apps/personemanagment/serializers.rs b/src-tauri/src/apps/personemanagment/serializers.rs index e9d487f..0d55503 100644 --- a/src-tauri/src/apps/personemanagment/serializers.rs +++ b/src-tauri/src/apps/personemanagment/serializers.rs @@ -11,9 +11,85 @@ static EMPLOYEE_FIELDS: &[Field] = &[ static TASK_FIELDS: &[Field] = &[ Field::new("id").read_only(), - Field::new("name"), - Field::new("author_id").required(false).nullable(), - Field::new("responsible_id").required(false).nullable(), + Field::json("project").required(false).nullable(), + Field::json("doer").required(false).nullable(), + Field::new("doer_name"), + Field::json("author").required(false).nullable(), + Field::json("memo_full").required(false).nullable(), + Field::json("bill_full").required(false).nullable(), + Field::json("contract_full").required(false).nullable(), + Field::json("contract_application_full") + .required(false) + .nullable(), + Field::json("outgoing_letter_full") + .required(false) + .nullable(), + Field::json("entry_letter_full").required(false).nullable(), + Field::json("protocolitem_full").required(false).nullable(), + Field::json("decree_full").required(false).nullable(), + Field::json("delivery_full").required(false).nullable(), + Field::new("get_status"), + Field::new("get_status_class"), + Field::new("get_scan_url").required(false).nullable(), + Field::new("get_last_day"), + Field::new("frc_icon"), + Field::json("uploadfile_set").required(false).nullable(), + Field::new("deadline"), + Field::new("request_new_deadline") + .required(false) + .nullable(), + Field::new("plan_date").required(false).nullable(), + Field::new("date"), + Field::json("message_set").required(false).nullable(), + Field::json("responsible").required(false).nullable(), + Field::json("counterparty").required(false).nullable(), + Field::json("get_deadline_history") + .required(false) + .nullable(), + Field::new("duration").required(false).nullable(), + Field::json("bid_full").required(false).nullable(), + Field::json("price_agreement_full") + .required(false) + .nullable(), + Field::json("transfer").required(false).nullable(), + Field::new("text"), + Field::new("status"), + Field::new("result"), + Field::new("complit_date").required(false).nullable(), + Field::new("comment"), + Field::new("note"), + Field::new("approve"), + Field::new("archive"), + Field::new("approve_date").required(false).nullable(), + Field::new("approve_required"), + Field::new("progress_status"), + Field::new("start_date").required(false).nullable(), + Field::new("end_date").required(false).nullable(), + Field::new("order_number").required(false).nullable(), + Field::new("priority").required(false).nullable(), + Field::new("typ"), + Field::json("stage").required(false).nullable(), + Field::json("contract").required(false).nullable(), + Field::json("questionnair").required(false).nullable(), + Field::json("contract_application") + .required(false) + .nullable(), + Field::json("entry_letter").required(false).nullable(), + Field::json("outgoing_letter").required(false).nullable(), + Field::json("protocol").required(false).nullable(), + Field::json("bill").required(false).nullable(), + Field::json("decree").required(false).nullable(), + Field::json("court_case").required(false).nullable(), + Field::json("bill_register").required(false).nullable(), + Field::json("price_agreement").required(false).nullable(), + Field::json("bid").required(false).nullable(), + Field::json("delivery").required(false).nullable(), + Field::json("scheduled_task").required(false).nullable(), + Field::json("report").required(false).nullable(), + Field::json("memo").required(false).nullable(), + Field::json("protocolitem").required(false).nullable(), + Field::json("related_note").required(false).nullable(), + Field::json("task").required(false).nullable(), ]; static MESSAGE_FIELDS: &[Field] = &[ @@ -25,12 +101,12 @@ static MESSAGE_FIELDS: &[Field] = &[ static TASK_TRANSFER_FIELDS: &[Field] = &[ Field::new("id").read_only(), - Field::new("employee_from_id").required(false).nullable(), - Field::new("employee_to_id").required(false).nullable(), + Field::json("employee_from").required(false).nullable(), + Field::json("employee_to").required(false).nullable(), Field::new("date_create").read_only(), + Field::json("task").required(false).nullable(), Field::new("status"), Field::new("typ"), - Field::new("project_id"), ]; pub fn employee_serializer() -> ModelSerializer { diff --git a/src-tauri/src/apps/projectapp/filters.rs b/src-tauri/src/apps/projectapp/filters.rs index 403193b..d80fe47 100644 --- a/src-tauri/src/apps/projectapp/filters.rs +++ b/src-tauri/src/apps/projectapp/filters.rs @@ -5,11 +5,11 @@ use super::models::Project; static PROJECT_FILTERS: &[Filter] = &[ Filter::exact("id"), Filter::exact("name"), - Filter::contains("name"), + Filter::contains("name").remote("search"), Filter::exact("short_name"), - Filter::contains("short_name"), + Filter::contains("short_name").remote("search"), ]; pub fn project_filterset() -> FilterSet { - FilterSet::new(PROJECT_FILTERS) + FilterSet::new(PROJECT_FILTERS).remote_ordering("order_by") } diff --git a/src-tauri/src/apps/projectapp/mod.rs b/src-tauri/src/apps/projectapp/mod.rs index e351576..42a584c 100644 --- a/src-tauri/src/apps/projectapp/mod.rs +++ b/src-tauri/src/apps/projectapp/mod.rs @@ -16,8 +16,9 @@ impl AppModule for ProjectModule { } fn init(&self, ctx: &mut ModuleContext) { - ctx.resource::( + ctx.mapped_remote_resource::( "project", + "/api/project/", serializers::project_serializer(), filters::project_filterset(), ); diff --git a/src-tauri/src/apps/projectapp/serializers.rs b/src-tauri/src/apps/projectapp/serializers.rs index ba1fb5a..2d1fbcd 100644 --- a/src-tauri/src/apps/projectapp/serializers.rs +++ b/src-tauri/src/apps/projectapp/serializers.rs @@ -6,9 +6,15 @@ static PROJECT_FIELDS: &[Field] = &[ Field::new("id").read_only(), Field::new("name"), Field::new("full_name"), - Field::new("short_name"), - Field::new("locality_id").required(false).nullable(), - Field::new("locality_name").required(false).nullable(), + Field::new("short_name").source("get_short_name"), + Field::new("locality_id") + .source("locality") + .required(false) + .nullable(), + Field::new("locality_name") + .source("locality.name") + .required(false) + .nullable(), ]; pub fn project_serializer() -> ModelSerializer { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index de966a1..83288fb 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -152,7 +152,7 @@ pub fn run() { url: String::from("sqlite://ewa-mobile.sqlite?mode=rwc"), }, remote: Some(RemoteConfig { - base_url: String::from("https://ewa-corp.ru/"), + base_url: String::from("http://127.0.0.1:8000/"), auth_path: Some(String::from(" /api-token-auth/")), }), };