diff --git a/app/assets/javascripts/user/quser.js.coffee b/app/assets/javascripts/user/quser.js.coffee index 31644e8c..82c17702 100644 --- a/app/assets/javascripts/user/quser.js.coffee +++ b/app/assets/javascripts/user/quser.js.coffee @@ -107,7 +107,12 @@ window.Quser= foot = $('#active-list-table tfoot') Quser.build_list_table(body, foot, res) ) - load_history_list: (list_id) -> + load_history_list: () -> + match = window.document.URL.toString().match('([0-9a-zA-Z]+)(\\?|$)') + if match + list_id = match[1] + else + return $.get(data_host + '/user/list_history/'+list_id+'.json', (res) -> body = $('#history-list-table tbody') foot = $('#history-list-table tfoot') @@ -254,7 +259,13 @@ window.Quser= redirect_to 'list_products_for_table', {table_id: table.table_id} , 'json') - join_occupied_table: (table_id) -> + join_occupied_table: () -> + match = window.document.URL.toString().match('table_id=([0-9a-zA-Z]+)') + if match + table_id = match[1] + else + redirect_to 'user_root', {message: 'cannot_identify_table'} + return $('.form-actions').remove() cont = $('#join-occupied-table-progress-container') cont.html('') diff --git a/app/views/user/history_list.html.slim b/app/views/user/history_list.html.slim index 61ef430c..c437604e 100644 --- a/app/views/user/history_list.html.slim +++ b/app/views/user/history_list.html.slim @@ -17,5 +17,5 @@ dl.dl-horizontal - content_for :footer do javascript: jQuery(function(){ - Quser.load_history_list('#{@list.id}'); + Quser.load_history_list(); }) diff --git a/app/views/user/join_occupied_table.html.slim b/app/views/user/join_occupied_table.html.slim index 1c1d961b..f0b2df47 100644 --- a/app/views/user/join_occupied_table.html.slim +++ b/app/views/user/join_occupied_table.html.slim @@ -3,7 +3,16 @@ .form-actions = link_to t('user.join_occupied_table.back'), user_root_path, class: :btn ' - = link_to t('user.join_occupied_table.show_the_products'), user_list_products_for_table_path(table_id: @table.id), class: [:btn, 'btn-primary'] + = link_to t('user.join_occupied_table.show_the_products'), user_root_path(message: 'cannot_identify_table'), class: [:btn, 'btn-primary'], id: 'join_table_products' ' - button.btn.btn-warning{onClick="Quser.join_occupied_table('#{@table.id}')"} = t('user.join_occupied_table.join_this_table') + button.btn.btn-warning{onClick="Quser.join_occupied_table()"} = t('user.join_occupied_table.join_this_table') #join-occupied-table-progress-container +- content_for :footer do + javascript: + $(function(){ + var list_products_for_table_base = '#{raw user_list_products_for_table_path}'; + var match = window.document.URL.toString().match('table_id=([0-9a-zA-Z]+)'); + if(match){ + $('#join_table_products').attr('href', list_products_for_table_base + '?table_id=' + match[1]); + } + }); diff --git a/config/locales/en.yml b/config/locales/en.yml index 0effb3cf..4cd555ba 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -22,6 +22,7 @@ en: join_request_rejected: Your request to join the table has been rejected table_is_from_other_supplier: You cannot move to another table when you have a %{list} open moved_to_another_table: You successfully moved to another table + cannot_identify_table: The application cannot determine the table number action: index: label: Listing %{models}