pricing: add js & css for ordering & formset (#65440)
This commit is contained in:
parent
b443ea9fc1
commit
7d1764c97c
|
@ -14,3 +14,4 @@ lingo.egg-info/
|
||||||
junit*xml
|
junit*xml
|
||||||
pylint.out
|
pylint.out
|
||||||
*.swp
|
*.swp
|
||||||
|
lingo/manager/static/css/style.css
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
div.paragraph {
|
||||||
|
background: white;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #386ede;
|
||||||
|
border-radius: 3px;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 5px 15px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
h4 {
|
||||||
|
margin-top: 5px;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sortable {
|
||||||
|
span.handle {
|
||||||
|
cursor: move;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.5ex;
|
||||||
|
text-align: center;
|
||||||
|
width: 2em;
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.objects-list.sortable {
|
||||||
|
li {
|
||||||
|
position: relative;
|
||||||
|
& > a {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
$(function() {
|
||||||
|
$(document).on('click', '#add-pricing-variable-form', function() {
|
||||||
|
if (typeof property_forms === "undefined") {var property_forms = $('.pricing-variable-form');}
|
||||||
|
if (typeof total_forms === "undefined") {var total_form = $('#id_form-TOTAL_FORMS');}
|
||||||
|
if (typeof form_num === "undefined") {var form_num = property_forms.length - 1;}
|
||||||
|
var new_form = $(property_forms[0]).clone();
|
||||||
|
var form_regex = RegExp(`form-(\\d){1}-`,'g');
|
||||||
|
form_num++;
|
||||||
|
new_form.html(new_form.html().replace(form_regex, `form-${form_num}-`));
|
||||||
|
new_form.appendTo('#pricing-variable-forms tbody');
|
||||||
|
$('#id_form-' + form_num + '-key').val('');
|
||||||
|
$('#id_form-' + form_num + '-value').val('');
|
||||||
|
total_form.val(form_num + 1);
|
||||||
|
})
|
||||||
|
|
||||||
|
$('.sortable').sortable({
|
||||||
|
handle: '.handle',
|
||||||
|
items: '.sortable-item',
|
||||||
|
update : function(event, ui) {
|
||||||
|
var new_order = '';
|
||||||
|
$(this).find('.sortable-item').each(function(i, x) {
|
||||||
|
var item_id = $(x).data('item-id');
|
||||||
|
if (new_order) {
|
||||||
|
new_order += ',';
|
||||||
|
}
|
||||||
|
new_order += item_id;
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: $(this).data('order-url'),
|
||||||
|
data: {'new-order': new_order}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -1 +1,7 @@
|
||||||
{% extends "lingo/base.html" %}
|
{% extends "lingo/base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block extrascripts %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/lingo.manager.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -130,7 +130,7 @@ class compile_scss(Command):
|
||||||
|
|
||||||
|
|
||||||
class build(_build):
|
class build(_build):
|
||||||
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
|
||||||
|
|
||||||
|
|
||||||
class install_lib(_install_lib):
|
class install_lib(_install_lib):
|
||||||
|
@ -169,6 +169,7 @@ setup(
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
cmdclass={
|
cmdclass={
|
||||||
'build': build,
|
'build': build,
|
||||||
|
'compile_scss': compile_scss,
|
||||||
'compile_translations': compile_translations,
|
'compile_translations': compile_translations,
|
||||||
'install_lib': install_lib,
|
'install_lib': install_lib,
|
||||||
'sdist': eo_sdist,
|
'sdist': eo_sdist,
|
||||||
|
|
Loading…
Reference in New Issue