Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Export in a child process #2

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4275112
Add toggable navigation menus
grillermo Feb 18, 2015
f668f75
Update readme and add loop index
grillermo Apr 3, 2015
8ec3713
Add search scope as an alternative filtering scope with queries
grillermo Apr 5, 2015
9455a8e
Add selection by drawing a box
grillermo Apr 21, 2015
7ebc53f
Only allow drawing a box near the checkboxes
grillermo Apr 24, 2015
b5cc89a
Fix checkbox padding
grillermo Apr 24, 2015
50f68ef
Fix binding selectable on pjax end
grillermo Jun 30, 2015
3d12d3a
Add set edited_in_rails_admin to true to objects that define it
grillermo Jul 1, 2015
46b0198
Bind without ajax
grillermo Jul 2, 2015
3a24918
Add possibility to add class to each row in the list view
grillermo Jul 9, 2015
cc9884a
fixing invalid linear grandient direction to make it work with autopr…
orlando Jul 14, 2015
e971cf9
Merge pull request #1 from aliada-mx/fix/invalid_linear_gradient
grillermo Jul 14, 2015
1991be8
Edited in rails admin works when creating a new object
grillermo Sep 17, 2015
84f8d36
Merge branch 'master' of https://github.com/aliada-mx/rails_admin
grillermo Sep 17, 2015
5b3da7f
Set edited_in_rails_admin only for objects supporting the attr
grillermo Sep 17, 2015
658a078
Remove collapser, fix lazo for history
grillermo Feb 16, 2016
527670b
Fix history for polymorphic STI tables
grillermo May 12, 2016
573e90c
Replaces the TrailingComma with the TrailingCommaInLiteral property
babasbot Sep 14, 2016
5093732
Creates the ExportMailer class
babasbot Sep 14, 2016
82f0ec4
Exports the model data in a child process and sends the report by email
babasbot Sep 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ Style/RaiseArgs:
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Style/TrailingComma:
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: 'comma'
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,39 @@

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.


## In this fork
* Collapsing of parent sections in the sidebar navigation
* addex @loop_index to the list index
* Draw selection boxes around checkboxes in the index view
* Added search_scope to list for custom scopes use it like so

```ruby
list do
search_scope do
Proc.new do |scope, query|
scope.merge(status: 'paid').merge(datetime: Date.today).joins(:user).where('users.first_name = ?', query)
end
end
end
# Note, this won't work with existing filterable, searchable fields as merge will create an AND condition with the scope's WHERE s
# see https://gist.github.com/j-mcnally/250eaaceef234dd8971b if you want OR conditions
```
* If a model defines an attribute(or method) edited_in_rails_admin (virtual or real): rails admin will set it to true to objects edited throught its UI.
* If a model defines an attribute(or method) rails_admin_row_class (virtual or real): rails admin will add to each row in the list view the string returned from this method in a class. Use it this way
```css
.service_row
&.notice
td
background: $light_yellow !important
&.error
td, td > tr:nth-child(odd) > td
background: tint($light_error, 80) !important
```




## Features
* CRUD any data with ease
* Custom actions
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/rails_admin/custom/ui.coffee
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
#= override this file in your application to add custom behaviour
272 changes: 272 additions & 0 deletions app/assets/javascripts/rails_admin/jquery-ui-selectable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
/*!
* jQuery UI Selectable 1.11.4
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/selectable/
*/


var selectable = $.widget("ui.selectable", $.ui.mouse, {
version: "1.11.4",
options: {
appendTo: "body",
autoRefresh: true,
distance: 0,
filter: "*",
tolerance: "touch",

// callbacks
selected: null,
selecting: null,
start: null,
stop: null,
unselected: null,
unselecting: null
},
_create: function() {
var selectees,
that = this;

this.element.addClass("ui-selectable");

this.dragged = false;

// cache selectee children based on filter
this.refresh = function() {
selectees = $(that.options.filter, that.element[0]);
selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this),
pos = $this.offset();
$.data(this, "selectable-item", {
element: this,
$element: $this,
left: pos.left,
top: pos.top,
right: pos.left + $this.outerWidth(),
bottom: pos.top + $this.outerHeight(),
startselected: false,
selected: $this.hasClass("ui-selected"),
selecting: $this.hasClass("ui-selecting"),
unselecting: $this.hasClass("ui-unselecting")
});
});
};
this.refresh();

this.selectees = selectees.addClass("ui-selectee");

this._mouseInit();

this.helper = $("<div class='ui-selectable-helper'></div>");
},

_destroy: function() {
this.selectees
.removeClass("ui-selectee")
.removeData("selectable-item");
this.element
.removeClass("ui-selectable ui-selectable-disabled");
this._mouseDestroy();
},

_mouseStart: function(event) {
var that = this,
options = this.options;

this.opos = [ event.pageX, event.pageY ];

if (this.options.disabled) {
return;
}

this.selectees = $(options.filter, this.element[0]);

this._trigger("start", event);

$(options.appendTo).append(this.helper);
// position helper (lasso)
this.helper.css({
"left": event.pageX,
"top": event.pageY,
"width": 0,
"height": 0
});

if (options.autoRefresh) {
this.refresh();
}

this.selectees.filter(".ui-selected").each(function() {
var selectee = $.data(this, "selectable-item");
selectee.startselected = true;
if (!event.metaKey && !event.ctrlKey) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
});

$(event.target).parents().addBack().each(function() {
var doSelect,
selectee = $.data(this, "selectable-item");
if (selectee) {
doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
selectee.$element
.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
selectee.unselecting = !doSelect;
selectee.selecting = doSelect;
selectee.selected = doSelect;
// selectable (UN)SELECTING callback
if (doSelect) {
that._trigger("selecting", event, {
selecting: selectee.element
});
} else {
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
return false;
}
});

},

_mouseDrag: function(event) {

this.dragged = true;

if (this.options.disabled) {
return;
}

var tmp,
that = this,
options = this.options,
x1 = this.opos[0],
y1 = this.opos[1],
x2 = event.pageX,
y2 = event.pageY;

if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });

this.selectees.each(function() {
var selectee = $.data(this, "selectable-item"),
hit = false;

//prevent helper from being selected if appendTo: selectable
if (!selectee || selectee.element === that.element[0]) {
return;
}

if (options.tolerance === "touch") {
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
} else if (options.tolerance === "fit") {
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
}

if (hit) {
// SELECT
if (selectee.selected) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
}
if (selectee.unselecting) {
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
}
if (!selectee.selecting) {
selectee.$element.addClass("ui-selecting");
selectee.selecting = true;
// selectable SELECTING callback
that._trigger("selecting", event, {
selecting: selectee.element
});
}
} else {
// UNSELECT
if (selectee.selecting) {
if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
selectee.$element.addClass("ui-selected");
selectee.selected = true;
} else {
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
if (selectee.startselected) {
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
}
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
}
if (selectee.selected) {
if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;

selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
}
}
});

return false;
},

_mouseStop: function(event) {
var that = this;

this.dragged = false;

$(".ui-unselecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
selectee.startselected = false;
that._trigger("unselected", event, {
unselected: selectee.element
});
});
$(".ui-selecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
that._trigger("selected", event, {
selected: selectee.element
});
});
this._trigger("stop", event);

this.helper.remove();

return false;
}

});


2 changes: 2 additions & 0 deletions app/assets/javascripts/rails_admin/rails_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
//= require 'rails_admin/ra.widgets'
//= require 'rails_admin/ui'
//= require 'rails_admin/custom/ui'
//= require 'rails_admin/jquery-ui-selectable'
//= require 'rails_admin/select-checkboxes'
20 changes: 20 additions & 0 deletions app/assets/javascripts/rails_admin/select-checkboxes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$(function() {
bind_selectable = function() {
$('tbody').selectable({
cancel: '.not-checkbox',
filter: 'input',
distance: 1,
selected: function(event, ui) {
$element = $(ui.selected)

if ($element.is(':checkbox')) {
$element.click();
}
return true;
}
});
}
bind_selectable()

$(document).on('pjax:end', bind_selectable)
});
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
background: -webkit-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* IE10+ */
background: linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* W3C */
background: linear-gradient(to bottom, #ededed 0%,#c4c4c4 100%); /* W3C */
}
.ui-widget-header a { color: #4F4F4F; }

Expand All @@ -83,7 +83,7 @@
background: -webkit-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* IE10+ */
background: linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* W3C */
background: linear-gradient(to bottom, #ededed 0%,#c4c4c4 100%); /* W3C */
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
-moz-box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
Expand All @@ -100,7 +100,7 @@
background: -webkit-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* IE10+ */
background: linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* W3C */
background: linear-gradient(to bottom, #b9e0f5 0%,#92bdd6 100%); /* W3C */
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
Expand Down Expand Up @@ -481,7 +481,7 @@ button.ui-button-icons-only { width: 3.7em; }
background: -webkit-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* IE10+ */
background: linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* W3C */
background: linear-gradient(to bottom, #b9e0f5 0%,#92bdd6 100%); /* W3C */
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255,255,255,0.8) inset;
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255,255,255,0.8) inset;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255,255,255,0.8) inset;
Expand Down Expand Up @@ -527,7 +527,7 @@ input.ui-button::-moz-focus-inner {
background: -webkit-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* IE10+ */
background: linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* W3C */
background: linear-gradient(to bottom, #b9e0f5 0%,#92bdd6 100%); /* W3C */
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
Expand Down
Loading