@@ -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