From 066c8876ffbb675e3272863efa5ba5878e12e473 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 12 Jun 2015 15:49:01 +0800 Subject: [PATCH] Only serializing unresolved enterprise issues, styling tweaks and fixes for index --- .../enterprise_index_row_controller.js.coffee | 16 +++--- .../index_status_panel_controller.js.coffee | 4 +- .../admin/panels/enterprise_status.html.haml | 2 +- .../admin/enterprise_index_panels.css.scss | 2 + .../stylesheets/admin/index_panels.css.scss | 23 +++++---- .../api/admin/index_enterprise_serializer.rb | 50 ++++++++++--------- .../_enterprise_user_index.html.haml | 2 +- 7 files changed, 51 insertions(+), 48 deletions(-) diff --git a/app/assets/javascripts/admin/enterprises/controllers/enterprise_index_row_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/enterprise_index_row_controller.js.coffee index 226438c434..63b8daf07c 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/enterprise_index_row_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/enterprise_index_row_controller.js.coffee @@ -1,14 +1,11 @@ angular.module("admin.enterprises").controller "EnterpriseIndexRowCtrl", ($scope) -> - $scope.statusText = -> - issueCount = (issue for issue in $scope.enterprise.issues when !issue.resolved).length - if issueCount > 0 - $scope.statusClass = "issue" + $scope.status = -> + if $scope.enterprise.issues.length > 0 + "issue" + else if $scope.enterprise.warnings.length > 0 + "warning" else - warningCount = (warning for warning in $scope.enterprise.warnings when !warning.resolved).length - if warningCount > 0 - $scope.statusClass = "warning" - else - $scope.statusClass = "ok" + "ok" $scope.producerText = -> @@ -42,7 +39,6 @@ angular.module("admin.enterprises").controller "EnterpriseIndexRowCtrl", ($scope $scope.updateRowText = -> $scope.producer = $scope.producerText() $scope.package = $scope.packageText() - $scope.status = $scope.statusText() $scope.producerError = ($scope.producer == "Choose") $scope.packageError = ($scope.package == "Choose") diff --git a/app/assets/javascripts/admin/enterprises/controllers/index_status_panel_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/index_status_panel_controller.js.coffee index 7a0765e29b..987a206bd0 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/index_status_panel_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/index_status_panel_controller.js.coffee @@ -1,3 +1,3 @@ angular.module("admin.enterprises").controller 'indexStatusPanelCtrl', ($scope, $filter) -> - $scope.issues = $filter('filter')($scope.object.issues, {resolved: false }) - $scope.warnings = $filter('filter')($scope.object.warnings, {resolved: false}) + $scope.issues = $scope.object.issues + $scope.warnings = $scope.object.warnings diff --git a/app/assets/javascripts/templates/admin/panels/enterprise_status.html.haml b/app/assets/javascripts/templates/admin/panels/enterprise_status.html.haml index 63f416f091..5c673a7e00 100644 --- a/app/assets/javascripts/templates/admin/panels/enterprise_status.html.haml +++ b/app/assets/javascripts/templates/admin/panels/enterprise_status.html.haml @@ -21,7 +21,7 @@ %td.resolve %div{ ng: { bind: { html: "issue.link" } } } %tr{ ng: { repeat: "warning in warnings"} } - %td.severity.text-center + %td.severity %i.icon-warning-sign.warning %td.description %span{ bo: { bind: "warning.description" } } diff --git a/app/assets/stylesheets/admin/enterprise_index_panels.css.scss b/app/assets/stylesheets/admin/enterprise_index_panels.css.scss index 665a806ce8..2ce2916497 100644 --- a/app/assets/stylesheets/admin/enterprise_index_panels.css.scss +++ b/app/assets/stylesheets/admin/enterprise_index_panels.css.scss @@ -96,6 +96,8 @@ } td.severity { + text-align: center; + i { font-size: 1.5rem; diff --git a/app/assets/stylesheets/admin/index_panels.css.scss b/app/assets/stylesheets/admin/index_panels.css.scss index 8694c96dd6..735226fb35 100644 --- a/app/assets/stylesheets/admin/index_panels.css.scss +++ b/app/assets/stylesheets/admin/index_panels.css.scss @@ -59,16 +59,6 @@ tr.panel-toggle-row { } } - &.selected { - background-color: #ffffff; - border-left: 2px solid #444444; - border-right: 2px solid #444444; - border-top: 2px solid #444444; - * { - color: #1b3c56; - } - } - &:hover { cursor: pointer; background-color: #d0e2f6; @@ -87,10 +77,23 @@ tr.panel-toggle-row { border-bottom: 2px solid #444444; &.selected { + background-color: #ffffff; + border-left: 2px solid #444444; + border-right: 2px solid #444444; + border-top: 2px solid #444444; border-bottom: none; + &:hover { background-color: #ffffff; } + + * { + color: #1b3c56; + } + + i.status::before { + opacity: 1.0; + } } } } diff --git a/app/serializers/api/admin/index_enterprise_serializer.rb b/app/serializers/api/admin/index_enterprise_serializer.rb index a252557208..777ddd6469 100644 --- a/app/serializers/api/admin/index_enterprise_serializer.rb +++ b/app/serializers/api/admin/index_enterprise_serializer.rb @@ -23,32 +23,34 @@ class Api::Admin::IndexEnterpriseSerializer < ActiveModel::Serializer end def issues - [ - { - resolved: shipping_methods_ok?, - description: "#{object.name} currently has no shipping methods.", - link: "Create New" - }, - { - resolved: payment_methods_ok?, - description: "#{object.name} currently has no payment methods.", - link: "Create New" - }, - { - resolved: object.confirmed?, - description: "Email confirmation is pending. We've sent a confirmation email to #{object.email}.", - link: "Resend Email" - } - ] + issues = [] + + issues << { + description: "#{object.name} currently has no shipping methods.", + link: "Create New" + } unless shipping_methods_ok? + + issues << { + description: "#{object.name} currently has no payment methods.", + link: "Create New" + } unless shipping_methods_ok? + + issues << { + description: "Email confirmation is pending. We've sent a confirmation email to #{object.email}.", + link: "Resend Email" + } unless object.confirmed? + + issues end def warnings - [ - { - resolved: object.visible, - description: "#{object.name} is not visible and so cannot be found on the map or in searches", - link: "Edit" - } - ] + warnings = [] + + warnings << { + description: "#{object.name} is not visible and so cannot be found on the map or in searches", + link: "Edit" + } unless object.visible + + warnings end end diff --git a/app/views/admin/enterprises/_enterprise_user_index.html.haml b/app/views/admin/enterprises/_enterprise_user_index.html.haml index 3eaff9dc13..543b912f23 100644 --- a/app/views/admin/enterprises/_enterprise_user_index.html.haml +++ b/app/views/admin/enterprises/_enterprise_user_index.html.haml @@ -50,7 +50,7 @@ %h5{ ng: { bind: "producer" } } %td.package.panel-toggle.text-center{ ng: { show: 'columns.package.visible', class: "{error: packageError}" }, name: "package" } %h5{ ng: { bind: "package" } } - %td.status.panel-toggle.text-center{ ng: { show: 'columns.status.visible' }, bo: { class: "statusClass" }, name: "status" } + %td.status.panel-toggle.text-center{ ng: { show: 'columns.status.visible' }, name: "status" } %i.status{ bo: { class: "status" } } %td.manage{ ng: { show: 'columns.manage.visible' } } %a.button.fullwidth{ bo: { href: 'enterprise.edit_path' } }