hide search if no searchable fields

This commit is contained in:
manuel 2022-08-06 13:55:17 +02:00
parent e79ae0a592
commit 08130f12fe
8 changed files with 7 additions and 5 deletions

View File

@ -37,6 +37,7 @@ pub fn derive_crud_fns(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
let field_for_primary_key = get_field_for_primary_key(&fields);
let fields_for_validate_model = get_fields_for_validate_model(&fields);
let fields_searchable = get_actix_admin_fields_searchable(&fields);
let has_searchable_fields = fields_searchable.len() > 0;
let fields_type_path = get_actix_admin_fields_type_path_string(&fields);
let select_lists = get_select_lists(&fields);
@ -60,7 +61,8 @@ pub fn derive_crud_fns(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
ActixAdminViewModel {
primary_key: #name_primary_field_str.to_string(),
entity_name: entity.table_name().to_string(),
fields: Entity::get_fields()
fields: Entity::get_fields(),
show_search: #has_searchable_fields
}
}
}

View File

@ -98,7 +98,6 @@ impl ActixAdminModel {
}
let parsed_val = f(val);
println!("{:?}", val);
match parsed_val {
Ok(val) => Ok(Some(val)),

View File

@ -36,7 +36,6 @@ async fn create_or_edit_post<T: ActixAdminAppDataTrait, E: ActixAdminViewModelTr
let entity_names = &data.get_actix_admin().entity_names;
let actix_admin = data.get_actix_admin();
let view_model = actix_admin.view_models.get(&entity_name).unwrap();
println!("{:?}", model);
if model.has_errors() {
let mut ctx = Context::new();

View File

@ -3,7 +3,6 @@ use sea_orm::DatabaseConnection;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use crate::ActixAdminModel;
use std::convert::From;
#[async_trait(?Send)]
pub trait ActixAdminViewModelTrait {
@ -33,6 +32,7 @@ pub struct ActixAdminViewModel {
pub entity_name: String,
pub primary_key: String,
pub fields: Vec<ActixAdminViewModelField>,
pub show_search: bool
}
#[derive(Clone, Debug, Serialize, Deserialize)]

View File

@ -5,5 +5,5 @@
name="{{ model_field.field_name }}"
placeholder="{{ model_field.field_name }}"
aria-label="{{ model_field.field_name }}"
{% if model.values | get(key=model_field.field_name) == "true" %}checked{% endif %}
{% if model.values | get(key=model_field.field_name, default="false") == "true" %}checked{% endif %}
>

View File

@ -28,6 +28,7 @@
</div>
</div>
<div class="column is-narrow">
{% if view_model.show_search %}
<div class="field">
<p class="control has-icons-left has-icons-right">
<input class="input is-rounded" type="search" id="search" value="{{ search }}" name="search"
@ -40,6 +41,7 @@
</span>
</p>
</div>
{% endif %}
</div>
<div class="column is-narrow">
<div>

Binary file not shown.

Binary file not shown.