Loading app/assets/javascripts/notifications.js→app/assets/javascripts/notifications.js.erb +6 −11 Original line number Diff line number Diff line Loading @@ -3,20 +3,20 @@ $(function() { NotificationDefaults = { fill: function(options) { var id = options.id; var code = $('div#'+id+' select option:selected').text(); NotificationDefaults._fetch(id, code); var topDiv = options.topDiv; var url = options.url; NotificationDefaults._fetch(topDiv, url); }, _fetch: function(id, code) { _fetch: function(topDiv, url) { var code = topDiv.find('select option:selected').text(); $.ajax({ type: "GET", dataType: "json", url: '#{ call_for_papers_default_notifications_path(conference_acronym: @conference.acronym) }', url: url, data: {'code':code}, success: function(result){ var texts = result.notification; var topDiv = $('div#'+id); var inputs = topDiv.find('input[type=text]'); $(inputs.get(0)).val(texts.accept_subject); $(inputs.get(1)).val(texts.reject_subject); Loading @@ -29,10 +29,5 @@ $(function() { }; $('[data-function="notification-defaults"]').click(function(){ var uuid = $(this).data("uuid") NotificationDefaults.fill({ id: uuid }); return false; }); }); app/controllers/call_for_papers_controller.rb +2 −7 Original line number Diff line number Diff line Loading @@ -43,13 +43,8 @@ class CallForPapersController < ApplicationController def default_notifications locale = params[:code] notification = Notification.new(locale: locale) notification.set_default_text(locale) respond_to do |format| format.json { render json: notification.to_json } end @notification = Notification.new(locale: locale) @notification.set_default_text(locale) end private Loading app/views/call_for_papers/_notification_fields.html.haml +10 −3 Original line number Diff line number Diff line - uuid = "nf#{get_uuid}" %div{ :id => uuid } .notification %fieldset.inputs = link_to "use default text", "#", style: 'float:right', data: { function: 'notification-defaults', args: "#{uuid}" } = link_to "use default text", "#", style: 'float:right', data: { function: 'notification-defaults', args: { url: "#{ call_for_papers_default_notifications_path(conference_acronym: @conference.acronym) }" } } = f.input :locale, as: :select, collection: available_locales(@conference), hint: "Available locales for this conference and its speakers" = f.input "accept_subject", label: 'Accept subject' = f.input "accept_body", label: 'Accept body', as: :text = f.input "reject_subject", label: 'Reject subject' = f.input "reject_body", label: 'Reject body', as: :text = remove_association_link :notification, f :javascript $('[data-function="notification-defaults"]').click(function(){ var args = $(this).data("args"); var topDiv = $(this).closest('div.notification'); NotificationDefaults.fill({ topDiv: topDiv, url: args.url }); return false; }); app/views/call_for_papers/default_notifications.json.jbuilder 0 → 100644 +3 −0 Original line number Diff line number Diff line json.notification do json.extract! @notification, :accept_subject, :accept_body, :reject_subject, :reject_body end Loading
app/assets/javascripts/notifications.js→app/assets/javascripts/notifications.js.erb +6 −11 Original line number Diff line number Diff line Loading @@ -3,20 +3,20 @@ $(function() { NotificationDefaults = { fill: function(options) { var id = options.id; var code = $('div#'+id+' select option:selected').text(); NotificationDefaults._fetch(id, code); var topDiv = options.topDiv; var url = options.url; NotificationDefaults._fetch(topDiv, url); }, _fetch: function(id, code) { _fetch: function(topDiv, url) { var code = topDiv.find('select option:selected').text(); $.ajax({ type: "GET", dataType: "json", url: '#{ call_for_papers_default_notifications_path(conference_acronym: @conference.acronym) }', url: url, data: {'code':code}, success: function(result){ var texts = result.notification; var topDiv = $('div#'+id); var inputs = topDiv.find('input[type=text]'); $(inputs.get(0)).val(texts.accept_subject); $(inputs.get(1)).val(texts.reject_subject); Loading @@ -29,10 +29,5 @@ $(function() { }; $('[data-function="notification-defaults"]').click(function(){ var uuid = $(this).data("uuid") NotificationDefaults.fill({ id: uuid }); return false; }); });
app/controllers/call_for_papers_controller.rb +2 −7 Original line number Diff line number Diff line Loading @@ -43,13 +43,8 @@ class CallForPapersController < ApplicationController def default_notifications locale = params[:code] notification = Notification.new(locale: locale) notification.set_default_text(locale) respond_to do |format| format.json { render json: notification.to_json } end @notification = Notification.new(locale: locale) @notification.set_default_text(locale) end private Loading
app/views/call_for_papers/_notification_fields.html.haml +10 −3 Original line number Diff line number Diff line - uuid = "nf#{get_uuid}" %div{ :id => uuid } .notification %fieldset.inputs = link_to "use default text", "#", style: 'float:right', data: { function: 'notification-defaults', args: "#{uuid}" } = link_to "use default text", "#", style: 'float:right', data: { function: 'notification-defaults', args: { url: "#{ call_for_papers_default_notifications_path(conference_acronym: @conference.acronym) }" } } = f.input :locale, as: :select, collection: available_locales(@conference), hint: "Available locales for this conference and its speakers" = f.input "accept_subject", label: 'Accept subject' = f.input "accept_body", label: 'Accept body', as: :text = f.input "reject_subject", label: 'Reject subject' = f.input "reject_body", label: 'Reject body', as: :text = remove_association_link :notification, f :javascript $('[data-function="notification-defaults"]').click(function(){ var args = $(this).data("args"); var topDiv = $(this).closest('div.notification'); NotificationDefaults.fill({ topDiv: topDiv, url: args.url }); return false; });
app/views/call_for_papers/default_notifications.json.jbuilder 0 → 100644 +3 −0 Original line number Diff line number Diff line json.notification do json.extract! @notification, :accept_subject, :accept_body, :reject_subject, :reject_body end