Skip to content

Commit

Permalink
#1290 | Allow deletion of location types
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Aug 22, 2024
1 parent 56b93ee commit de10a1d
Showing 1 changed file with 8 additions and 49 deletions.
57 changes: 8 additions & 49 deletions src/adminApp/addressLevelType.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,11 @@ import { createdAudit, modifiedAudit } from "./components/AuditUtil";
import { ToolTipContainer } from "../common/components/ToolTipContainer";

export const LocationTypeList = props => (
<List
{...props}
bulkActions={false}
title="Location Types"
sort={{ field: "level", order: "DESC" }}
>
<List {...props} bulkActions={false} title="Location Types" sort={{ field: "level", order: "DESC" }}>
<Datagrid rowClick="show">
<TextField label="Location Type" source="name" />
<TextField label="Level" source="level" />
<ReferenceField
label="Parent"
source="parentId"
reference="addressLevelType"
linkType="show"
allowEmpty
>
<ReferenceField label="Parent" source="parentId" reference="addressLevelType" linkType="show" allowEmpty>
<TextField source="name" />
</ReferenceField>
</Datagrid>
Expand All @@ -55,17 +44,8 @@ const ParentReferenceField = ({ showToolTip, ...props }) => {
return isNil(props.record.parentId) ? (
<None />
) : (
<Container
toolTipKey={"ADMIN_LOCATION_TYPE_PARENT"}
styles={{ paddingTop: 10, marginRight: "10px" }}
>
<ReferenceField
{...props}
source="parentId"
linkType="show"
reference="addressLevelType"
allowEmpty
>
<Container toolTipKey={"ADMIN_LOCATION_TYPE_PARENT"} styles={{ paddingTop: 10, marginRight: "10px" }}>
<ReferenceField {...props} source="parentId" linkType="show" reference="addressLevelType" allowEmpty>
<FunctionField render={record => record.name} />
</ReferenceField>
</Container>
Expand All @@ -92,40 +72,19 @@ export const LocationTypeDetail = props => (
const CreateEditToolbar = ({ edit, ...props }) => (
<Toolbar {...props}>
<SaveButton />
{edit && (
<DeleteButton
undoable={false}
disabled={!props.record.voidable}
style={{ marginLeft: "auto" }}
/>
)}
{edit && <DeleteButton undoable={false} style={{ marginLeft: "auto" }} />}
</Toolbar>
);

const LocationTypeForm = ({ edit, ...props }) => {
return (
<SimpleForm toolbar={<CreateEditToolbar edit={edit} />} {...props} redirect="show">
<AvniTextInput
source="name"
label="Name"
validate={required()}
toolTipKey={"ADMIN_LOCATION_TYPE_NAME"}
/>
<AvniTextInput
source="level"
label="Level"
validate={[required(), number()]}
toolTipKey={"ADMIN_LOCATION_TYPE_LEVEL"}
/>
<AvniTextInput source="name" label="Name" validate={required()} toolTipKey={"ADMIN_LOCATION_TYPE_NAME"} />
<AvniTextInput source="level" label="Level" validate={[required(), number()]} toolTipKey={"ADMIN_LOCATION_TYPE_LEVEL"} />
{edit ? (
<ParentReferenceField label="Parent Type" showToolTip={true} />
) : (
<AvniReferenceInput
source="parentId"
reference="addressLevelType"
label="Parent"
toolTipKey={"ADMIN_LOCATION_TYPE_PARENT"}
>
<AvniReferenceInput source="parentId" reference="addressLevelType" label="Parent" toolTipKey={"ADMIN_LOCATION_TYPE_PARENT"}>
<SelectInput optionText="name" resettable />
</AvniReferenceInput>
)}
Expand Down

0 comments on commit de10a1d

Please sign in to comment.