Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
5b119348
Commit
5b119348
authored
3 years ago
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2416 Fixing Mozilla input number lack off blur event firing
parent
5cfdcae6
dev_cooperatic
…
#5673_bug_calendrier_echange_service
3832-makeups-and-member-status-update
4081
4444_improve_presence_recording
4709
4778-reception-dont-get-finished-orders
4809-remove-shelf-value-col-to-reduce-server-load
4880-rapports-reception-faux
4950-douchage-appli-reception
5474-et-5462-Voir-les-rattrapages-choisis-dans-admin-bdm-et-corrige-lenteur-affichage-admin-rattrapages
5641-reception-trier-a-la-maj-prix-dans-ordre-de-pointage-quantites
6286_bug_encaissement_souscription_cheque_espece
6813-marking-parent-gone-when-unpairing-binom-does-not-unsuscribe-parent-from-shift-template
6832--certaines-absences-engendrent-une-erreur
7723-7559-change-purchase-order-workflow-django-side
7731-third-party-side-brinks-pos-export-not-working
7747-inventaire-par-article
7800-make-test-solution-work
7819-prevent-adding-product-already-in-order
7848-cannot-validate-qty-with-decimal-on-kg-product
7918_bug_quantites_stade_demande_prix
adaptation_supercafoutch
adaptation_supercoop
adaptation_supercoop_supercafoutch
adpatation_chouette
assistance_import_article
coop_dev_necessitant_modules_bdm_odoo_modifies
correctif_nb_rattrapages_creation_binome_avec_ajout_automatique_au_point_negatif
dev_principale
export_capital_detenu
fix_bug_process_picking
fusion_custom_graoucoop
graoucoop_backup
graoucoop_prod
graoucoop_tmp
hot_fix_shelf_labels_auto_print
impression_etiquettes_rayons
integration_lien_precommandes_dans_espace_membre
lacagette_prod
local_branch
meal-voucher-and-label-printer-software-bug
migration-v12
pour_graoucoop_prod
pour_version_prod_cagette
refonte_espace_membre_sc
retouches_tickets_supercoop
sc-setup-stock-app
supercafoutch-preprod
supercafoutch-prod-20221003
supercafoutch_prod
ticket_4146
supercafoutch_20250120_151258
supercafoutch_20250120_150340
supercafoutch_20240909_080630
supercafoutch_20240609_115709
supercafoutch_20240212_082431
supercafoutch_20240107_181851
supercafoutch_prod_until_240107
supercafoutch-prod-20221003
supercafoutch-230911
supercafoutch-230824
supercafoutch-230823
supercafoutch-230823-the-true-one
migration-v12-tag
lacagette_20240310_074751
lacagette_20240107_122554
lacagette_20240107_120916
graoucoop_20240609_122614
cagette_testtag
cagette-230814
cagette-230630
2 merge requests
!135
#2416 Fixing Mozilla input number lack off blur event firing
,
!164
Intégration des dév. Cooperatic pour la Cagette
Pipeline
#1887
failed with stage
in 1 minute 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
130 deletions
+161
-130
orders_helper.js
orders/static/js/orders_helper.js
+161
-130
No files found.
orders/static/js/orders_helper.js
View file @
5b119348
...
...
@@ -9,7 +9,8 @@ var suppliers_list = [],
new_product_supplier_association
=
{
package_qty
:
null
,
price
:
null
};
},
qties_values
=
{};
var
dbc
=
null
,
sync
=
null
,
...
...
@@ -30,6 +31,10 @@ var dbc = null,
var
clicked_order_pill
=
null
;
let
userAgent
=
navigator
.
userAgent
;
var
timerId
;
/* - UTILS */
...
...
@@ -124,7 +129,68 @@ function debounceFunction(func, delay = 1000) {
timerId
=
setTimeout
(
func
,
delay
);
}
/* - PRODUCTS */
var
process_new_product_qty
=
function
(
input
)
{
// Remove line coloring on input blur
const
row
=
$
(
input
).
closest
(
'tr'
);
row
.
removeClass
(
'focused_line'
);
let
val
=
(
$
(
input
).
val
()
==
''
)
?
0
:
$
(
input
).
val
();
const
id_split
=
$
(
input
).
attr
(
'id'
)
.
split
(
'_'
);
const
prod_id
=
id_split
[
1
];
const
supplier_id
=
id_split
[
3
];
if
(
val
==
-
1
)
{
let
modal_end_supplier_product_association
=
$
(
'#templates #modal_end_supplier_product_association'
);
const
product
=
products
.
find
(
p
=>
p
.
id
==
prod_id
);
modal_end_supplier_product_association
.
find
(
".product_name"
).
text
(
product
.
name
);
const
supplier
=
selected_suppliers
.
find
(
s
=>
s
.
id
==
supplier_id
);
modal_end_supplier_product_association
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
openModal
(
modal_end_supplier_product_association
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_end_supplier_product_association'
))
{
end_supplier_product_association
(
product
,
supplier
);
}
},
'Valider'
,
false
,
true
,
()
=>
{
// Reset value in input on cancel
const
psi
=
product
.
suppliersinfo
.
find
(
psi_item
=>
psi_item
.
supplier_id
==
supplier_id
);
$
(
input
).
val
(
psi
.
qty
);
}
);
}
else
{
val
=
parseFloat
(
val
);
// If value is a number
if
(
!
isNaN
(
val
))
{
// Save value
save_product_supplier_qty
(
prod_id
,
supplier_id
,
val
);
// Update row
const
product
=
products
.
find
(
p
=>
p
.
id
==
prod_id
);
const
new_row_data
=
prepare_datatable_data
([
product
.
id
])[
0
];
products_table
.
row
(
$
(
input
).
closest
(
'tr'
)).
data
(
new_row_data
)
.
draw
();
debounceFunction
(
update_cdb_order
);
display_total_values
();
}
else
{
$
(
input
).
val
(
''
);
}
}
};
/**
* Add a product.
*
...
...
@@ -1674,151 +1740,94 @@ function display_products(params) {
row
.
addClass
(
'focused_line'
);
});
// Manage data on inputs blur
$
(
'#products_table'
).
on
(
'blur'
,
'tbody td .product_qty_input'
,
function
()
{
// Remove line coloring on input blur
const
row
=
$
(
this
).
closest
(
'tr'
);
row
.
removeClass
(
'focused_line'
);
let
val
=
(
$
(
this
).
val
()
==
''
)
?
0
:
$
(
this
).
val
();
const
id_split
=
$
(
this
).
attr
(
'id'
)
.
split
(
'_'
);
const
prod_id
=
id_split
[
1
];
const
supplier_id
=
id_split
[
3
];
if
(
val
==
-
1
)
{
let
modal_end_supplier_product_association
=
$
(
'#templates #modal_end_supplier_product_association'
);
const
product
=
products
.
find
(
p
=>
p
.
id
==
prod_id
);
modal_end_supplier_product_association
.
find
(
".product_name"
).
text
(
product
.
name
);
const
supplier
=
selected_suppliers
.
find
(
s
=>
s
.
id
==
supplier_id
);
$
(
'#products_table'
)
.
on
(
'blur'
,
'tbody td .product_qty_input'
,
function
()
{
process_new_product_qty
(
this
);
})
.
on
(
'keypress'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
// Validate on Enter pressed
if
(
e
.
which
==
13
)
{
$
(
this
).
blur
();
}
})
.
on
(
'keydown'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
if
(
e
.
which
==
38
)
{
e
.
preventDefault
();
modal_end_supplier_product_association
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
// On arrow up pressed, focus next row input
let
next_input
=
$
(
this
).
closest
(
"tr"
)
.
prev
()
.
find
(
".product_qty_input"
);
openModal
(
modal_end_supplier_product_association
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_end_supplier_product_association'
))
{
end_supplier_product_association
(
product
,
supplier
);
}
},
'Valider'
,
false
,
true
,
()
=>
{
// Reset value in input on cancel
const
psi
=
product
.
suppliersinfo
.
find
(
psi_item
=>
psi_item
.
supplier_id
==
supplier_id
);
next_input
.
focus
();
$
(
this
).
val
(
psi
.
qty
);
}
);
}
else
{
val
=
parseFloat
(
val
);
// Scroll to a position where the target input is not hidden by the sticky suppliers container
const
suppliers_container_top_offset
=
$
(
"#suppliers_container"
).
offset
().
top
-
$
(
window
).
scrollTop
()
+
$
(
"#suppliers_container"
).
outerHeight
();
const
next_input_top_offset
=
next_input
.
offset
().
top
-
$
(
window
).
scrollTop
();
// If value is a number
if
(
!
isNaN
(
val
))
{
// Save value
save_product_supplier_qty
(
prod_id
,
supplier_id
,
val
);
if
(
next_input_top_offset
<
suppliers_container_top_offset
)
{
window
.
scrollTo
({
top
:
$
(
window
).
scrollTop
()
-
$
(
"#suppliers_container"
).
outerHeight
()
});
}
}
else
if
(
e
.
which
==
40
)
{
e
.
preventDefault
();
// Update row
const
product
=
products
.
find
(
p
=>
p
.
id
==
prod_id
);
const
new_row_data
=
prepare_datatable_data
([
product
.
id
])[
0
];
// On arrow down pressed, focus previous row input
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
(
new_row_data
)
.
draw
();
}
else
if
(
e
.
which
==
13
)
{
e
.
preventDefault
();
debounceFunction
(
update_cdb_order
);
display_total_values
();
}
else
{
$
(
this
).
val
(
''
);
}
// On enter pressed, focus previous row input
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
}
})
.
on
(
'keypress'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
// Validate on Enter pressed
if
(
e
.
which
==
13
)
{
$
(
this
).
blur
();
}
})
.
on
(
'keydown'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
if
(
e
.
which
==
38
)
{
e
.
preventDefault
();
// On arrow up pressed, focus next row input
let
next_input
=
$
(
this
).
closest
(
"tr"
)
.
prev
()
.
find
(
".product_qty_input"
);
next_input
.
focus
();
// Scroll to a position where the target input is not hidden by the sticky suppliers container
const
suppliers_container_top_offset
=
$
(
"#suppliers_container"
).
offset
().
top
-
$
(
window
).
scrollTop
()
+
$
(
"#suppliers_container"
).
outerHeight
();
const
next_input_top_offset
=
next_input
.
offset
().
top
-
$
(
window
).
scrollTop
();
if
(
next_input_top_offset
<
suppliers_container_top_offset
)
{
window
.
scrollTo
({
top
:
$
(
window
).
scrollTop
()
-
$
(
"#suppliers_container"
).
outerHeight
()
});
}
}
else
if
(
e
.
which
==
40
)
{
e
.
preventDefault
();
// On arrow down pressed, focus previous row input
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
}
else
if
(
e
.
which
==
13
)
{
e
.
preventDefault
();
// On enter pressed, focus previous row input
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
}
})
.
on
(
'click'
,
'tbody td .product_actions'
,
function
(
e
)
{
// Save / unsave selected row
const
p_id
=
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
().
id
;
const
product
=
products
.
find
(
p
=>
p
.
id
==
p_id
);
.
on
(
'click'
,
'tbody td .product_actions'
,
function
(
e
)
{
// Save / unsave selected row
const
p_id
=
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
().
id
;
const
product
=
products
.
find
(
p
=>
p
.
id
==
p_id
);
let
modal_product_actions
=
$
(
'#templates #modal_product_actions'
);
let
modal_product_actions
=
$
(
'#templates #modal_product_actions'
);
modal_product_actions
.
find
(
".product_name"
).
text
(
product
.
name
);
modal_product_actions
.
find
(
".product_name"
).
text
(
product
.
name
);
const
product_can_be_archived
=
product
.
incoming_qty
===
0
;
const
product_can_be_archived
=
product
.
incoming_qty
===
0
;
if
(
product_can_be_archived
==
true
)
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
false
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
removeClass
(
"checkbox_action_disabled"
);
}
else
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
true
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
addClass
(
"checkbox_action_disabled"
);
}
if
(
product_can_be_archived
==
true
)
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
false
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
removeClass
(
"checkbox_action_disabled"
);
}
else
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
true
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
addClass
(
"checkbox_action_disabled"
);
}
openModal
(
modal_product_actions
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_product_actions'
))
{
commit_actions_on_product
(
product
,
modal
.
find
(
'input'
));
}
},
'Valider'
,
false
);
modal
.
find
(
'input[name="minimal_stock"]'
).
val
(
product
.
minimal_stock
);
openModal
(
modal_product_actions
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_product_actions'
))
{
commit_actions_on_product
(
product
,
modal
.
find
(
'input'
));
}
},
'Valider'
,
false
);
modal
.
find
(
'input[name="minimal_stock"]'
).
val
(
product
.
minimal_stock
);
});
});
// Associate product to supplier on click on 'X' in the table
$
(
'#products_table'
).
on
(
'click'
,
'tbody .product_not_from_supplier'
,
function
()
{
...
...
@@ -2590,6 +2599,28 @@ $(document).ready(function() {
panel
.
style
.
display
=
"block"
;
}
});
if
(
/Firefox
\/
/
.
exec
(
userAgent
))
{
// needed to prevent bug using number input arrow to change quantity (https://bugzilla.mozilla.org/show_bug.cgi?id=1012818)
// Have to capture mousedown and mouseup events, instead of using only click event
// Indeed, capturing click only remove the ability to click to have focus on the input to type a number.
$
(
document
).
on
(
"mousedown"
,
'[type="number"]'
,
function
()
{
const
clicked
=
this
;
qties_values
[
$
(
clicked
).
attr
(
'id'
)]
=
$
(
clicked
).
val
();
});
$
(
document
).
on
(
"mouseup"
,
'[type="number"]'
,
function
()
{
const
clicked
=
this
;
try
{
if
(
$
(
clicked
).
val
()
!=
qties_values
[
$
(
clicked
).
attr
(
'id'
)])
{
process_new_product_qty
(
clicked
);
}
}
catch
(
err
)
{
console
.
log
(
err
)
}
});
}
}
else
{
$
(
'#not_connected_content'
).
show
();
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment