From 6d682ae928eb89d083b05279ee0f6f97a3bebf23 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 25 Jan 2018 15:27:07 +0100 Subject: ComplianceCheckSetDecorator: Convert to new action links interface Refs #5586 --- app/controllers/compliance_check_sets_controller.rb | 5 ++--- app/decorators/compliance_check_set_decorator.rb | 12 +++++------- app/views/compliance_check_sets/index.html.slim | 1 - app/views/compliance_check_sets/show.html.slim | 13 +------------ 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb index 4ec86f0d6..9882d6aca 100644 --- a/app/controllers/compliance_check_sets_controller.rb +++ b/app/controllers/compliance_check_sets_controller.rb @@ -11,9 +11,8 @@ class ComplianceCheckSetsController < ChouetteController scope = self.ransack_period_range(scope: @compliance_check_sets, error_message: t('compliance_check_sets.filters.error_period_filter'), query: :where_created_at_between) @q_for_form = scope.ransack(params[:q]) format.html { - @compliance_check_sets = ModelDecorator.decorate( - @q_for_form.result.order(created_at: :desc), - with: ComplianceCheckSetDecorator + @compliance_check_sets = ComplianceCheckSetDecorator.decorate( + @q_for_form.result.order(created_at: :desc) ) } end diff --git a/app/decorators/compliance_check_set_decorator.rb b/app/decorators/compliance_check_set_decorator.rb index c58e14d88..1a9c19546 100644 --- a/app/decorators/compliance_check_set_decorator.rb +++ b/app/decorators/compliance_check_set_decorator.rb @@ -1,15 +1,13 @@ -class ComplianceCheckSetDecorator < Draper::Decorator - delegate_all - - def action_links - links = [] +class ComplianceCheckSetDecorator < AF83::Decorator + with_instance_decorator do |instance_decorator| + instance_decorator.show_action_link end - def lines_status + define_instance_method :lines_status do object.compliance_check_resources.where(status: :OK, resource_type: :line).count end - def lines_in_compliance_check_set + define_instance_method :lines_in_compliance_check_set do object.compliance_check_resources.where(resource_type: :line).count end diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index f15e85bdd..ead467174 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -41,7 +41,6 @@ ), \ ], sortable: true, - links: [:show], cls: 'table has-filter has-search' - unless @compliance_check_sets.any? .row.mt-xs diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim index 4db2e805f..4df14ab06 100644 --- a/app/views/compliance_check_sets/show.html.slim +++ b/app/views/compliance_check_sets/show.html.slim @@ -1,15 +1,4 @@ -- breadcrumb :compliance_check_set, @workbench, @compliance_check_set -/ PageHeader -- content_for :page_header_content do - .row - .col-lg-12.text-right.mb-sm - - @compliance_check_set.action_links.each do |link| - = link_to link.href, - method: link.method, - data: link.data, - class: 'btn btn-primary' do - = link.content - +- breadcrumb :compliance_check_sets, @workbench, @compliance_check_set - page_header_content_for @compliance_check_set / PageContent -- cgit v1.2.3