diff --git a/examples/main.py b/examples/main.py
index 1e13ff2..2f718e8 100644
--- a/examples/main.py
+++ b/examples/main.py
@@ -65,6 +65,7 @@ def create_app():
login_description='FastAPI Admin Dashboard',
locale='en-US',
locale_switcher=True,
+ theme_switcher=True,
menus=[
Menu(
name='Home',
diff --git a/fastapi_admin/factory.py b/fastapi_admin/factory.py
index 8e756d5..dbc71ee 100644
--- a/fastapi_admin/factory.py
+++ b/fastapi_admin/factory.py
@@ -114,7 +114,7 @@ class AdminApp(FastAPI):
sortable=name in sort_fields
)
}
- if not exclude_actions:
+ if not exclude_actions and menu.actions:
fields['_actions'] = menu.actions
for data_field in data_fields:
@@ -186,12 +186,14 @@ class AdminApp(FastAPI):
pk, fields, search_fields = await self._build_resource_from_model_describe(resource, model, model_describe,
exclude_pk, exclude_m2m_field,
exclude_actions)
+ menu = self.model_menu_mapping[resource]
return Resource(
title=model_describe.get('description') or resource.title(),
fields=fields,
searchFields=search_fields,
pk=pk,
- bulk_actions=self.model_menu_mapping[resource].bulk_actions,
+ bulk_actions=menu.bulk_actions,
+ export=menu.export
)
diff --git a/fastapi_admin/site.py b/fastapi_admin/site.py
index 42ceb27..64eee35 100644
--- a/fastapi_admin/site.py
+++ b/fastapi_admin/site.py
@@ -26,9 +26,8 @@ class Menu(BaseModel):
sort_fields: Optional[Set[str]] = set()
# define field type,like select,radiolist,text,date
fields_type: Dict = {}
- actions: Dict = {
- 'export': True
- }
+ export: bool = True
+ actions: Optional[Dict]
bulk_actions: List[Dict] = [{
'value': 'delete',
'text': 'delete_all',
@@ -80,6 +79,7 @@ class Resource(BaseModel):
resource_fields: Dict[str, Union[Field, Dict]]
searchFields: Optional[Dict[str, Field]]
bulk_actions: Optional[List[Dict]]
+ export: bool
class Config:
fields = {
diff --git a/front/src/views/CustomTable.vue b/front/src/views/CustomTable.vue
index 8d20e87..c8e6182 100644
--- a/front/src/views/CustomTable.vue
+++ b/front/src/views/CustomTable.vue
@@ -46,7 +46,7 @@
type="button"
@click="searchAndExport"
variant="success"
- v-if="_.get(actions, 'export')"
+ v-if="this.export"
>{{$t('actions.search_and_export')}}
@@ -83,15 +83,6 @@
:sort-desc.sync="sortDesc"
:sort-direction="sortDirection"
>
-
-
-
-
{{$d(new Date(data.value), 'long')}}
@@ -117,7 +108,9 @@
{{ _.find(data.field.options,{value:data.value}).text }}
+
{{ data.value}}
+
@@ -205,11 +198,10 @@
sortDirection: null,
perPage: 10,
where: {},
- pk: null,
selected_pk_list: [],
bulkActions: {},
selectBulkAction: null,
- pages: [10, 50, 100]
+ pages: [10, 50, 100],
};
},
watch: {
@@ -233,6 +225,12 @@
}
})
},
+ pk() {
+ return _.get(this.table, "pk");
+ },
+ export() {
+ return _.get(this.table, "export");
+ },
populate() {
return _(this.table.fields || {})
.map("ref")
@@ -363,7 +361,6 @@
});
this.table = res.data;
- this.pk = res.data.pk;
if (_.get(this.table, "fields._actions") !== false) {
_.set(