mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 20:23:16 +08:00
Fix legacy inline editing [SCI-9274]
This commit is contained in:
parent
2303b72f78
commit
ab8deeb181
5 changed files with 22 additions and 20 deletions
|
@ -1,10 +1,10 @@
|
||||||
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "initInlineEditing" }]*/
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "initInlineEditing" }]*/
|
||||||
/* global SmartAnnotation HelperModule I18n */
|
/* global SmartAnnotation HelperModule I18n */
|
||||||
|
|
||||||
var inlineEditing = (function() {
|
let inlineEditing = (function() {
|
||||||
const SIDEBAR_ITEM_TYPES = ['project', 'experiment', 'my_module', 'repository'];
|
const SIDEBAR_ITEM_TYPES = ['project', 'experiment', 'my_module', 'repository'];
|
||||||
|
|
||||||
var editBlocks = '.inline-init-handler';
|
const editBlocks = '.inline-init-handler';
|
||||||
|
|
||||||
function appendAfterLabel(container) {
|
function appendAfterLabel(container) {
|
||||||
if (container.data('label-after')) {
|
if (container.data('label-after')) {
|
||||||
|
@ -114,8 +114,8 @@ var inlineEditing = (function() {
|
||||||
if (!error) error = response.responseJSON.errors[fieldToUpdate];
|
if (!error) error = response.responseJSON.errors[fieldToUpdate];
|
||||||
container.addClass('error');
|
container.addClass('error');
|
||||||
if (error) container.find('.error-block').html(error.join(', '));
|
if (error) container.find('.error-block').html(error.join(', '));
|
||||||
inputField(container).removeClass('border-sn-science-blue');
|
inputField(container).removeClass('!border-b-sn-science-blue');
|
||||||
inputField(container).addClass('border-sn-delete-red');
|
inputField(container).addClass('!border-b-sn-delete-red');
|
||||||
inputField(container).focus();
|
inputField(container).focus();
|
||||||
container.data('disabled', false);
|
container.data('disabled', false);
|
||||||
$('.tooltip').hide();
|
$('.tooltip').hide();
|
||||||
|
@ -148,6 +148,9 @@ var inlineEditing = (function() {
|
||||||
$(editBlocks).click();
|
$(editBlocks).click();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.on('blur', `${editBlocks} textarea, ${editBlocks} input`, function(e) {
|
||||||
|
saveAllEditFields();
|
||||||
|
})
|
||||||
.on('click', editBlocks, function(e) {
|
.on('click', editBlocks, function(e) {
|
||||||
// 'A' mean that, if we click on <a></a> element we will not go in edit mode
|
// 'A' mean that, if we click on <a></a> element we will not go in edit mode
|
||||||
var container = $(this);
|
var container = $(this);
|
||||||
|
@ -168,8 +171,8 @@ var inlineEditing = (function() {
|
||||||
.scrollTop(container.offsetTop);
|
.scrollTop(container.offsetTop);
|
||||||
$('.tooltip').hide();
|
$('.tooltip').hide();
|
||||||
}
|
}
|
||||||
inputField(container).removeClass('border-sn-delete-red');
|
inputField(container).removeClass('!border-b-sn-delete-red');
|
||||||
inputField(container).addClass('border-sn-science-blue');
|
inputField(container).addClass('!border-b-sn-science-blue');
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-block {
|
.error-block {
|
||||||
bottom: 3px;
|
bottom: 1px;
|
||||||
color: $brand-danger;
|
color: $brand-danger;
|
||||||
display: none;
|
display: none;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
@ -47,23 +47,21 @@
|
||||||
.input-field {
|
.input-field {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
padding-bottom: 10px;
|
outline: none;
|
||||||
padding-top: 0;
|
padding-bottom: .5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-mode {
|
.view-mode {
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
cursor: url("/images/icon_small/edit.svg") 0 16, auto;
|
cursor: url("/images/icon_small/edit.svg") 0 16, auto;
|
||||||
line-height: 26px;
|
height: 2rem;
|
||||||
margin-left: -5px;
|
min-height: 1.5rem;
|
||||||
min-height: 30px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 2px 4px;
|
|
||||||
padding-right: 36px;
|
padding-right: 36px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: calc(100% - 32px);
|
width: 100%;
|
||||||
|
|
||||||
&:empty:not(:focus):before {
|
&:empty:not(:focus):before {
|
||||||
color: $color-silver-chalice;
|
color: $color-silver-chalice;
|
||||||
|
@ -73,12 +71,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
|
border: 1px solid transparent;
|
||||||
cursor: initial;
|
cursor: initial;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: -5px;
|
height: 2rem;
|
||||||
padding: 2px 4px;
|
padding-left: 0;
|
||||||
padding-right: 36px;
|
padding-right: 36px;
|
||||||
width: calc(100% - 32px);
|
width: 100%;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: $color-silver-chalice;
|
color: $color-silver-chalice;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
max-width: calc(100% - 2rem);
|
max-width: calc(100% - 2.5rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.name-readonly-placeholder {
|
.name-readonly-placeholder {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</h1>
|
</h1>
|
||||||
<% if @repository.shared_with_anybody? %>
|
<% if @repository.shared_with_anybody? %>
|
||||||
<% team_name = @repository.team == current_team ? t('repositories.show.your_team') : @repository.team.name %>
|
<% team_name = @repository.team == current_team ? t('repositories.show.your_team') : @repository.team.name %>
|
||||||
<div class="repository-subtitle"><%= t('repositories.show.subtitle', team_name: team_name) %></div>
|
<div class="repository-subtitle mt-0.5"><%= t('repositories.show.subtitle', team_name: team_name) %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
data-placeholder='<%= config[:placeholder] %>'
|
data-placeholder='<%= config[:placeholder] %>'
|
||||||
>
|
>
|
||||||
<div class="view-mode" data-placeholder="<%= config[:placeholder] %>" tabindex=0><%= initial_value %></div>
|
<div class="view-mode" data-placeholder="<%= config[:placeholder] %>" tabindex=0><%= initial_value %></div>
|
||||||
<input placeholder="<%= config[:placeholder] %>" class="hidden input-field outline-none p-0 pb-2 border-0 border-solid border-b w-full break-words border-sn-science-blue caret-black bg-transparent" type="text" value="<%= initial_value %>" disabled/>
|
<input placeholder="<%= config[:placeholder] %>" class="hidden input-field" type="text" value="<%= initial_value %>" disabled/>
|
||||||
<div class="button-container hidden">
|
<div class="button-container hidden">
|
||||||
<span class="save-button"><i class="sn-icon sn-icon-check"></i></span>
|
<span class="save-button"><i class="sn-icon sn-icon-check"></i></span>
|
||||||
<span class="cancel-button"><i class="sn-icon sn-icon-close"></i></span>
|
<span class="cancel-button"><i class="sn-icon sn-icon-close"></i></span>
|
||||||
|
|
Loading…
Reference in a new issue