diff --git a/Gemfile b/Gemfile index 017d396..0bd6fff 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ # ------------------------------------------------ # SUPER ADMIN SECTION -gem "administrate", :github => 'thoughtbot/administrate', :branch =>'v0.4.0' +gem "administrate", :github => 'thoughtbot/administrate', :branch =>'master' #:branch =>'v0.4.0' # ------------------------------------------------ # USERS diff --git a/Gemfile.lock b/Gemfile.lock index 51506da..9784215 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,17 +1,17 @@ GIT remote: git://github.com/thoughtbot/administrate.git - revision: 5ee0c2ffe4de99ebf639befd63831c1083dc535f - branch: v0.4.0 + revision: 47a2f99e22be87119ef0e3a7af3956984df5842c + branch: master specs: administrate (0.4.0) autoprefixer-rails (~> 6.0) - bourbon (~> 4.2) + bourbon (>= 5.0.0.beta.6) datetime_picker_rails (~> 0.0.7) jquery-rails (~> 4.0) - kaminari (~> 0.16) + kaminari (>= 1.0) momentjs-rails (~> 2.8) neat (~> 1.1) - normalize-rails (~> 3.0) + normalize-rails (>= 3.0) rails (>= 4.2, < 5.1) sass-rails (~> 5.0) selectize-rails (~> 0.6) @@ -65,7 +65,7 @@ addressable (2.4.0) ansi (1.5.0) arel (6.0.3) - autoprefixer-rails (6.7.6) + autoprefixer-rails (6.7.7.1) execjs bcrypt (3.1.11) better_errors (2.1.1) @@ -74,9 +74,9 @@ rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bourbon (4.3.3) - sass (~> 3.4) - thor (~> 0.19) + bourbon (5.0.0.beta.7) + sass (~> 3.4.22) + thor (~> 0.19.1) builder (3.2.2) byebug (9.0.5) capybara (2.9.1) @@ -158,9 +158,18 @@ thor (>= 0.14, < 2.0) json (1.8.3) jwt (1.5.6) - kaminari (0.17.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) ledermann-rails-settings (2.4.2) activerecord (>= 3.1) less (2.6.0) @@ -211,7 +220,7 @@ nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) - normalize-rails (3.0.3) + normalize-rails (4.1.1) oauth2 (1.2.0) faraday (>= 0.8, < 0.10) jwt (~> 1.0) diff --git a/app/dashboards/guidance_group_dashboard.rb b/app/dashboards/guidance_group_dashboard.rb index 5aee6df..a8a83cc 100644 --- a/app/dashboards/guidance_group_dashboard.rb +++ b/app/dashboards/guidance_group_dashboard.rb @@ -60,4 +60,8 @@ # def display_resource(guidance_group) # "GuidanceGroup ##{guidance_group.id}" # end + + def display_resource(guidance_group) + guidance_group.name + end end diff --git a/app/dashboards/identifier_scheme_dashboard.rb b/app/dashboards/identifier_scheme_dashboard.rb index 7c65ea8..7dc1dca 100644 --- a/app/dashboards/identifier_scheme_dashboard.rb +++ b/app/dashboards/identifier_scheme_dashboard.rb @@ -60,4 +60,9 @@ # def display_resource(identifier_scheme) # "IdentifierScheme ##{identifier_scheme.id}" # end + + def display_resource(identifier_scheme) + identifier_scheme.description + end + end diff --git a/app/dashboards/language_dashboard.rb b/app/dashboards/language_dashboard.rb index b6f5a48..c888a7d 100644 --- a/app/dashboards/language_dashboard.rb +++ b/app/dashboards/language_dashboard.rb @@ -46,8 +46,8 @@ # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ - :users, - :orgs, + # :users, + # :orgs, :abbreviation, :description, :name, @@ -60,4 +60,9 @@ # def display_resource(language) # "Language ##{language.id}" # end + + def display_resource(language) + language.abbreviation + end + end diff --git a/app/dashboards/org_dashboard.rb b/app/dashboards/org_dashboard.rb index 3bc1cf4..013748f 100644 --- a/app/dashboards/org_dashboard.rb +++ b/app/dashboards/org_dashboard.rb @@ -8,7 +8,6 @@ # which determines how the attribute is displayed # on pages throughout the dashboard. ATTRIBUTE_TYPES = { - organisation_type: Field::BelongsTo, language: Field::BelongsTo, guidance_groups: Field::HasMany, templates: Field::HasMany, @@ -47,7 +46,6 @@ :templates, :contact_email, :org_type, - :organisation_type, ].freeze # SHOW_PAGE_ATTRIBUTES @@ -60,12 +58,10 @@ :templates, :contact_email, :org_type, - :organisation_type, - - :id, :users, :suggested_answers, :token_permission_types, + :id, :target_url, :wayfless_entity, :created_at, @@ -84,12 +80,11 @@ # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ - :organisation_type, :language, :guidance_groups, - :templates, - :users, - :suggested_answers, +# :templates, +# :users, +# :suggested_answers, :token_permission_types, :name, :abbreviation, @@ -113,4 +108,8 @@ # def display_resource(org) # "Org ##{org.id}" # end + + def display_resource(org) + org.name + end end diff --git a/app/dashboards/perm_dashboard.rb b/app/dashboards/perm_dashboard.rb index 63ea695..dc9e20b 100644 --- a/app/dashboards/perm_dashboard.rb +++ b/app/dashboards/perm_dashboard.rb @@ -41,7 +41,7 @@ # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ - :users, +# :users, :name, ].freeze @@ -51,4 +51,9 @@ # def display_resource(perm) # "Perm ##{perm.id}" # end + + def display_resource(perm) + perm.name + end + end diff --git a/app/dashboards/token_permission_type_dashboard.rb b/app/dashboards/token_permission_type_dashboard.rb index ce8d4ad..93deb0f 100644 --- a/app/dashboards/token_permission_type_dashboard.rb +++ b/app/dashboards/token_permission_type_dashboard.rb @@ -54,4 +54,8 @@ # def display_resource(token_permission_type) # "TokenPermissionType ##{token_permission_type.id}" # end + def display_resource(token_permission_type) + "#{token_permission_type.token_type}: #{token_permission_type.text_description}" + end + end diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index bd685f7..d7339b5 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -8,6 +8,18 @@ # which determines how the attribute is displayed # on pages throughout the dashboard. ATTRIBUTE_TYPES = { + invited_by: Field::Polymorphic, + perms: Field::HasMany, + language: Field::BelongsTo, + org: Field::BelongsTo, + answers: Field::HasMany, + notes: Field::HasMany, + exported_plans: Field::HasMany, + roles: Field::HasMany, + plans: Field::HasMany, + user_identifiers: Field::HasMany, + identifier_schemes: Field::HasMany, + setting_objects: Field::HasMany.with_options(class_name: "Settings::PlanList"), id: Field::Number, firstname: Field::String, surname: Field::String, @@ -36,18 +48,6 @@ dmponline3: Field::Boolean, accept_terms: Field::Boolean, api_token: Field::String, - invited_by: Field::Polymorphic, - perms: Field::HasMany, - language: Field::BelongsTo, - org: Field::BelongsTo, - answers: Field::HasMany, - notes: Field::HasMany, - exported_plans: Field::HasMany, - roles: Field::HasMany, - plans: Field::HasMany, - user_identifiers: Field::HasMany, - identifier_schemes: Field::HasMany, - setting_objects: Field::HasMany.with_options(class_name: "Settings::PlanList"), }.freeze # COLLECTION_ATTRIBUTES @@ -73,7 +73,6 @@ :org, :perms, :confirmed_at, - :id, :invited_by, :language, @@ -114,24 +113,24 @@ # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ - :invited_by, +# :invited_by, :perms, :language, :org, - :answers, - :notes, - :exported_plans, - :roles, - :plans, +# :answers, +# :notes, +# :exported_plans, +# :roles, +# :plans, :user_identifiers, :identifier_schemes, - :setting_objects, +# :setting_objects, :firstname, :surname, :email, :orcid_id, :shibboleth_id, - :encrypted_password, +# :encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, @@ -159,4 +158,9 @@ # def display_resource(user) # "User ##{user.id}" # end + + def display_resource(user) + "user.name (##{user.id})" + end + end diff --git a/app/dashboards/user_identifier_dashboard.rb b/app/dashboards/user_identifier_dashboard.rb index 181303e..fc6d73e 100644 --- a/app/dashboards/user_identifier_dashboard.rb +++ b/app/dashboards/user_identifier_dashboard.rb @@ -54,4 +54,9 @@ # def display_resource(user_identifier) # "UserIdentifier ##{user_identifier.id}" # end + + def display_resource(user_identifier) + user_identifier.identifier + end + end diff --git a/app/models/org.rb b/app/models/org.rb index 0062e1d..61e6691 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -5,7 +5,7 @@ ## # Associations - belongs_to :organisation_type # depricated, but cannot be removed until migration run +# belongs_to :organisation_type # depricated, but cannot be removed until migration run belongs_to :language has_many :guidance_groups has_many :templates @@ -17,11 +17,11 @@ ## # Possibly needed for active_admin # -relies on protected_attributes gem as syntax depricated in rails 4.2 - attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, - :logo_file_name, :name, :target_url, - :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, - :token_permission_type_ids, :language_id, :contact_email, - :language, :org_type, :region, :token_permission_types +# attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, +# :logo_file_name, :name, :target_url, +# :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, +# :token_permission_type_ids, :language_id, :contact_email, +# :language, :org_type, :region, :token_permission_types ## # Validators diff --git a/app/models/perm.rb b/app/models/perm.rb index 0db316b..5efd21f 100644 --- a/app/models/perm.rb +++ b/app/models/perm.rb @@ -6,7 +6,7 @@ ## # Possibly needed for active_admin # -relies on protected_attributes gem as syntax depricated in rails 4.2 - attr_accessible :name, :as => [:default, :admin] + #attr_accessible :name, :as => [:default, :admin] validates :name, presence: true, uniqueness: true diff --git a/app/models/user.rb b/app/models/user.rb index 30f3699..ace73b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,14 +40,14 @@ ## # Possibly needed for active_admin # -relies on protected_attributes gem as syntax depricated in rails 4.2 - accepts_nested_attributes_for :roles - attr_accessible :password_confirmation, :encrypted_password, :remember_me, - :id, :email, :firstname, :last_login,:login_count, :orcid_id, - :password, :shibboleth_id, :user_status_id, :surname, - :user_type_id, :org_id, :skip_invitation, :other_organisation, - :accept_terms, :role_ids, :dmponline3, :api_token, - :organisation, :language, :language_id, :org, :perms, - :confirmed_at, :org_id + #accepts_nested_attributes_for :roles + #attr_accessible :password_confirmation, :encrypted_password, :remember_me, + # :id, :email, :firstname, :last_login,:login_count, :orcid_id, + # :password, :shibboleth_id, :user_status_id, :surname, + # :user_type_id, :org_id, :skip_invitation, :other_organisation, + # :accept_terms, :role_ids, :dmponline3, :api_token, + # :organisation, :language, :language_id, :org, :perms, + # :confirmed_at, :org_id validates :email, email: true, allow_nil: true, uniqueness: true diff --git a/app/views/admin/application/_collection.html.erb b/app/views/admin/application/_collection.html.erb deleted file mode 100644 index ed64ea7..0000000 --- a/app/views/admin/application/_collection.html.erb +++ /dev/null @@ -1,83 +0,0 @@ -<%# -# Collection - -This partial is used on the `index` and `show` pages -to display a collection of resources in an HTML table. - -## Local variables: - -- `collection_presenter`: - An instance of [Administrate::Page::Collection][1]. - The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine - the columns displayed in the table -- `resources`: - An ActiveModel::Relation collection of resources to be displayed in the table. - By default, the number of resources is limited by pagination - or by a hard limit to prevent excessive page load times - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection -%> - - - - - <% collection_presenter.attribute_types.each do |attr_name, attr_type| %> - - <% end %> - - - - - - <% resources.each do |resource| %> - - <% collection_presenter.attributes_for(resource).each do |attribute| %> - - <% end %> - - - - - - <% end %> - -
- <%= link_to(sanitized_order_params.merge( - collection_presenter.order_params_for(attr_name) - )) do %> - <%= t( - "helpers.label.#{resource_name}.#{attr_name}", - default: attr_name.to_s, - ).titleize %> - - <% if collection_presenter.ordered_by?(attr_name) %> - - <%= svg_tag( - "administrate/sort_arrow.svg", - "sort_arrow", - width: "13", - height: "13" - ) %> - - <% end %> - <% end %> -
- <%= render_field attribute %> - <%= link_to( - t("administrate.actions.edit"), - [:edit, namespace, resource], - class: "action-edit", - ) %><%= link_to( - t("administrate.actions.destroy"), - [namespace, resource], - class: "table__action--destroy", - method: :delete, - data: { confirm: t("administrate.actions.confirm") } - ) %>
diff --git a/app/views/admin/application/_form.html.erb b/app/views/admin/application/_form.html.erb deleted file mode 100644 index cf991d0..0000000 --- a/app/views/admin/application/_form.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -<%# -# Form Partial - -This partial is rendered on a resource's `new` and `edit` pages, -and renders all form fields for a resource's editable attributes. - -## Local variables: - -- `page`: - An instance of [Administrate::Page::Form][1]. - Contains helper methods to display a form, - and knows which attributes should be displayed in the resource's form. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form -%> - -<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %> - <% if page.resource.errors.any? %> -
-

- <%= pluralize(page.resource.errors.count, "error") %> - prohibited this <%= page.resource_name %> from being saved: -

- - -
- <% end %> - - <% page.attributes.each do |attribute| -%> -
- <%= render_field attribute, f: f %> -
- <% end -%> - -
- <%= f.submit %> -
-<% end %> diff --git a/app/views/admin/application/edit.html.erb b/app/views/admin/application/edit.html.erb deleted file mode 100644 index 4fac99a..0000000 --- a/app/views/admin/application/edit.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<%# -# Edit - -This view is the template for the edit page. - -It displays a header, and renders the `_form` partial to do the heavy lifting. - -## Local variables: - -- `page`: - An instance of [Administrate::Page::Form][1]. - Contains helper methods to help display a form, - and knows which attributes should be displayed in the resource's form. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form -%> - -<% content_for(:title) { "Edit #{page.page_title}" } %> - -
-

<%= content_for(:title) %>

-
- <%= link_to( - "Show #{page.page_title}", - [namespace, page.resource], - class: "button", - ) %> -
-
- -<%= render "form", page: page %> diff --git a/app/views/admin/application/index.html.erb b/app/views/admin/application/index.html.erb deleted file mode 100644 index 2dd2be7..0000000 --- a/app/views/admin/application/index.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -<%# -# Index - -This view is the template for the index page. -It is responsible for rendering the search bar, header and pagination. -It renders the `_table` partial to display details about the resources. - -## Local variables: - -- `page`: - An instance of [Administrate::Page::Collection][1]. - Contains helper methods to help display a table, - and knows which attributes should be displayed in the resource's table. -- `resources`: - An instance of `ActiveRecord::Relation` containing the resources - that match the user's search criteria. - By default, these resources are passed to the table partial to be displayed. -- `search_term`: - A string containing the term the user has searched for, if any. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection -%> - -<% content_for(:title) do %> - <%= display_resource_name(page.resource_name) %> -<% end %> - -<% content_for(:search) do %> - <%= render "search", search_term: search_term %> -<% end %> - -
-

<%= content_for(:title) %>

-
- <%= link_to( - "New #{page.resource_name.titleize.downcase}", - [:new, namespace, page.resource_name], - class: "button", - ) %> -
-
- -<%= render "collection", collection_presenter: page, resources: resources %> - -<%= paginate resources %> diff --git a/app/views/admin/application/new.html.erb b/app/views/admin/application/new.html.erb deleted file mode 100644 index 7ff3f60..0000000 --- a/app/views/admin/application/new.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<%# -# New - -This view is the template for the "new resource" page. -It displays a header, and then renders the `_form` partial -to do the heavy lifting. - -## Local variables: - -- `page`: - An instance of [Administrate::Page::Form][1]. - Contains helper methods to help display a form, - and knows which attributes should be displayed in the resource's form. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form -%> - -<% content_for(:title) { "New #{page.resource_name.titleize}" } %> - -
-

<%= content_for(:title) %>

-
- <%= link_to 'Back', :back, class: "button" %> -
-
- -<%= render 'form', page: page %> diff --git a/app/views/admin/application/show.html.erb b/app/views/admin/application/show.html.erb deleted file mode 100644 index b4e453b..0000000 --- a/app/views/admin/application/show.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<%# -# Show - -This view is the template for the show page. -It renders the attributes of a resource, -as well as a link to its edit page. - -## Local variables: - -- `page`: - An instance of [Administrate::Page::Show][1]. - Contains methods for accessing the resource to be displayed on the page, - as well as helpers for describing how each attribute of the resource - should be displayed. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show -%> - -<% content_for(:title) { page.page_title } %> - -
-

<%= content_for(:title) %>

-
- <%= link_to( - "Edit", - [:edit, namespace, page.resource], - class: "button", - ) %> -
-
- -
- <% page.attributes.each do |attribute| %> -
- <%= t( - "helpers.label.#{resource_name}.#{attribute.name}", - default: attribute.name.titleize, - ) %> -
- -
<%= render_field attribute %>
- <% end %> -
diff --git a/config/locales/administrate.en_GB.yml b/config/locales/administrate.en_GB.yml index 9d429a2..71ab348 100644 --- a/config/locales/administrate.en_GB.yml +++ b/config/locales/administrate.en_GB.yml @@ -6,6 +6,8 @@ destroy: Destroy edit: Edit show: Show + new: New + back: Back controller: create: success: "%{resource} was successfully created."