Commit 352f51bc authored by Mario Manno's avatar Mario Manno

fix notifications texts js

parent 9e8c1579
......@@ -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);
......@@ -29,10 +29,5 @@ $(function() {
};
$('[data-function="notification-defaults"]').click(function(){
var uuid = $(this).data("uuid")
NotificationDefaults.fill({ id: uuid });
return false;
});
});
......@@ -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
......
- 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;
});
json.notification do
json.extract! @notification, :accept_subject, :accept_body, :reject_subject, :reject_body
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment