Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide "Asset Type" #6835

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cypress/e2e/assets_spec/asset_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ describe("Asset Tab", () => {
it("Filter Asset", () => {
assetFilters.filterAssets(
"Dummy Facility 1",
"INTERNAL",
"ACTIVE",
"ONVIF Camera",
"Camera Loc"
);
assetFilters.clickadvancefilter();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 1");
assetFilters.assertAssetTypeText("INTERNAL");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Loc");
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe("Asset", () => {
assetPage.clickCreateAsset();

assetPage.verifyEmptyAssetNameError();
assetPage.verifyEmptyAssetTypeError();
assetPage.verifyEmptyLocationError();
assetPage.verifyEmptyStatusError();
assetPage.verifyEmptyPhoneError();
Expand All @@ -41,7 +40,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 1");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");

const qr_id_1 = uuidv4();
Expand All @@ -68,7 +66,6 @@ describe("Asset", () => {
const qr_id_2 = uuidv4();

assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");
assetPage.enterAssetDetails(
"New Test Asset 2",
Expand Down Expand Up @@ -141,7 +138,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 1");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("HL7 Vitals Monitor");

const qr_id_1 = uuidv4();
Expand Down
15 changes: 0 additions & 15 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export class AssetPage {
});
}

selectAssetType(assetType: string) {
cy.get("[data-testid=asset-type-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
}

selectAssetClass(assetClass: string) {
cy.get("[data-testid=asset-class-input] button")
.click()
Expand Down Expand Up @@ -205,13 +197,6 @@ export class AssetPage {
);
}

verifyEmptyAssetTypeError() {
cy.get("[data-testid=asset-type-input] span").should(
"contain",
"Select an asset type"
);
}

verifyEmptyStatusError() {
cy.get("[data-testid=asset-working-status-input] span").should(
"contain",
Expand Down
9 changes: 0 additions & 9 deletions cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export class AssetFilters {
filterAssets(
facilityName: string,
assetType: string,
assetStatus: string,
assetClass: string,
assetLocation: string
Expand All @@ -13,11 +12,6 @@ export class AssetFilters {
.then(() => {
cy.get("[role='option']").contains(facilityName).click();
});
cy.get("#asset-type")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
cy.get("#asset-status")
.click()
.then(() => {
Expand Down Expand Up @@ -67,9 +61,6 @@ export class AssetFilters {
assertFacilityText(text) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetTypeText(text) {
cy.get("[data-testid='Asset Type']").should("contain", text);
}
assertAssetClassText(text) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
Expand Down
20 changes: 3 additions & 17 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const getDate = (value: any) =>
function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
// const [asset_type, setAssetType] = useState<string>(
// filter.asset_type ? filter.asset_type : ""
// );
const [asset_status, setAssetStatus] = useState<string>(filter.status || "");
const [asset_class, setAssetClass] = useState<string>(
filter.asset_class || ""
Expand Down Expand Up @@ -56,7 +56,6 @@ function AssetFilter(props: any) {
const clearFilter = useCallback(() => {
removeFilters([
"facility",
"asset_type",
"asset_class",
"status",
"location",
Expand All @@ -69,7 +68,6 @@ function AssetFilter(props: any) {
const applyFilter = () => {
const data = {
facility: facilityId,
asset_type: asset_type ?? "",
asset_class: asset_class ?? "",
status: asset_status ?? "",
location: locationId ?? "",
Expand Down Expand Up @@ -133,18 +131,6 @@ function AssetFilter(props: any) {
</div>
)}

<SelectFormField
label="Asset Type"
errorClassName="hidden"
id="asset-type"
name="asset_type"
options={["EXTERNAL", "INTERNAL"]}
optionLabel={(o) => o}
optionValue={(o) => o}
value={asset_type}
onChange={({ value }) => setAssetType(value)}
/>

<SelectFormField
id="asset-status"
name="asset_status"
Expand Down
5 changes: 0 additions & 5 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ const AssetManage = (props: AssetManageProps) => {
{asset?.description}
</div>
<div className="flex flex-wrap gap-2">
{asset?.asset_type === "INTERNAL" ? (
<Chip text="Internal" startIcon="l-building" />
) : (
<Chip text="External" startIcon="l-globe" />
)}
{asset?.status === "ACTIVE" ? (
<Chip text="Active" startIcon="l-check" />
) : (
Expand Down
45 changes: 1 addition & 44 deletions src/Components/Facility/AssetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ const AssetCreate = (props: AssetProps) => {
const { goBack } = useAppHistory();
const { facilityId, assetId } = props;

let assetTypeInitial: AssetType;
let assetClassInitial: AssetClass;

const [state, dispatch] = useReducer(asset_create_reducer, initialState);
const [name, setName] = useState("");
const [asset_type, setAssetType] = useState<AssetType>();
const [asset_class, setAssetClass] = useState<AssetClass>();
const [not_working_reason, setNotWorkingReason] = useState("");
const [description, setDescription] = useState("");
Expand Down Expand Up @@ -199,7 +197,6 @@ const AssetCreate = (props: AssetProps) => {
setName(asset.name);
setDescription(asset.description);
setLocation(asset.location_object.id);
setAssetType(asset.asset_type);
setAssetClass(asset.asset_class);
setIsWorking(String(asset.is_working));
setNotWorkingReason(asset.not_working_reason);
Expand Down Expand Up @@ -241,12 +238,6 @@ const AssetCreate = (props: AssetProps) => {
invalidForm = true;
}
return;
case "asset_type":
if (!asset_type || asset_type == "NONE") {
errors[field] = "Select an asset type";
invalidForm = true;
}
return;
case "support_phone": {
if (!support_phone) {
errors[field] = "Field is required";
Expand Down Expand Up @@ -304,7 +295,6 @@ const AssetCreate = (props: AssetProps) => {
setName("");
setDescription("");
setLocation("");
setAssetType(assetTypeInitial);
setAssetClass(assetClassInitial);
setIsWorking(undefined);
setNotWorkingReason("");
Expand All @@ -329,7 +319,7 @@ const AssetCreate = (props: AssetProps) => {
setIsLoading(true);
const data: any = {
name: name,
asset_type: asset_type,
asset_type: AssetType.INTERNAL,
asset_class: asset_class || "",
description: description,
is_working: is_working,
Expand Down Expand Up @@ -567,40 +557,7 @@ const AssetCreate = (props: AssetProps) => {
errors={state.errors.location}
/>
</div>
{/* Asset Type */}
<div className="col-span-6 flex flex-col gap-x-12 transition-all lg:flex-row xl:gap-x-16">
<div
ref={fieldRef["asset_type"]}
className="flex-1"
data-testid="asset-type-input"
>
<SelectFormField
label={t("asset_type")}
name="asset_type"
required
options={[
{
title: "Internal",
description:
"Asset is inside the facility premises.",
value: AssetType.INTERNAL,
},
{
title: "External",
description:
"Asset is outside the facility premises.",
value: AssetType.EXTERNAL,
},
]}
value={asset_type}
optionLabel={({ title }) => title}
optionDescription={({ description }) => description}
optionValue={({ value }) => value}
onChange={({ value }) => setAssetType(value)}
error={state.errors.asset_type}
/>
</div>

{/* Asset Class */}
<div
ref={fieldRef["asset_class"]}
Expand Down
Loading