spina-admin-journal 0.4.2 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spina/admin/journal/application_controller.rb +2 -0
  3. data/app/controllers/spina/admin/journal/articles_controller.rb +4 -3
  4. data/app/controllers/spina/admin/journal/authors_controller.rb +5 -4
  5. data/app/controllers/spina/admin/journal/institutions_controller.rb +1 -1
  6. data/app/controllers/spina/admin/journal/issues_controller.rb +8 -2
  7. data/app/controllers/spina/admin/journal/journals_controller.rb +2 -2
  8. data/app/controllers/spina/admin/journal/licences_controller.rb +95 -0
  9. data/app/models/spina/admin/journal/article.rb +3 -0
  10. data/app/models/spina/admin/journal/licence.rb +32 -0
  11. data/app/models/spina/parts/admin/journal/page_range.rb +31 -0
  12. data/app/views/layouts/spina/admin/journal/licences.html.haml +10 -0
  13. data/app/views/spina/admin/hooks/journal/_primary_navigation.html.haml +12 -10
  14. data/app/views/spina/admin/journal/articles/_form.html.haml +1 -1
  15. data/app/views/spina/admin/journal/articles/_form_details.html.haml +5 -0
  16. data/app/views/spina/admin/journal/authors/_form.html.haml +1 -1
  17. data/app/views/spina/admin/journal/authors/_form_affiliation.html.haml +1 -1
  18. data/app/views/spina/admin/journal/institutions/_form.html.haml +1 -1
  19. data/app/views/spina/admin/journal/issues/_form.html.haml +1 -1
  20. data/app/views/spina/admin/journal/issues/_form_articles.html.haml +1 -1
  21. data/app/views/spina/admin/journal/journals/_form.html.haml +1 -1
  22. data/app/views/spina/admin/journal/licences/_form.html.haml +43 -0
  23. data/app/views/spina/admin/journal/licences/_licence.html.haml +11 -0
  24. data/app/views/spina/admin/journal/licences/edit.html.haml +1 -0
  25. data/app/views/spina/admin/journal/licences/index.html.haml +17 -0
  26. data/app/views/spina/admin/journal/licences/new.html.haml +1 -0
  27. data/app/views/spina/admin/journal/volumes/_form.html.haml +1 -1
  28. data/app/views/spina/admin/parts/admin/journal/page_ranges/_form.html.haml +6 -0
  29. data/config/locales/en.yml +20 -0
  30. data/config/routes.rb +1 -0
  31. data/db/migrate/20210618090155_create_spina_admin_journal_licences.rb +13 -0
  32. data/db/migrate/20210618094533_add_licence_to_spina_admin_journal_articles.rb +8 -0
  33. data/db/migrate/20210626153728_create_spina_parts_admin_journal_page_ranges.rb +7 -0
  34. data/lib/spina/admin/journal/engine.rb +6 -0
  35. data/lib/spina/admin/journal/version.rb +1 -1
  36. metadata +18 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf3f41e632c032cf855ea7be3d2d6297e0f3d0eba015906afcb2c7497b8a0e16
4
- data.tar.gz: 59e90ab32fa02f5400870002cffa3a0b7f7fe1f590ca03f8f2b22f008a72b074
3
+ metadata.gz: afadf6fe1f99997005bc61d4c3d31b6a1fd02ea35e400539a6e3f3806010910a
4
+ data.tar.gz: 7a4375228d01fa343613e8978860ff64c4ba8b1d3232d439efc71e150cab6d93
5
5
  SHA512:
6
- metadata.gz: d8aebef70619bebbab5d5832639aa4dff527f909e4828a62aea7210eb69c0c2f0cddf2eb68871890457f751b3af00df686dbca919fedffb13276d89894b3b9ea
7
- data.tar.gz: 1f1de9525d2e5ae4c57bdd9eeb55bfb106e3bcc3b9d32fcb1f8591820a89865a57311b65c7f57f48ca2a4ee95dcc219f4199ccd2354fdb11339accf1bf0dcc75
6
+ metadata.gz: 63d5deaf2bc734aafefcbd7ddb814f1593ab18ea6a3653beeadfede9ddb386579107f87147a78d036d9e95e5f1fd868f088a03352de57652b9a30afcc3a2fa58
7
+ data.tar.gz: ad6606f902897fc5ffa29d00241c89c1c4cb68a666313e53bc21227e357dd06e760a9d7e011c7f6e1870b6f872327f4052ceacc77c63fbd5745d8ba10bda1800
@@ -5,6 +5,8 @@ module Spina
5
5
  module Journal
6
6
  # Custom controller for journal plugin. Sets the layout and adds a flash type.
7
7
  class ApplicationController < AdminController
8
+ helper ::Spina::Engine.routes.url_helpers
9
+
8
10
  add_flash_types :success
9
11
 
10
12
  layout :admin_layout, only: %i[new edit]
@@ -7,6 +7,7 @@ module Spina
7
7
  class ArticlesController < ApplicationController
8
8
  PARTS_PARAMS = [
9
9
  :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
10
+ :first_page, :last_page,
10
11
  { images_attributes: %i[filename signed_blob_id image_id alt],
11
12
  content_attributes: [
12
13
  :name, :title,
@@ -19,8 +20,8 @@ module Spina
19
20
  CONTENT_PARAMS = Spina.config.locales.inject({}) do |params, locale|
20
21
  params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
21
22
  end
22
- PARAMS = [:issue_id, :title, :url, :doi, :status, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
23
- PARTS = %w[abstract attachment].freeze
23
+ PARAMS = [:issue_id, :licence_id, :title, :url, :doi, :status, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
24
+ PARTS = %w[abstract attachment page_range].freeze
24
25
 
25
26
  before_action :set_breadcrumb
26
27
  before_action :set_tabs, except: %i[index destroy sort]
@@ -84,7 +85,7 @@ module Spina
84
85
  private
85
86
 
86
87
  def article_params
87
- params.require(:admin_journal_article).permit(PARAMS)
88
+ params.require(:article).permit(PARAMS)
88
89
  end
89
90
 
90
91
  def sort_params
@@ -16,6 +16,7 @@ module Spina
16
16
  def new
17
17
  @author = Author.new
18
18
  @author.affiliations << Affiliation.new(status: :primary)
19
+ add_breadcrumb t('.new')
19
20
  end
20
21
 
21
22
  def edit; end
@@ -63,13 +64,13 @@ module Spina
63
64
  private
64
65
 
65
66
  def author_params
66
- params.require(:admin_journal_author).permit(:primary_affiliation_index,
67
- affiliations_attributes: %i[id institution_id first_name
68
- surname])
67
+ params.require(:author).permit(:primary_affiliation_index,
68
+ affiliations_attributes: %i[id institution_id first_name
69
+ surname])
69
70
  end
70
71
 
71
72
  def modified_params
72
- primary_affiliation_index = params[:admin_journal_author][:primary_affiliation_index]
73
+ primary_affiliation_index = params[:author][:primary_affiliation_index]
73
74
  new_params = author_params.except :primary_affiliation_index
74
75
  unless new_params[:affiliations_attributes].nil? || primary_affiliation_index.nil?
75
76
  new_params[:affiliations_attributes].each_key do |index|
@@ -50,7 +50,7 @@ module Spina
50
50
  private
51
51
 
52
52
  def institution_params
53
- params.require(:admin_journal_institution).permit(:name)
53
+ params.require(:institution).permit(:name)
54
54
  end
55
55
 
56
56
  def set_breadcrumb
@@ -4,7 +4,8 @@ module Spina
4
4
  module Admin
5
5
  module Journal
6
6
  # Controller for {Issue} records.
7
- class IssuesController < ApplicationController
7
+ # TODO: extract methods to helpers to reduce class length
8
+ class IssuesController < ApplicationController # rubocop:disable Metrics/ClassLength
8
9
  PARTS_PARAMS = [
9
10
  :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
10
11
  { images_attributes: %i[filename signed_blob_id image_id alt],
@@ -25,6 +26,7 @@ module Spina
25
26
  before_action :set_breadcrumb
26
27
  before_action :set_tabs, except: %i[index destroy sort]
27
28
  before_action :set_issue, only: %i[edit update destroy]
29
+ before_action :set_articles, only: %i[edit update]
28
30
  before_action :set_parts_attributes, only: %i[new edit]
29
31
  before_action :build_parts, only: %i[edit]
30
32
 
@@ -92,8 +94,12 @@ module Spina
92
94
  @issue = Issue.find(params[:id])
93
95
  end
94
96
 
97
+ def set_articles
98
+ @articles = @issue.articles.sorted_asc
99
+ end
100
+
95
101
  def issue_params
96
- params.require(:admin_journal_issue).permit(PARAMS)
102
+ params.require(:issue).permit(PARAMS)
97
103
  end
98
104
 
99
105
  def sort_params
@@ -21,7 +21,7 @@ module Spina
21
21
  params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
22
22
  end
23
23
  PARAMS = [:name, { **CONTENT_PARAMS }].freeze
24
- PARTS = %w[logo description].freeze
24
+ PARTS = %w[journal_abbreviation logo description documents issn].freeze
25
25
 
26
26
  before_action :set_journal
27
27
  before_action :set_parts_attributes
@@ -65,7 +65,7 @@ module Spina
65
65
  end
66
66
 
67
67
  def journal_params
68
- params.require(:admin_journal_journal).permit(PARAMS)
68
+ params.require(:journal).permit(PARAMS)
69
69
  end
70
70
  end
71
71
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Journal
6
+ # Controller for {Licence} records.
7
+ class LicencesController < ApplicationController
8
+ PARTS_PARAMS = [
9
+ :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
10
+ { images_attributes: %i[filename signed_blob_id image_id alt],
11
+ content_attributes: [
12
+ :name, :title,
13
+ { parts_attributes: [
14
+ :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
15
+ { images_attributes: %i[filename signed_blob_id image_id alt] }
16
+ ] }
17
+ ] }
18
+ ].freeze
19
+ CONTENT_PARAMS = Spina.config.locales.inject({}) do |params, locale|
20
+ params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
21
+ end
22
+ PARAMS = [:name, :abbreviated_name, { **CONTENT_PARAMS }].freeze
23
+ PARTS = %w[text url logo].freeze
24
+
25
+ before_action :set_breadcrumb
26
+ before_action :set_licence, only: %i[edit update destroy]
27
+ before_action :set_parts_attributes, only: %i[new edit]
28
+ before_action :build_parts, only: %i[edit]
29
+
30
+ def index
31
+ @licences = Licence.sorted
32
+ end
33
+
34
+ def new
35
+ @licence = Licence.new
36
+ build_parts
37
+ add_breadcrumb t('.new')
38
+ end
39
+
40
+ def edit; end
41
+
42
+ def create
43
+ @licence = Licence.new(licence_params)
44
+ if @licence.save
45
+ redirect_to admin_journal_licences_path, success: t('.saved')
46
+ else
47
+ render :new
48
+ end
49
+ end
50
+
51
+ def update
52
+ if @licence.update(licence_params)
53
+ redirect_to admin_journal_licences_path, success: t('.saved')
54
+ else
55
+ render :edit
56
+ end
57
+ end
58
+
59
+ def destroy
60
+ @licence.destroy
61
+ respond_to do |format|
62
+ format.html do
63
+ redirect_to admin_journal_licences_path, success: t('.deleted')
64
+ end
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def licence_params
71
+ params.require(:licence).permit(PARAMS)
72
+ end
73
+
74
+ def set_breadcrumb
75
+ add_breadcrumb Licence.model_name.human(count: :many), admin_journal_licences_path
76
+ end
77
+
78
+ def set_licence
79
+ @licence = Licence.find(params[:id])
80
+ add_breadcrumb @licence.name
81
+ end
82
+
83
+ def set_parts_attributes
84
+ @parts_attributes = current_theme.parts.select { |part| PARTS.include? part[:name] }
85
+ end
86
+
87
+ def build_parts
88
+ return unless @parts_attributes.is_a? Array
89
+
90
+ @parts = @parts_attributes.collect { |part_attributes| @licence.part(part_attributes) }
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -34,6 +34,9 @@ module Spina
34
34
  # @!attribute [rw] issue
35
35
  # @return [Issue] The issue that contains this article.
36
36
  belongs_to :issue
37
+ # @!attribute [rw] licence
38
+ # @return [Licence] the licence under which the article is released
39
+ belongs_to :licence, optional: true
37
40
 
38
41
  # @!attribute [rw] authorships
39
42
  has_many :authorships, dependent: :destroy
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Journal
6
+ # A record to hold information about copyright licences.
7
+ #
8
+ # Associated with individual articles.
9
+ #
10
+ # === Validators
11
+ # Presence:: {#name}
12
+ class Licence < ApplicationRecord
13
+ include AttrJson::Record
14
+ include AttrJson::NestedAttributes
15
+ include Spina::Partable
16
+ include Spina::TranslatedContent
17
+
18
+ # @!attribute [rw] name
19
+ # @return [String] the name of the licence
20
+ # @!attribute [rw] abbreviated_name
21
+ # @return [String] an optional abbreviated form of the licence name
22
+ # @!attribute [rw] articles
23
+ # @return [ActiveRecord::Relation] articles which use this licence
24
+ has_many :articles, dependent: :nullify
25
+
26
+ validates :name, presence: true
27
+
28
+ scope :sorted, -> { order(name: :asc) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Parts
5
+ module Admin
6
+ module Journal
7
+ # Part representing a range of pages
8
+ class PageRange < Spina::Parts::Base
9
+ attr_json :first_page, :integer
10
+ attr_json :last_page, :integer
11
+
12
+ validate :valid_range
13
+
14
+ def content
15
+ self
16
+ end
17
+
18
+ def valid_range
19
+ return if first_page.nil? && last_page.nil?
20
+
21
+ if last_page.nil?
22
+ errors.add :last_page, 'must be present'
23
+ elsif last_page < first_page
24
+ errors.add :last_page, 'must be larger than the first page'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ - content_for :application do
2
+ %header#header
3
+ #header_actions
4
+ = yield :header_actions
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = yield
9
+
10
+ = render template: 'layouts/spina/admin/admin'
@@ -1,27 +1,29 @@
1
1
  %li{ class: ('active' if %w[articles issues volumes].include? controller_name) }
2
- = link_to admin_journal_volumes_path do
2
+ = link_to spina.admin_journal_volumes_path do
3
3
  = icon 'pages'
4
- = ::Spina::Admin::Journal::Journal.instance.name
4
+ = ::Spina::Admin::Journal::Journal.instance.has_content?(:journal_abbreviation) ? ::Spina::Admin::Journal::Journal.instance.content(:journal_abbreviation) : ::Spina::Admin::Journal::Journal.instance.name
5
5
  = icon 'caret-right'
6
6
 
7
7
  %ul
8
8
  %li{ class: ('active' if %w[volumes].include? controller_name) }
9
- = link_to ::Spina::Admin::Journal::Volume.model_name.human(count: :many), admin_journal_volumes_path
9
+ = link_to ::Spina::Admin::Journal::Volume.model_name.human(count: :many), spina.admin_journal_volumes_path
10
10
  %li{ class: ('active' if %w[issues].include? controller_name) }
11
- = link_to ::Spina::Admin::Journal::Issue.model_name.human(count: :many), admin_journal_issues_path
11
+ = link_to ::Spina::Admin::Journal::Issue.model_name.human(count: :many), spina.admin_journal_issues_path
12
12
  %li{ class: ('active' if %w[articles].include? controller_name) }
13
- = link_to ::Spina::Admin::Journal::Article.model_name.human(count: :many), admin_journal_articles_path
13
+ = link_to ::Spina::Admin::Journal::Article.model_name.human(count: :many), spina.admin_journal_articles_path
14
14
 
15
- %li{ class: ('active' if %w[journals authors institutions].include? controller_name) }
16
- = link_to edit_admin_journal_journal_path(::Spina::Admin::Journal::Journal.instance.id) do
15
+ %li{ class: ('active' if %w[journals authors institutions licences].include? controller_name) }
16
+ = link_to spina.edit_admin_journal_journal_path(::Spina::Admin::Journal::Journal.instance.id) do
17
17
  = icon 'dots'
18
18
  = t 'spina.admin.journal.navigation_title'
19
19
  = icon 'caret-right'
20
20
 
21
21
  %ul
22
22
  %li{ class: ('active' if %w[journals].include? controller_name) }
23
- = link_to ::Spina::Admin::Journal::Journal.model_name.human(count: :one), edit_admin_journal_journal_path(::Spina::Admin::Journal::Journal.instance.id)
23
+ = link_to ::Spina::Admin::Journal::Journal.model_name.human(count: :one), spina.edit_admin_journal_journal_path(::Spina::Admin::Journal::Journal.instance.id)
24
24
  %li{ class: ('active' if %w[authors].include? controller_name) }
25
- = link_to ::Spina::Admin::Journal::Author.model_name.human(count: :many), admin_journal_authors_path
25
+ = link_to ::Spina::Admin::Journal::Author.model_name.human(count: :many), spina.admin_journal_authors_path
26
26
  %li{ class: ('active' if %w[institutions].include? controller_name) }
27
- = link_to ::Spina::Admin::Journal::Institution.model_name.human(count: :many), admin_journal_institutions_path
27
+ = link_to ::Spina::Admin::Journal::Institution.model_name.human(count: :many), spina.admin_journal_institutions_path
28
+ %li{ class: ('active' if %w[licences].include? controller_name) }
29
+ = link_to ::Spina::Admin::Journal::Licence.model_name.human(count: :many), spina.admin_journal_licences_path
@@ -8,7 +8,7 @@
8
8
  = link_to '#', data: { close_notification: true } do
9
9
  = icon 'cross'
10
10
 
11
- = form_for @article, html: { autocomplete: "off" } do |f|
11
+ = form_for [:admin_journal, @article], html: { autocomplete: "off" } do |f|
12
12
  %header#header
13
13
  = render partial: 'spina/admin/shared/breadcrumbs'
14
14
 
@@ -20,6 +20,11 @@
20
20
  = Spina::Admin::Journal::Article.human_attribute_name :status
21
21
  .page-form-content
22
22
  = f.select :status, Spina::Admin::Journal::Article.statuses.keys.map { |key| [key.humanize, key] }
23
+ .page-form-group
24
+ .page-form-label
25
+ = Spina::Admin::Journal::Article.human_attribute_name :licence
26
+ .page-form-content
27
+ = f.collection_select :licence_id, Spina::Admin::Journal::Licence.sorted, :id, :name, prompt: true
23
28
  .page-form-group
24
29
  .page-form-label
25
30
  = ::Spina::Admin::Journal::Author.model_name.human count: :many
@@ -8,7 +8,7 @@
8
8
  = link_to '#', data: {close_notification: true} do
9
9
  = icon 'cross'
10
10
 
11
- = form_for @author, html: {autocomplete: "off"} do |f|
11
+ = form_for [:admin_journal, @author], html: {autocomplete: "off"} do |f|
12
12
  %header#header
13
13
  = render partial: 'spina/admin/shared/breadcrumbs'
14
14
 
@@ -17,4 +17,4 @@
17
17
  .page-form-label
18
18
  = t '.primary'
19
19
  .page-form-content
20
- = radio_button_tag 'admin_journal_author[primary_affiliation_index]', ff.index, ff.object.status == 'primary'
20
+ = radio_button_tag 'author[primary_affiliation_index]', ff.index, ff.object.status == 'primary'
@@ -8,7 +8,7 @@
8
8
  = link_to '#', data: { close_notification: true } do
9
9
  = icon 'cross'
10
10
 
11
- = form_for @institution, html: {autocomplete: "off"} do |f|
11
+ = form_for [:admin_journal, @institution], html: {autocomplete: "off"} do |f|
12
12
  %header#header
13
13
  = render partial: 'spina/admin/shared/breadcrumbs'
14
14
 
@@ -8,7 +8,7 @@
8
8
  = link_to '#', data: { close_notification: true } do
9
9
  = icon 'cross'
10
10
 
11
- = form_for @issue, html: { autocomplete: 'off' } do |f|
11
+ = form_for [:admin_journal, @issue], html: { autocomplete: 'off' } do |f|
12
12
  %header#header
13
13
  = render partial: 'spina/admin/shared/breadcrumbs'
14
14
 
@@ -11,4 +11,4 @@
11
11
  %th= ::Spina::Admin::Journal::Article.human_attribute_name :title
12
12
  %th
13
13
  %tbody.html5sortable{ data: { id: @issue.id, sorted_collection: 'admin_journal_articles', sort_url: !@issue.id.nil? && sort_admin_journal_articles_url(@issue) } }
14
- = render @issue.articles.any? ? @issue.articles : 'empty_list', message: t('.no_articles')
14
+ = render @articles && @articles.any? ? @articles : 'empty_list', message: t('.no_articles')
@@ -8,7 +8,7 @@
8
8
  = link_to '#', data: { close_notification: true } do
9
9
  = icon 'cross'
10
10
 
11
- = form_for @journal, html: { autocomplete: "off" } do |f|
11
+ = form_for [:admin_journal, @journal], html: { autocomplete: "off" } do |f|
12
12
  %header#header
13
13
  .breadcrumbs
14
14
  = render_breadcrumbs
@@ -0,0 +1,43 @@
1
+ - if @licence.errors.any?
2
+ - content_for :notifications do
3
+ .notification.notification-danger.animated.fadeInRight
4
+ = icon 'exclamation'
5
+ .notification-message
6
+ = t 'spina.notifications.alert'
7
+ %small= @licence.errors.full_messages.join('<br />').html_safe
8
+ = link_to '#', data: { close_notification: true } do
9
+ = icon 'cross'
10
+
11
+ = form_for [:admin_journal, @licence], html: { autocomplete: 'off' } do |f|
12
+ %header#header
13
+ = render partial: 'spina/admin/shared/breadcrumbs'
14
+
15
+ #header_actions
16
+ %button.button.button-primary{ type: 'submit', style: 'margin-right: 0', data: { disable_with: t('spina.pages.saving') } }
17
+ = icon 'check'
18
+ = t '.save'
19
+
20
+ .button{ style: 'margin-right: 0' }= link_to t('spina.cancel'), admin_journal_licences_path
21
+
22
+ .page-form
23
+ .page-form-group
24
+ .page-form-label
25
+ = ::Spina::Admin::Journal::Licence.human_attribute_name :name
26
+ .page-form-content
27
+ = f.text_field :name
28
+ .page-form-group
29
+ .page-form-label
30
+ = ::Spina::Admin::Journal::Licence.human_attribute_name :abbreviated_name
31
+ .page-form-content
32
+ = f.text_field :abbreviated_name
33
+
34
+ = f.fields_for :"#{@locale}_content", @parts do |ff|
35
+ = ff.hidden_field :type, value: ff.object.class.name
36
+ = ff.hidden_field :title
37
+ = ff.hidden_field :name
38
+
39
+ .page-form-group.page-part{ data: { name: ff.object.name } }
40
+ = render "spina/admin/parts/#{parts_partial_namespace(ff.object.class.name)}/form", f: ff
41
+
42
+ - unless @licence.new_record?
43
+ .pull-right= link_to t('spina.permanently_delete'), admin_journal_licence_path(@licence), method: :delete, data: { confirm: t('.delete_confirmation', name: @licence.name) }, class: 'button button-link button-danger'
@@ -0,0 +1,11 @@
1
+ %tr{ data: { id: licence.id } }
2
+ %td
3
+ = link_to licence.name, edit_admin_journal_licence_path(licence)
4
+ %td
5
+ = licence.abbreviated_name
6
+ %td
7
+ = licence.articles.count
8
+ %td.nowrap.align-right
9
+ = link_to edit_admin_journal_licence_path(licence), class: 'button button-link' do
10
+ = icon 'pencil-outline'
11
+ = t '.edit'
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -0,0 +1,17 @@
1
+ - content_for(:header_actions) do
2
+ = link_to new_admin_journal_licence_path, class: 'button button-primary' do
3
+ = icon 'plus'
4
+ = t '.new'
5
+
6
+ .well
7
+ .table-container
8
+ %table.table
9
+ %thead
10
+ %tr
11
+ %th= ::Spina::Admin::Journal::Licence.human_attribute_name :name
12
+ %th= ::Spina::Admin::Journal::Licence.human_attribute_name :abbreviated_name
13
+ %th= t '.num_articles'
14
+ %th
15
+
16
+ %tbody
17
+ = render @licences.any? ? @licences : 'empty_list', message: t('.empty')
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -1,4 +1,4 @@
1
- = form_for @volume, html: { autocomplete: 'off' } do |f|
1
+ = form_for [:admin_journal, @volume], html: { autocomplete: 'off' } do |f|
2
2
  %header#header
3
3
  = render partial: 'spina/admin/shared/breadcrumbs'
4
4
 
@@ -0,0 +1,6 @@
1
+ .page-form-label= f.object.title
2
+ .page-form-control
3
+ = f.number_field :first_page, style: 'width: 10%;'
4
+ &ndash;
5
+ = f.number_field :last_page, style: 'width: 10%;'
6
+
@@ -134,6 +134,20 @@ en:
134
134
  delete_confirmation:
135
135
  "Are you sure you want to delete the institution <strong>%{name}</strong>?
136
136
  This action is irreversible, and will delete all associated affiliations. Authors will not be deleted."
137
+ licences:
138
+ new:
139
+ new: New licence
140
+ create:
141
+ saved: Licence saved.
142
+ update:
143
+ saved: Licence saved.
144
+ destroy:
145
+ deleted: Licence deleted.
146
+ form:
147
+ save: Save licence
148
+ delete_confirmation:
149
+ "Are you sure you want to delete the licence <strong>%{name}</strong>?"
150
+
137
151
  activerecord:
138
152
  models:
139
153
  spina/admin/journal/journal:
@@ -160,6 +174,9 @@ en:
160
174
  spina/admin/journal/institution:
161
175
  one: Institution
162
176
  other: Institutions
177
+ spina/admin/journal/licence:
178
+ one: Licence
179
+ other: Licences
163
180
  attributes:
164
181
  spina/admin/journal/journal:
165
182
  name: Name
@@ -180,6 +197,9 @@ en:
180
197
  spina/admin/journal/author:
181
198
  spina/admin/journal/institution:
182
199
  name: Institution Name
200
+ spina/admin/journal/licence:
201
+ name: Licence Name
202
+ abbreviated_name: Short Name
183
203
 
184
204
  date:
185
205
  formats:
data/config/routes.rb CHANGED
@@ -18,6 +18,7 @@ Spina::Engine.routes.draw do
18
18
  end
19
19
 
20
20
  resources :institutions, except: %i[show]
21
+ resources :licences, except: %i[show]
21
22
  end
22
23
  end
23
24
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalLicences < ActiveRecord::Migration[6.1] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_licences do |t|
6
+ t.string :name, null: false, default: 'Unnamed Licence'
7
+ t.string :abbreviated_name, null: false, default: ''
8
+ t.jsonb :json_attributes
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddLicenceToSpinaAdminJournalArticles < ActiveRecord::Migration[6.1] # :nodoc:
4
+ def change
5
+ add_reference :spina_admin_journal_articles, :licence, null: true,
6
+ foreign_key: { to_table: :spina_admin_journal_licences }
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaPartsAdminJournalPageRanges < ActiveRecord::Migration[6.1] # :nodoc:
4
+ def change
5
+ create_table :spina_parts_admin_journal_page_ranges, &:timestamps
6
+ end
7
+ end
@@ -5,12 +5,18 @@ module Spina
5
5
  module Journal
6
6
  # Registers the plugin with Spina.
7
7
  class Engine < ::Rails::Engine
8
+ isolate_namespace Spina::Admin::Journal
9
+
8
10
  config.before_initialize do
9
11
  ::Spina::Plugin.register do |plugin|
10
12
  plugin.name = 'journal'
11
13
  plugin.namespace = 'journal'
12
14
  end
13
15
  end
16
+
17
+ config.after_initialize do
18
+ Spina::Part.register Spina::Parts::Admin::Journal::PageRange
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -3,7 +3,7 @@
3
3
  module Spina
4
4
  module Admin
5
5
  module Journal
6
- VERSION = '0.4.2'
6
+ VERSION = '0.6.2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spina-admin-journal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Van Steene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: babel-transpiler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: 2.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -281,6 +281,7 @@ files:
281
281
  - app/controllers/spina/admin/journal/institutions_controller.rb
282
282
  - app/controllers/spina/admin/journal/issues_controller.rb
283
283
  - app/controllers/spina/admin/journal/journals_controller.rb
284
+ - app/controllers/spina/admin/journal/licences_controller.rb
284
285
  - app/controllers/spina/admin/journal/volumes_controller.rb
285
286
  - app/models/spina/admin/journal.rb
286
287
  - app/models/spina/admin/journal/affiliation.rb
@@ -290,13 +291,16 @@ files:
290
291
  - app/models/spina/admin/journal/institution.rb
291
292
  - app/models/spina/admin/journal/issue.rb
292
293
  - app/models/spina/admin/journal/journal.rb
294
+ - app/models/spina/admin/journal/licence.rb
293
295
  - app/models/spina/admin/journal/volume.rb
296
+ - app/models/spina/parts/admin/journal/page_range.rb
294
297
  - app/validators/spina/admin/journal/uri_validator.rb
295
298
  - app/views/layouts/spina/admin/journal/articles.html.haml
296
299
  - app/views/layouts/spina/admin/journal/authors.html.haml
297
300
  - app/views/layouts/spina/admin/journal/institutions.html.haml
298
301
  - app/views/layouts/spina/admin/journal/issues.html.haml
299
302
  - app/views/layouts/spina/admin/journal/journals.html.haml
303
+ - app/views/layouts/spina/admin/journal/licences.html.haml
300
304
  - app/views/layouts/spina/admin/journal/volumes.html.haml
301
305
  - app/views/spina/admin/hooks/journal/_head.html.haml
302
306
  - app/views/spina/admin/hooks/journal/_primary_navigation.html.haml
@@ -337,6 +341,11 @@ files:
337
341
  - app/views/spina/admin/journal/journals/edit.html.haml
338
342
  - app/views/spina/admin/journal/journals/index.html.haml
339
343
  - app/views/spina/admin/journal/journals/new.html.haml
344
+ - app/views/spina/admin/journal/licences/_form.html.haml
345
+ - app/views/spina/admin/journal/licences/_licence.html.haml
346
+ - app/views/spina/admin/journal/licences/edit.html.haml
347
+ - app/views/spina/admin/journal/licences/index.html.haml
348
+ - app/views/spina/admin/journal/licences/new.html.haml
340
349
  - app/views/spina/admin/journal/volumes/_form.html.haml
341
350
  - app/views/spina/admin/journal/volumes/_form_details.html.haml
342
351
  - app/views/spina/admin/journal/volumes/_form_issues.html.haml
@@ -344,6 +353,7 @@ files:
344
353
  - app/views/spina/admin/journal/volumes/edit.html.haml
345
354
  - app/views/spina/admin/journal/volumes/index.html.haml
346
355
  - app/views/spina/admin/journal/volumes/new.html.haml
356
+ - app/views/spina/admin/parts/admin/journal/page_ranges/_form.html.haml
347
357
  - config/locales/en.yml
348
358
  - config/routes.rb
349
359
  - db/migrate/20201216152147_create_spina_admin_journal_journals.rb
@@ -360,6 +370,9 @@ files:
360
370
  - db/migrate/20210424123555_add_json_attributes_to_spina_admin_journal_articles.rb
361
371
  - db/migrate/20210512122931_add_position_to_spina_admin_journal_authorships.rb
362
372
  - db/migrate/20210521121318_add_status_to_spina_admin_journal_articles.rb
373
+ - db/migrate/20210618090155_create_spina_admin_journal_licences.rb
374
+ - db/migrate/20210618094533_add_licence_to_spina_admin_journal_articles.rb
375
+ - db/migrate/20210626153728_create_spina_parts_admin_journal_page_ranges.rb
363
376
  - lib/spina/admin/journal.rb
364
377
  - lib/spina/admin/journal/engine.rb
365
378
  - lib/spina/admin/journal/version.rb
@@ -384,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
397
  - !ruby/object:Gem::Version
385
398
  version: '0'
386
399
  requirements: []
387
- rubygems_version: 3.1.4
400
+ rubygems_version: 3.1.6
388
401
  signing_key:
389
402
  specification_version: 4
390
403
  summary: Academic journal plugin for Spina.