Permalink
Browse files

add initial controller and UI

  • Loading branch information...
1 parent 7c212fc commit 04031262d686873cdb13faf1c17619dc9dc3c5ac @phlipper committed Aug 6, 2012
Showing with 1,386 additions and 7 deletions.
  1. BIN app/assets/images/dead_letter_office/bootstrap/glyphicons-halflings-white.png
  2. BIN app/assets/images/dead_letter_office/bootstrap/glyphicons-halflings.png
  3. BIN app/assets/images/dead_letter_office/datatables/Sorting icons.psd
  4. BIN app/assets/images/dead_letter_office/datatables/back_disabled.png
  5. BIN app/assets/images/dead_letter_office/datatables/back_enabled.png
  6. BIN app/assets/images/dead_letter_office/datatables/back_enabled_hover.png
  7. BIN app/assets/images/dead_letter_office/datatables/favicon.ico
  8. BIN app/assets/images/dead_letter_office/datatables/forward_disabled.png
  9. BIN app/assets/images/dead_letter_office/datatables/forward_enabled.png
  10. BIN app/assets/images/dead_letter_office/datatables/forward_enabled_hover.png
  11. BIN app/assets/images/dead_letter_office/datatables/sort_asc.png
  12. BIN app/assets/images/dead_letter_office/datatables/sort_asc_disabled.png
  13. BIN app/assets/images/dead_letter_office/datatables/sort_both.png
  14. BIN app/assets/images/dead_letter_office/datatables/sort_desc.png
  15. BIN app/assets/images/dead_letter_office/datatables/sort_desc_disabled.png
  16. +4 −1 app/assets/javascripts/dead_letter_office/application.js
  17. +7 −0 app/assets/javascripts/dead_letter_office/bootstrap.min.js
  18. +95 −0 app/assets/javascripts/dead_letter_office/bootstrap_pagination.js
  19. +154 −0 app/assets/javascripts/dead_letter_office/datatables.js
  20. +17 −0 app/assets/javascripts/dead_letter_office/dead_letters.js
  21. +12 −1 app/assets/stylesheets/dead_letter_office/application.css
  22. +727 −0 app/assets/stylesheets/dead_letter_office/bootstrap.min.css.scss
  23. +47 −0 app/assets/stylesheets/dead_letter_office/datatables.css.scss
  24. +4 −0 app/assets/stylesheets/dead_letter_office/dead_letters.css
  25. +13 −0 app/assets/stylesheets/dead_letter_office/dead_letters.css.scss
  26. +21 −0 app/controllers/dead_letter_office/dead_letters_controller.rb
  27. +20 −0 app/views/dead_letter_office/dead_letters/_action_links.html.erb
  28. +68 −0 app/views/dead_letter_office/dead_letters/_dead_letter.html.erb
  29. +5 −0 app/views/dead_letter_office/dead_letters/_notice.html.erb
  30. +4 −0 app/views/dead_letter_office/dead_letters/destroy.js.erb
  31. +38 −0 app/views/dead_letter_office/dead_letters/index.html.erb
  32. +34 −5 app/views/layouts/dead_letter_office/application.html.erb
  33. +2 −0 config/routes.rb
  34. +54 −0 spec/controllers/dead_letter_office/dead_letters_controller_spec.rb
  35. +3 −0 spec/dummy/config/application.rb
  36. +5 −0 spec/dummy/config/routes.rb
  37. +20 −0 spec/dummy/db/migrate/20120712072359_create_dead_letter_office_dead_letters.dead_letter_office.rb
  38. +32 −0 spec/dummy/db/schema.rb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -12,4 +12,7 @@
//
//= require jquery
//= require jquery_ujs
-//= require_tree .
+//= require dead_letter_office/bootstrap.min
+//= require dead_letter_office/datatables
+//= require dead_letter_office/bootstrap_pagination
+//= require dead_letter_office/dead_letters
Oops, something went wrong.
@@ -0,0 +1,95 @@
+/* Default class modification */
+$.extend( $.fn.dataTableExt.oStdClasses, {
+ "sWrapper": "dataTables_wrapper form-inline"
+} );
+
+/* API method to get paging information */
+$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
+{
+ return {
+ "iStart": oSettings._iDisplayStart,
+ "iEnd": oSettings.fnDisplayEnd(),
+ "iLength": oSettings._iDisplayLength,
+ "iTotal": oSettings.fnRecordsTotal(),
+ "iFilteredTotal": oSettings.fnRecordsDisplay(),
+ "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
+ "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
+ };
+}
+
+/* Bootstrap style pagination control */
+$.extend( $.fn.dataTableExt.oPagination, {
+ "bootstrap": {
+ "fnInit": function( oSettings, nPaging, fnDraw ) {
+ var oLang = oSettings.oLanguage.oPaginate;
+ var fnClickHandler = function ( e ) {
+ e.preventDefault();
+ if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
+ fnDraw( oSettings );
+ }
+ };
+
+ $(nPaging).addClass('pagination').append(
+ '<ul>'+
+ '<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+
+ '<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+
+ '</ul>'
+ );
+ var els = $('a', nPaging);
+ $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
+ $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
+ },
+
+ "fnUpdate": function ( oSettings, fnDraw ) {
+ var iListLength = 5;
+ var oPaging = oSettings.oInstance.fnPagingInfo();
+ var an = oSettings.aanFeatures.p;
+ var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
+
+ if ( oPaging.iTotalPages < iListLength) {
+ iStart = 1;
+ iEnd = oPaging.iTotalPages;
+ }
+ else if ( oPaging.iPage <= iHalf ) {
+ iStart = 1;
+ iEnd = iListLength;
+ } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
+ iStart = oPaging.iTotalPages - iListLength + 1;
+ iEnd = oPaging.iTotalPages;
+ } else {
+ iStart = oPaging.iPage - iHalf + 1;
+ iEnd = iStart + iListLength - 1;
+ }
+
+ for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
+ // Remove the middle elements
+ $('li:gt(0)', an[i]).filter(':not(:last)').remove();
+
+ // Add the new list items and their event handlers
+ for ( j=iStart ; j<=iEnd ; j++ ) {
+ sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
+ $('<li '+sClass+'><a href="#">'+j+'</a></li>')
+ .insertBefore( $('li:last', an[i])[0] )
+ .bind('click', function (e) {
+ e.preventDefault();
+ oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
+ fnDraw( oSettings );
+ } );
+ }
+
+ // Add / remove disabled classes from the static elements
+ if ( oPaging.iPage === 0 ) {
+ $('li:first', an[i]).addClass('disabled');
+ } else {
+ $('li:first', an[i]).removeClass('disabled');
+ }
+
+ if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
+ $('li:last', an[i]).addClass('disabled');
+ } else {
+ $('li:last', an[i]).removeClass('disabled');
+ }
+ }
+ }
+ }
+} );
Oops, something went wrong.
@@ -0,0 +1,17 @@
+jQuery(function($) {
+ $("#dead_letters").dataTable({
+ "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
+ "sPaginationType": "bootstrap",
+ "oLanguage": {
+ "sLengthMenu": "_MENU_ records per page"
+ },
+ "aoColumnDefs": [
+ { "bSortable": false, "aTargets": [ 4 ] } // don't sort 'Actions'
+ ]
+ });
+
+ $(document).on("click", "a[data-message-id]", function() {
+ var messageId = $(this).data("message-id");
+ $("#details_dead_letter_" + messageId).modal();
+ });
+});
@@ -8,6 +8,17 @@
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
+ *= require dead_letter_office/bootstrap.min
+ *= require dead_letter_office/datatables
+ *= require dead_letter_office/dead_letters
*= require_self
- *= require_tree .
*/
+
+
+body {
+ margin-top: 50px;
+}
+
+#dead_letters_wrapper {
+ margin-top: 20px;
+}
Oops, something went wrong.

0 comments on commit 0403126

Please sign in to comment.