Closed lpbonomi closed 8 months ago
@lpbonomi I've released 1.1.0
of @adminjs/relations
which allows you to configure deleteOptions
for M:N
export interface ManyToManyRelationOptions extends BaseRelationOptions {
type: RelationType.ManyToMany;
junction?: {
joinKey: string;
inverseJoinKey: string;
throughResourceId: string;
};
target: {
resourceId: string;
};
/**
* Override default delete options.
*/
deleteOptions?: {
/**
* Whether user can delete a relation (record in junction table)
*/
enableDeleteRelation: boolean;
/**
* Whether user can delete related record (target record).
* If target record's delete action is disabled, you won't be able to delete the record even if this option is set to true.
*/
enableDeleteRelatedRecord: boolean;
};
}
By default, both options are enabled to match previous behaviour. You can configure it to only display "Remove relation" button though:
deleteOptions: {
enableDeleteRelation: true,
enableDeleteRelatedRecord: false,
}
Amazing @dziraf , you've been making my whole week, thanks!
Description
This is the current dialog when you click the trash can in the relations package:
I think that it is not a very good idea to have the option to delete a record when managing relations and even less as the primary option
Suggested Solution
My suggestion is to have a normal "Remove relation" dialog with a cancel/yes button.
Alternatives
No response
Additional Context
No response