From cc9c6e698b1e7ebc8fd4782964df341947c16c20 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Thu, 27 Jul 2023 17:22:14 +0100 Subject: [PATCH] Rework cell and sample UI around new collections graph - Update cypress tests - Update starting material UI with collections list --- pydatalab/pydatalab/routes/v0_1/graphs.py | 6 +- webapp/cypress/e2e/editPage.cy.js | 2 - webapp/cypress/e2e/sampleTablePage.cy.js | 4 - webapp/src/components/CellInformation.vue | 179 ++++++++++-------- .../src/components/CollectionInformation.vue | 4 +- .../components/FancyCollectionSampleTable.vue | 4 +- webapp/src/components/ItemGraph.vue | 6 + .../ItemRelationshipVisualization.vue | 59 ++++++ webapp/src/components/SampleInformation.vue | 91 +++++---- .../StartingMaterialInformation.vue | 20 +- webapp/src/views/CollectionPage.vue | 4 +- webapp/src/views/EditPage.vue | 17 +- 12 files changed, 248 insertions(+), 148 deletions(-) create mode 100644 webapp/src/components/ItemRelationshipVisualization.vue diff --git a/pydatalab/pydatalab/routes/v0_1/graphs.py b/pydatalab/pydatalab/routes/v0_1/graphs.py index 93dee6f11..8f3598a8a 100644 --- a/pydatalab/pydatalab/routes/v0_1/graphs.py +++ b/pydatalab/pydatalab/routes/v0_1/graphs.py @@ -51,7 +51,6 @@ def get_graph_cy_format(item_id: Optional[str] = None, collection_id: Optional[s } if len(node_ids) > 1: or_query = [{"item_id": id} for id in node_ids if id != item_id] - # query.extend([{"relationships.item_id": id} for id in node_ids if id != item_id]) next_shell = flask_mongo.db.items.find( { "$or": or_query, @@ -112,10 +111,7 @@ def get_graph_cy_format(item_id: Optional[str] = None, collection_id: Optional[s ) continue - if not document.get("relationships"): - continue - - for relationship in document["relationships"]: + for relationship in document.get("relationships", []): # only considering child-parent relationships: if relationship.get("relation") not in ("parent", "is_part_of"): continue diff --git a/webapp/cypress/e2e/editPage.cy.js b/webapp/cypress/e2e/editPage.cy.js index a95e10907..5bc9fb5c7 100644 --- a/webapp/cypress/e2e/editPage.cy.js +++ b/webapp/cypress/e2e/editPage.cy.js @@ -58,7 +58,6 @@ describe("Edit Page", () => { it("Checks editing the sample edit page", () => { cy.findByText("editable_sample").click(); - cy.findByLabelText("Sample ID").should("have.value", "editable_sample"); cy.findByLabelText("Name").should("have.value", "This is a sample name"); cy.findByLabelText("Chemical formula").type("NaCoO2", { force: true }); @@ -212,7 +211,6 @@ describe("Edit Page", () => { it("Add some blocks to the sample and checks unsaved warning behavior", () => { cy.findByText("editable_sample").click(); - cy.findByLabelText("Sample ID").should("have.value", "editable_sample"); cy.findByLabelText("Name").should("have.value", "This is a sample name"); cy.findByText("Add a block").click(); diff --git a/webapp/cypress/e2e/sampleTablePage.cy.js b/webapp/cypress/e2e/sampleTablePage.cy.js index 085256aae..8fe08d353 100644 --- a/webapp/cypress/e2e/sampleTablePage.cy.js +++ b/webapp/cypress/e2e/sampleTablePage.cy.js @@ -108,7 +108,6 @@ describe("Sample table page", () => { it("Checks the sample edit page", () => { cy.findByText("12345678910").click(); - cy.findByLabelText("Sample ID").should("have.value", "12345678910"); cy.go("back"); cy.findByText("12345678910"); cy.findByText("This is a sample name"); @@ -186,7 +185,6 @@ describe("Sample table page", () => { // check one of the pages to make sure it is generating properly cy.findByText("122.rwre").click(); - cy.findByLabelText("Sample ID").should("have.value", "122.rwre"); cy.go("back"); more_ids.map((id) => verifySample(id)); @@ -283,7 +281,6 @@ describe("Advanced sample creation features", () => { it("checks the edit page of the copied sample", () => { cy.findByText("testBcopy").click(); - cy.findByLabelText("Sample ID").should("have.value", "testBcopy"); cy.findByLabelText("Name").should("have.value", "COPY OF the second test sample"); cy.findByText("this is a description of testB."); cy.findByText("a comment is added here."); @@ -319,7 +316,6 @@ describe("Advanced sample creation features", () => { it("checks the edit page of the copied sample with components", () => { cy.findByText("testBcopy_copy").click(); - cy.findByLabelText("Sample ID").should("have.value", "testBcopy_copy"); cy.findByLabelText("Name").should("have.value", "COPY OF COPY OF the second test sample"); cy.findByText("this is a description of testB."); cy.findByText("a comment is added here."); diff --git a/webapp/src/components/CellInformation.vue b/webapp/src/components/CellInformation.vue index eb4446a0d..7ed6a70e8 100644 --- a/webapp/src/components/CellInformation.vue +++ b/webapp/src/components/CellInformation.vue @@ -1,90 +1,105 @@