mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
Unifify view and edit modes for number cells [SCI-4233]
This commit is contained in:
parent
3093e84581
commit
470f6ff541
4 changed files with 5 additions and 13 deletions
|
@ -143,7 +143,7 @@ $.fn.dataTable.render.editRepositoryNumberValue = function(formId, columnId, cel
|
|||
type="number"
|
||||
name="repository_cells[${columnId}]"
|
||||
placeholder="${I18n.t('repositories.table.number.enter_number')}"
|
||||
value="${$cell.find('.number-value').data('full-value')}"
|
||||
value="${$cell.find('.number-value').data('value')}"
|
||||
data-type="RepositoryNumberValue">
|
||||
</div>`);
|
||||
};
|
||||
|
|
|
@ -75,8 +75,6 @@ $.fn.dataTable.render.newRepositoryNumberValue = function(formId, columnId, $cel
|
|||
placeholder="${I18n.t('repositories.table.number.enter_number')}"
|
||||
data-type="RepositoryNumberValue">
|
||||
</div>`);
|
||||
|
||||
SmartAnnotation.init($cell.find('input'));
|
||||
};
|
||||
|
||||
$.fn.dataTable.render.newRepositoryDateTimeValue = function(formId, columnId, $cell) {
|
||||
|
|
|
@ -63,8 +63,8 @@ $.fn.dataTable.render.defaultRepositoryDateTimeValue = function() {
|
|||
};
|
||||
|
||||
$.fn.dataTable.render.RepositoryDateTimeValue = function(data) {
|
||||
return `<span data-time="${data.value.time_formatted}"
|
||||
data-datetime="${data.value.datetime}"
|
||||
return `<span data-time="${data.value.time_formatted}"
|
||||
data-datetime="${data.value.datetime}"
|
||||
data-date="${data.value.date_formatted}">${data.value.formatted}</span>`;
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ $.fn.dataTable.render.defaultRepositoryTimeValue = function() {
|
|||
};
|
||||
|
||||
$.fn.dataTable.render.RepositoryTimeValue = function(data) {
|
||||
return `<span data-time="${data.value.formatted}"
|
||||
return `<span data-time="${data.value.formatted}"
|
||||
data-datetime="${data.value.datetime}">${data.value.formatted}</span>`;
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ $.fn.dataTable.render.defaultRepositoryNumberValue = function() {
|
|||
};
|
||||
|
||||
$.fn.dataTable.render.RepositoryNumberValue = function(data) {
|
||||
return `<span class="number-value" data-full-value="${data.full_value}">
|
||||
return `<span class="number-value" data-value="${data.value}">
|
||||
${data.value}
|
||||
</span>`;
|
||||
};
|
||||
|
|
|
@ -2,15 +2,9 @@
|
|||
|
||||
module RepositoryDatatable
|
||||
class RepositoryNumberValueSerializer < RepositoryBaseValueSerializer
|
||||
attributes :full_value
|
||||
|
||||
def value
|
||||
decimal_number = scope[:column].metadata.fetch('decimals') { Constants::REPOSITORY_NUMBER_TYPE_DEFAULT_DECIMALS }
|
||||
BigDecimal(object.data).round(decimal_number.to_i)
|
||||
end
|
||||
|
||||
def full_value
|
||||
object.data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue