Usage example
see_all_link(:total_count => <total records available>, :visible_count => <number of records initially displayed>, :update => <ID of div to update>, :url => <url of action that will render all the records>, :item_style => <style of each item that is rendered as list>)
Options: :total_count - This has to be the total records that are available for the given entity.
:visible_count - The number of records that will be initially displayed as well as when clicked on “See Less”
:url - This will be the action that is responsible for rendering all the records.
:update - This is the ID of the html element that will be updated with the response of the action that is specified in :url option.
:item_style - The “See All” link in most of the cases will be used to display list of records. When render a record in the view, each of the record should be wrapped within an html element with same css class. The name of the css class should be passed to this option.
E.g If I am rendering list of recommendations then, I need to wrap each recommendation within a common css class.
- recommendations_given.each do |recommendation|
.a_dummy_style_name
= "#{recommendation.title} - #{recommendation.user.full_name}"
The implementation of the “See All” link can be found in my_learnings/recommendations_given_controller and related views can be found at corresponding views folder.
Usage examples:
Type 1 (will generate an ajax pagination link)
= will_paginate(collection, :renderer => ManualPageInputPaginationLinkRenderer, :remote => {:hash_for_path => hash_for_xxx_path, :update => 'div_to_update'})
Type 2 (will generate an ajax pagination link which will point to the action from which the view was rendered)
= will_paginate(collection, :renderer => ManualPageInputPaginationLinkRenderer, :remote => :update => 'div_to_update'})
Type 3 (will generate a normal link)
= will_paginate(collection, :renderer => ManualPageInputPaginationLinkRenderer)
Options:
- :remote - Use this if the pagination has to be ajaxified.
- :remote ⇒ :hash_for_path - This options has to be a hash which points to an action. e.g. {:action ⇒ 'show', :controller ⇒ 'users'}. If one want to use a restful route then the hash_for* can be used here. e.g. hash_for_users_path. The hash_for* is created by rails for each of the routes defined in routes.rb.
- :remote ⇒ :update - Specify the ID of the html element that has to updated with the response.
The implementation of this pagination can be found in “views/my_learnings/recommendations/_index.html.haml”
This panel can be used to create panels similar to the ones seen on Profile View mockup. Usage of this helper avoids the code duplication for the header part of it and the panels on the page would be consistent.
profile_page_panel(opts, &block)
Options:
options is a hash with the following keys
The code that renders content of the panel should be passed as a block to this method.
Sample implementation can be found at - app/views/users/recently_shared/_index.html.haml and at - app/views/users/comments_made/_index.html.haml
Used to expand and collapse large amount of text.
Usage:
= truncate_words_with_more_link(text, number_of_words_to_display_initially)
Usage:
= avatar_for(user, options)
Options:
Usage:
= link_to_popup(name, options)
Options:
Note: To programatically close the popup use the close_popup(id) helper method. Id here is the ID that is specified in the link_to_popup call.
Usage:
- scrollable_content(options) do = some scrollable html here = some html here
Options:
Usage:
stars(value, size, color)
Arguments:
The links like “Follow”, “Like”, “Bookmark”, “Share” can be obtained by following helper methods. All the methods take the object which has to be worked upon as a parameter. e.g. in case of “Like” pass object of comment for liking a comment, pass an object of user for liking a user etc…
To display the flash UI for ajax calls use
Usage:
In the action's render section do something like below
render :update do |page|
if(success)
page << flash_notice("Yes done")
else
page << flash_warning("Nop")
end
end