Sha256: 6bc2a28fefab2d04203762cc3983a28f767ab97df19cd3663c4bc421b8b62e39
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module Api module V1 class FileAssetsController < BaseController def index sort_hash = params[:sort].blank? ? {} : Hash.symbolize_keys(JSON.parse(params[:sort]).first) sort = sort_hash[:property] || 'description' dir = sort_hash[:direction] || 'ASC' limit = params[:limit] || 25 start = params[:start] || 0 query_filter = params[:query_filter].blank? ? {} : JSON.parse(params[:query_filter]).symbolize_keys # apply filters file_assets = FileAsset.apply_filters(query_filter) # if no file asset holder was passed we need to scope by dba_organization if !query_filter[:file_asset_holder_type].present? && !query_filter[:file_asset_holder_id].present? file_assets = file_assets.scope_by_dba_org(current_user.party.dba_organization) end total_count = file_assets.count file_assets = file_assets.limit(limit).offset(start) file_assets.order("#{sort} #{dir}") render json: {success: true, total_count: total_count, file_assets: file_assets.collect { |file| file.to_data_hash }} end def destroy file_asset = FileAsset.find(params[:id]) file_asset.destroy render json: {success: true} end end # FileAssetsController end # V1 end # Api
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_tech_svcs-4.2.0 | app/controllers/api/v1/file_assets_controller.rb |