Skip to content

Commit d503b76

Browse files
authored
Merge pull request #399 from ncbo/copy_uri_fix
Resolves the issue with the 'copy-to-clipboard' (#390) and the issue with bad display of long values (#396)
2 parents 2447a8a + a202933 commit d503b76

File tree

8 files changed

+34
-39
lines changed

8 files changed

+34
-39
lines changed

app/assets/images/check.svg

+4
Loading

app/components/concept_details_component.rb

+14-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ def row_hash_properties(properties_set, ontology_acronym, &block)
4040

4141
values = data[:values]
4242
url = data[:key]
43-
44-
is_list = values.is_a?(Array) && values.size > 1
43+
style_as_badge = values.is_a?(Array) && values.size > 1 && short_values(values)
4544

4645
ajax_links = Array(values).map do |v|
4746
if block_given?
4847
capture(v, &block)
4948
else
5049
if v.is_a?(String)
51-
get_link_for_cls_ajax(v, ontology_acronym, '_blank', is_list)
50+
get_link_for_cls_ajax(v, ontology_acronym, '_blank', style_as_badge)
5251
else
5352
display_in_multiple_languages([v].to_h, style_as_badge: true)
5453
end
@@ -63,6 +62,18 @@ def row_hash_properties(properties_set, ontology_acronym, &block)
6362
out
6463
end
6564

65+
def short_values(vals)
66+
vals.each do |str|
67+
word_count = str.split.count
68+
character_count = str.length
69+
70+
unless word_count < 10 && character_count < 100
71+
return false
72+
end
73+
end
74+
true
75+
end
76+
6677
def properties_set_by_keys(keys, concept_properties, exclude_keys = [])
6778
concept_properties&.select do |k, v|
6879
(keys.include?(k) || !keys.select { |key| v[:key].to_s.include?(key) }.empty?) && !exclude_keys.include?(k) &&

app/controllers/admin_controller.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ class AdminController < ApplicationController
1414

1515
def index
1616
@users = LinkedData::Client::Models::User.all
17+
1718
if session[:user].nil? || !session[:user].admin?
1819
redirect_to controller: 'login', action: 'index', redirect: '/admin'
1920
else
21+
update_info(false)
2022
render action: 'index'
2123
end
2224
end
2325

24-
def update_info
26+
def update_info(render_response = true)
2527
response = { update_info: {}, errors: '', success: '', notices: '' }
2628
json = LinkedData::Client::HTTP.get("#{ADMIN_URL}update_info", params, raw: true)
2729

@@ -32,14 +34,15 @@ def update_info
3234
response[:errors] = update_info['error']
3335
response[:update_info] = update_info
3436
else
37+
@update_info = update_info.symbolize_keys
3538
response[:update_info] = update_info
3639
response[:notices] = update_info['notes'] if update_info['notes']
3740
response[:success] = 'Update info successfully retrieved'
3841
end
3942
rescue StandardError => e
4043
response[:errors] = "Problem retrieving update info - #{e.message}"
4144
end
42-
render json: response
45+
render json: response if render_response
4346
end
4447

4548
def update_check_enabled

app/helpers/application_helper.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,11 @@ def get_link_for_cls_ajax(cls_id, ont_acronym, target = nil, style_as_badge = fa
379379
if style_as_badge
380380
render ChipButtonComponent.new(text: cls_id)
381381
else
382-
content_tag(:span, cls_id)
382+
content_tag(:div, cls_id)
383383
end
384384
end
385385
end
386386

387-
388387
def get_link_for_ont_ajax(ont_acronym)
389388
# Ajax call will replace the acronym with an ontology name (triggered by class='ont4ajax')
390389
href_ont = " href='#{bp_ont_link(ont_acronym)}' "

app/javascript/controllers/clipboard_controller.js

-16
This file was deleted.

app/javascript/controllers/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ application.register("change-requests", ChangeRequestsController)
1919
import LanguageChangeController from "./language_change_controller"
2020
application.register("language-change", LanguageChangeController)
2121

22-
import ClipboardController from "./clipboard_controller"
23-
application.register("clipboard", ClipboardController)
22+
import ClipboardComponentController from '../../components/clipboard_component/clipboard_component_controller'
23+
application.register('clipboard', ClipboardComponentController)
2424

2525
import LoadChartController from "./load_chart_controller"
2626
application.register("load-chart", LoadChartController)

app/views/admin/index.html.haml

+5-9
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@
5656
%div#site-admin-appliance-id.mb-5
5757
%div.site-admin-page-header
5858
APPLIANCE ID
59-
%dive.site-admin-page-section
60-
%div{'data-controller': 'clipboard'}
61-
%div#appliance-id
62-
%span{'data-clipboard-target': 'source'}
63-
%div{class: 'd-flex align-items-center mt-2'}
64-
= tag.button('Copy to clipboard', 'data-action': 'clipboard#copy',
65-
class: 'btn btn-sm btn-outline-secondary')
66-
%span{'data-clipboard-target': 'copiedIndicator',
67-
class: 'hidden text-success fw-semibold ms-2'} Copied!
59+
%div.site-admin-page-section
60+
%div#appliance-id
61+
%span
62+
= content_tag(:span, style: 'display: inline-block;') do
63+
= render ClipboardComponent.new(message: @update_info[:appliance_id], title: 'Copy Appliance ID', show_content: false)
6864

6965
-# Ontology Administration tab
7066
%div.tab-pane.fade{id: "ontology-admin", role: "tabpanel", aria: { labelledby: "ontology-admin-tab" }}

app/views/users/show.html.haml

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
-# User's API key
3030
%h4{class: 'pb-2 my-4 border-bottom'} API Key
3131
= tag.p("Your API key can be used to access the #{$SITE} RESTful API and services", class: 'text-muted')
32-
%div{'data-controller': 'clipboard'}
33-
%span{'data-clipboard-target': 'source'}= session[:user].apikey
34-
%div{class: 'd-flex align-items-center mt-2'}
35-
= tag.button 'Copy to clipboard', 'data-action': 'clipboard#copy', class: 'btn btn-sm btn-outline-secondary'
36-
%span{'data-clipboard-target': 'copiedIndicator', class: 'hidden text-success fw-semibold ms-2'} Copied!
32+
= session[:user].apikey
33+
= content_tag(:span, style: 'display: inline-block;') do
34+
= render ClipboardComponent.new(message: session[:user].apikey, title: 'Copy API Key', show_content: false)
3735

3836
-# User's subscriptions
3937
- unless @user.subscription.blank?

0 commit comments

Comments
 (0)