diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 79ffd2395f0112b50c5957654bc9d757507b7630..d5b57dee4e5a818ccd0fcc9f51e1ecd835196811 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -1 +1,2 @@ @import "bootstrap" +@import 'application/*' diff --git a/app/assets/stylesheets/application/layout.sass b/app/assets/stylesheets/application/layout.sass new file mode 100644 index 0000000000000000000000000000000000000000..16ae7bbad0f8b94f976cfdc05e3ed56f217ba244 --- /dev/null +++ b/app/assets/stylesheets/application/layout.sass @@ -0,0 +1,2 @@ +footer + margin-top: 100px diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e91846c9bf7ed7317a2a3961b2a07665bb4c04b0..9af4384ebfca34d9d01abfa063c109e882d41ddf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,7 @@ class ApplicationController < ActionController::Base include WithContext + + def breadcrumb + add_breadcrumb t('home'), root_path + end end diff --git a/app/controllers/research/journal/volumes_controller.rb b/app/controllers/research/journal/volumes_controller.rb index 95c9eff70a0a9a453c267c906c8aac346d5618eb..db04246a2f3ecf8aecf3d7e44ade75666cd0e7c1 100644 --- a/app/controllers/research/journal/volumes_controller.rb +++ b/app/controllers/research/journal/volumes_controller.rb @@ -1,69 +1,24 @@ class Research::Journal::VolumesController < ApplicationController - before_action :set_research_journal_volume, only: %i[ show edit update destroy ] - - # GET /research/journal/volumes or /research/journal/volumes.json def index - @research_journal_volumes = Research::Journal::Volume.all + @journal = current_university.research_journals.find params[:journal_id] + @volumes = @journal.volumes + breadcrumb end - # GET /research/journal/volumes/1 or /research/journal/volumes/1.json def show + @journal = current_university.research_journals.find params[:journal_id] + @volume = @journal.volumes.find params[:id] + breadcrumb + add_breadcrumb @volume end - # GET /research/journal/volumes/new - def new - @research_journal_volume = Research::Journal::Volume.new - end - - # GET /research/journal/volumes/1/edit - def edit - end - - # POST /research/journal/volumes or /research/journal/volumes.json - def create - @research_journal_volume = Research::Journal::Volume.new(research_journal_volume_params) + protected - respond_to do |format| - if @research_journal_volume.save - format.html { redirect_to @research_journal_volume, notice: "Volume was successfully created." } - format.json { render :show, status: :created, location: @research_journal_volume } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @research_journal_volume.errors, status: :unprocessable_entity } - end - end + def breadcrumb + super + add_breadcrumb Research.model_name.human + add_breadcrumb Research::Journal.model_name.human(count: 2), research_journals_path + add_breadcrumb @journal, @journal + add_breadcrumb Research::Journal::Volume.model_name.human(count: 2), research_journal_volumes_path(journal_id: @journal) end - - # PATCH/PUT /research/journal/volumes/1 or /research/journal/volumes/1.json - def update - respond_to do |format| - if @research_journal_volume.update(research_journal_volume_params) - format.html { redirect_to @research_journal_volume, notice: "Volume was successfully updated." } - format.json { render :show, status: :ok, location: @research_journal_volume } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @research_journal_volume.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /research/journal/volumes/1 or /research/journal/volumes/1.json - def destroy - @research_journal_volume.destroy - respond_to do |format| - format.html { redirect_to research_journal_volumes_url, notice: "Volume was successfully destroyed." } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_research_journal_volume - @research_journal_volume = Research::Journal::Volume.find(params[:id]) - end - - # Only allow a list of trusted parameters through. - def research_journal_volume_params - params.require(:research_journal_volume).permit(:title, :number, :published_at) - end end diff --git a/app/controllers/research/journals_controller.rb b/app/controllers/research/journals_controller.rb index 2063cefc0d3a45486de53c7978ba0be5bfb293f1..03a97e9f5f7a7f521d3e396b2576a760db48c839 100644 --- a/app/controllers/research/journals_controller.rb +++ b/app/controllers/research/journals_controller.rb @@ -1,9 +1,20 @@ class Research::JournalsController < ApplicationController def index @journals = current_university.research_journals + breadcrumb end def show @journal = current_university.research_journals.find params[:id] + breadcrumb + end + + protected + + def breadcrumb + super + add_breadcrumb Research.model_name.human + add_breadcrumb Research::Journal.model_name.human(count: 2), research_journals_path + add_breadcrumb @journal, @journal if @journal end end diff --git a/app/models/research.rb b/app/models/research.rb index 24ccdcbe3d481d5915819aa3855051ca2a7c7320..ac5b622d13967b4ff83fd5d74e8559cf5948eec0 100644 --- a/app/models/research.rb +++ b/app/models/research.rb @@ -1,4 +1,7 @@ module Research + extend ActiveModel::Naming + extend ActiveModel::Translation + def self.table_name_prefix 'research_' end diff --git a/app/views/research/journal/volumes/_volume.html.erb b/app/views/research/journal/volumes/_volume.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a5211261776535e5ba2b40d8d0391c477d85a50b --- /dev/null +++ b/app/views/research/journal/volumes/_volume.html.erb @@ -0,0 +1,9 @@ +<article class="card mt-4"> + <div class="card-body"> + <h1 class="h4"> + <%= link_to volume, + research_journal_volume_path(journal_id: journal, id: volume), + class: 'stretched-link' %> + </h1> + </div> +</article> diff --git a/app/views/research/journal/volumes/index.html.erb b/app/views/research/journal/volumes/index.html.erb index 728aa29d5856c85499c9c6879c6ec74c33d15ff8..7c29510cdff9b8e7fed19c6690ee427a8e8374ba 100644 --- a/app/views/research/journal/volumes/index.html.erb +++ b/app/views/research/journal/volumes/index.html.erb @@ -1,31 +1,9 @@ -<p id="notice"><%= notice %></p> - -<h1>Research Journal Volumes</h1> - -<table> - <thead> - <tr> - <th>Title</th> - <th>Number</th> - <th>Published at</th> - <th colspan="3"></th> - </tr> - </thead> - - <tbody> - <% @research_journal_volumes.each do |research_journal_volume| %> - <tr> - <td><%= research_journal_volume.title %></td> - <td><%= research_journal_volume.number %></td> - <td><%= research_journal_volume.published_at %></td> - <td><%= link_to 'Show', research_journal_volume %></td> - <td><%= link_to 'Edit', edit_research_journal_volume_path(research_journal_volume) %></td> - <td><%= link_to 'Destroy', research_journal_volume, method: :delete, data: { confirm: 'Are you sure?' } %></td> - </tr> - <% end %> - </tbody> -</table> - -<br> - -<%= link_to 'New Research Journal Volume', new_research_journal_volume_path %> +<% content_for :title, Research::Journal::Volume.model_name.human(count: 2) %> + +<div class="row"> + <% @journal.volumes.each do |volume| %> + <div class="col-md-3"> + <%= render volume, journal: @journal %> + </div> + <% end %> +</div> diff --git a/app/views/research/journal/volumes/show.html.erb b/app/views/research/journal/volumes/show.html.erb index 2b3f84d474ed923dfc19a9032a7e53cb605f556f..ace032fb16a504f5317eba378781fd2028d4a2bd 100644 --- a/app/views/research/journal/volumes/show.html.erb +++ b/app/views/research/journal/volumes/show.html.erb @@ -1,19 +1,11 @@ -<p id="notice"><%= notice %></p> - -<p> - <strong>Title:</strong> - <%= @research_journal_volume.title %> -</p> +<% content_for :title, @volume %> <p> <strong>Number:</strong> - <%= @research_journal_volume.number %> + <%= @volume.number %> </p> <p> <strong>Published at:</strong> - <%= @research_journal_volume.published_at %> + <%= @volume.published_at %> </p> - -<%= link_to 'Edit', edit_research_journal_volume_path(@research_journal_volume) %> | -<%= link_to 'Back', research_journal_volumes_path %> diff --git a/app/views/research/journals/_journal.json.jbuilder b/app/views/research/journals/_journal.json.jbuilder index 74b1dbbe69547725562aa3601c125388d330ddab..e0145a24de523f3ebe1c3e730ba360a64499b872 100644 --- a/app/views/research/journals/_journal.json.jbuilder +++ b/app/views/research/journals/_journal.json.jbuilder @@ -1,2 +1,6 @@ -json.extract! journal, :id, :title, :description, :created_at, :updated_at +json.extract! journal, :id, :title, :description json.url research_journal_url(journal, format: :json) +json.volumes journal.volumes do |volume| + json.extract! volume, :id, :title, :published_at + json.url research_journal_volume_url(journal_id: journal, id: volume, format: :json) +end diff --git a/app/views/research/journals/index.html.erb b/app/views/research/journals/index.html.erb index c5e1cad2e622db7ba7e10888c3c8db8da999ada0..b6ccc1d402277d8d96e21a7a45ea7aec5f7bc0a6 100644 --- a/app/views/research/journals/index.html.erb +++ b/app/views/research/journals/index.html.erb @@ -2,12 +2,15 @@ <h1><%= Research::Journal.model_name.human(count: 2) %></h1> -<div class="row"> - <% @journals.each do |journal| %> - <div class="col-md-6"> +<% @journals.each do |journal| %> + <div class="row"> + <div class="col-md-8"> <h2 class="mt-5"><%= journal %></h2> <p><%= journal.description %></p> <%= link_to 'Lire', journal, class: 'btn btn-primary stretched-link' %> </div> - <% end %> -</div> + <div class="offset-md-1 col-md-3"> + <%= render journal.volumes.first, journal: journal if journal.volumes.any? %> + </div> + </div> +<% end %> diff --git a/app/views/research/journals/index.json.jbuilder b/app/views/research/journals/index.json.jbuilder index 5e48c2f4ba9ede0e0558afb32d8c9c0d19251ab3..465e2b7ccab013fdc6b4baa5f45fa8041b988947 100644 --- a/app/views/research/journals/index.json.jbuilder +++ b/app/views/research/journals/index.json.jbuilder @@ -1 +1,4 @@ -json.array! @journals, partial: "research/journals/journal", as: :journal +json.array! @journals do |journal| + json.extract! journal, :id, :title, :description + json.url research_journal_url(journal, format: :json) +end diff --git a/app/views/research/journals/show.html.erb b/app/views/research/journals/show.html.erb index e9aa77443b641c704717392b4c491b0e0c16e06f..ec810e91809ecdf45bc51ff521861d7e76b9bc82 100644 --- a/app/views/research/journals/show.html.erb +++ b/app/views/research/journals/show.html.erb @@ -6,3 +6,11 @@ <p><%= @journal.description %></p> </div> </div> + +<div class="row"> + <% @journal.volumes.each do |volume| %> + <div class="col-md-3"> + <%= render volume, journal: @journal %> + </div> + <% end %> +</div> diff --git a/app/views/research/journals/show.json.jbuilder b/app/views/research/journals/show.json.jbuilder index fd0abfd124835c78f1b9e1f0b51b07a5fe609c41..90c860bf4261e20db4485917d21a6f5e03047606 100644 --- a/app/views/research/journals/show.json.jbuilder +++ b/app/views/research/journals/show.json.jbuilder @@ -1 +1,6 @@ -json.partial! "research/journals/journal", journal: @journal +json.extract! @journal, :id, :title, :description +json.url research_journal_url(@journal, format: :json) +json.volumes @journal.volumes do |volume| + json.extract! volume, :id, :title, :published_at + json.url research_journal_volume_url(journal_id: @journal, id: volume, format: :json) +end diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 9e129820fb573493ce05fb60321908b3afc73997..0720713edbad9c65578c97668b7909b0be8df04f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1,6 +1,7 @@ fr: true: Oui false: Non + home: Accueil dashboard: Tableau de bord show: Voir create: Créer diff --git a/config/routes.rb b/config/routes.rb index 2852bdaeb55f288c878209a24fd932b458b36439..5a0cea317eeb42a4c000bdae2d78611bc4c35507 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,4 @@ Rails.application.routes.draw do - namespace :research do - namespace :journal do - resources :volumes - end - end devise_for :users, controllers: { registrations: 'users/registrations', sessions: 'users/sessions' @@ -20,7 +15,8 @@ Rails.application.routes.draw do namespace :research do resources :journals, only: [:index, :show] do - resources :volumes, only: [:index, :show] + resources :volumes, only: [:index, :show], controller: 'journal/volumes' + resources :articles, only: [:index, :show], controller: 'journal/articles' end end