hide search if no searchable fields
This commit is contained in:
parent
e79ae0a592
commit
08130f12fe
@ -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 field_for_primary_key = get_field_for_primary_key(&fields);
|
||||||
let fields_for_validate_model = get_fields_for_validate_model(&fields);
|
let fields_for_validate_model = get_fields_for_validate_model(&fields);
|
||||||
let fields_searchable = get_actix_admin_fields_searchable(&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 fields_type_path = get_actix_admin_fields_type_path_string(&fields);
|
||||||
|
|
||||||
let select_lists = get_select_lists(&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 {
|
ActixAdminViewModel {
|
||||||
primary_key: #name_primary_field_str.to_string(),
|
primary_key: #name_primary_field_str.to_string(),
|
||||||
entity_name: entity.table_name().to_string(),
|
entity_name: entity.table_name().to_string(),
|
||||||
fields: Entity::get_fields()
|
fields: Entity::get_fields(),
|
||||||
|
show_search: #has_searchable_fields
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ impl ActixAdminModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let parsed_val = f(val);
|
let parsed_val = f(val);
|
||||||
println!("{:?}", val);
|
|
||||||
|
|
||||||
match parsed_val {
|
match parsed_val {
|
||||||
Ok(val) => Ok(Some(val)),
|
Ok(val) => Ok(Some(val)),
|
||||||
|
@ -36,7 +36,6 @@ async fn create_or_edit_post<T: ActixAdminAppDataTrait, E: ActixAdminViewModelTr
|
|||||||
let entity_names = &data.get_actix_admin().entity_names;
|
let entity_names = &data.get_actix_admin().entity_names;
|
||||||
let actix_admin = data.get_actix_admin();
|
let actix_admin = data.get_actix_admin();
|
||||||
let view_model = actix_admin.view_models.get(&entity_name).unwrap();
|
let view_model = actix_admin.view_models.get(&entity_name).unwrap();
|
||||||
println!("{:?}", model);
|
|
||||||
|
|
||||||
if model.has_errors() {
|
if model.has_errors() {
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
|
@ -3,7 +3,6 @@ use sea_orm::DatabaseConnection;
|
|||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::ActixAdminModel;
|
use crate::ActixAdminModel;
|
||||||
use std::convert::From;
|
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
pub trait ActixAdminViewModelTrait {
|
pub trait ActixAdminViewModelTrait {
|
||||||
@ -33,6 +32,7 @@ pub struct ActixAdminViewModel {
|
|||||||
pub entity_name: String,
|
pub entity_name: String,
|
||||||
pub primary_key: String,
|
pub primary_key: String,
|
||||||
pub fields: Vec<ActixAdminViewModelField>,
|
pub fields: Vec<ActixAdminViewModelField>,
|
||||||
|
pub show_search: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
name="{{ model_field.field_name }}"
|
name="{{ model_field.field_name }}"
|
||||||
placeholder="{{ model_field.field_name }}"
|
placeholder="{{ model_field.field_name }}"
|
||||||
aria-label="{{ 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 %}
|
||||||
>
|
>
|
@ -28,6 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
|
{% if view_model.show_search %}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<p class="control has-icons-left has-icons-right">
|
<p class="control has-icons-left has-icons-right">
|
||||||
<input class="input is-rounded" type="search" id="search" value="{{ search }}" name="search"
|
<input class="input is-rounded" type="search" id="search" value="{{ search }}" name="search"
|
||||||
@ -40,6 +41,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
<div>
|
<div>
|
||||||
|
BIN
database.db
BIN
database.db
Binary file not shown.
BIN
database.db-wal
BIN
database.db-wal
Binary file not shown.
Loading…
Reference in New Issue
Block a user