Much UI work, significant improvement.
This commit is contained in:
parent
9c3af4c936
commit
5356f65ca3
44 changed files with 1865 additions and 1213 deletions
|
|
@ -1,10 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
<!-- File form-dwellings-Dwelling.html generated 2018-07-09T20:55:34.547Z by adl.to-selmer-templates.
|
||||
<!-- File form-dwellings-Dwelling.html generated 2018-07-10T15:25:24.216Z by adl.to-selmer-templates.
|
||||
See [Application Description Language](https://github.com/simon-brooke/adl).-->
|
||||
|
||||
|
||||
{% block extra-head %}
|
||||
|
||||
{% script "/js/lib/node_modules/selectize/dist/js/standalone/selectize.min.js" %}
|
||||
{% style "/js/lib/node_modules/selectize/dist/css/selectize.css" %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div id='content' class='edit'>
|
||||
|
|
@ -17,13 +19,9 @@ Address_id
|
|||
</label>
|
||||
{% if {{record.address_id}} %}
|
||||
{% ifmemberof admin %}
|
||||
<span class='select-box' farside='addresses' found='true'>
|
||||
<input name='address_id_search_box' onchange='$.getJSON("/auto/json/seach-strings-addresses?postcode=" + address_id_search_box.text + "&address=" + address_id_search_box.text, null, function (data) {updateMenuOptions("address_id", "id", ["postcode", "address"], data);})'/>
|
||||
<br/>
|
||||
<select id='address_id' name='address_id'>
|
||||
{% for r in addresses %}<option value='{{r.id}}' {% ifequal record.address_id r.id%}selected{% endifequal %}>{{r.address}} {{r.postcode}}</option>{% endfor %}
|
||||
{% for option in address_id %}<option value='{{option.id}}' {% ifequal record.address_id option.id%}selected{% endifequal %}>{{option.address}} {{option.postcode}}</option>{% endfor %}
|
||||
</select>
|
||||
</span>
|
||||
{% else %}
|
||||
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
|
||||
<span id='address_id' name='address_id' class='pseudo-widget disabled'>
|
||||
|
|
@ -37,13 +35,9 @@ You are not permitted to view address_id of dwellings
|
|||
{% endifmemberof %}
|
||||
{% else %}
|
||||
{% ifmemberof admin %}
|
||||
<span class='select-box' farside='addresses' found='true'>
|
||||
<input name='address_id_search_box' onchange='$.getJSON("/auto/json/seach-strings-addresses?postcode=" + address_id_search_box.text + "&address=" + address_id_search_box.text, null, function (data) {updateMenuOptions("address_id", "id", ["postcode", "address"], data);})'/>
|
||||
<br/>
|
||||
<select id='address_id' name='address_id'>
|
||||
{% for r in addresses %}<option value='{{r.id}}' {% ifequal record.address_id r.id%}selected{% endifequal %}>{{r.address}} {{r.postcode}}</option>{% endfor %}
|
||||
{% for option in address_id %}<option value='{{option.id}}' {% ifequal record.address_id option.id%}selected{% endifequal %}>{{option.address}} {{option.postcode}}</option>{% endfor %}
|
||||
</select>
|
||||
</span>
|
||||
{% else %}
|
||||
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
|
||||
<span id='address_id' name='address_id' class='pseudo-widget disabled'>
|
||||
|
|
@ -113,20 +107,34 @@ To delete this dwellings record
|
|||
{% endblock %}
|
||||
{% block extra-tail %}
|
||||
<script type='text/javascript'>
|
||||
/**
|
||||
* update the select menu with id `wid` from this `data` whose fields include
|
||||
* this `entity_key` and these `fields`
|
||||
*/
|
||||
function updateMenuOptions(wid, entity_key, fields, data){
|
||||
$('#' + wid).children().filter(function(){
|
||||
return $(this).attr('selected') === undefined;
|
||||
}).remove().end();
|
||||
/**
|
||||
* selectize one select widget. Substitute the actual id of the widget for `address_id`.
|
||||
*/
|
||||
$('#address_id').selectize({
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
|
||||
$.each(data, function(key, entry){
|
||||
$('#' + wid).append(
|
||||
$('<option></option>').attr('value', key).text(entry));
|
||||
});
|
||||
}
|
||||
load: function(query, callback) {
|
||||
console.log('Desperately seeking ' + query);
|
||||
if (query === null || !query.length) return callback();
|
||||
$.ajax({
|
||||
url: '/json/auto/search-strings-electors?name=' + query,
|
||||
type: 'GET',
|
||||
dataType: 'jsonp',
|
||||
error: function() {
|
||||
console.log( 'Query ' + query + ' failed.');
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
console.log('Received ' + res + ' records for ' + query);
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue