Class: Workarea::Admin::ApplicationController

Inherits:
Workarea::ApplicationController
  • Object
show all
Includes:
AdminGuestBrowsing, Authentication, Authorization, CurrentRelease, Impersonation, Turbolinks::Controller, Publishing, Visiting
Defined in:
app/controllers/workarea/admin/application_controller.rb

Direct Known Subclasses

ActivitiesController, BookmarksController, BulkActionDeletionsController, BulkActionProductEditsController, BulkActionSequentialProductEditsController, BulkActionsController, CatalogCategoriesController, CatalogProductCopiesController, CatalogProductImagesController, CatalogProductsController, CatalogVariantsController, CategorizationsController, ChangesetsController, CommentsController, ContentAssetsController, ContentBlockDraftsController, ContentBlocksController, ContentController, ContentEmailsController, ContentPagesController, ContentPresetsController, CreateCatalogCategoriesController, CreateCatalogProductsController, CreateContentPagesController, CreatePricingDiscountsController, CreateReleasesController, CreateUsersController, DashboardsController, DataFileExportsController, DataFileImportsController, DataFileTaxImportsController, DataFilesController, DirectUploadsController, EmailSignupsController, FeaturedProductsController, FulfillmentsController, GuestBrowsingsController, HelpAssetsController, HelpController, ImpersonationsController, InventorySkusController, JumpToController, NavigationMenusController, NavigationRedirectsController, NavigationTaxonsController, OrdersController, PaymentTransactionsController, PaymentsController, PricesController, PricingDiscountCodeListsController, PricingDiscountsController, PricingOverridesController, PricingSkusController, ProductRulesController, RecommendationsController, ReleasablesController, ReleaseSessionsController, ReleasesController, ReportsController, SearchCustomizationsController, SearchSettingsController, SearchesController, ShippingServicesController, ShippingsController, StyleGuidesController, TaxCategoriesController, TaxRatesController, TimelineController, ToolbarController, TrashController, UsersController

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Class Method Details

.wrap_in_view_model(model, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/workarea/admin/application_controller.rb', line 28

def self.wrap_in_view_model(model, options = {})
  prefixes = [
    model.model_name.name.demodulize,
    model.model_name.param_key.camelize
  ]

  prefixes.each do |prefix|
    begin
      view_model_class_name = "Workarea::Admin::#{prefix}ViewModel"
      klass = view_model_class_name.constantize
      return klass.new(model, options)
    rescue NameError
      model
    end
  end

  model
end

Instance Method Details

#current_userObject



63
64
65
66
67
68
69
# File 'app/controllers/workarea/admin/application_controller.rb', line 63

def current_user
  if impersonating? || admin_browsing_as_guest?
    current_admin
  else
    super
  end
end

#find_sort(klass) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/workarea/admin/application_controller.rb', line 51

def find_sort(klass)
  result = params[:sort].presence || klass.sorts.first.to_s

  klass.sorts.map do |sortable|
    if sortable.to_s == result
      return [sortable.field, sortable.direction]
    end
  end

  [:created_at, :desc]
end

#wrap_in_view_model(*args) ⇒ Object



47
48
49
# File 'app/controllers/workarea/admin/application_controller.rb', line 47

def wrap_in_view_model(*args)
  self.class.wrap_in_view_model(*args)
end