-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display an icon for imported fields in metadata.
- Loading branch information
1 parent
6e7a10f
commit 70280fa
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,7 @@ li[dir=rtl] { | |
margin-top: -1px; | ||
} | ||
} | ||
|
||
.import-tooltip { | ||
margin-left: 10px; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/views/spotlight/metadata_configurations/_metadata_field.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<tr data-id="<%= key.parameterize %>" class="dd-item"> | ||
<%= f.fields_for key do |field| %> | ||
<td> | ||
<%= field.hidden_field :weight, 'data-property' => 'weight' %> | ||
<div class="handle-wrap" data-in-place-edit-target=".edit-in-place" data-in-place-edit-field-target="[data-edit-field-target='true']"> | ||
<div class="dd-handle dd3-handle"><%= t :drag %></div> | ||
<a href="#edit-in-place" class="field-label edit-in-place"><%= index_field_label(nil, key) %></a> | ||
<%- if @exhibit.custom_fields.vocab.map(&:field).include?(key) %> | ||
<span class="import-tooltip glyphicon glyphicon-import" title="Imported from Plum" data-toggle="tooltip"></span> | ||
<% end %> | ||
<%= field.hidden_field :label, value: index_field_label(nil, key), class: 'form-control input-sm', data: {:"edit-field-target" => 'true'} %> | ||
</div> | ||
</td> | ||
<td class="checkbox-cell text-center"><%= field.check_box :show, inline: true, checked: config.show, label: "" %></td> | ||
<% available_view_fields.keys.each do |type| %> | ||
<td class="checkbox-cell text-center"><%= field.check_box type, inline: true, checked: config.send(type), label: "" %></td> | ||
<% end %> | ||
<% end %> | ||
</tr> |
35 changes: 35 additions & 0 deletions
35
spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'spotlight/metadata_configurations/_metadata_field', type: :view do | ||
let(:exhibit) { FactoryGirl.create(:exhibit) } | ||
let(:p) { 'spotlight/metadata_configurations/metadata_field.html.erb' } | ||
before do | ||
assign(:exhibit, exhibit) | ||
assign(:blacklight_configuration, exhibit.blacklight_configuration) | ||
allow(view).to receive_messages( | ||
current_exhibit: exhibit, | ||
blacklight_config: exhibit.blacklight_configuration, | ||
available_view_fields: { some_view_type: 1, another_view_type: 2 }, | ||
select_deselect_button: nil | ||
) | ||
end | ||
|
||
let(:facet_field) { Blacklight::Configuration::FacetField.new } | ||
let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} } | ||
|
||
it 'renders a tooltip for imported fields' do | ||
Spotlight::CustomField.create!(exhibit: exhibit, slug: "two", field: "two", label: "two", field_type: "vocab", readonly_field: true) | ||
allow(view).to receive(:index_field_label).with(nil, 'two').and_return 'Some label' | ||
render partial: p, locals: { key: 'two', config: facet_field, f: builder } | ||
|
||
expect(rendered).to have_selector '.import-tooltip' | ||
end | ||
|
||
it "doesn't render a tooltip for writeable fields" do | ||
Spotlight::CustomField.create!(exhibit: exhibit, slug: "two", field: "two", label: "two", field_type: "vocab", readonly_field: false) | ||
allow(view).to receive(:index_field_label).with(nil, 'two').and_return 'Some label' | ||
render partial: p, locals: { key: 'two', config: facet_field, f: builder } | ||
|
||
expect(rendered).to have_selector '.import-tooltip' | ||
end | ||
end |