Skip to content

Commit

Permalink
add an optional caption field to file_version
Browse files Browse the repository at this point in the history
  • Loading branch information
quoideneuf committed Feb 9, 2016
1 parent 37182d7 commit 442c3e0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions backend/spec/model_digital_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,21 @@

end


it "supports optional captions for file versions" do
obj = create(:json_digital_object, {
:publish => true,
:file_versions => [build(:json_file_version, {
:publish => true,
:file_uri => 'http://foo.com/bar1',
:caption => "bar one"
})]
})

obj = JSONModel(:digital_object).find(obj.id)


obj.file_versions.first['caption'].should eq("bar one");
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
alter_table(:file_version) do
add_unique_constraint([:is_representative, :digital_object_id],
:name => "digital_object_one_representative_file_version")
add_column(:caption, String, :null => true)

end
end
Expand Down
1 change: 1 addition & 0 deletions common/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ en:
<li>SHA-256</li>
</ul>
identifier: Identifier
caption: Caption

extent: &extent_attributes
portion: Portion
Expand Down
2 changes: 1 addition & 1 deletion common/schemas/file_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

"checksum" => {"type" => "string", "maxLength" => 255},
"checksum_method" => {"type" => "string", "dynamic_enum" => "file_version_checksum_methods"},

"caption" => {"type" => "string", "maxLength" => 16384},
},
},
}
2 changes: 2 additions & 0 deletions frontend/app/views/file_versions/_template.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@

<%= form.label_and_textfield("checksum") %>
<%= form.label_and_select("checksum_method", form.possible_options_for("checksum_method", true)) %>

<%= form.label_and_textfield("caption") %>
</div>
<% end %>
2 changes: 2 additions & 0 deletions public-new/app/assets/javascripts/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var app = app || {};

this.representativeImage = _.get(model, 'attributes.representative_image.file_uri') || "https://s-media-cache-ak0.pinimg.com/736x/2b/bf/e5/2bbfe51b1761d2dd0e88e5a540722451.jpg";

this.representativeImageCaption = _.get(model, 'attributes.representative_image.caption') || "Optional image, with caption";

if(model.attributes.title) {
this.title = model.attributes.title;
} else if(model.attributes.jsonmodel_type == 'accession') {
Expand Down
2 changes: 1 addition & 1 deletion public-new/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ <h2>${title}</h2>
<div class="image-container">
<img src="${representativeImage}" />
</div>
<p>Optional image, with caption.</p>
<p>${representativeImageCaption}</p>
</div>

<p>${abstract}</p>
Expand Down

0 comments on commit 442c3e0

Please sign in to comment.