Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started adding auto complete to contributors #1994

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
use serviceURL
claudiawulee committed Nov 26, 2024
commit 4cb34584ec1a66f72cc7f6c47d3fc1f253ea97eb
15 changes: 15 additions & 0 deletions app/controllers/creators_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true
class CreatorsController < ApplicationController
before_action :authenticate_user!

def ajax_list
creators = { suggestions: [
{ value: 'Claudia', data: 'cl7359' },
{ value: 'Hector', data: 'hc8719' },
{ value: 'Kate', data: 'klynch' },
{ value: 'Jaymee', data: 'jhypolitte' }
]
}
render json: creators.to_json
end
end
10 changes: 2 additions & 8 deletions app/views/works/_required_creators_table.html.erb
Original file line number Diff line number Diff line change
@@ -78,17 +78,11 @@
</div>

<script>
var creators = [
{ value: 'Claudia', data: 'cl7359' },
{ value: 'Hector', data: 'hc8719' },
{ value: 'Kate', data: 'klynch' },
{ value: 'Jaymee', data: 'jhypolitte' }
];

// debugger;
// Documentation: https://github.com/devbridge/jQuery-Autocomplete
$('#creator-row-givenname').devbridgeAutocomplete({
serviceUrl: 'http://localhost:3000/creators/ajax-list',
serviceUrl: '/creators/ajax-list',
// lookup: creators,
onSelect: function (suggestion) {
$("#creator-row-familyname").val(suggestion.data);
}
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -93,7 +93,10 @@

get "/collections/:id", to: redirect("/groups/%{id}"), as: :collections
get "/reports/dataset-list", to: "reports#dataset_list", as: :reports_dataset_list


# creators
get "creators/ajax-list", to: "creators#ajax_list", as: :creators_ajax_list

# Anything still unmatched by the end of the routes file should go to the not_found page
# match '*a', to: redirect('/404'), via: :get