term_search.html 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {% extends 'base.html' %}
  2. {% block title %}Term Search{% endblock %}
  3. {% block content %}
  4. <p>Enter terms to query:</p>
  5. <ul>
  6. <li><strong>Logic:</strong> use "and" or "or" logic to concatenate multiple query criteria.</li>
  7. <li><strong>Prefix:</strong> optionally select a namespace prefix from a list of pre-configured ones.</li>
  8. <li><strong>Predicate:</strong> the fully qualified predicate URI if the prefix is empty, or the URI part following the namespace prefix (without the colon sign).</li>
  9. <li><strong>Operand:</strong> Select an operand for the comparison. The "Matches Term" operand expects an RDF literal or URI, all others a string.</li>
  10. <li><strong>Value:</strong> Value to compare against. If "Matches Term" is selected, an RDF URI literal as represented in SPARQL should be used, e.g. <pre>&lt;http://ex.org/ns/A&gt;</pre> or <pre>"title"^^xsd:string</pre>. For other operands, use a plain string without quotes.</li>
  11. </ul>
  12. <form id="term-search-form" method="POST" action="">
  13. <div class="my-sm-3 mb-2">
  14. <label for="logic">Logic</label>
  15. <select class="form-control" name="logic">
  16. <option value="and" selected>AND</option>
  17. <option value="or">OR</option>
  18. </select>
  19. </div>
  20. <div id="term-cont">
  21. <div class="term-block form-row">
  22. <div class="form-group col-md-1">
  23. <label for="pred_ns[]">Prefix</label>
  24. <select class="form-control" name="pred_ns[]">
  25. <option selected value=""></option>
  26. {% for ns in nsm.namespaces() | sort %}
  27. <option value="{{ns[0]}}">{{ns[0]}}</option>
  28. {% endfor %}
  29. </select>
  30. </div>
  31. <div class="form-group col-md-4">
  32. <label for="pred[]">Predicate</label>
  33. <input type="text" class="form-control" name="pred[]">
  34. </div>
  35. <div class="form-group col-md-2">
  36. <label for="op[]">Operand</label>
  37. <select class="form-control" name="op[]">
  38. {% for op in operands %}
  39. <option value="{{op[0]}}">{{op[1]}}</option>
  40. {% endfor %}
  41. </select>
  42. </div>
  43. <div class="form-group col-md-4">
  44. <label for="val[]">Value</label>
  45. <input type="text" class="form-control" name="val[]">
  46. </div>
  47. <div class="form-group col-md-1">
  48. <a class="delete-row btn btn-danger" href="#">- Remove</a>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="form-row my-sm-3">
  53. <a class="add-row btn btn-success" id="add-row" href="#">+ Add Row</a>
  54. </div>
  55. <div class="form-row my-sm-3">
  56. <input type="submit" class="btn btn-primary btn-lg">
  57. </div>
  58. </form>
  59. <div id="search-results-wrap"></div>
  60. {% include 'namespaces.html' %}
  61. {% endblock %}
  62. {% block tail_js %}
  63. <script>
  64. $(function(){
  65. $('.term-block').first().find('.delete-row').hide();
  66. $('#add-row').on('click', function(){
  67. var term = $('.term-block').last().clone(true, true);
  68. term.find('input[type="text"]').val('');
  69. term.find('select').val('');
  70. term.find('.delete-row').show();
  71. term.appendTo('#term-cont');
  72. });
  73. $('.delete-row').on('click', function(){
  74. $(this).closest('.term-block').remove();
  75. });
  76. $('#term-search-form').submit(function(ev) {
  77. $.ajax({
  78. type: 'POST',
  79. url: '',
  80. data: $(this).serialize(),
  81. encode: true
  82. })
  83. .done(function(data) {
  84. //var cont = $('#search-results-wrap')
  85. $('#search-results-wrap').removeClass('bg-danger')
  86. .html(data);
  87. })
  88. .fail(function(data) {
  89. $('#search-results-wrap').addClass('bg-danger')
  90. .html(data.responseText);
  91. });
  92. ev.preventDefault();
  93. });
  94. });
  95. </script>
  96. {% endblock %}