spina-admin-journal 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c43ca7425af717514efb0bc6a142651eae11fd79446019ab19b87bb8c952f497
4
- data.tar.gz: 3af013de932268d05fb32013c7d1f09a89166eedd43276ce73c1756819cdea75
3
+ metadata.gz: 6c0a0d703a86719e315f9ea84b71b62a8ca32dff43d33ba9b012dc924f550b4e
4
+ data.tar.gz: c3c548eb605e39ecd8b2bfe56c6343e9187c8bb7c8747fc8c7169240d2e160ed
5
5
  SHA512:
6
- metadata.gz: d792437f01a6474b290daa7deaea9232eb78892a77e08c877abbab9ce97221785c653eca15062b2656a70e155b74ad3ed77aae3e2a3260306c153bfb9c4401fc
7
- data.tar.gz: 1ef7f100bd6d37727916951f588d4fcad17d4c896e3fab8c136f2ac663b0290afb3293adc3c6c1cb2d1e99f463363a4c352879a09d53df624e31403d1120a111
6
+ metadata.gz: ff8186db67c005d436664f43492133268aa44b7af675076b2e16a40764920f5c9403f236964d57040aa9388b4b1540bca5e448fb63874c06cab8f644af687db4
7
+ data.tar.gz: f66bce803e4e7269991dc0199b32eb05e33b7c11ae555a7971105dfc1f1bcb24fdec3c6eb7b1571abb27d95317d5f3165656fedf4ae7e17a00b33786de472e2c
@@ -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,
@@ -20,7 +21,7 @@ module Spina
20
21
  params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
21
22
  end
22
23
  PARAMS = [:issue_id, :licence_id, :title, :url, :doi, :status, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
23
- PARTS = %w[abstract attachment].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]
@@ -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
@@ -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,6 +94,10 @@ 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
102
  params.require(:admin_journal_issue).permit(PARAMS)
97
103
  end
@@ -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[journal_abbreviation logo description documents].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
@@ -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
@@ -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')
@@ -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
+
@@ -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
@@ -11,6 +11,10 @@ module Spina
11
11
  plugin.namespace = 'journal'
12
12
  end
13
13
  end
14
+
15
+ config.after_initialize do
16
+ Spina::Part.register Spina::Parts::Admin::Journal::PageRange
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -3,7 +3,7 @@
3
3
  module Spina
4
4
  module Admin
5
5
  module Journal
6
- VERSION = '0.5.0'
6
+ VERSION = '0.6.0'
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.5.0
4
+ version: 0.6.0
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-06-23 00:00:00.000000000 Z
11
+ date: 2021-09-07 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
@@ -293,6 +293,7 @@ files:
293
293
  - app/models/spina/admin/journal/journal.rb
294
294
  - app/models/spina/admin/journal/licence.rb
295
295
  - app/models/spina/admin/journal/volume.rb
296
+ - app/models/spina/parts/admin/journal/page_range.rb
296
297
  - app/validators/spina/admin/journal/uri_validator.rb
297
298
  - app/views/layouts/spina/admin/journal/articles.html.haml
298
299
  - app/views/layouts/spina/admin/journal/authors.html.haml
@@ -352,6 +353,7 @@ files:
352
353
  - app/views/spina/admin/journal/volumes/edit.html.haml
353
354
  - app/views/spina/admin/journal/volumes/index.html.haml
354
355
  - app/views/spina/admin/journal/volumes/new.html.haml
356
+ - app/views/spina/admin/parts/admin/journal/page_ranges/_form.html.haml
355
357
  - config/locales/en.yml
356
358
  - config/routes.rb
357
359
  - db/migrate/20201216152147_create_spina_admin_journal_journals.rb
@@ -370,6 +372,7 @@ files:
370
372
  - db/migrate/20210521121318_add_status_to_spina_admin_journal_articles.rb
371
373
  - db/migrate/20210618090155_create_spina_admin_journal_licences.rb
372
374
  - db/migrate/20210618094533_add_licence_to_spina_admin_journal_articles.rb
375
+ - db/migrate/20210626153728_create_spina_parts_admin_journal_page_ranges.rb
373
376
  - lib/spina/admin/journal.rb
374
377
  - lib/spina/admin/journal/engine.rb
375
378
  - lib/spina/admin/journal/version.rb