Skip to content

Commit c238092

Browse files
committed
fix: animate on item load
1 parent 95cbe34 commit c238092

File tree

2 files changed

+65
-16
lines changed

2 files changed

+65
-16
lines changed

erpnext/public/scss/point-of-sale.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,35 @@
117117
overflow-y: scroll;
118118
overflow-x: hidden;
119119

120+
&.item-loading {
121+
position: relative;
122+
pointer-events: none;
123+
}
124+
125+
&.item-loading::after {
126+
content: "";
127+
position: absolute;
128+
inset: 0;
129+
background: repeating-linear-gradient(
130+
90deg,
131+
#f3f3f3 0px,
132+
#f3f3f3 160px,
133+
#e9ecef 160px,
134+
#e9ecef 320px
135+
);
136+
animation: skeletonMove 1.1s linear infinite;
137+
z-index: 1;
138+
}
139+
140+
@keyframes skeletonMove {
141+
from {
142+
background-position: 0 0;
143+
}
144+
to {
145+
background-position: 320px 0;
146+
}
147+
}
148+
120149
&.items-not-found {
121150
display: flex;
122151
align-items: center;

erpnext/selling/page/point_of_sale/pos_item_selector.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ erpnext.PointOfSale.ItemSelector = class {
5353
async load_items_data() {
5454
await this.item_ready_group;
5555

56+
this.start_item_loading_animation();
57+
5658
if (!this.price_list) {
5759
const res = await frappe.db.get_value("POS Profile", this.pos_profile, "selling_price_list");
5860
this.price_list = res.message.selling_price_list;
5961
}
6062

61-
this.get_items({}).then(({ message }) => {
62-
this.render_item_list(message.items);
63-
});
63+
this.get_items({})
64+
.then(({ message }) => {
65+
this.render_item_list(message.items);
66+
})
67+
.always(() => {
68+
this.stop_item_loading_animation();
69+
});
6470
}
6571

6672
get_items({ start = 0, page_length = 40, search_term = "" }) {
@@ -403,6 +409,8 @@ erpnext.PointOfSale.ItemSelector = class {
403409
}
404410

405411
filter_items({ search_term = "" } = {}) {
412+
this.start_item_loading_animation();
413+
406414
const selling_price_list = this.events.get_frm().doc.selling_price_list;
407415

408416
if (search_term) {
@@ -423,19 +431,31 @@ erpnext.PointOfSale.ItemSelector = class {
423431
}
424432
}
425433

426-
this.get_items({ search_term }).then(({ message }) => {
427-
// eslint-disable-next-line no-unused-vars
428-
const { items, serial_no, batch_no, barcode } = message;
429-
if (search_term && !barcode) {
430-
this.search_index[selling_price_list][search_term] = items;
431-
}
432-
this.items = items;
433-
this.render_item_list(items);
434-
this.auto_add_item &&
435-
this.search_field.$input[0].value &&
436-
this.items.length == 1 &&
437-
this.add_filtered_item_to_cart();
438-
});
434+
this.get_items({ search_term })
435+
.then(({ message }) => {
436+
// eslint-disable-next-line no-unused-vars
437+
const { items, serial_no, batch_no, barcode } = message;
438+
if (search_term && !barcode) {
439+
this.search_index[selling_price_list][search_term] = items;
440+
}
441+
this.items = items;
442+
this.render_item_list(items);
443+
this.auto_add_item &&
444+
this.search_field.$input[0].value &&
445+
this.items.length == 1 &&
446+
this.add_filtered_item_to_cart();
447+
})
448+
.always(() => {
449+
this.stop_item_loading_animation();
450+
});
451+
}
452+
453+
start_item_loading_animation() {
454+
this.$items_container.addClass("is-loading");
455+
}
456+
457+
stop_item_loading_animation() {
458+
this.$items_container.removeClass("is-loading");
439459
}
440460

441461
add_filtered_item_to_cart() {

0 commit comments

Comments
 (0)