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

ANW-1498: update frontend so setting representative and published are linked #2651

Merged
merged 2 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/app/assets/javascripts/representativemembers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ $(function () {
var eventName =
'newrepresentative' + object_name.replace(/_/, '') + '.aspace';

$subform.find('.js-file-version-publish').click(function (e) {
if (
$subform.hasClass('is-representative') &&
$(this).prop('checked', true)
) {
handleRepresentativeChange($subform, false);
$(this).prop('checked', false);
}
});

$subform.find('.is-representative-toggle').click(function (e) {
var local_publish_button = $subform.find('.js-file-version-publish');

local_publish_button.prop('checked', true);
});

if (isRepresentative) {
$subform.addClass('is-representative');
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/file_versions/_template.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<button class="btn btn-small is-representative-toggle"><%= I18n.t("file_version._frontend.action.make_representative") %></button>
</h3>
<%= form.label_and_textarea("file_uri") %>
<%= form.label_and_boolean("publish", {}, user_prefs["publish"]) %>
<%= form.label_and_boolean("publish", {:class => "js-file-version-publish"}, user_prefs["publish"]) %>
<%= form.label_and_select("use_statement", form.possible_options_for("use_statement", true)) %>
<%= form.label_and_select("xlink_actuate_attribute", form.possible_options_for("xlink_actuate_attribute", true)) %>
<%= form.label_and_select("xlink_show_attribute", form.possible_options_for("xlink_show_attribute", true)) %>
Expand Down
27 changes: 27 additions & 0 deletions frontend/spec/selenium/spec/digital_objects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@
@driver.click_and_wait_until_gone(:link, 'Edit')
end

it "sets published when make representative is checked, and vice versa" do
@driver.find_element(:link, 'Create').click
@driver.click_and_wait_until_gone(:link, 'Digital Object')

@driver.clear_and_send_keys([:id, 'digital_object_title_'], digital_object_title)
@driver.clear_and_send_keys([:id, 'digital_object_digital_object_id_'], Digest::MD5.hexdigest(Time.now.to_s))

@driver.find_element(id: 'digital_object_digital_object_type_').select_option_with_text('Mixed Materials')

@driver.find_element(css: 'section#digital_object_file_versions_ > h3 > .btn:not(.show-all)').click

@driver.clear_and_send_keys([:id, 'digital_object_file_versions__0__file_uri_'], '/uri/for/this/file/version')
@driver.clear_and_send_keys([:id, 'digital_object_file_versions__0__file_size_bytes_'], '100')

@driver.click_and_wait_until_gone(css: "form#new_digital_object button[type='submit']")

# make sure publish is checked when is representative is checked
@driver.find_element(css: '.is-representative-toggle').click
publish_box = @driver.find_element(css: '.js-file-version-publish')
expect(publish_box.attribute('checked')).to_not be_nil

# make sure is representative is unchecked with publish is unchecked
publish_box.click
subform = @driver.find_element(id: 'digital_object_file_versions__0_')
expect(subform.attribute('class')).to_not include('is-representative')
end

it 'reports errors if adding a child with no title to a Digital Object' do
@driver.get_edit_page(@do2)
@driver.find_element(:link, 'Add Child').click
Expand Down