scinote-web/app/assets/javascripts/repositories/renderers/new_renderers.js

96 lines
3.6 KiB
JavaScript
Raw Normal View History

/*
2019-12-23 21:40:15 +08:00
global ListColumnHelper ChecklistColumnHelper StatusColumnHelper SmartAnnotation I18n
AssetColumnHelper DateTimeHelper
*/
$.fn.dataTable.render.newRowName = function(formId, $cell) {
$cell.html(`
2020-01-23 20:12:58 +08:00
<div class="sci-input-container text-field error-icon">
2020-01-15 23:46:01 +08:00
<input class="sci-input-field"
id="newRepoNameField"
form="${formId}"
type="text"
2019-12-10 15:41:09 +08:00
name="repository_row[name]"
value=""
2020-01-09 21:57:37 +08:00
placeholder="${I18n.t('repositories.table.enter_row_name')}"
data-type="RowName">
</div>
`);
};
$.fn.dataTable.render.newRepositoryAssetValue = function(formId, columnId, $cell) {
AssetColumnHelper.renderCell($cell, formId, columnId);
};
$.fn.dataTable.render.newRepositoryTextValue = function(formId, columnId, $cell) {
$cell.html(`
2020-01-23 20:12:58 +08:00
<div class="sci-input-container text-field error-icon">
2020-01-15 23:46:01 +08:00
<input class="sci-input-field"
form="${formId}"
type="text"
name="repository_cells[${columnId}]"
value=""
2020-01-09 21:57:37 +08:00
placeholder="${I18n.t('repositories.table.text.enter_text')}"
data-type="RepositoryTextValue">
</div>`);
SmartAnnotation.init($cell.find('input'), false);
};
$.fn.dataTable.render.newRepositoryListValue = function(formId, columnId, $cell) {
2019-12-11 21:49:14 +08:00
ListColumnHelper.initialListEditMode(formId, columnId, $cell);
};
$.fn.dataTable.render.newRepositoryStatusValue = function(formId, columnId, $cell) {
2019-12-23 21:40:15 +08:00
StatusColumnHelper.initialStatusEditMode(formId, columnId, $cell);
};
2019-12-06 20:18:35 +08:00
$.fn.dataTable.render.newRepositoryChecklistValue = function(formId, columnId, $cell) {
2019-12-11 21:49:14 +08:00
ChecklistColumnHelper.initialChecklistEditMode(formId, columnId, $cell);
2019-12-06 20:18:35 +08:00
};
$.fn.dataTable.render.newRepositoryNumberValue = function(formId, columnId, $cell, $header) {
let decimals = $header.data('metadata-decimals');
$cell.html(`
2020-01-23 20:12:58 +08:00
<div class="sci-input-container text-field error-icon">
2020-01-15 23:46:01 +08:00
<input class="sci-input-field"
form="${formId}"
type="text"
oninput="this.value = this.value.replace(/[^0-9.]/g, '');
this.value = this.value.match(/^\\d*(\\.\\d{0,${decimals}})?/)[0];"
name="repository_cells[${columnId}]"
value=""
2020-01-09 21:57:37 +08:00
placeholder="${I18n.t('repositories.table.number.enter_number')}"
data-type="RepositoryNumberValue">
</div>`);
};
$.fn.dataTable.render.newRepositoryDateTimeValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, '', 'RepositoryDateTimeValue');
};
$.fn.dataTable.render.newRepositoryTimeValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, 'timeonly', 'RepositoryTimeValue');
};
$.fn.dataTable.render.newRepositoryDateValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, 'dateonly', 'RepositoryDateValue');
};
2019-12-17 18:27:07 +08:00
$.fn.dataTable.render.newRepositoryDateTimeRangeValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, '', 'RepositoryDateTimeRangeValue');
2019-12-17 18:27:07 +08:00
};
2019-12-17 20:42:25 +08:00
$.fn.dataTable.render.newRepositoryDateRangeValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, 'dateonly', 'RepositoryDateRangeValue');
2019-12-17 20:42:25 +08:00
};
$.fn.dataTable.render.newRepositoryTimeRangeValue = function(formId, columnId, $cell) {
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, 'timeonly', 'RepositoryTimeRangeValue');
2019-12-17 20:42:25 +08:00
};
$.fn.dataTable.render.newRepositoryStockValue = function() {
return '';
};