# HG changeset patch # User alistair # Date 1441684307 14400 # Node ID 72dc19d750ad34ef1eff21070314c273cd04b4e1 # Parent aea1b2097f4f11afa4109bd110db910cdce55b1d ADDED: Basic text box implementation for predefined constraints, to be added to in the coming week. nodeProvider, linkProvider additions. diff -r aea1b2097f4f -r 72dc19d750ad popoto/ismi.html --- a/popoto/ismi.html Tue Sep 01 17:05:31 2015 +0200 +++ b/popoto/ismi.html Mon Sep 07 23:51:47 2015 -0400 @@ -13,8 +13,19 @@
-
+
Graph search +
+ + +
+ + +
diff -r aea1b2097f4f -r 72dc19d750ad popoto/js/app-ismi.js --- a/popoto/js/app-ismi.js Tue Sep 01 17:05:31 2015 +0200 +++ b/popoto/js/app-ismi.js Mon Sep 07 23:51:47 2015 -0400 @@ -16,6 +16,41 @@ * For example Base64 encoding value of "neo4j:password" is "bmVvNGo6cGFzc3dvcmQ=" */ popoto.rest.AUTHORIZATION = "Basic " + btoa("neo4j:neo5j"); +//popoto.rest.AUTHORIZATION = "Basic " + btoa("neo4j:eagrussell"); + +/** + * These functions fill the predefinedConstraints array for "PERSON" + * Called when the filter button is hit + * + * Uses the text box implementation currently + */ + // TODO: finish textbox implementation as backup and add in dropdown menu implementation +var personPredefinedConstraints = []; +d3.select("#filter-button").on("click", function (d) { + var constraint = d3.select("#constraint")[0][0].value; + + personPredefinedConstraints = [constraint]; + + // Recreate taxonomies panel + d3.select("#" + popoto.taxonomy.containerId).selectAll("ul").data([]).exit().remove(); + popoto.taxonomy.createTaxonomyPanel(); + + popoto.tools.reset(); +}); + +d3.select("#filter-button2").on("click", function (d) { + var constraint = d3.select("#constraint2")[0][0].value; + + personPredefinedConstraints = [constraint]; + + // Recreate taxonomies panel + d3.select("#" + popoto.taxonomy.containerId).selectAll("ul").data([]).exit().remove(); + popoto.taxonomy.createTaxonomyPanel(); + + popoto.tools.reset(); +}); + + /** * Define the Label provider you need for your application. @@ -27,33 +62,133 @@ * These label provider configuration can be used to customize the node display in the graph. * See www.popotojs.com or example for more details on available configuration options. */ +// TODO: add in predefined constraint functions for other nodeProviders popoto.provider.nodeProviders = { "CODEX": { "returnAttributes": ["label", "ismi_id", "identifier"], - "displayAttribute": "label" + "displayAttribute": "label", + //"getPredefinedConstraints": function (node) { + // return personPredefinedConstraints; + //}, }, "WITNESS": { "returnAttributes": ["label", "ismi_id", "folios"], - "displayAttribute": "label" + "displayAttribute": "label", + //"getPredefinedConstraints": function (node) { + // return personPredefinedConstraints; + //}, }, "TEXT": { "returnAttributes": ["label", "full_title", "ismi_id"], - "displayAttribute": "label" + "displayAttribute": "label", + //"getPredefinedConstraints": function (node) { + // return personPredefinedConstraints; + //}, }, "PERSON": { "returnAttributes": ["label", "ismi_id", "death_date_text", "url"], - "displayAttribute": "label" + "displayAttribute": "label", + "getPredefinedConstraints": function (node) { + return personPredefinedConstraints; + }, }, "REPOSITORY": { "returnAttributes": ["label", "ismi_id"], - "displayAttribute": "label" + "displayAttribute": "label", + //"getPredefinedConstraints": function (node) { + // return personPredefinedConstraints; + //}, }, "FLORUIT_DATE": { "isSearchable": false + //"getPredefinedConstraints": function (node) { + // return personPredefinedConstraints; + //}, } }; /** + * Popoto label provider + * Define the label provider used to customize the link displayed text: + */ +// TODO: ensure these cover all the different relations. Commented out for now. +/* +popoto.provider.linkProvider = { + + // Customize the text displayed on links: + "getLinkTextValue": function (link) { + + // The links labels are just changed in lower case in this example. + // But it is possible to use a localization mechanism here to replace values. + if (link.type === popoto.graph.link.LinkTypes.RELATION) { + + if (link.source.label == "PERSON") { + switch (link.label) { + case "was_student_of": + return "was student of"; + case "is_prime_alias_name_of": + return "is prime alias name of"; + case "was_born_in": + return "was born in"; + case "lived_in": + return "lived in"; + case "has_role": + return "has role"; + case "has_floruit_date": + return "has floruit date"; + case "died_in": + return "died in"; + default : + return "" + } + } + if (link.source.label == "CODEX") { + switch (link.label) { + case "owned_by": + return "owned by"; + case "is_alias_of": + return "is alias of"; + case "is_part_of": + return "is part of"; + } + } + if (link.source.label == "WITNESS") { + switch (link.label) { + case "was_copied_in": + return "was copied in"; + case "was_studied_by": + return "was studied by"; + case "had_patron": + return "had patron"; + case "is_part_of": + return "is part of"; + case "is_exemplar_of": + return "is exemplar of"; + case "has_title_written_as": + return "has title written as"; + case "has_author_written_as": + return "as author written as"; + case "was_copied_by": + return "was copied by"; + } + } + if (link.source.label == "PLACE") { + switch (link.label) { + case "is_part_of": + return "is part of"; + case "is_in": + return "is in"; + } + } + } else { + return popoto.provider.getSemanticValue(link.target); + } + } + +}; +*/ + +/** * Here a listener is used to retrieve the total results count and update the page accordingly. * This listener will be called on every graph modification. */