Module: KirguduBase::Controllers::BasicActions::Common

Defined in:
app/helpers/kirgudu_base/controllers/basic_actions.rb

Defined Under Namespace

Modules: Ajax

Instance Method Summary collapse

Instance Method Details

#kb_dp_breadcrumbs_build_for_index(local_data, is_index_page) ⇒ Object



1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
# File 'app/helpers/kirgudu_base/controllers/basic_actions.rb', line 1145

def kb_dp_breadcrumbs_build_for_index(local_data, is_index_page)
  # getting home controller
  local_home_path = self.class.get_method_latest_result(:get_kb_home_path)

  if is_index_page
    if local_home_path
      if self.class == local_home_path
        add_new_breadcrumb(I18n.t("#{local_home_path.to_i18n}.index.title"))
      else
        add_new_breadcrumb(I18n.t("#{local_home_path.to_i18n}.index.title"), local_home_path.to_url_for(:index))
      end
    end
  else
    add_new_breadcrumb(I18n.t("#{local_home_path.to_i18n}.index.title"), local_home_path.to_url_for(:index))
  end if local_home_path

  # building breadcrumbs for parents
  parent_ids = {}
  local_data[:parents].each do |parent|
    # breadcrumbs: adding parent index
    add_new_breadcrumb(I18n.t("#{parent[:controller].to_i18n}.index.title"), parent[:controller].to_url_for(:index, parent_ids))
    # breadcrumbs: getting parent entry name
    parent_entry_name = nil
    parent_entry_name = parent[:entry].name_for_breadcrumbs if parent[:entry].respond_to?(:name_for_breadcrumbs)
    parent_entry_name = parent[:entry].id unless parent_entry_name
    # breadcrumbs: adding parent entry
    add_new_breadcrumb(parent_entry_name, parent[:controller].to_url_for(:show, parent_ids.merge(id: parent[:entry].id)))
    parent_ids[parent[:id_param]] = parent[:id_value]
  end if local_data[:parents]

  # breadcrumbs: adding current index
  add_new_breadcrumb(I18n.t("#{self.to_i18n}.index.title"), self.to_url_for(:index, local_data[:parent_ids]))

  unless is_index_page
    # breadcrumbs: getting entry name
    entry_name = nil
    entry_name = local_data[:entry].name_for_breadcrumbs if local_data[:entry].respond_to?(:name_for_breadcrumbs)
    #entry_name.trim(20) if entry_name && entry_name.length > 20
    # breadcrumbs: adding current entry
    page_name = local_data[:page].name
    if page_name == :edit
      add_new_breadcrumb(local_data[:entry].id)
    elsif page_name == :show || page_name == :delete
      add_new_breadcrumb(entry_name || local_data[:entry].id)
    elsif page_name == :new
      add_new_breadcrumb(I18n.t("#{self.to_i18n}.new.title"))
    elsif page_name == :management
      add_new_breadcrumb(I18n.t("#{self.to_i18n}.management.title"))
    elsif page_name == :sorting
      add_new_breadcrumb(I18n.t("#{self.to_i18n}.sorting.title"))
    end
  end
end

#kb_dp_render_page_404Object



1136
1137
1138
1139
1140
1141
1142
# File 'app/helpers/kirgudu_base/controllers/basic_actions.rb', line 1136

def kb_dp_render_page_404
  respond_to do |format|
    #format.html { render_html1 "#{self.class.get_method_latest_result(:get_kb_template)}/#{self.class.get_method_latest_result(:get_kb_view_path, :page_404)}" }
    format.html { render_html1 self.get_view_path(:page_404), layout: self.get_view_path(:layout) }
    format.json { render_json_page_404 }
  end
end