diff options
Diffstat (limited to 'ishtar_common/templates')
14 files changed, 455 insertions, 9 deletions
diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index 1ebebd815..92e61493b 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -19,6 +19,7 @@ <link type="text/css" href="{{JQUERY_UI_URL}}css/smoothness/jquery-ui.css" rel="stylesheet" /> <link rel="stylesheet" href="{{STATIC_URL}}/js/prettyPhoto/css/prettyPhoto.css" /> <link rel="stylesheet" href="{{STATIC_URL}}/media/style.css" /> + {% include "blocks/extra_head.html" %} {% block extra_head %} {% endblock %} </head> diff --git a/ishtar_common/templates/blocks/JQueryAdvancedTown.html b/ishtar_common/templates/blocks/JQueryAdvancedTown.html new file mode 100644 index 000000000..78d2d7831 --- /dev/null +++ b/ishtar_common/templates/blocks/JQueryAdvancedTown.html @@ -0,0 +1,99 @@ +{% load i18n %}{% load url from future %}</td></tr> +<tr> + <td>{% trans "State" context "Région" %}</td> + <td> + <select id='current-state'> + <option value=''>--------</option>{% for state in states %} + <option value='{{state.number}}'{% if state.number == selected_state %}selected='selected'{% endif %}>{{state}}</option> + {% endfor %}</select> + </td> +</tr> +<tr> + <td>{% trans "Department" %}</td> + <td> + <select id='current-department'> + </select> + </td> +</tr> +<tr class='required'> + <th><label>{% trans "Town" %}</label></th> + <td><input{{attrs_select}}/> +<input type="hidden"{{attrs_hidden}}/> +<script type="text/javascript"><!--// + selected_department = "{{selected_department}}"; + var empty_select = "<option value=''>--------</option>"; + + function update_department_field(){ + var selected_state = $("#current-state").val(); + if (!selected_state){ + $("#current-department").html("<option value=''>"+"{% trans 'Choose a state first' %}"+"</option>"); + $("#current-department").prop('disabled', true); + $('#id_select_{{field_id}}').prop('disabled', true); + return; + } + $.ajax({ + url: "{% url 'department-by-state' %}" + selected_state, + type: 'get', + dataType: 'json', + success: function(data) { + var html = ""; + for (idx in data){ + dpt = data[idx]; + html += "<option value='" + dpt.number + "'"; + if (String(dpt.number) == String(selected_department)){ + html += " selected='selected'"; + } + html += ">" + dpt.value + "</option>"; + } + $("#current-department").html(html); + $("#current-department").prop('disabled', false); + update_search_town(); + } + }); + } + + function update_search_town(){ + selected_department = $("#current-department").val(); + if (selected_department){ + $("#id_select_{{field_id}}").autocomplete( "option", "source", {{source}}+selected_department); + $('#id_select_{{field_id}}').prop('disabled', false); + } else { + $('#id_select_{{field_id}}').prop('disabled', true); + } + } + + function empty_town(){ + $('#id_{{field_id}}').val(null); + $('#id_select_{{field_id}}').val(null); + } + + $(function() { + update_department_field(); + + $("#current-state").change(function(){ + empty_town(); + update_department_field(); + }); + + $("#current-department").change(function(){ + empty_town(); + update_search_town(); + }); + + $("#id_select_{{field_id}}").autocomplete({ + source: {{source}}, + select: function( event, ui ) { + if(ui.item){ + $('#id_{{field_id}}').val(ui.item.id); + } else { + $('#id_{{field_id}}').val(null); + } + }, + minLength: 2{% if options %}, + {{options}} + {% endif %} + }); + + $('#id_select_{{field_id}}').live('click', empty_town); + +});//--></script> diff --git a/ishtar_common/templates/blocks/JQueryAdvancedTown.js b/ishtar_common/templates/blocks/JQueryAdvancedTown.js new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/ishtar_common/templates/blocks/JQueryAdvancedTown.js @@ -0,0 +1 @@ + diff --git a/ishtar_common/templates/blocks/JQueryPersonOrganization.js b/ishtar_common/templates/blocks/JQueryPersonOrganization.js new file mode 100644 index 000000000..b13a2c28e --- /dev/null +++ b/ishtar_common/templates/blocks/JQueryPersonOrganization.js @@ -0,0 +1,50 @@ + +$("#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 ); + }); +}); + +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 ); + }); +}; +person_new_callback = function(){ + var url = {{edit_source}}; + $('#id_{{field_id}}').val(null); + $('#id_select_{{field_id}}').val(null); +} diff --git a/ishtar_common/templates/blocks/PersonOrganization.html b/ishtar_common/templates/blocks/PersonOrganization.html new file mode 100644 index 000000000..6e7264c8e --- /dev/null +++ b/ishtar_common/templates/blocks/PersonOrganization.html @@ -0,0 +1,9 @@ +{% load i18n %}<input{{attrs_select}}/> +</table> + +<div id='div-{{name}}'></div> + +<input type="hidden"{{attrs_hidden}}/> +<script type="text/javascript"><!--// +{{js}} +//--></script> diff --git a/ishtar_common/templates/blocks/extra_head.html b/ishtar_common/templates/blocks/extra_head.html new file mode 100644 index 000000000..139597f9c --- /dev/null +++ b/ishtar_common/templates/blocks/extra_head.html @@ -0,0 +1,2 @@ + + diff --git a/ishtar_common/templates/ishtar/organization_form.html b/ishtar_common/templates/ishtar/organization_form.html new file mode 100644 index 000000000..207116c21 --- /dev/null +++ b/ishtar_common/templates/ishtar/organization_form.html @@ -0,0 +1,30 @@ +{% load i18n %}<table class='organization'> +<tr> + <th><label>{{form.name.label}}</label></th> + <td>{{form.name}}</td> +</tr> +</table> +{% for hidden in form.hidden_fields %}{{hidden}}{% endfor %} +<table class='organization-address'> +<tr> + <th><label>{{form.organization_type.label}}</label></th> + <td>{{form.organization_type}}</td> +</tr> +<tr> + <th><label>{{form.address.label}}</label></th> + <td>{{form.address}}</td> +</tr> +<tr> + <th><label>{{form.address_complement.label}}</label></th> + <td>{{form.address_complement}}</td> +</tr> +<tr> + <th><label>{{form.postal_code.label}}</label></th> + <td>{{form.postal_code}}</td> +</tr> +<tr> + <th><label>{{form.town.label}}</label></th> + <td>{{form.town}}</td> +</tr> +</table> + diff --git a/ishtar_common/templates/ishtar/organization_person_form.html b/ishtar_common/templates/ishtar/organization_person_form.html new file mode 100644 index 000000000..46f2cdc15 --- /dev/null +++ b/ishtar_common/templates/ishtar/organization_person_form.html @@ -0,0 +1,131 @@ +{% load i18n %}{% load url from future %} +<div id='orga-person-form'> +<form id='dyn-form-person' method='post'> +{% csrf_token %} +{% for hidden_field in form.hidden_fields %}{{hidden_field}}{% endfor %} +<input type='hidden' name='hidden_person_pk' id='hidden_person_pk' value='{{object.pk}}'/> +<input type='hidden' name='hidden_person_lbl' id='hidden_person_lbl' value="{{object}}"/> +<table class='organization'> +<caption>{% trans "Identification" %}</caption> +<tr> + <th> </th> + <td>{{form.attached_to}}</td> +</tr> +</table> + +<table class='person'> +<caption>{{relative_label}}</caption> +<tr> + <th><label>{{form.title.label}}</label></th> + <td>{{form.title}}</td> +</tr> +<tr> + <th><label>{{form.name.label}}</label></th> + <td>{{form.name}}</td> +</tr> +<tr> + <th><label>{{form.surname.label}}</label></th> + <td>{{form.surname}}</td> +</tr> +</table> +<div> +<input type='submit' id='btn-modify-person' value="{% trans "Modify"%}"/> +<input type='submit' id='btn-new-person' value="{% trans "New"%}"/> +<input type='submit' id='btn-save-person' value="{% trans "Save"%}"/> +<input type='submit' id='btn-cancel-person' value="{% trans "Cancel"%}"/> +</div> +</form> +</div> +<script type="text/javascript"><!--// + +function checkPendingRequest(todo) { + window.setTimeout(function () { + if ($.active > 0) { + window.setTimeout(checkPendingRequest(todo), 250); + } else { + todo(); + } + }, 250); +}; + +person_save_callback = function(){ + var item_id = $('#hidden_person_pk').val(); + + var url = edit_url; + $('#id_' + parent_id).val(null); + if (item_id){ + url = edit_url+item_id; + $('#id_'+parent_id).val(item_id); + } + $("#id_select_"+parent_id).trigger('autocompletechange'); + $.get(url , function( data ) { + $( "#div-"+parent_id ).html( data ); + var lbl = $('#hidden_person_lbl').val(); + $('#id_select_' + parent_id).val(lbl); + }); +}; + +person_new_callback = function(){ + var url = edit_url; + $('#id_'+parent_id).val(null); + $('#id_select_'+parent_id).val(null); +} +$(function() { + disable_person = function(){ + $("#orga-person-form :input[type='text'], #orga-person-form textarea, #orga-person-form select").prop("disabled", true); + $("#btn-save-person").hide(); + $("#btn-cancel-person").hide(); + $("#btn-modify-person").show(); + $("#btn-new-person").show(); + $("#orga-person-form").removeClass('selected'); + } + enable_person = function(){ + $("#orga-person-form :input[type='text'], #orga-person-form textarea, #orga-person-form select").prop("disabled", false); + $("#btn-save-person").show(); + $("#btn-cancel-person").show(); + $("#btn-modify-person").hide(); + $("#btn-new-person").hide(); + $("#orga-person-form").addClass('selected'); + } + + checkPendingRequest(disable_person); + + $("#btn-modify-person").on('click', function(){ + {% if object %}submit_url = "{% url 'organization_person_edit' object.pk %}"; + {% else %}submit_url = "{% url 'organization_person_create' %}";{% endif %} + enable_person(); + return false; + }); + $("#btn-new-person").on('click', function(){ + submit_url = "{% url 'organization_person_create' %}"; + $("#orga-person-form").find("input[type=text], textarea, input[type=hidden]").val(""); + enable_person(); + person_new_callback(); + return false; + }); + $("#btn-cancel-person").on('click', function(){ + person_save_callback(); + disable_person(); + return false; + }); + $("#btn-save-person").on('click', function(){ + var form = $("#dyn-form-person"); + $.ajax({ + url: submit_url, + type: 'post', + data: form.serialize(), + dataType: 'html', + success: function(data) { + $("#orga-person-form").parent().html(data); + person_save_callback(); + disable_person(); + return false; + } + }); + return false; + }); + + +}); +//--></script> + diff --git a/ishtar_common/templates/ishtar/person_form.html b/ishtar_common/templates/ishtar/person_form.html new file mode 100644 index 000000000..555aa1a5f --- /dev/null +++ b/ishtar_common/templates/ishtar/person_form.html @@ -0,0 +1,113 @@ +{% load i18n %}{% load url from future %} +<div id='person-form'> +<form id='dyn-form-person' method='post'> +{% csrf_token %} +{% for hidden_field in form.hidden_fields %}{{hidden_field}}{% endfor %} +<input type='hidden' name='hidden_person_pk' id='hidden_person_pk' value='{{object.pk}}'/> +<input type='hidden' name='hidden_person_lbl' id='hidden_person_lbl' value="{{object}}"/> +<table class='person'> +<caption>{% trans "Identification" %}</caption> +<tr> + <th><label>{{form.title.label}}</label></th> + <td>{{form.title}}</td> +</tr> +<tr> + <th><label>{{form.name.label}}</label></th> + <td>{{form.name}}</td> +</tr> +<tr> + <th><label>{{form.surname.label}}</label></th> + <td>{{form.surname}}</td> +</tr> +</table> +<table class='person-address'> +<caption>{% trans "Contact informations" %}</caption> +<tr> + <th><label>{{form.address.label}}</label></th> + <td>{{form.address}}</td> +</tr> +<tr> + <th><label>{{form.address_complement.label}}</label></th> + <td>{{form.address_complement}}</td> +</tr> +<tr> + <th><label>{{form.postal_code.label}}</label></th> + <td>{{form.postal_code}}</td> +</tr> +<tr> + <th><label>{{form.town.label}}</label></th> + <td>{{form.town}}</td> +</tr> +</table> +<div> +<input type='submit' id='btn-modify-person' value="{% trans "Modify"%}"/> +<input type='submit' id='btn-new-person' value="{% trans "New"%}"/> +<input type='submit' id='btn-save-person' value="{% trans "Save"%}"/> +<input type='submit' id='btn-cancel-person' value="{% trans "Cancel"%}"/> +</div> +</form> +</div> +<script type="text/javascript"><!--// +$(function() { + // person_save_callback and person_new_callback must have been defined + disable_person = function(){ + $("#person-form :input[type='text'], #person-form textarea, #person-form select").prop("disabled", true); + $("#btn-save-person").hide(); + $("#btn-cancel-person").hide(); + $("#btn-modify-person").show(); + $("#btn-new-person").show(); + $("#person-form").removeClass('selected'); + } + + enable_person = function(){ + $("#person-form :input[type='text'], #person-form textarea, #person-form select").prop("disabled", false); + $("#btn-save-person").show(); + $("#btn-cancel-person").show(); + $("#btn-modify-person").hide(); + $("#btn-new-person").hide(); + $("#person-form").addClass('selected'); + } + + disable_person(); + + var submit_url; + $("#btn-modify-person").on('click', function(){ + {% if object %}submit_url = "{% url 'person_edit' object.pk %}"; + {% else %}submit_url = "{% url 'person_create' %}";{% endif %} + enable_person(); + return false; + }); + $("#btn-new-person").on('click', function(){ + submit_url = "{% url 'person_create' %}"; + $("#person-form").find("input[type=text], textarea").val(""); + enable_person(); + person_new_callback(); + return false; + }); + $("#btn-cancel-person").on('click', function(){ + person_save_callback($('#hidden_person_pk').val(), + $('#hidden_person_lbl').val()); + disable_person(); + return false; + }); + $("#btn-save-person").on('click', function(){ + var form = $("#dyn-form-person"); + $.ajax({ + url: submit_url, + type: 'post', + data: form.serialize(), + dataType: 'html', + success: function(data) { + $("#person-form").parent().html(data); + person_save_callback($('#hidden_person_pk').val(), + $('#hidden_person_lbl').val()); + disable_person(); + return false; + } + }); + return false; + }); + + +}); +//--></script> diff --git a/ishtar_common/templates/ishtar/wizard/confirm_wizard.html b/ishtar_common/templates/ishtar/wizard/confirm_wizard.html index 0dd1f6f12..15bb9e9bd 100644 --- a/ishtar_common/templates/ishtar/wizard/confirm_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/confirm_wizard.html @@ -36,8 +36,10 @@ </table> {% endif %} {% block "extra_informations" %}{% endblock %} +<div id='validation-bar' class='big'> <p>{%if confirm_end_msg %}{{confirm_end_msg|safe}}{%else%}{% trans "Would you like to save them?" %}{%endif%}</p> <input type="submit" value="{% trans "Validate" %}"/> </div> +</div> </form> {% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 3f2f3943e..a39037d10 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n range table_form %} +{% load url from future %} {% block extra_head %} {{form.media}} {% endblock %} @@ -40,10 +41,9 @@ {% endif %} <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> {{ previous_fields|safe }} -<div id='validation-bar'> - <input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/> - {% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %} -</div> +{% block "validation_bar" %} +{% include 'ishtar/wizard/validation_bar.html' %} +{% endblock %} </div> </form> {% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html index b550cf6c4..ce2bc9780 100644 --- a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html @@ -9,7 +9,6 @@ {{ wizard.form.media }} {{ wizard.management_form }} {{ wizard.form.management_form }} -<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div> {%if wizard.form.non_form_errors%} <table class='formset'> <tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr> @@ -24,8 +23,9 @@ <p><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></p> <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> {{ previous_fields|safe }} -<input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/> -{% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %} +{% block "validation_bar" %} +{% include 'ishtar/wizard/validation_bar.html' %} +{% endblock %} </div> </form> {% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/towns_wizard.html b/ishtar_common/templates/ishtar/wizard/towns_wizard.html index 8e0b3551f..4f9ff6c5f 100644 --- a/ishtar_common/templates/ishtar/wizard/towns_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/towns_wizard.html @@ -9,7 +9,6 @@ <div class='form'> {% if TOWNS %} {% if wizard.form.forms %} -<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div> <table class='formset'> {{ wizard.management_form }} {%if wizard.form.non_form_errors%}<tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr>{%endif%} @@ -29,7 +28,9 @@ {% endif %} <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> {{ previous_fields|safe }} -<input type="submit" id="submit_form" value="{% trans "Validate" %}"/> +{% block "validation_bar" %} +{% include 'ishtar/wizard/validation_bar.html' %} +{% endblock %} </div> </form> {% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/validation_bar.html b/ishtar_common/templates/ishtar/wizard/validation_bar.html new file mode 100644 index 000000000..09907af67 --- /dev/null +++ b/ishtar_common/templates/ishtar/wizard/validation_bar.html @@ -0,0 +1,7 @@ +{% load i18n %} +{% load url from future %} +<div id='validation-bar'> + <input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/> + {% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %} + <a href='{% url 'reset_wizards' %}' id="reset_wizards" class='button'>{% trans "Cancel" %}</a> +</div> |