diff --git a/app/controllers/admin/programme_activity_groupings_controller.rb b/app/controllers/admin/programme_activity_groupings_controller.rb new file mode 100644 index 0000000000..421ed7c679 --- /dev/null +++ b/app/controllers/admin/programme_activity_groupings_controller.rb @@ -0,0 +1,14 @@ +module Admin + class ProgrammeActivityGroupingsController < Admin::ApplicationController + def find_resource(param) + ProgrammeActivityGrouping.find_by!(id: param) + end + + def resource_params + params.require(resource_class.model_name.param_key).permit( + dashboard.permitted_attributes(action_name), + web_copy: {} + ) + end + end +end diff --git a/app/dashboards/pathway_activity_dashboard.rb b/app/dashboards/pathway_activity_dashboard.rb index bd4347fa19..b6cb12704f 100644 --- a/app/dashboards/pathway_activity_dashboard.rb +++ b/app/dashboards/pathway_activity_dashboard.rb @@ -59,7 +59,7 @@ class PathwayActivityDashboard < BaseDashboard # Overwrite this method to customize how pathway activities are displayed # across all pages of the admin dashboard. # - # def display_resource(pathway_activity) - # "PathwayActivity ##{pathway_activity.id}" - # end + def display_resource(pathway_activity) + "#{pathway_activity.activity.stem_activity_code} - #{pathway_activity.activity.title}" + end end diff --git a/app/dashboards/programme_activity_dashboard.rb b/app/dashboards/programme_activity_dashboard.rb new file mode 100644 index 0000000000..7f6a013f76 --- /dev/null +++ b/app/dashboards/programme_activity_dashboard.rb @@ -0,0 +1,74 @@ +require "administrate/base_dashboard" + +class ProgrammeActivityDashboard < Administrate::BaseDashboard + # ATTRIBUTE_TYPES + # a hash that describes the type of each of the model's fields. + # + # Each different type represents an Administrate::Field object, + # which determines how the attribute is displayed + # on pages throughout the dashboard. + ATTRIBUTE_TYPES = { + id: Field::String, + activity: Field::BelongsTo, + legacy: Field::Boolean, + order: Field::Number, + programme: Field::BelongsTo, + programme_activity_grouping: Field::BelongsTo, + created_at: Field::DateTime, + updated_at: Field::DateTime + }.freeze + + # COLLECTION_ATTRIBUTES + # an array of attributes that will be displayed on the model's index page. + # + # By default, it's limited to four items to reduce clutter on index pages. + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = %i[ + activity + legacy + order + ].freeze + + # SHOW_PAGE_ATTRIBUTES + # an array of attributes that will be displayed on the model's show page. + SHOW_PAGE_ATTRIBUTES = %i[ + id + activity + legacy + order + programme + programme_activity_grouping + created_at + updated_at + ].freeze + + # FORM_ATTRIBUTES + # an array of attributes that will be displayed + # on the model's form (`new` and `edit`) pages. + FORM_ATTRIBUTES = %i[ + activity + legacy + order + programme + programme_activity_grouping + ].freeze + + # COLLECTION_FILTERS + # a hash that defines filters that can be used while searching via the search + # field of the dashboard. + # + # For example to add an option to search for open resources by typing "open:" + # in the search field: + # + # COLLECTION_FILTERS = { + # open: ->(resources) { resources.where(open: true) } + # }.freeze + COLLECTION_FILTERS = {}.freeze + + # Overwrite this method to customize how programme activities are displayed + # across all pages of the admin dashboard. + # + def display_resource(programme_activity) + programme_activity.activity.title + end +end diff --git a/app/dashboards/programme_activity_grouping_dashboard.rb b/app/dashboards/programme_activity_grouping_dashboard.rb new file mode 100644 index 0000000000..d2d85951df --- /dev/null +++ b/app/dashboards/programme_activity_grouping_dashboard.rb @@ -0,0 +1,81 @@ +require "administrate/base_dashboard" +require "administrate/field/jsonb" + +class ProgrammeActivityGroupingDashboard < Administrate::BaseDashboard + # ATTRIBUTE_TYPES + # a hash that describes the type of each of the model's fields. + # + # Each different type represents an Administrate::Field object, + # which determines how the attribute is displayed + # on pages throughout the dashboard. + ATTRIBUTE_TYPES = { + id: Field::String, + activities: Field::HasMany, + community: Field::Boolean, + programme: Field::BelongsTo, + programme_activities: Field::HasMany, + progress_bar_title: Field::String, + required_for_completion: Field::Number, + sort_key: Field::Number, + title: Field::String, + web_copy: ProgrammeActivityGroupingJsonViewerField, + created_at: Field::DateTime, + updated_at: Field::DateTime + }.freeze + + # COLLECTION_ATTRIBUTES + # an array of attributes that will be displayed on the model's index page. + # + # By default, it's limited to four items to reduce clutter on index pages. + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = %i[ + title + programme + activities + community + ].freeze + + # SHOW_PAGE_ATTRIBUTES + # an array of attributes that will be displayed on the model's show page. + SHOW_PAGE_ATTRIBUTES = %i[ + title + progress_bar_title + programme + community + programme_activities + web_copy + ].freeze + + # FORM_ATTRIBUTES + # an array of attributes that will be displayed + # on the model's form (`new` and `edit`) pages. + FORM_ATTRIBUTES = %i[ + title + activities + community + programme + programme_activities + progress_bar_title + required_for_completion + web_copy + ].freeze + + # COLLECTION_FILTERS + # a hash that defines filters that can be used while searching via the search + # field of the dashboard. + # + # For example to add an option to search for open resources by typing "open:" + # in the search field: + # + # COLLECTION_FILTERS = { + # open: ->(resources) { resources.where(open: true) } + # }.freeze + COLLECTION_FILTERS = {}.freeze + + # Overwrite this method to customize how programme activity groupings are displayed + # across all pages of the admin dashboard. + # + def display_resource(programme_activity_grouping) + programme_activity_grouping.title.to_s + end +end diff --git a/app/fields/programme_activity_grouping_json_viewer_field.rb b/app/fields/programme_activity_grouping_json_viewer_field.rb new file mode 100644 index 0000000000..40664e0ea5 --- /dev/null +++ b/app/fields/programme_activity_grouping_json_viewer_field.rb @@ -0,0 +1,3 @@ +require "administrate/field/base" + +class ProgrammeActivityGroupingJsonViewerField < Administrate::Field::Base; end diff --git a/app/views/fields/programme_activity_grouping_json_viewer_field/_form.html.erb b/app/views/fields/programme_activity_grouping_json_viewer_field/_form.html.erb new file mode 100644 index 0000000000..da5ec183a2 --- /dev/null +++ b/app/views/fields/programme_activity_grouping_json_viewer_field/_form.html.erb @@ -0,0 +1,14 @@ +
| + <%= f.label "web_copy[#{k}]", k.humanize %> + | ++ <%= f.text_field "web_copy[#{k}]", value: v %> + | +
|---|