Skip to content

Commit

Permalink
table row selector controller to look for a string in a baserow table
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Oct 9, 2024
1 parent 1eb98b1 commit c12d53b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/controllers/champs/table_row_selector_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class Champs::TableRowSelectorController < ApplicationController
before_action :authenticate_logged_user!

def search
@params = search_params
if bad_parameters
render json: [], status: 400
else
render json: TableRowSelector::API.search(@params[:domain], @params[:term])
end
end

def bad_parameters
@params[:domain].blank? || @params[:domain].to_i == 0 || @params[:term].blank?
end

def search_params = params.permit(:domain, :term)
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
post ':dossier_id/:stable_id/repetition', to: 'repetition#add', as: :repetition
delete ':dossier_id/:stable_id/repetition', to: 'repetition#remove'

get 'table_row_selector/search', to: 'table_row_selector#search'

get ':dossier_id/:stable_id/siret', to: 'siret#show', as: :siret
get ':dossier_id/:stable_id/rna', to: 'rna#show', as: :rna
delete ':dossier_id/:stable_id/options', to: 'options#remove', as: :options
Expand Down

0 comments on commit c12d53b

Please sign in to comment.