Merge branch 'erdn_front' into 'tranfer_front'

Some front

See merge request bde/nk20!77
This commit is contained in:
ynerant 2020-04-10 23:52:41 +02:00
commit c5f3f9b760
7 changed files with 233 additions and 161 deletions

View File

@ -1,6 +1,7 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from note.models import NoteSpecial
from treasury.models import SpecialTransactionProxy, RemittanceType from treasury.models import SpecialTransactionProxy, RemittanceType
@ -8,5 +9,6 @@ def save_special_transaction(instance, created, **kwargs):
""" """
When a special transaction is created, we create its linked proxy When a special transaction is created, we create its linked proxy
""" """
if created and RemittanceType.objects.filter(note=instance.source).exists(): if created and isinstance(instance.source, NoteSpecial) \
and RemittanceType.objects.filter(note=instance.source).exists():
SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save() SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save()

View File

@ -86,7 +86,7 @@ function getMatchedNotes(pattern, fun) {
* Generate a <li> entry with a given id and text * Generate a <li> entry with a given id and text
*/ */
function li(id, text, extra_css) { function li(id, text, extra_css) {
return "<li class=\"list-group-item py-1 d-flex justify-content-between align-items-center " + extra_css + "\"" + return "<li class=\"list-group-item py-1 px-2 d-flex justify-content-between align-items-center text-truncate " + extra_css + "\"" +
" id=\"" + id + "\">" + text + "</li>\n"; " id=\"" + id + "\">" + text + "</li>\n";
} }
@ -162,7 +162,8 @@ function removeNote(d, note_prefix = "note", notes_display, note_list_id, user_n
disp.quantity -= disp.id === d.id ? 1 : 0; disp.quantity -= disp.id === d.id ? 1 : 0;
new_notes_display.push(disp); new_notes_display.push(disp);
html += li(note_prefix + "_" + disp.id, disp.name html += li(note_prefix + "_" + disp.id, disp.name
+ "<span class=\"badge badge-dark badge-pill\">" + disp.quantity + "</span>"); + "<span class=\"badge badge-dark badge-pill\">" + disp.quantity + "</span>",
displayStyle(disp.note));
} }
}); });
@ -186,7 +187,6 @@ function removeNote(d, note_prefix = "note", notes_display, note_list_id, user_n
/** /**
* Generate an auto-complete field to query a note with its alias * Generate an auto-complete field to query a note with its alias
* @param field_id The identifier of the text field where the alias is typed * @param field_id The identifier of the text field where the alias is typed
* @param alias_matched_id The div block identifier where the matched aliases are displayed
* @param note_list_id The div block identifier where the notes of the buyers are displayed * @param note_list_id The div block identifier where the notes of the buyers are displayed
* @param notes An array containing the note objects of the buyers * @param notes An array containing the note objects of the buyers
* @param notes_display An array containing the infos of the buyers: [alias, note id, note object, quantity] * @param notes_display An array containing the infos of the buyers: [alias, note id, note object, quantity]
@ -200,11 +200,22 @@ function removeNote(d, note_prefix = "note", notes_display, note_list_id, user_n
* the associated note is not displayed. * the associated note is not displayed.
* Useful for a consumption if the item is selected before. * Useful for a consumption if the item is selected before.
*/ */
function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes_display, alias_prefix = "alias", function autoCompleteNote(field_id, note_list_id, notes, notes_display, alias_prefix = "alias",
note_prefix = "note", user_note_field = null, profile_pic_field = null, alias_click = null) { note_prefix = "note", user_note_field = null, profile_pic_field = null, alias_click = null) {
let field = $("#" + field_id); let field = $("#" + field_id);
// When the user clicks on the search field, it is immediately cleared
// Configure tooltip
field.tooltip({
html: true,
placement: 'bottom',
title: 'Loading...',
trigger: 'manual',
container: field.parent()
});
// Clear search on click
field.click(function () { field.click(function () {
field.tooltip('hide');
field.val(""); field.val("");
}); });
@ -213,7 +224,7 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
// When the user type "Enter", the first alias is clicked // When the user type "Enter", the first alias is clicked
field.keypress(function (event) { field.keypress(function (event) {
if (event.originalEvent.charCode === 13 && notes.length > 0) { if (event.originalEvent.charCode === 13 && notes.length > 0) {
let li_obj = $("#" + alias_matched_id + " li").first(); let li_obj = field.parent().find("ul li").first();
displayNote(notes[0], li_obj.text(), user_note_field, profile_pic_field); displayNote(notes[0], li_obj.text(), user_note_field, profile_pic_field);
li_obj.trigger("click"); li_obj.trigger("click");
} }
@ -225,19 +236,16 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
return; return;
let pattern = field.val(); let pattern = field.val();
// If the pattern is not modified, we don't query the API // If the pattern is not modified, we don't query the API
if (pattern === old_pattern) if (pattern === old_pattern)
return; return;
old_pattern = pattern; old_pattern = pattern;
notes.length = 0; notes.length = 0;
let aliases_matched_obj = $("#" + alias_matched_id);
let aliases_matched_html = "";
// get matched Alias with note associated // get matched Alias with note associated
if (pattern === "") { if (pattern === "") {
aliases_matched_obj = $("#" + alias_matched_id); field.tooltip('hide');
aliases_matched_html = "";
aliases_matched_obj.html("")
notes.length = 0; notes.length = 0;
return; return;
} }
@ -249,6 +257,9 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
// The response arrived too late, we stop the request // The response arrived too late, we stop the request
if (pattern !== $("#" + field_id).val()) if (pattern !== $("#" + field_id).val())
return; return;
// Build tooltip content
let aliases_matched_html = '<ul class="list-group list-group-flush">';
consumers.results.forEach(function (consumer) { consumers.results.forEach(function (consumer) {
let note = consumer.note; let note = consumer.note;
note.email_confirmed = consumer.email_confirmed; note.email_confirmed = consumer.email_confirmed;
@ -258,7 +269,11 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
extra_css); extra_css);
notes.push(note); notes.push(note);
}); });
aliases_matched_obj.html(aliases_matched_html); aliases_matched_html += '</ul>';
// Show tooltip
field.attr('data-original-title', aliases_matched_html).tooltip('show');
consumers.results.forEach(function (consumer) { consumers.results.forEach(function (consumer) {
let note = consumer.note; let note = consumer.note;
let consumer_obj = $("#" + alias_prefix + "_" + consumer.id); let consumer_obj = $("#" + alias_prefix + "_" + consumer.id);
@ -266,8 +281,6 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
displayNote(consumer.note, consumer.name, user_note_field, profile_pic_field) displayNote(consumer.note, consumer.name, user_note_field, profile_pic_field)
}); });
consumer_obj.click(function () { consumer_obj.click(function () {
field.val("");
old_pattern = ""; // reset input field
var disp = null; var disp = null;
notes_display.forEach(function (d) { notes_display.forEach(function (d) {
// We compare the note ids // We compare the note ids
@ -299,12 +312,15 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
disp.name disp.name
+ "<span class=\"badge badge-dark badge-pill\">" + "<span class=\"badge badge-dark badge-pill\">"
+ disp.quantity + "</span>", + disp.quantity + "</span>",
displayStyle(disp.note.balance)); displayStyle(disp.note));
}); });
// Emitters are displayed // Emitters are displayed
note_list.html(html); note_list.html(html);
// Update tooltip position
field.tooltip('update');
notes_display.forEach(function (disp) { notes_display.forEach(function (disp) {
let line_obj = $("#" + note_prefix + "_" + disp.id); let line_obj = $("#" + note_prefix + "_" + disp.id);
// Hover an emitter display also the profile picture // Hover an emitter display also the profile picture

View File

@ -24,13 +24,10 @@ $(document).ready(function() {
}); });
// Switching in double consumptions mode should update the layout // Switching in double consumptions mode should update the layout
let double_conso_obj = $("#double_conso"); $("#double_conso").click(function() {
double_conso_obj.click(function() { $("#consos_list_div").removeClass('d-none');
$("#consos_list_div").show();
$("#infos_div").attr('class', 'col-sm-5 col-xl-6');
$("#note_infos_div").attr('class', 'col-xl-3');
$("#user_select_div").attr('class', 'col-xl-4'); $("#user_select_div").attr('class', 'col-xl-4');
$("#buttons_div").attr('class', 'col-sm-7 col-xl-6'); $("#infos_div").attr('class', 'col-sm-5 col-xl-6');
let note_list_obj = $("#note_list"); let note_list_obj = $("#note_list");
if (buttons.length > 0 && note_list_obj.text().length > 0) { if (buttons.length > 0 && note_list_obj.text().length > 0) {
@ -44,13 +41,10 @@ $(document).ready(function() {
} }
}); });
let single_conso_obj = $("#single_conso"); $("#single_conso").click(function() {
single_conso_obj.click(function() { $("#consos_list_div").addClass('d-none');
$("#consos_list_div").hide();
$("#infos_div").attr('class', 'col-sm-5 col-md-4');
$("#note_infos_div").attr('class', 'col-xl-5');
$("#user_select_div").attr('class', 'col-xl-7'); $("#user_select_div").attr('class', 'col-xl-7');
$("#buttons_div").attr('class', 'col-sm-7 col-md-8'); $("#infos_div").attr('class', 'col-sm-5 col-md-4');
let consos_list_obj = $("#consos_list"); let consos_list_obj = $("#consos_list");
if (buttons.length > 0) { if (buttons.length > 0) {
@ -69,12 +63,8 @@ $(document).ready(function() {
} }
}); });
// Ensure we begin in single consumption. Removing these lines may cause problems when reloading. // Ensure we begin in single consumption. Fix issue with TurboLinks and BootstrapJS
single_conso_obj.prop('checked', 'true'); $("label[for='double_conso']").removeClass('active');
double_conso_obj.removeAttr('checked');
$("label[for='double_conso']").attr('class', 'btn btn-sm btn-outline-primary');
$("#consos_list_div").hide();
$("#consume_all").click(consumeAll); $("#consume_all").click(consumeAll);
}); });
@ -84,7 +74,7 @@ notes_display = [];
buttons = []; buttons = [];
// When the user searches an alias, we update the auto-completion // When the user searches an alias, we update the auto-completion
autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display, autoCompleteNote("note", "note_list", notes, notes_display,
"alias", "note", "user_note", "profile_pic", function() { "alias", "note", "user_note", "profile_pic", function() {
if (buttons.length > 0 && $("#single_conso").is(":checked")) { if (buttons.length > 0 && $("#single_conso").is(":checked")) {
consumeAll(); consumeAll();
@ -152,7 +142,6 @@ function reset() {
notes.length = 0; notes.length = 0;
buttons.length = 0; buttons.length = 0;
$("#note_list").html(""); $("#note_list").html("");
$("#alias_matched").html("");
$("#consos_list").html(""); $("#consos_list").html("");
$("#user_note").text(""); $("#user_note").text("");
$("#profile_pic").attr("src", "/media/pic/default.png"); $("#profile_pic").attr("src", "/media/pic/default.png");

View File

@ -14,8 +14,6 @@ function reset() {
dests.length = 0; dests.length = 0;
$("#source_note_list").html(""); $("#source_note_list").html("");
$("#dest_note_list").html(""); $("#dest_note_list").html("");
$("#source_alias_matched").html("");
$("#dest_alias_matched").html("");
$("#amount").val(""); $("#amount").val("");
$("#reason").val(""); $("#reason").val("");
$("#last_name").val(""); $("#last_name").val("");
@ -28,14 +26,20 @@ function reset() {
} }
$(document).ready(function() { $(document).ready(function() {
autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display, /**
"source_alias", "source_note", "user_note", "profile_pic"); * If we are in credit/debit mode, check that only one note is entered.
autoCompleteNote("dest_note", "dest_alias_matched", "dest_note_list", dests, dests_notes_display, * More over, get first name and last name to autocomplete fields.
"dest_alias", "dest_note", "user_note", "profile_pic", function() { */
function checkUniqueNote() {
if ($("#type_credit").is(":checked") || $("#type_debit").is(":checked")) { if ($("#type_credit").is(":checked") || $("#type_debit").is(":checked")) {
let last = dests_notes_display[dests_notes_display.length - 1]; let arr = $("#type_credit").is(":checked") ? dests_notes_display : sources_notes_display;
dests_notes_display.length = 0;
dests_notes_display.push(last); if (arr.length === 0)
return;
let last = arr[arr.length - 1];
arr.length = 0;
arr.push(last);
last.quantity = 1; last.quantity = 1;
@ -57,8 +61,75 @@ $(document).ready(function() {
} }
return true; return true;
}
autoCompleteNote("source_note", "source_note_list", sources, sources_notes_display,
"source_alias", "source_note", "user_note", "profile_pic", checkUniqueNote);
autoCompleteNote("dest_note", "dest_note_list", dests, dests_notes_display,
"dest_alias", "dest_note", "user_note", "profile_pic", checkUniqueNote);
let source = $("#source_note");
let dest = $("#dest_note");
$("#type_gift").click(function() {
$("#special_transaction_div").addClass('d-none');
source.attr('disabled', true);
source.val(username);
source.tooltip('hide');
$("#source_note_list").addClass('d-none');
dest.attr('disabled', false);
$("#dest_note_list").removeClass('d-none');
}); });
$("#type_transfer").click(function() {
$("#special_transaction_div").addClass('d-none');
source.attr('disabled', false);
$("#source_note_list").removeClass('d-none');
dest.attr('disabled', false);
$("#dest_note_list").removeClass('d-none');
});
$("#type_credit").click(function() {
$("#special_transaction_div").removeClass('d-none');
$("#source_note_list").addClass('d-none');
$("#dest_note_list").removeClass('d-none');
source.attr('disabled', true);
source.val($("#credit_type option:selected").text());
source.tooltip('hide');
dest.attr('disabled', false);
dest.val('');
dest.tooltip('hide');
if (dests_notes_display.length > 1) {
$("#dest_note_list").html('');
dests_notes_display.length = 0;
}
});
$("#type_debit").click(function() {
$("#special_transaction_div").removeClass('d-none');
$("#source_note_list").removeClass('d-none');
$("#dest_note_list").addClass('d-none');
source.attr('disabled', false);
source.val('');
source.tooltip('hide');
dest.attr('disabled', true);
dest.val($("#credit_type option:selected").text());
dest.tooltip('hide');
if (sources_notes_display.length > 1) {
$("#source_note_list").html('');
sources_notes_display.length = 0;
}
});
$("#credit_type").change(function() {
let type = $("#credit_type option:selected").text();
if ($("#type_credit").is(":checked"))
source.val(type);
else
dest.val(type);
});
// Ensure we begin in gift mode. Removing these lines may cause problems when reloading. // Ensure we begin in gift mode. Removing these lines may cause problems when reloading.
let type_gift = $("#type_gift"); // Default mode let type_gift = $("#type_gift"); // Default mode
@ -184,10 +255,11 @@ $("#btn_transfer").click(function() {
}); });
} else if ($("#type_credit").is(':checked') || $("#type_debit").is(':checked')) { } else if ($("#type_credit").is(':checked') || $("#type_debit").is(':checked')) {
let special_note = $("#credit_type").val(); let special_note = $("#credit_type").val();
let user_note = dests_notes_display[0].note.id; let user_note;
let given_reason = $("#reason").val(); let given_reason = $("#reason").val();
let source, dest, reason; let source, dest, reason;
if ($("#type_credit").is(':checked')) { if ($("#type_credit").is(':checked')) {
user_note = dests_notes_display[0].note.id;
source = special_note; source = special_note;
dest = user_note; dest = user_note;
reason = "Crédit " + $("#credit_type option:selected").text().toLowerCase(); reason = "Crédit " + $("#credit_type option:selected").text().toLowerCase();
@ -195,6 +267,7 @@ $("#btn_transfer").click(function() {
reason += " (" + given_reason + ")"; reason += " (" + given_reason + ")";
} }
else { else {
user_note = sources_notes_display[0].note.id;
source = user_note; source = user_note;
dest = special_note; dest = special_note;
reason = "Retrait " + $("#credit_type option:selected").text().toLowerCase(); reason = "Retrait " + $("#credit_type option:selected").text().toLowerCase();

View File

@ -32,7 +32,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"> crossorigin="anonymous">
<link rel="stylesheet" <link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
crossorigin="anonymous">
{# JQuery, Bootstrap and Turbolinks JavaScript #} {# JQuery, Bootstrap and Turbolinks JavaScript #}
<script src="https://code.jquery.com/jquery-3.4.1.min.js" <script src="https://code.jquery.com/jquery-3.4.1.min.js"
@ -58,6 +59,20 @@ SPDX-License-Identifier: GPL-3.0-or-later
cursor: pointer; cursor: pointer;
text-decoration: underline; text-decoration: underline;
} }
.tooltip.show {
opacity: 1; /* opaque tooltip */
}
.tooltip-inner {
background-color: #fff;
box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
border: 1px solid rgba(0,0,0,.250);
color: #000;
margin: 0 .5rem .25rem .5rem;
padding: 0;
}
.bs-tooltip-bottom .arrow::before {
border-bottom-color: rgba(0,0,0,.250);
}
</style> </style>
{% block extracss %}{% endblock %} {% block extracss %}{% endblock %}

View File

@ -10,11 +10,10 @@
<div class="col-sm-5 col-md-4" id="infos_div"> <div class="col-sm-5 col-md-4" id="infos_div">
<div class="row"> <div class="row">
{# User details column #} {# User details column #}
<div class="col-xl-5" id="note_infos_div"> <div class="col">
<div class="card border-success shadow mb-4 text-center"> <div class="card border-success shadow mb-4 text-center">
<img src="/media/pic/default.png" <img src="/media/pic/default.png"
id="profile_pic" alt="" id="profile_pic" alt="" class="card-img-top">
class="img-thumbnail">
<div class="card-body text-center"> <div class="card-body text-center">
<span id="user_note"></span> <span id="user_note"></span>
</div> </div>
@ -29,38 +28,42 @@
{% trans "Consum" %} {% trans "Consum" %}
</p> </p>
</div> </div>
<div class="card-body px-0 py-0" style="min-height:125px;"> <div class="card-body p-0" style="min-height:125px;">
<ul class="list-group list-group-flush" id="note_list"> <ul class="list-group list-group-flush" id="note_list">
</ul> </ul>
</div> </div>
<div class="card-footer bg-white">
<input class="form-control mx-auto d-block" type="text" id="note" /> {# User search with autocompletion #}
<ul class="list-group list-group-flush" <div class="card-footer">
id="alias_matched"> <input class="form-control mx-auto d-block"
</ul> placeholder="{% trans "Name or alias..." %}" type="text" id="note" autofocus />
</div> </div>
</div> </div>
</div> </div>
<div class="col-xl-5" id="consos_list_div"> <div class="col-xl-5 d-none" id="consos_list_div">
<div class="card border-info shadow mb-4"> <div class="card border-info shadow mb-4">
<div class="card-header"> <div class="card-header">
<p class="card-text font-weight-bold"> <p class="card-text font-weight-bold">
{% trans "Select consumptions" %} {% trans "Select consumptions" %}
</p> </p>
</div> </div>
<div class="card-body p-0" style="min-height:125px;">
<ul class="list-group list-group-flush" id="consos_list"> <ul class="list-group list-group-flush" id="consos_list">
</ul> </ul>
<button id="consume_all" class="form-control btn btn-primary"> </div>
<div class="card-footer text-center">
<a id="consume_all" href="#" class="btn btn-primary">
{% trans "Consume!" %} {% trans "Consume!" %}
</button> </a>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{# Buttons column #} {# Buttons column #}
<div class="col-sm-7 col-md-8" id="buttons_div"> <div class="col">
{# Show last used buttons #} {# Show last used buttons #}
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<div class="card-header"> <div class="card-header">
@ -127,10 +130,12 @@
<div class="btn-group btn-group-toggle float-right" data-toggle="buttons"> <div class="btn-group btn-group-toggle float-right" data-toggle="buttons">
<label for="single_conso" class="btn btn-sm btn-outline-primary active"> <label for="single_conso" class="btn btn-sm btn-outline-primary active">
<input type="radio" name="conso_type" id="single_conso" checked> <input type="radio" name="conso_type" id="single_conso" checked>
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
{% trans "Single consumptions" %} {% trans "Single consumptions" %}
</label> </label>
<label for="double_conso" class="btn btn-sm btn-outline-primary"> <label for="double_conso" class="btn btn-sm btn-outline-primary">
<input type="radio" name="conso_type" id="double_conso"> <input type="radio" name="conso_type" id="double_conso">
<i class="fa fa-arrows-h" aria-hidden="true"></i>
{% trans "Double consumptions" %} {% trans "Double consumptions" %}
</label> </label>
</div> </div>
@ -150,7 +155,7 @@
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}
<script type="text/javascript" src="/static/js/consos.js"></script> <script type="text/javascript" src="{% static "js/consos.js" %}"></script>
<script type="text/javascript"> <script type="text/javascript">
{% for button in most_used %} {% for button in most_used %}
{% if button.display %} {% if button.display %}

View File

@ -38,8 +38,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-3" id="note_infos_div">
<div class="col-xl-4" id="note_infos_div">
<div class="card border-success shadow mb-4"> <div class="card border-success shadow mb-4">
<img src="/media/pic/default.png" <img src="/media/pic/default.png"
id="profile_pic" alt="" class="img-fluid rounded mx-auto d-block"> id="profile_pic" alt="" class="img-fluid rounded mx-auto d-block">
@ -48,7 +47,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-4" id="emitters_div" style="display: none;">
<div class="col-md-3" id="emitters_div">
<div class="card border-success shadow mb-4"> <div class="card border-success shadow mb-4">
<div class="card-header"> <div class="card-header">
<p class="card-text font-weight-bold"> <p class="card-text font-weight-bold">
@ -58,24 +58,53 @@ SPDX-License-Identifier: GPL-2.0-or-later
<ul class="list-group list-group-flush" id="source_note_list"> <ul class="list-group list-group-flush" id="source_note_list">
</ul> </ul>
<div class="card-body"> <div class="card-body">
<input class="form-control mx-auto d-block" type="text" id="source_note" /> <input class="form-control mx-auto d-block" type="text" id="source_note" placeholder="{% trans "Name or alias..." %}" />
<ul class="list-group list-group-flush" id="source_alias_matched"> </div>
</div>
</div>
<div class="col-md-3" id="dests_div">
<div class="card border-info shadow mb-4">
<div class="card-header">
<p class="card-text font-weight-bold" id="dest_title">
{% trans "Select receivers" %}
</p>
</div>
<ul class="list-group list-group-flush" id="dest_note_list">
</ul>
<div class="card-body">
<input class="form-control mx-auto d-block" type="text" id="dest_note" placeholder="{% trans "Name or alias..." %}" />
<ul class="list-group list-group-flush" id="dest_alias_matched">
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
{% if "note.notespecial"|not_empty_model_list %} <div class="col-md-3" id="external_div">
<div class="col-md-4" id="external_div" style="display: none;"> <div class="card border-warning shadow mb-4">
<div class="card border-success shadow mb-4">
<div class="card-header"> <div class="card-header">
<p class="card-text font-weight-bold"> <p class="card-text font-weight-bold">
{% trans "External payment" %} {% trans "Action" %}
</p> </p>
</div> </div>
<ul class="list-group list-group-flush" id="source_note_list"> <ul class="list-group list-group-flush" id="source_note_list">
</ul> </ul>
<div class="card-body"> <div class="card-body">
<div class="form-row">
<div class="col-md-12">
<label for="amount">{% trans "Amount" %} :</label>
{% include "note/amount_input.html" with widget=amount_widget %}
</div>
</div>
<div class="form-row">
<div class="col-md-12">
<label for="reason">{% trans "Reason" %} :</label>
<input class="form-control mx-auto d-block" type="text" id="reason" required />
</div>
</div>
<div class="d-none" id="special_transaction_div">
<div class="form-row"> <div class="form-row">
<div class="col-md-12"> <div class="col-md-12">
<label for="credit_type">{% trans "Transfer type" %} :</label> <label for="credit_type">{% trans "Transfer type" %} :</label>
@ -105,46 +134,16 @@ SPDX-License-Identifier: GPL-2.0-or-later
</div> </div>
</div> </div>
</div> </div>
</div> <hr>
</div>
{% endif %}
<div class="col-md-8" id="dests_div">
<div class="card border-info shadow mb-4">
<div class="card-header">
<p class="card-text font-weight-bold" id="dest_title">
{% trans "Select receivers" %}
</p>
</div>
<ul class="list-group list-group-flush" id="dest_note_list">
</ul>
<div class="card-body">
<input class="form-control mx-auto d-block" type="text" id="dest_note" />
<ul class="list-group list-group-flush" id="dest_alias_matched">
</ul>
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="amount">{% trans "Amount" %} :</label>
{% include "note/amount_input.html" with widget=amount_widget %}
</div>
<div class="form-group col-md-6">
<label for="reason">{% trans "Reason" %} :</label>
<input class="form-control mx-auto d-block" type="text" id="reason" required />
</div>
</div>
<div class="form-row"> <div class="form-row">
<div class="col-md-12"> <div class="col-md-12">
<button id="btn_transfer" class="form-control btn btn-primary">{% trans 'Transfer' %}</button> <button id="btn_transfer" class="form-control btn btn-primary">{% trans 'Transfer' %}</button>
</div> </div>
</div> </div>
</div>
</div>
</div>
</div>
<div class="card shadow mb-4" id="history"> <div class="card shadow mb-4" id="history">
<div class="card-header"> <div class="card-header">
@ -161,34 +160,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
TRANSFER_POLYMORPHIC_CTYPE = {{ polymorphic_ctype }}; TRANSFER_POLYMORPHIC_CTYPE = {{ polymorphic_ctype }};
SPECIAL_TRANSFER_POLYMORPHIC_CTYPE = {{ special_polymorphic_ctype }}; SPECIAL_TRANSFER_POLYMORPHIC_CTYPE = {{ special_polymorphic_ctype }};
user_id = {{ user.note.pk }}; user_id = {{ user.note.pk }};
username = "{{ user.username }}";
$("#type_gift").click(function() {
$("#emitters_div").hide();
$("#external_div").hide();
$("#dests_div").attr('class', 'col-md-8');
$("#dest_title").text("{% trans "Select receivers" %}");
});
$("#type_transfer").click(function() {
$("#external_div").hide();
$("#emitters_div").show();
$("#dests_div").attr('class', 'col-md-4');
$("#dest_title").text("{% trans "Select receivers" %}");
});
$("#type_credit").click(function() {
$("#emitters_div").hide();
$("#external_div").show();
$("#dests_div").attr('class', 'col-md-4');
$("#dest_title").text("{% trans "Credit note" %}");
});
$("#type_debit").click(function() {
$("#emitters_div").hide();
$("#external_div").show();
$("#dests_div").attr('class', 'col-md-4');
$("#dest_title").text("{% trans "Debit note" %}");
});
</script> </script>
<script src="/static/js/transfer.js"></script> <script src="/static/js/transfer.js"></script>
{% endblock %} {% endblock %}