Class: DashboardController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DashboardController
- Defined in:
- app/controllers/dashboard_controller.rb
Overview
Copyright 2011-2013 innoQ Deutschland GmbH
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
Instance Method Details
#collection_index ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/dashboard_controller.rb', line 43 def collection_index :use, :dashboard collections = Iqvoc::Collection.base_class.for_dashboard.load if params[:sort] && params[:sort].include?('state ') sort = params[:sort].split(',').select { |s| s.include? 'state ' }.last.gsub('state ', '') collections = collections.to_a.sort_by { |c| c.state } collections = sort == 'DESC' ? collections.reverse : collections elsif params[:sort] order_params = sanatize_order params[:sort] order_params = order_params.gsub('value', 'labels.value').gsub('updated_at', 'concepts.updated_at') collections = collections.includes(:pref_labels).references(:pref_labels).order(order_params) else collections = collections.includes(:pref_labels).order('labels.value') end @items = Kaminari.paginate_array(collections).page(params[:page]) render 'index', locals: { active_class: Iqvoc::Collection.base_class } end |
#concept_index ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/dashboard_controller.rb', line 18 def concept_index :use, :dashboard concepts = Iqvoc::Concept.base_class.for_dashboard.load if params[:sort] && params[:sort].include?('state ') sort = params[:sort].split(',').select { |s| s.include? 'state ' }.last.gsub('state ', '') concepts = concepts.to_a.sort_by { |c| c.state } concepts = sort == 'DESC' ? concepts.reverse : concepts elsif params[:sort] order_params = params[:sort] #FIXME: how to order by state in database? order_params = sanatize_order order_params order_params = order_params.gsub('value', 'labels.value').gsub('follow_up', 'concepts.follow_up').gsub('updated_at', 'concepts.updated_at') concepts = concepts.includes(:pref_labels).references(:pref_labels).order(order_params) else concepts = concepts.includes(:pref_labels).order('labels.value') end @items = Kaminari.paginate_array(concepts).page(params[:page]) render 'index', locals: { active_class: Iqvoc::Concept.base_class } end |
#glance ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/dashboard_controller.rb', line 66 def glance :use, :dashboard objects = params[:type].constantize.by_origin(params[:origin]) object = objects.send(params[:published] == "1" ? 'published' : 'unpublished').first @title = object.to_s @editorial_notes = object.notes_for_class(Note::SKOS::EditorialNote) @path = send(object.class_path, id: object, published: params[:published]) respond_to do |format| format.html do render layout: false end end end |
#reset ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/dashboard_controller.rb', line 83 def reset :reset, :thesaurus if request.post? DatabaseCleaner.strategy = :truncation, { except: Iqvoc.truncation_blacklist } DatabaseCleaner.clean flash.now[:success] = t('txt.views.dashboard.reset_success') else flash.now[:danger] = t('txt.views.dashboard.reset_warning') flash.now[:error] = t('txt.views.dashboard.jobs_pending_warning') if Delayed::Job.any? end end |