spina-admin-journal 0.6.2 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/config/spina_admin_journal_manifest.js +5 -2
- data/app/assets/javascripts/spina/admin/journal/application.js +0 -0
- data/app/components/spina/admin/journal/affiliations_list_component.rb +32 -0
- data/app/components/spina/admin/journal/application_component.rb +11 -0
- data/app/components/spina/admin/journal/articles_list_component.rb +54 -0
- data/app/components/spina/admin/journal/authors_list_component.rb +37 -0
- data/app/components/spina/admin/journal/authorships_list_component.rb +45 -0
- data/app/components/spina/admin/journal/empty_list_component.html.haml +1 -0
- data/app/components/spina/admin/journal/empty_list_component.rb +14 -0
- data/app/components/spina/admin/journal/institutions_list_component.rb +32 -0
- data/app/components/spina/admin/journal/issues_list_component.rb +47 -0
- data/app/components/spina/admin/journal/licences_list_component.rb +32 -0
- data/app/components/spina/admin/journal/list_component.html.haml +10 -0
- data/app/components/spina/admin/journal/list_component.rb +22 -0
- data/app/components/spina/admin/journal/list_item_component.html.haml +17 -0
- data/app/components/spina/admin/journal/list_item_component.rb +23 -0
- data/app/components/spina/admin/journal/volumes_list_component.rb +34 -0
- data/app/controllers/spina/admin/journal/application_controller.rb +1 -1
- data/app/controllers/spina/admin/journal/articles_controller.rb +11 -23
- data/app/controllers/spina/admin/journal/authors_controller.rb +10 -24
- data/app/controllers/spina/admin/journal/institutions_controller.rb +6 -4
- data/app/controllers/spina/admin/journal/issues_controller.rb +12 -25
- data/app/controllers/spina/admin/journal/journals_controller.rb +2 -1
- data/app/controllers/spina/admin/journal/licences_controller.rb +6 -4
- data/app/controllers/spina/admin/journal/volumes_controller.rb +9 -20
- data/app/views/spina/admin/hooks/journal/_primary_navigation.html.haml +35 -26
- data/app/views/spina/admin/journal/articles/_form.html.haml +23 -24
- data/app/views/spina/admin/journal/articles/_form_authors.html.haml +1 -15
- data/app/views/spina/admin/journal/articles/_form_details.html.haml +27 -56
- data/app/views/spina/admin/journal/articles/index.html.haml +7 -17
- data/app/views/spina/admin/journal/authors/_form.html.haml +24 -24
- data/app/views/spina/admin/journal/authors/_form_affiliation.html.haml +8 -20
- data/app/views/spina/admin/journal/authors/_form_articles.html.haml +1 -18
- data/app/views/spina/admin/journal/authors/_form_details.html.haml +2 -6
- data/app/views/spina/admin/journal/authors/index.html.haml +7 -15
- data/app/views/spina/admin/journal/institutions/_form.html.haml +24 -24
- data/app/views/spina/admin/journal/institutions/_form_details.html.haml +2 -8
- data/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml +1 -10
- data/app/views/spina/admin/journal/institutions/index.html.haml +7 -15
- data/app/views/spina/admin/journal/issues/_form.html.haml +23 -23
- data/app/views/spina/admin/journal/issues/_form_articles.html.haml +1 -14
- data/app/views/spina/admin/journal/issues/_form_details.html.haml +13 -28
- data/app/views/spina/admin/journal/issues/index.html.haml +7 -16
- data/app/views/spina/admin/journal/journals/_form.html.haml +22 -32
- data/app/views/spina/admin/journal/licences/_form.html.haml +19 -34
- data/app/views/spina/admin/journal/licences/index.html.haml +7 -16
- data/app/views/spina/admin/journal/volumes/_form.html.haml +25 -12
- data/app/views/spina/admin/journal/volumes/_form_details.html.haml +4 -10
- data/app/views/spina/admin/journal/volumes/_form_issues.html.haml +1 -13
- data/app/views/spina/admin/journal/volumes/index.html.haml +7 -16
- data/config/locales/en.yml +25 -3
- data/config/routes.rb +5 -5
- data/lib/spina/admin/journal/engine.rb +12 -0
- data/lib/spina/admin/journal/version.rb +1 -1
- data/lib/spina/admin/journal.rb +1 -0
- metadata +47 -65
- data/app/assets/javascripts/spina/admin/journal/application.es6 +0 -72
- data/app/views/layouts/spina/admin/journal/articles.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/authors.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/institutions.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/issues.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/journals.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/licences.html.haml +0 -10
- data/app/views/layouts/spina/admin/journal/volumes.html.haml +0 -10
- data/app/views/spina/admin/journal/affiliations/_affiliation.html.haml +0 -8
- data/app/views/spina/admin/journal/application/_empty_list.html.haml +0 -3
- data/app/views/spina/admin/journal/articles/_article.html.haml +0 -10
- data/app/views/spina/admin/journal/authors/_author.html.haml +0 -8
- data/app/views/spina/admin/journal/authorships/_authorship.html.haml +0 -9
- data/app/views/spina/admin/journal/institutions/_institution.html.haml +0 -9
- data/app/views/spina/admin/journal/issues/_issue.html.haml +0 -9
- data/app/views/spina/admin/journal/journals/index.html.haml +0 -27
- data/app/views/spina/admin/journal/licences/_licence.html.haml +0 -11
- data/app/views/spina/admin/journal/volumes/_volume.html.haml +0 -7
- data/vendor/assets/javascripts/spina/admin/journal/html5sortable.js +0 -1295
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e696fd8633a8dc7ab2b57166808c7e989792307f0d3481a0eb5e73b0d05d175
|
|
4
|
+
data.tar.gz: bb15a7e5c115a2302e95f3224d85840dcfc6f46d8ec88b1c18bd67b4d0ba02b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e1f1e24116d3955595ef1fc705f4e93a25028daeaac15b42a147d4cadeec0b2bb5c6176d4d9c98dbb104f66dd325a006a156eea6d8afab270cb096cb386772f
|
|
7
|
+
data.tar.gz: d6541162de0b4e925c3c6dda25ac08d4e5292c6f3b2c8ac4306f933000aee56dfbc8cbcd2ee0704a0499a5a512e1179d429b47cbe8a17ea205a47324eaf2c382
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
//= link spina/admin/journal/application.js
|
|
2
1
|
//= link spina/admin/journal/application.css
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
//= link_directory ../javascripts/spina/admin/journal/controllers
|
|
4
|
+
//= link_directory ../javascripts/spina/admin/journal/libraries
|
|
5
|
+
|
|
6
|
+
//= link spina/admin/journal/application.js
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of licences. Not sortable.
|
|
7
|
+
class AffiliationsListComponent < ListComponent
|
|
8
|
+
def initialize(affiliations:)
|
|
9
|
+
@affiliations = affiliations
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def before_render
|
|
13
|
+
@list_items = generate_list_items(@affiliations)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
render ListComponent.new(list_items: @list_items, sortable: false)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def generate_list_items(affiliations)
|
|
23
|
+
affiliations.map do |affiliation|
|
|
24
|
+
{ id: affiliation.id,
|
|
25
|
+
label: affiliation.reversed_name,
|
|
26
|
+
path: helpers.spina.edit_admin_journal_author_path(affiliation.author) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of articles. Articles should only be sortable if presented within the contex of an
|
|
7
|
+
# issue.
|
|
8
|
+
class ArticlesListComponent < ListComponent
|
|
9
|
+
attr_reader :sortable
|
|
10
|
+
|
|
11
|
+
def initialize(articles:, sortable: false)
|
|
12
|
+
@articles = articles
|
|
13
|
+
@sortable = sortable
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def before_render
|
|
17
|
+
@list_items = generate_list_items(@articles)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def call
|
|
21
|
+
render ListComponent.new(list_items: @list_items,
|
|
22
|
+
sortable: sortable?,
|
|
23
|
+
sort_path: generate_sort_path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def sortable?
|
|
27
|
+
sortable
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def generate_list_items(articles)
|
|
33
|
+
articles.map do |article|
|
|
34
|
+
{ id: article.id,
|
|
35
|
+
label: generate_label(article),
|
|
36
|
+
path: helpers.spina.edit_admin_journal_article_path(article.id) }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def generate_label(article) # rubocop:disable Metrics/AbcSize
|
|
41
|
+
t('spina.admin.journal.articles.article_number', volume_number: article.issue.volume.number, # rubocop:disable Style/StringConcatenation
|
|
42
|
+
issue_number: article.issue.number,
|
|
43
|
+
article_number: article.number
|
|
44
|
+
) + ' | ' + t('spina.admin.journal.articles.title_author', title: article.title, # rubocop:disable Layout/MultilineMethodCallBraceLayout Layout/SpaceInsideParens
|
|
45
|
+
author: article.authorships.sorted_within_article.map { |authorship| authorship.affiliation.surname }.join(', ')) # rubocop:disable Layout/LineLength
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def generate_sort_path
|
|
49
|
+
@articles.any? ? helpers.spina.sort_admin_journal_issues_path(@articles.first.issue.id) : ''
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of authors. Not sortable.
|
|
7
|
+
class AuthorsListComponent < ListComponent
|
|
8
|
+
def initialize(authors:)
|
|
9
|
+
@authors = authors
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def before_render
|
|
13
|
+
@list_items = generate_list_items(@authors)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
render ListComponent.new(list_items: @list_items, sortable: false)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def generate_list_items(authors)
|
|
23
|
+
authors.map do |author|
|
|
24
|
+
{ id: author.id,
|
|
25
|
+
label: generate_label(author),
|
|
26
|
+
path: helpers.spina.edit_admin_journal_author_path(author) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def generate_label(author)
|
|
31
|
+
t 'spina.admin.journal.authors.name_institution', name: author.primary_affiliation.name,
|
|
32
|
+
institution: author.primary_affiliation.institution.name
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of authorships. Sortable when displayed in their corresponding article.
|
|
7
|
+
class AuthorshipsListComponent < ListComponent
|
|
8
|
+
attr_reader :sortable
|
|
9
|
+
|
|
10
|
+
def initialize(authorships:, sortable: false)
|
|
11
|
+
@authorships = authorships
|
|
12
|
+
@sortable = sortable
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def before_render
|
|
16
|
+
@list_items = generate_list_items(@authorships)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call
|
|
20
|
+
render ListComponent.new(list_items: @list_items,
|
|
21
|
+
sortable: sortable?,
|
|
22
|
+
sort_path: generate_sort_path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def sortable?
|
|
26
|
+
sortable
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def generate_list_items(authorships)
|
|
32
|
+
authorships.map do |authorship|
|
|
33
|
+
{ id: authorship.id,
|
|
34
|
+
label: authorship.affiliation.reversed_name,
|
|
35
|
+
path: helpers.spina.edit_admin_journal_author_path(authorship.affiliation.author) }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def generate_sort_path
|
|
40
|
+
@authorships.any? ? helpers.spina.sort_admin_journal_authors_path(@authorships.first.article.id) : ''
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
= @message
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# Displays a message indicating that a {ListComponent} has no items.
|
|
7
|
+
class EmptyListComponent < ApplicationComponent
|
|
8
|
+
def initialize(message: t('spina.admin.journal.empty_list'))
|
|
9
|
+
@message = message
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of institutions. Not sortable.
|
|
7
|
+
class InstitutionsListComponent < ListComponent
|
|
8
|
+
def initialize(institutions:)
|
|
9
|
+
@institutions = institutions
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def before_render
|
|
13
|
+
@list_items = generate_list_items(@institutions)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
render ListComponent.new(list_items: @list_items, sortable: false)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def generate_list_items(institutions)
|
|
23
|
+
institutions.map do |institution|
|
|
24
|
+
{ id: institution.id,
|
|
25
|
+
label: institution.name,
|
|
26
|
+
path: helpers.spina.edit_admin_journal_institution_path(institution.id) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of issues. Issues should only be sortable if presented within the contex of a
|
|
7
|
+
# volume.
|
|
8
|
+
class IssuesListComponent < ListComponent
|
|
9
|
+
attr_reader :sortable
|
|
10
|
+
|
|
11
|
+
def initialize(issues:, sortable: false)
|
|
12
|
+
@issues = issues
|
|
13
|
+
@sortable = sortable
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def before_render
|
|
17
|
+
@list_items = generate_list_items(@issues)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def call
|
|
21
|
+
render ListComponent.new(list_items: @list_items,
|
|
22
|
+
sortable: sortable?,
|
|
23
|
+
sort_path: generate_sort_path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def sortable?
|
|
27
|
+
sortable
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def generate_list_items(issues)
|
|
33
|
+
issues.map do |issue|
|
|
34
|
+
{ id: issue.id,
|
|
35
|
+
label: t('spina.admin.journal.issues.volume_issue', volume_number: issue.volume.number,
|
|
36
|
+
issue_number: issue.number),
|
|
37
|
+
path: helpers.spina.edit_admin_journal_issue_path(issue.id) }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def generate_sort_path
|
|
42
|
+
@issues.any? ? helpers.spina.sort_admin_journal_issues_path(@issues.first.volume.id) : ''
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A list of licences. Not sortable.
|
|
7
|
+
class LicencesListComponent < ListComponent
|
|
8
|
+
def initialize(licences:)
|
|
9
|
+
@licences = licences
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def before_render
|
|
13
|
+
@list_items = generate_list_items(@licences)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
render ListComponent.new(list_items: @list_items, sortable: false)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def generate_list_items(licences)
|
|
23
|
+
licences.map do |licence|
|
|
24
|
+
{ id: licence.id,
|
|
25
|
+
label: licence.name,
|
|
26
|
+
path: helpers.spina.edit_admin_journal_licence_path(licence) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
- if sortable?
|
|
2
|
+
.ml-8.mt-8.text-gray-600.text-sm= t 'spina.admin.journal.sort_info'
|
|
3
|
+
.my-6.md:m-8.bg-white.md:rounded-lg.border-l-0.border-r-0.border.md:border-r.md:border-l.border-gray-200.border-b-0.shadow-sm{ data: { controller: 'sortable' } }
|
|
4
|
+
= form_with(url: @sort_path, data: { sortable_target: 'form' }) { |f| }
|
|
5
|
+
%ul{ data: { sortable_target: 'list' } }
|
|
6
|
+
- if @list_items.any?
|
|
7
|
+
- @list_items.each do |item|
|
|
8
|
+
= render Spina::Admin::Journal::ListItemComponent.new(id: item[:id], label: item[:label], path: item[:path], sortable: sortable?)
|
|
9
|
+
- else
|
|
10
|
+
= render Spina::Admin::Journal::EmptyListComponent.new
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A generic implementation of a list, resembling Spina's page list.
|
|
7
|
+
class ListComponent < ApplicationComponent
|
|
8
|
+
attr_reader :sortable
|
|
9
|
+
|
|
10
|
+
def initialize(list_items:, sortable: false, sort_path: '')
|
|
11
|
+
@sortable = sortable
|
|
12
|
+
@list_items = list_items
|
|
13
|
+
@sort_path = sort_path
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def sortable?
|
|
17
|
+
sortable
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
%li{data: { id: @id }}
|
|
2
|
+
.flex.items-center.border-gray-200.border-b.bg-opacity-50.w-full
|
|
3
|
+
- if sortable?
|
|
4
|
+
.p-4.text-gray-300.hover:text-gray-600.cursor-move{ data: { 'sortable-handle': true } }
|
|
5
|
+
= helpers.heroicon('menu-alt-4', style: :solid, class: 'w-4 h-4 -mr-4')
|
|
6
|
+
|
|
7
|
+
.flex-auto
|
|
8
|
+
.block.text-spina.font-medium.text-sm.p-4{class: 'hover:text-spina-dark' }
|
|
9
|
+
= link_to @path do
|
|
10
|
+
= @label
|
|
11
|
+
|
|
12
|
+
.flex-1
|
|
13
|
+
|
|
14
|
+
= link_to @path, class: 'btn btn-link mr-4' do
|
|
15
|
+
.flex.flex-nowrap.items-center.px-8.py-1
|
|
16
|
+
= helpers.heroicon 'pencil-alt', style: :outline, class: 'w-4 h-4'
|
|
17
|
+
.ml-2= t 'spina.admin.journal.edit'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A generic list item that is only intended to be called by {ListItemComponent}.
|
|
7
|
+
class ListItemComponent < ApplicationComponent
|
|
8
|
+
attr_reader :sortable
|
|
9
|
+
|
|
10
|
+
def initialize(id:, label:, path:, sortable: false)
|
|
11
|
+
@label = label
|
|
12
|
+
@id = id
|
|
13
|
+
@path = path
|
|
14
|
+
@sortable = sortable
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def sortable?
|
|
18
|
+
sortable
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spina
|
|
4
|
+
module Admin
|
|
5
|
+
module Journal
|
|
6
|
+
# A sortable list of volumes.
|
|
7
|
+
class VolumesListComponent < ListComponent
|
|
8
|
+
def initialize(volumes:)
|
|
9
|
+
@volumes = volumes
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def before_render
|
|
13
|
+
@list_items = generate_list_items(@volumes)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
render ListComponent.new(list_items: @list_items,
|
|
18
|
+
sortable: true,
|
|
19
|
+
sort_path: helpers.spina.sort_admin_journal_volumes_path(Journal.instance.id))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def generate_list_items(volumes)
|
|
25
|
+
volumes.map do |volume|
|
|
26
|
+
{ id: volume.id,
|
|
27
|
+
label: t('spina.admin.journal.volumes.volume_number', number: volume.number),
|
|
28
|
+
path: helpers.spina.edit_admin_journal_volume_path(volume.id) }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -41,23 +41,25 @@ module Spina
|
|
|
41
41
|
|
|
42
42
|
def edit; end
|
|
43
43
|
|
|
44
|
-
def create
|
|
44
|
+
def create # rubocop:disable Metrics/AbcSize
|
|
45
45
|
@article = Article.new(article_params)
|
|
46
46
|
sister_articles = Article.where(issue: @article.issue_id)
|
|
47
47
|
@article.number = sister_articles.any? ? sister_articles.sorted_desc.first.number + 1 : 1
|
|
48
48
|
|
|
49
49
|
if @article.save
|
|
50
|
-
redirect_to
|
|
50
|
+
redirect_to edit_admin_journal_article_path(@article), success: t('.saved')
|
|
51
51
|
else
|
|
52
|
-
|
|
52
|
+
flash.now[:alert] = t('.failed')
|
|
53
|
+
render :new, status: :unprocessable_entity
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
def update
|
|
57
58
|
if @article.update(article_params)
|
|
58
|
-
redirect_to
|
|
59
|
+
redirect_to edit_admin_journal_article_path(@article), success: t('.saved')
|
|
59
60
|
else
|
|
60
|
-
|
|
61
|
+
flash.now[:alert] = t('.failed')
|
|
62
|
+
render :edit, status: :unprocessable_entity
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
|
|
@@ -71,15 +73,11 @@ module Spina
|
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
def sort
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Article.find(id.to_i).update_attribute(:number, new_pos.to_i) # rubocop:disable Rails/SkipsModelValidations
|
|
77
|
-
end
|
|
78
|
-
validate_sort_order
|
|
76
|
+
params[:ids].each.with_index do |id, index|
|
|
77
|
+
Article.where(id: id).update_all(number: index + 1) # rubocop:disable Rails/SkipsModelValidations
|
|
79
78
|
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
render json: { success: false, message: t('.sort_error') }
|
|
79
|
+
flash.now[:info] = t('spina.pages.sorting_saved')
|
|
80
|
+
render_flash
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
private
|
|
@@ -88,16 +86,6 @@ module Spina
|
|
|
88
86
|
params.require(:article).permit(PARAMS)
|
|
89
87
|
end
|
|
90
88
|
|
|
91
|
-
def sort_params
|
|
92
|
-
params.require(:admin_journal_articles).require(:list).permit!
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def validate_sort_order
|
|
96
|
-
Article.where(issue_id: params[:issue_id]).each do |article|
|
|
97
|
-
raise ActiveRecord::RecordInvalid if article.invalid?
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
89
|
def set_breadcrumb
|
|
102
90
|
add_breadcrumb Article.model_name.human(count: :many), admin_journal_articles_path
|
|
103
91
|
end
|
|
@@ -24,17 +24,19 @@ module Spina
|
|
|
24
24
|
def create
|
|
25
25
|
@author = Author.new(modified_params)
|
|
26
26
|
if @author.save
|
|
27
|
-
redirect_to
|
|
27
|
+
redirect_to edit_admin_journal_author_path(@author), success: t('.saved')
|
|
28
28
|
else
|
|
29
|
-
|
|
29
|
+
flash.now[:alert] = t('.failed')
|
|
30
|
+
render :new, status: :unprocessable_entity
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def update
|
|
34
35
|
if @author.update(modified_params)
|
|
35
|
-
redirect_to
|
|
36
|
+
redirect_to edit_admin_journal_author_path(@author), success: t('.saved')
|
|
36
37
|
else
|
|
37
|
-
|
|
38
|
+
flash.now[:alert] = t('.failed')
|
|
39
|
+
render :edit, status: :unprocessable_entity
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
|
|
@@ -48,17 +50,11 @@ module Spina
|
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def sort
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# ignore uniqueness validation for now
|
|
54
|
-
Authorship.find(id.to_i).update_attribute(:position, new_pos.to_i) # rubocop:disable Rails/SkipsModelValidations
|
|
55
|
-
end
|
|
56
|
-
# do validations after reordering is complete
|
|
57
|
-
validate_sort_order
|
|
53
|
+
params[:ids].each.with_index do |id, index|
|
|
54
|
+
Authorship.where(id: id).update_all(position: index + 1) # rubocop:disable Rails/SkipsModelValidations
|
|
58
55
|
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
render json: { success: false, message: t('.sort_error') }
|
|
56
|
+
flash.now[:info] = t('spina.pages.sorting_saved')
|
|
57
|
+
render_flash
|
|
62
58
|
end
|
|
63
59
|
|
|
64
60
|
private
|
|
@@ -80,10 +76,6 @@ module Spina
|
|
|
80
76
|
new_params
|
|
81
77
|
end
|
|
82
78
|
|
|
83
|
-
def sort_params
|
|
84
|
-
params.require(:admin_journal_authorships).require(:list).permit!
|
|
85
|
-
end
|
|
86
|
-
|
|
87
79
|
def set_breadcrumb
|
|
88
80
|
add_breadcrumb Author.model_name.human(count: :many), admin_journal_authors_path
|
|
89
81
|
end
|
|
@@ -96,12 +88,6 @@ module Spina
|
|
|
96
88
|
@author = Author.find(params[:id])
|
|
97
89
|
add_breadcrumb @author.primary_affiliation.name
|
|
98
90
|
end
|
|
99
|
-
|
|
100
|
-
def validate_sort_order
|
|
101
|
-
Authorship.where(article_id: params[:article_id]).each do |authorship|
|
|
102
|
-
raise ActiveRecord::RecordInvalid if authorship.invalid?
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
91
|
end
|
|
106
92
|
end
|
|
107
93
|
end
|
|
@@ -24,17 +24,19 @@ module Spina
|
|
|
24
24
|
@institution = Institution.new(institution_params)
|
|
25
25
|
|
|
26
26
|
if @institution.save
|
|
27
|
-
redirect_to
|
|
27
|
+
redirect_to edit_admin_journal_institution_path(@institution), success: t('.saved')
|
|
28
28
|
else
|
|
29
|
-
|
|
29
|
+
flash.now[:alert] = t('.failed')
|
|
30
|
+
render :new, status: :unprocessable_entity
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def update
|
|
34
35
|
if @institution.update(institution_params)
|
|
35
|
-
redirect_to
|
|
36
|
+
redirect_to edit_admin_journal_institution_path(@institution), success: t('.saved')
|
|
36
37
|
else
|
|
37
|
-
|
|
38
|
+
flash.now[:alert] = t('.failed')
|
|
39
|
+
render :edit, status: :unprocessable_entity
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
|