Skip to content

Commit

Permalink
Merge pull request #192 from shaktik1989/refactor_forms
Browse files Browse the repository at this point in the history
Refactor forms., Fixes #185
  • Loading branch information
scott authored Jun 14, 2016
2 parents cdf3384 + cf0f99b commit a55fbe8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions app/assets/javascripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ Helpy.admin = function(){
}
});

$('.settings-section.email select').off().on('change', function(){
var chosen = $(".settings-section.email select").val();
$('.imap-settings').addClass('hidden');
$('.pop3-settings').addClass('hidden');
if (chosen == 'pop3' ){
$('.pop3-settings').removeClass('hidden');
}
if (chosen == 'imap' ){
$('.imap-settings').removeClass('hidden');
}
});

$("#new_doc select, #edit_doc select").focusout(function(){
if($(this).val() == ""){
$("div.select").removeClass("has-success").addClass("has-error");
$("select").next().removeClass("glyphicon-ok").addClass("glyphicon-remove");
$("div.select .glyphicon-ok").remove();
$("<span class='help-block'>can't be blank</span>").insertAfter("div.select .glyphicon-remove")
$('input[type="submit"]').prop('disabled', true);
}
else{
$('input[type="submit"]').prop('disabled', false);
}
})

};

Helpy.showPanel = function(panel) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/docs/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2 class="form-subhead"><%= t(:edit, default:'Edit') %>: <%= @doc.title %></h2>
<%= locale_select if AppSettings['i18n.available_locales'].count > 1 %>
<%= simple_form_for @doc, url: admin_category_doc_path(category_id: @category.id, id: @doc.id), validate: true, :method => 'patch' do |f| %>

<%= simple_form_for @doc, validate: true, url: admin_category_doc_path(category_id: @category.id, id: @doc.id), html: { method: :patch, id: :edit_doc } do |f| %>
<% Globalize.with_locale(params['lang']) do %>
<%= render 'shared/error_messages', object: f.object %>
<%= render :partial => 'form', :object => @doc, :locals => {:f => f} %>
Expand Down

0 comments on commit a55fbe8

Please sign in to comment.