diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 02db8f0ee93c100a2b3e78fc89ae1aa6b8f5496b..fea49cd7e92803f95374eb1212c651da6c2389c8 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -1,7 +1,7 @@ class CollectionsController < ApplicationController before_action :set_collection, only: [:show, :update, :destroy, :like, :change_privacy] before_action :set_collections, only: [:list, :add_learning_object, :remove_learning_object] - before_action :authenticate_user!, only: [:update, :destroy, :like, :list, :add_learning_object, :remove_learning_object, :change_privacy] + before_action :authenticate_user!, only: [:update, :destroy, :like, :list, :me, :add_learning_object, :remove_learning_object, :change_privacy] # GET /collections # GET /collections.json @@ -100,6 +100,19 @@ class CollectionsController < ApplicationController render layout: false end + def me + @new_collection = Collection.new + + @publishers = publishers_for current_user + + @groups = [ + CollectionsGroup.new(title: 'Coleções Automáticas', + collections: [current_user.bookmarks]), + CollectionsGroup.new(title: 'Coleções Adicionadas', + collections: current_user.collections) + ] + end + # POST /collections/1/learning_object def add_learning_object @collections.each do |collection| @@ -171,6 +184,14 @@ class CollectionsController < ApplicationController end end + def publishers_for(user) + user_new = Institution.new() + user_new.id = user.rid + user_new.name = user.name + + [user_new] + user.institutions + end + # Never trust parameters from the scary internet, only allow the white list through. def collection_params params.require(:collection).permit(:name, :description, :owner,learning_objects: []) diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 1ee0aae318eef3359d60ddf16360a69f280d403b..240d0db24886ab53d73e9598b9c274b64392fa32 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,8 +1,8 @@ -<h1>Coleções de Recursos</h1> +<h1>Coleções Institucionais</h1> <% if @collections.count == 0 %> <div class="row no-collections"> - <p>Nenhuma coleção foi criada, seja o primeiro!</p> + <p>Nenhuma coleção foi criada!</p> </div> <% else %> diff --git a/app/views/collections/me.html.erb b/app/views/collections/me.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a376516eba43b2fc2f582e113d2d96bff6608dbc --- /dev/null +++ b/app/views/collections/me.html.erb @@ -0,0 +1,18 @@ +<div class="user-files"> + <div class="row user-page-subtitle"> + <div class="col-md-6"> + <div class="media"> + <div class="media-body"> + <h2 class="media-heading">Minhas Coleções</h2> + </div> + </div> + </div> + <div class="col-md-6 right-column align-right"> + <%= render 'collections/create', collection: @new_collection, publishers: @publishers, placement: 'left' %> + </div> + </div> + + <% @groups.each do |group| %> + <%= render 'collections/group', title: group.title, collections: group.collections %> + <% end %> +</div> diff --git a/app/views/shared/application/_collections.html.erb b/app/views/shared/application/_collections.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..cb474f8c80931c39314373fcecba7981e754f932 --- /dev/null +++ b/app/views/shared/application/_collections.html.erb @@ -0,0 +1,6 @@ +<div class="row"> + <div class="col-md-12"> + <h4><b><a href="/collections">Institucionais</a></b></h4><br> + <h4><b><a href="/collections/me">Minhas Coleções</a></b></h4> + </div> +</div> diff --git a/app/views/shared/application/_header.html.erb b/app/views/shared/application/_header.html.erb index 8c29a321875f9c57ab92ef918de8675eed992fc5..46ef6ac2515bff0c28d736665d6eeb286531d962 100644 --- a/app/views/shared/application/_header.html.erb +++ b/app/views/shared/application/_header.html.erb @@ -20,7 +20,6 @@ <div class="logo"> <%= link_to root_path do %> <%= image_tag image_path("logo.png"), class: "logo-image" %><br/> - <h3>CONTEÚDO EDUCACIONAL</h3> <% end %> </div> @@ -36,15 +35,12 @@ <div class="search-input"> <form action="/search" method="get"> <div class="input-group" id="search"> - <input type="text" placeholder="buscar em <%= number_with_delimiter(@learning_object_count, delimiter: ".") %> objetos" class="form-control" name="query" id="main_search"> - <div class="input-group-btn"> <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button> </div> </div> </form> - </div> </div> @@ -79,7 +75,7 @@ <div class="row"> <ul class="nav navbar-nav"> <li role="separator" class="divider"></li> - <li class="nav-button"><h3><%= link_to 'Coleções', collections_path %></h3></li> + <li class="nav-button"><h3><a class="nav-dropdown" data-content="collections" href="javascript:void(0);">Coleções <span class="caret"/></a></h3></li> <li role="separator" class="divider"></li> <li class="dropdown nav-button"><h3><a class="nav-dropdown" data-content="links" href="javascript:void(0);">Links úteis <span class="caret"/></a></h3></li> @@ -98,6 +94,9 @@ <a class="navigation-content-close pull-right" aria-label="Close" href="javascript:void(0);"> <h3><span aria-hidden="true">×</span></h3></a> </div> + <div class="navigation-content-collections"> + <%= render 'shared/application/collections' %> + </div> <div class="navigation-content-links"> <%= render 'shared/application/links' %> </div> diff --git a/config/routes.rb b/config/routes.rb index 3394943267b68f8cb81e40d083f987f462a4a2d7..c0a3c3bf6ff21f054efafe8a13bb9c176ef26f86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,7 @@ Rails.application.routes.draw do end end + get '/collections/me' => 'collections#me', as: 'collections_me' resources :collections do member do # collection list