Fix placeholder for authors

This commit is contained in:
aignatov-bio 2019-11-15 16:23:48 +01:00
parent ca76c0ca0c
commit b9a34fa809
8 changed files with 31 additions and 41 deletions

View file

@ -69,12 +69,19 @@
cursor: pointer;
line-height: 26px;
margin-left: -5px;
min-height: 30px;
overflow: hidden;
padding: 2px 4px;
padding-right: 36px;
text-overflow: ellipsis;
white-space: nowrap;
width: calc(100% - 32px);
&:empty:not(:focus):before{
color: $color-silver-chalice;
content:attr(data-placeholder);
font-weight: normal;
}
}
input {
@ -88,6 +95,11 @@
padding-right: 36px;
width: calc(100% - 32px);
&::placeholder {
color: $color-silver-chalice;
font-weight: normal;
}
&:focus {
outline: 0;
}

View file

@ -57,6 +57,4 @@
</div>
</div>
<%= render partial: "protocols/header/edit_metadata_modal.html.erb" %>
<%= javascript_include_tag "protocols/header" %>

View file

@ -1,18 +1,15 @@
<% if @protocol.authors.present? %>
<% if can_manage_protocol_in_repository?(@protocol) && editable %>
<%= render partial: "shared/inline_editing.html.erb",
locals: {
initial_value: @protocol.authors,
config: {
field_to_udpate: 'authors',
params_group: 'protocol',
path_to_update: authors_protocol_path(@protocol)
}
} %>
<% else %>
<span class="view-mode"><%= @protocol.authors %></span>
<% end %>
<% if can_manage_protocol_in_repository?(@protocol) && editable %>
<%= render partial: "shared/inline_editing.html.erb",
locals: {
initial_value: @protocol.authors,
config: {
field_to_udpate: 'authors',
params_group: 'protocol',
placeholder: t("protocols.header.no_authors"),
path_to_update: authors_protocol_path(@protocol)
}
}
%>
<% else %>
<em><%= t("protocols.header.no_authors") %></em>
<% end %>
<span class="view-mode"><%= @protocol.authors || t("protocols.header.no_authors") %></span>
<% end %>

View file

@ -1,3 +0,0 @@
<%= bootstrap_form_for @protocol, url: metadata_protocol_path(@protocol, format: :json), remote: :true do |f| %>
<%= f.smart_text_area :authors, label: t("protocols.header.edit_authors_modal.label") %>
<% end %>

View file

@ -1,15 +0,0 @@
<div class="modal" id="edit-protocol-metadata-modal" tabindex="-1" role="dialog" aria-labelledby="edit-protocol-metadata-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="edit-protocol-metadata-modal-label"></h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<button type="button" class="btn btn-success" data-action="submit"><%=t "general.save" %></button>
</div>
</div>
</div>
</div>

View file

@ -5,9 +5,10 @@
data-path-to-update="<%= config[:path_to_update] %>"
data-original-name="<%= initial_value %>"
data-label-after='<%= config[:label_after]&.html_safe %>'
data-placeholder='<%= config[:placeholder] %>'
>
<div class="view-mode"><%= initial_value %></div>
<input class="hidden input-field" type="text" value="<%= initial_value %>" disabled/>
<div class="view-mode" data-placeholder="<%= config[:placeholder] %>"><%= initial_value %></div>
<input placeholder="<%= config[:placeholder] %>" class="hidden input-field" type="text" value="<%= initial_value %>" disabled/>
<div class="button-container">
<span class="save-button"><i class="fas fa-check"></i></span>
<span class="cancel-button"><i class="fas fa-times"></i></span>

View file

@ -16,4 +16,4 @@
object_id: object.id,
highlightjs_path: asset_path('highlightjs-github-theme.css'),
last_updated: object.updated_at.to_i * 1000 } ) %>
<% end %>
<% end %>

View file

@ -106,7 +106,7 @@ describe ProtocolsController, type: :controller do
end
end
describe 'POST metadata' do
describe 'PUT description' do
let(:protocol) do
create :protocol, :in_public_repository, team: team, added_by: user
end