summaryrefslogtreecommitdiff
path: root/archaeological_files_pdl/templates/ishtar/blocks
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2014-12-28 01:15:07 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-05-06 15:38:32 +0200
commit086cb36acde4343f5e4dc8dc18a70cdbd8512c33 (patch)
treecf7782840ce79aee720cf3b6c55571ab0b2e7c8e /archaeological_files_pdl/templates/ishtar/blocks
parentee6a1eb3588da3c6c1c3f0e75691541cea2d37ab (diff)
downloadIshtar-086cb36acde4343f5e4dc8dc18a70cdbd8512c33.tar.bz2
Ishtar-086cb36acde4343f5e4dc8dc18a70cdbd8512c33.zip
Work on dynamic (too much of ajax and JS...) person/organization widget
Diffstat (limited to 'archaeological_files_pdl/templates/ishtar/blocks')
-rw-r--r--archaeological_files_pdl/templates/ishtar/blocks/JQueryCorporationPerson.js2
-rw-r--r--archaeological_files_pdl/templates/ishtar/blocks/JQueryNaturalPerson.js2
-rw-r--r--archaeological_files_pdl/templates/ishtar/blocks/JQueryPersonOrga.js65
3 files changed, 69 insertions, 0 deletions
diff --git a/archaeological_files_pdl/templates/ishtar/blocks/JQueryCorporationPerson.js b/archaeological_files_pdl/templates/ishtar/blocks/JQueryCorporationPerson.js
new file mode 100644
index 000000000..3eb375167
--- /dev/null
+++ b/archaeological_files_pdl/templates/ishtar/blocks/JQueryCorporationPerson.js
@@ -0,0 +1,2 @@
+var current_status = 'corporation';
+{% include "ishtar/blocks/JQueryPersonOrga.js" %}
diff --git a/archaeological_files_pdl/templates/ishtar/blocks/JQueryNaturalPerson.js b/archaeological_files_pdl/templates/ishtar/blocks/JQueryNaturalPerson.js
new file mode 100644
index 000000000..fc4b9a90c
--- /dev/null
+++ b/archaeological_files_pdl/templates/ishtar/blocks/JQueryNaturalPerson.js
@@ -0,0 +1,2 @@
+var current_status = 'natural';
+{% include "ishtar/blocks/JQueryPersonOrga.js" %}
diff --git a/archaeological_files_pdl/templates/ishtar/blocks/JQueryPersonOrga.js b/archaeological_files_pdl/templates/ishtar/blocks/JQueryPersonOrga.js
new file mode 100644
index 000000000..c151a5e4d
--- /dev/null
+++ b/archaeological_files_pdl/templates/ishtar/blocks/JQueryPersonOrga.js
@@ -0,0 +1,65 @@
+person_save_callback = function(item_id, lbl){
+ var url = {{edit_source}};
+ $('#id_{{field_id}}').val(null);
+ $('#id_select_{{field_id}}').val(lbl);
+ if (item_id){
+ url = {{edit_source}}+item_id;
+ $('#id_{{field_id}}').val(item_id);
+ }
+ $("#id_select_{{field_id}}").trigger('autocompletechange');
+ $.get(url , function( data ) {
+ $( "#div-{{field_id}}" ).html( data );
+ });
+};
+
+edit_url = {{edit_source}};
+parent_id = "{{field_id}}";
+
+person_new_callback = function(){
+ var url = {{edit_source}};
+ $('#id_{{field_id}}').val(null);
+ $('#id_select_{{field_id}}').val(null);
+}
+
+$(function() {
+ var $radios = $('input:radio[name=person_type]');
+ if($radios.is(':checked') === false) {
+ $radios.filter('[value='+ current_status +']').prop('checked', true);
+ }
+
+ $radios.change(function(){
+ var loc = window.location;
+ window.location = loc.protocol + '//' + loc.host + loc.pathname + "?status=" + $('input:radio[name=person_type]:checked').val();
+ });
+
+ $("#id_select_{{field_id}}").autocomplete({
+ source: {{source}},
+ select: function( event, ui ) {
+ var url = {{edit_source}};
+ if(ui.item){
+ url = {{edit_source}}+ui.item.id;
+ $('#id_{{field_id}}').val(ui.item.id);
+ } else {
+ $('#id_{{field_id}}').val(null);
+ }
+ $.get(url , function( data ) {
+ $( "#div-{{field_id}}" ).html( data );
+ });
+ },
+ minLength: 2{% if options %},
+ {{options}}
+ {% endif %}
+ });
+
+ $.get( {{edit_source}}{% if selected %}+'{{selected}}'{% endif %}, function( data ) {
+ $( "#div-{{field_id}}" ).html( data );
+ });
+
+ $('#id_select_{{field_id}}').live('click', function(){
+ $('#id_{{field_id}}').val(null);
+ $('#id_select_{{field_id}}').val(null);
+ $.get( {{edit_source}}, function( data ) {
+ $( "#div-{{field_id}}" ).html( data );
+ });
+ });
+});