description |
---|
is responsible for editing record in a given resource |
Endpoint: /api/resources/[RESOURCE-ID]/records/[RECORD-ID]/edit
Method: POST
Request payload:
FormData
Object with all required fields for the given resource
Response:
redirectUrl
- URL that the user should be directed to after a successful updatenotice
message
- the message that is later displayed in the dashboardtype
- a type of response, possible values aresuccess
,error
,info
record
- record you're requestingparams
- all record dataid
- record idtitle
- record titlerecordActions
- list all actions and their parameters available on this recordbulkActions
- list of all bulk actions and their parameters available on this record
records
- list of records with resource metadata
Example
Endpoint: https://demo.adminjs.co/admin/api/resources/User/actions/new
Payload:
{
email: "[email protected]",
firstName: "ClientName",
lastName: "ClientSurname",
gender: "male",
isMyFavourite: true
}
Response:
{
"redirectUrl":"/admin/resources/User",
"notice":{
"message":"Successfully updated given record",
"type":"success"
},
"record":{
"params":{
"_id":"63d3b2c982bf27f5606e44eb",
"firstName":"Admin Name",
"lastName":"Admin Surname",
"gender":"male",
"email":"[email protected]",
"isMyFavourite":true,
"__v":0
},
"populated":{
},
"baseError":null,
"errors":{
},
"id":"63d3b2c982bf27f5606e44eb",
"title":"[email protected]",
"recordActions":[
{
"name":"show",
"actionType":"record",
"icon":"Screen",
"label":"Show",
"resourceId":"User",
"guard":"",
"showFilter":false,
"showResourceActions":true,
"showInDrawer":false,
"hideActionHeader":false,
"containerWidth":1,
"layout":null,
"variant":"default",
"parent":null,
"hasHandler":true,
"custom":{
}
},
{
"name":"edit",
"actionType":"record",
"icon":"Edit",
"label":"Edit",
"resourceId":"User",
"guard":"",
"showFilter":false,
"showResourceActions":true,
"showInDrawer":false,
"hideActionHeader":false,
"containerWidth":1,
"layout":null,
"variant":"default",
"parent":null,
"hasHandler":true,
"custom":{
}
},
{
"name":"delete",
"actionType":"record",
"icon":"TrashCan",
"label":"Delete",
"resourceId":"User",
"guard":"Do you really want to remove this item?",
"showFilter":false,
"showResourceActions":true,
"component":false,
"showInDrawer":false,
"hideActionHeader":false,
"containerWidth":1,
"layout":null,
"variant":"danger",
"parent":null,
"hasHandler":true,
"custom":{
}
}
],
"bulkActions":[
{
"name":"bulkDelete",
"actionType":"bulk",
"icon":"Delete",
"label":"Delete all",
"resourceId":"User",
"guard":"",
"showFilter":false,
"showResourceActions":true,
"showInDrawer":true,
"hideActionHeader":false,
"containerWidth":"500px",
"layout":null,
"variant":"danger",
"parent":null,
"hasHandler":true,
"custom":{
}
}
]
}
}