Files
manyfold/app/components/model_component.html.erb
T

65 lines
3.5 KiB
ERB

<div class="col mb-4">
<div class="card preview-card">
<% if file = @model.preview_file %>
<% if file.is_image? %>
<%= content_tag :div, nil, class: "card-img-top card-img-top-background", style: "background-image: url(#{model_model_file_path(@model, file, format: file.extension)})" %>
<%= image_tag model_model_file_path(@model, file, format: file.extension), class: "card-img-top image-preview #{"sensitive" if helpers.needs_hiding?(@model)}", alt: file.name %>
<% elsif helpers.renderable?(file.extension) %>
<div class="card-img-top <%= "sensitive" if helpers.needs_hiding?(@model) %>">
<%= render partial: "object_preview", locals: {model: @model, file: file} %>
</div>
<% end %>
<% else %>
<div class='preview-empty'> <p>no preview availiable</p></div>
<% end %>
<div class="card-body">
<div class="row ">
<div class="col">
<div class="card-title">
<a data-field="model[name]" data-path="<%= model_path @model %>" contenteditable=true>
<%= @model.name %>
</a>
<%= helpers.icon("explicit", Model.human_attribute_name(:sensitive)) if @model.sensitive %>
<span style="float: right"><%= helpers.status_badges(@model) %></span>
</div>
<div class='mt-2'>
<%= link_to t(".open_button.text"), @model, {class: "btn btn-primary btn-sm", "aria-label": translate(".open_button.label", name: @model.name)} %>
<%= link_to helpers.icon("pencil-fill", t(".edit_button.text")), edit_model_path(@model), {class: "btn btn-outline-secondary btn-sm", "aria-label": translate(".edit_button.label", name: @model.name)} if @can_edit %>
<%= link_to helpers.icon("trash", t(".delete_button.text")), model_path(@model), {method: :delete, class: "btn btn-outline-danger btn-sm", "aria-label": translate(".delete_button.label", name: @model.name), data: {confirm: translate("models.destroy.confirm")}} if @can_destroy %>
</div>
</div>
<div class="col-auto">
<small>
<ul class="list-unstyled">
<% if @model.creator %>
<li>
<%= helpers.icon "person", Creator.model_name.human %>
<%= link_to @model.creator.name, @model.creator,
"aria-label": [Creator.model_name.human, @model.creator.name].join(": ") %>
</li>
<% end %>
<% if @model.collection %>
<li>
<%= helpers.icon "collection", @model.collection.model_name.human %>
<%= link_to @model.collection.name, models_path((@filters || {}).merge(collection: @model.collection)),
"aria-label": [@model.collection.model_name.human, @model.collection.name].join(": ") %>
</li>
<% end %>
<% if @library.nil? && @model.library %>
<li>
<%= helpers.icon "boxes", Library.model_name.human %>
<%= link_to @model.library.name, models_path((@filters || {}).merge(library: @model.library)),
"aria-label": [Library.model_name.human, @model.library.name].join(": ") %>
</li>
<% end %>
</ul>
<% if @model.caption %>
<p class="card-text"><%= sanitize @model.caption %></p>
<% end %>
</small>
</div>
</div>
</div>
</div>
</div>