Skip to content

Commit

Permalink
nearly done. Need to polish list, correct JS, correct tests, remove u…
Browse files Browse the repository at this point in the history
…nused assets, factorize _form_* partials to Builder.
  • Loading branch information
bbenezech committed Sep 22, 2011
1 parent 642f60e commit 8814867
Show file tree
Hide file tree
Showing 53 changed files with 509 additions and 862 deletions.
32 changes: 3 additions & 29 deletions README.md
Expand Up @@ -800,34 +800,8 @@ column, you can:

**Form rendering**

RailsAdmin renders these views with Rails' form builder (form_for). If you want to use a different
form builder then provide an override for the edit view or independingly for the
create and update views. The argument is a symbol or string that is sent to the view
to process the form. This is handy for integrating things like the nested form builder (https://github.com/ryanb/nested_form) if you need to override a field's edit template.

RailsAdmin.config do |config|
config.model Team do
edit do
form_builder :nested_form_for
field :name
end
end
end

or independently

RailsAdmin.config do |config|
config.model Team do
create do
form_builder :create_form_for
field :name
end
update do
form_builder :update_form_for
field :name
end
end
end
RailsAdmin renders these views with is own form builder: `RailsAdmin::FormBuilder`
You can inherit from it to customize form output.

**Field groupings**

Expand Down Expand Up @@ -1024,7 +998,7 @@ In `app/views/rails_admin/main/_yes_no.html.erb`

<%= %Q(No #{image_tag "no.png", :alt => "No"}).html_safe %>

<% if field.has_errors? %>
<% if field.errors.present? %>
<span class="errorMessage"><%= "#{field.label } #{field.errors.first}" %></span>
<% end %>
<p class="help"><%= field.help %></p>
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/rails_admin/application.js
Expand Up @@ -15,3 +15,6 @@ $j("table.table input.checkbox.toggle").live('click', function() {
}
});
});


$j(".alert-message").alert();
2 changes: 1 addition & 1 deletion app/assets/javascripts/rails_admin/ra.filter-box.js
Expand Up @@ -65,7 +65,7 @@

$('#filters_box').append(
'<div class="filter new" style="clear:both;">' +
'<div class="delete-box ui-state-default ui-corner-all"><span alt="delete" class="delete ui-icon ui-icon-trash" data-disabler-name="filters[' + field_name + '][' + index + '][disabled]" style="cursor:pointer" title="delete"></span></div>' +
'<span alt="delete" class="btn small" data-disabler-name="filters[' + field_name + '][' + index + '][disabled]" style="cursor:pointer" title="delete">x</span>' +
'<label>' + field_label + '</label>' +
control +
'</div>'
Expand Down
Expand Up @@ -41,13 +41,13 @@
_build: function() {
var i;

this.wrapper = $('<div class="input ra-multiselect">');
this.wrapper = $('<div class="ra-multiselect">');

this.wrapper.insertAfter(this.element);

this.header = $('<div class="ra-multiselect-header ui-helper-clearfix">');

this.filter = $('<input type="text" class="ra-multiselect-search"/>');
this.filter = $('<input type="search" class="ra-multiselect-search"/>');

this.header.append(this.filter)
.append('<div class="help"><strong>' + this.options.regional.chosen + '</strong><br />' + this.options.regional.selectChoice + '</div><div class="ui-icon ui-icon-circle-triangle-e"></div>');
Expand Down
14 changes: 6 additions & 8 deletions app/assets/javascripts/rails_admin/ra.filtering-select.js
Expand Up @@ -35,9 +35,8 @@
return { label: $(this).text(), value: this.value };
}).toArray();
}

var input_append = $("<div class='input-append'></div>")
var input = this.input = $("<input>")
.insertAfter(select)
.val(value)
.addClass("ra-filtering-select-input")
.attr('style', select.attr('style'))
Expand Down Expand Up @@ -73,7 +72,6 @@
}
}
})
.addClass("ui-widget ui-widget-content ui-corner-left");

input.data("autocomplete")._renderItem = function(ul, item) {
return $("<li></li>")
Expand All @@ -82,19 +80,15 @@
.appendTo(ul);
};

this.button = $("<button type='button'>&nbsp;</button>")
.attr("tabIndex", -1)
var button = this.button = $("<label class='add-on'>&nbsp;</label>")
.attr("title", "Show All Items")
.insertAfter(input)
.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
})

.removeClass("ui-corner-all")
.addClass("ra-filtering-select-button ui-corner-right")
.click(function() {
// close if already visible
if (input.autocomplete("widget").is(":visible")) {
Expand All @@ -106,6 +100,10 @@
input.autocomplete("search", "");
input.focus();
});

input_append.append(input).append(button).insertAfter(select);


},

_getResultSet: function(request, data, xhr) {
Expand Down
30 changes: 0 additions & 30 deletions app/assets/stylesheets/rails_admin/ra.filtering-select.css

This file was deleted.

22 changes: 22 additions & 0 deletions app/assets/stylesheets/rails_admin/rails_admin-bootstrap.css
@@ -0,0 +1,22 @@
/* We want input size to be used, unfixate input width */
input {
width:inherit;
}

/* ui-autocomplete has z-index 1 and is shown over filtering select button (.add-on) */
.input-prepend .add-on, .input-append .add-on {
z-index:0;
}

/* small visual glitches fixes for date-picker */
.ui-datepicker {
border-width:0px;
}
.ui-datepicker table {
margin:0px;
}

/* sidebar hack */
.sidebar {
height:0;
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/rails_admin/rails_admin.css
Expand Up @@ -4,10 +4,10 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require ./aristo/jquery-ui-1.8.7.custom.css
*= require ./bootstrap/bootstrap.css
*= require ./rails_admin-bootstrap.css
*= require ./jquery.colorpicker.css
*= require ./jquery.ui.timepicker.css
*= require ./ra.filtering-multiselect.css
*= require ./ra.filtering-select.css
*= require ./ra.timeline.css
*= require_self
*/
28 changes: 8 additions & 20 deletions app/controllers/rails_admin/main_controller.rb
Expand Up @@ -196,7 +196,7 @@ def destroy

if @object.destroy
AbstractHistory.create_history_item("Destroyed #{@model_config.with(:object => @object).object_label}", @object, @abstract_model, _current_user)
flash[:notice] = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.deleted"))
flash[:success] = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.deleted"))
else
flash[:error] = t("admin.flash.error", :name => @model_config.label, :action => t("admin.actions.deleted"))
end
Expand Down Expand Up @@ -225,12 +225,12 @@ def export
end

def bulk_action
redirect_to list_path, :notice => t("admin.flash.noaction") and return if params[:bulk_ids].blank?
redirect_to list_path, :flash => { :info => t("admin.flash.noaction") } and return if params[:bulk_ids].blank?

case params[:bulk_action]
when "delete" then bulk_delete
when "export" then export
else redirect_to(list_path(:model_name => @abstract_model.to_param), :notice => t("admin.flash.noaction"))
else redirect_to(list_path(:model_name => @abstract_model.to_param), :flash => { :info => t("admin.flash.noaction") })
end
end

Expand Down Expand Up @@ -260,7 +260,7 @@ def bulk_destroy
end

unless destroyed.empty?
flash[:notice] = t("admin.flash.successful", :name => pluralize(destroyed.count, @model_config.label), :action => t("admin.actions.deleted"))
flash[:success] = t("admin.flash.successful", :name => pluralize(destroyed.count, @model_config.label), :action => t("admin.actions.deleted"))
end

unless not_destroyed.empty?
Expand All @@ -270,18 +270,6 @@ def bulk_destroy
redirect_to list_path
end

def handle_error(e)
if RailsAdmin::AuthenticationNotConfigured === e
Rails.logger.error e.message
Rails.logger.error e.backtrace.join("\n")

@error = e
render 'authentication_not_setup', :status => 401
else
super
end
end

private

def get_bulk_objects(ids)
Expand Down Expand Up @@ -480,11 +468,11 @@ def get_attributes
def redirect_to_on_success
notice = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.#{params[:action]}d"))
if params[:_add_another]
redirect_to new_path, :notice => notice
redirect_to new_path, :flash => { :success => notice }
elsif params[:_add_edit]
redirect_to edit_path(:id => @object.id), :notice => notice
redirect_to edit_path(:id => @object.id), :flash => { :success => notice }
else
redirect_to list_path, :notice => notice
redirect_to list_path, :flash => { :success => notice }
end
end

Expand All @@ -501,7 +489,7 @@ def handle_save_error whereto = :new
end

def check_for_cancel
redirect_to list_path, :notice => t("admin.flash.noaction") if params[:_continue]
redirect_to list_path, :flash => { :success => t("admin.flash.noaction") } if params[:_continue]
end

def list_entries(other = {})
Expand Down

0 comments on commit 8814867

Please sign in to comment.