Skip to content

Commit

Permalink
piccoli aggiustamenti js
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Nov 12, 2023
1 parent b486c2d commit 790e9b7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 58 deletions.
2 changes: 1 addition & 1 deletion code/public/js/gasdotto.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/js/gasdotto.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/gasdotto.js": "/js/gasdotto.js?id=746e8540b3554998a960fee7b7d1a734",
"/js/gasdotto.js": "/js/gasdotto.js?id=bcc305898791465cd3619d09b5e8c6cf",
"/css/gasdotto.css": "/css/gasdotto.css?id=1319b6248551694a7cc664f14b15fa9c"
}
20 changes: 5 additions & 15 deletions code/resources/assets/js/bookings.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,11 @@ class Bookings
else {
i.removeClass('is-changed');
}
});

$('input.manual-total', container).change((e) => {
}).change((e) => {
let editor = $(e.currentTarget).closest('.booking-editor');
this.bookingTotal(editor);
});

$('.load-other-booking', container).click((e) => {
e.preventDefault();
var button = $(e.currentTarget);
var url = button.attr('data-booking-url');
var fill_target = button.closest('.other-booking');
utils.j().fetchNode(url, fill_target);
});

$('.inline-calculator button[type=submit]', container).click((e) => {
e.preventDefault();
var modal = $(e.currentTarget).closest('.modal');
Expand Down Expand Up @@ -410,10 +400,10 @@ class Bookings
varinputbox.closest('tr').find('.booking-product-price span').text(variant.total.toFixed(2));
}

let total_rows = $('input[name="variant_quantity_' + product_id + '[]"]', container).length;
if (total_rows > product_meta.variants.length) {
for (let i = product_meta.variants.length; i < total_rows; i++) {
let varinputbox = $('input[name="variant_quantity_' + product_id + '[]"]', container).eq(i);
let total_rows = $('input[name="variant_quantity_' + product_id + '[]"]', container);
if (total_rows.length > product_meta.variants.length) {
for (let i = product_meta.variants.length; i < total_rows.length; i++) {
let varinputbox = total_rows.eq(i);
varinputbox.val(0);
varinputbox.closest('tr').find('.booking-product-price span').text('0.00');
}
Expand Down
41 changes: 9 additions & 32 deletions code/resources/assets/js/callables.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ class Callables {
}
}

static afterProductChange(form, data) {
static genericAfterChange(form, data, endpoint) {
utils.postAjax({
method: 'GET',
url: 'products/' + data.id + '/post_feedback',
url: endpoint + '/' + data.id + '/post_feedback',
dataType: 'JSON',
success: function(data) {
for (let i = 0; i < data.length; i++) {
Expand All @@ -232,43 +232,20 @@ class Callables {
});
}

static afterProductChange(form, data) {
this.genericAfterChange(form, data, 'products');
}

static afterAggregateChange(form, data) {
utils.postAjax({
method: 'GET',
url: 'aggregates/' + data.id + '/post_feedback',
dataType: 'JSON',
success: function(data) {
for (let i = 0; i < data.length; i++) {
utils.j().fetchRemoteModal(data[i]);
}
}
});
this.genericAfterChange(form, data, 'aggregates');
}

static afterMovementTypeChange(form, data) {
utils.postAjax({
method: 'GET',
url: 'movtypes/' + data.id + '/post_feedback',
dataType: 'JSON',
success: function(data) {
for (let i = 0; i < data.length; i++) {
utils.j().fetchRemoteModal(data[i]);
}
}
});
this.genericAfterChange(form, data, 'movtypes');
}

static afterModifierChange(form, data) {
utils.postAjax({
method: 'GET',
url: 'modifiers/' + data.id + '/post_feedback',
dataType: 'JSON',
success: function(data) {
for (let i = 0; i < data.length; i++) {
utils.j().fetchRemoteModal(data[i]);
}
}
});
this.genericAfterChange(form, data, 'modifiers');
}

static afterBookingSaved(form, data) {
Expand Down
12 changes: 4 additions & 8 deletions code/resources/assets/js/gasdotto.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ function generalInit(container) {
Statistics.init(container);
}

function voidForm(form) {
form.find('input[type!=hidden]').val('');
form.find('textarea').val('');
form.find('select option:first').prop('selected', true);
form.find('.error-message').remove();
}

function wizardLoadPage(node, contents) {
try {
let previous = node.closest('.modal');
Expand Down Expand Up @@ -330,7 +323,10 @@ function miscInnerCallbacks(form, data) {
var test = form.find('input[name=void-form]');
if (test.length != 0) {
test.each(function() {
voidForm(form);
form.find('input[type!=hidden]').val('');
form.find('textarea').val('');
form.find('select option:first').prop('selected', true);
form.find('.error-message').remove();
});
}

Expand Down

0 comments on commit 790e9b7

Please sign in to comment.