Skip to content

Commit

Permalink
Add config for work_file_required, fixes #1715
Browse files Browse the repository at this point in the history
  • Loading branch information
hackartisan committed Aug 10, 2016
1 parent 28b0bf7 commit 2f82db6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/sufia/save_work/save_work_control.es6
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export class SaveWorkControl {

// sets the files indicator to complete/incomplete
validateFiles() {
if (!this.uploads.hasFileRequirement) {
return true
}
if (!this.isNew || this.uploads.hasFiles) {
this.requiredFiles.check()
return true
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/sufia/save_work/uploaded_files.es6
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export class UploadedFiles {
$('#fileupload').bind('fileuploadcompleted', callback)
}

get hasFileRequirement() {
let fileRequirement = this.form.find('li#required-files')
return fileRequirement.size() > 0
}

get hasFiles() {
let fileField = this.form.find('input[name="uploaded_files[]"]')
return fileField.size() > 0
Expand Down
4 changes: 3 additions & 1 deletion app/views/curation_concerns/base/_form_progress.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<legend class="legend-save-work">Requirements</legend>
<ul class="requirements">
<li class="incomplete" id="required-metadata">Enter required metadata</li>
<li class="incomplete" id="required-files">Add files</li>
<% if Sufia.config.work_requires_files %>
<li class="incomplete" id="required-files">Add files</li>
<% end %>
</ul>
</fieldset>
</div>
Expand Down
5 changes: 5 additions & 0 deletions lib/generators/sufia/templates/config/sufia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
# The default is true.
# config.active_deposit_agreement_acceptance = true

# Should work creation require file upload, or can a work be created first
# and a file added at a later time?
# The default is true.
# config.work_requires_files = true

# Should a button with "Share my work" show on the front page to all users (even those not logged in)?
# config.always_display_share_button = true

Expand Down
6 changes: 6 additions & 0 deletions lib/sufia/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def active_deposit_agreement_acceptance
@active_deposit_agreement_acceptance
end

attr_writer :work_requires_files
def work_requires_files
return true if @work_requires_files.nil?
@work_requires_files
end

attr_writer :batch_user_key
def batch_user_key
@batch_user_key ||= 'batchuser@example.com'
Expand Down

0 comments on commit 2f82db6

Please sign in to comment.