2019-12-20 21:46:36 +08:00
|
|
|
/*
|
2019-12-23 21:34:11 +08:00
|
|
|
global ListColumnHelper ChecklistColumnHelper StatusColumnHelper SmartAnnotation I18n
|
2020-02-06 21:43:17 +08:00
|
|
|
DateTimeHelper AssetColumnHelper
|
2019-12-20 21:46:36 +08:00
|
|
|
*/
|
2019-11-29 19:52:27 +08:00
|
|
|
|
2019-11-18 21:04:53 +08:00
|
|
|
$.fn.dataTable.render.editRowName = function(formId, cell) {
|
|
|
|
let $cell = $(cell.node());
|
|
|
|
let text = $cell.find('a').first().text();
|
|
|
|
|
|
|
|
$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"
|
2019-11-18 21:04:53 +08:00
|
|
|
form="${formId}"
|
|
|
|
type="text"
|
2019-12-10 15:41:09 +08:00
|
|
|
name="repository_row[name]"
|
2020-12-15 19:23:19 +08:00
|
|
|
value=""
|
2020-01-09 21:57:37 +08:00
|
|
|
placeholder="${I18n.t('repositories.table.enter_row_name')}"
|
2019-11-18 21:04:53 +08:00
|
|
|
data-type="RowName">
|
|
|
|
</div>
|
|
|
|
`);
|
2020-12-15 19:23:19 +08:00
|
|
|
$cell.find('input').val(text);
|
2019-11-18 21:04:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryAssetValue = function(formId, columnId, cell) {
|
2019-12-04 21:52:52 +08:00
|
|
|
let $cell = $(cell.node());
|
2020-02-06 21:43:17 +08:00
|
|
|
AssetColumnHelper.renderCell($cell, formId, columnId);
|
2019-11-18 21:04:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryTextValue = function(formId, columnId, cell) {
|
2019-11-29 19:52:27 +08:00
|
|
|
let $cell = $(cell.node());
|
2020-07-22 23:27:36 +08:00
|
|
|
let text = $cell.find('.text-value').data('edit-value') || '';
|
2019-11-29 19:52:27 +08:00
|
|
|
$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"
|
2019-11-29 19:52:27 +08:00
|
|
|
form="${formId}"
|
|
|
|
type="text"
|
|
|
|
name="repository_cells[${columnId}]"
|
2020-12-15 19:23:19 +08:00
|
|
|
value=""
|
2020-01-09 21:57:37 +08:00
|
|
|
placeholder="${I18n.t('repositories.table.text.enter_text')}"
|
2019-11-29 19:52:27 +08:00
|
|
|
data-type="RepositoryTextValue">
|
|
|
|
</div>`);
|
2020-12-15 19:23:19 +08:00
|
|
|
$cell.find('input').val(text);
|
2022-11-29 20:47:52 +08:00
|
|
|
SmartAnnotation.init($cell.find('input'), true);
|
2019-11-18 21:04:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryListValue = function(formId, columnId, cell) {
|
2019-12-10 22:48:53 +08:00
|
|
|
var $cell = $(cell.node());
|
2019-12-11 21:49:14 +08:00
|
|
|
var currentElement = $cell.find('.list-label');
|
|
|
|
var currentValue = null;
|
|
|
|
if (currentElement.length) {
|
|
|
|
currentValue = {
|
|
|
|
value: currentElement.attr('data-value-id'),
|
|
|
|
label: currentElement.text()
|
|
|
|
};
|
2019-12-10 22:48:53 +08:00
|
|
|
}
|
|
|
|
|
2019-12-11 21:49:14 +08:00
|
|
|
ListColumnHelper.initialListEditMode(formId, columnId, $cell, currentValue);
|
2019-11-18 21:04:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryStatusValue = function(formId, columnId, cell) {
|
2019-12-02 18:03:05 +08:00
|
|
|
let $cell = $(cell.node());
|
2019-12-23 21:34:11 +08:00
|
|
|
var currentElement = $cell.find('.status-label');
|
|
|
|
var iconElement = $cell.find('.repository-status-value-icon');
|
|
|
|
var currentValue = null;
|
|
|
|
if (currentElement.length) {
|
|
|
|
currentValue = {
|
|
|
|
value: currentElement.attr('data-value-id'),
|
2020-01-21 17:49:45 +08:00
|
|
|
label: iconElement.find('img').attr('alt') + ' ' + currentElement.text()
|
2019-12-23 21:34:11 +08:00
|
|
|
};
|
|
|
|
}
|
2019-12-02 18:03:05 +08:00
|
|
|
|
2019-12-23 21:34:11 +08:00
|
|
|
StatusColumnHelper.initialStatusEditMode(formId, columnId, $cell, currentValue);
|
2019-11-18 21:04:53 +08:00
|
|
|
};
|
2019-11-29 19:52:27 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryDateTimeValue = function(formId, columnId, cell) {
|
2019-12-16 22:21:50 +08:00
|
|
|
let $cell = $(cell.node());
|
|
|
|
|
2019-12-20 21:46:36 +08:00
|
|
|
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, '', 'RepositoryDateTimeValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryDateValue = function(formId, columnId, cell) {
|
2019-12-16 22:21:50 +08:00
|
|
|
let $cell = $(cell.node());
|
|
|
|
|
2019-12-20 21:46:36 +08:00
|
|
|
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, 'dateonly', 'RepositoryDateValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryTimeValue = function(formId, columnId, cell) {
|
2019-12-16 22:21:50 +08:00
|
|
|
let $cell = $(cell.node());
|
|
|
|
|
2019-12-20 21:46:36 +08:00
|
|
|
DateTimeHelper.initDateTimeEditMode(formId, columnId, $cell, 'timeonly', 'RepositoryTimeValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryDateTimeRangeValue = function(formId, columnId, cell) {
|
2019-12-17 18:27:07 +08:00
|
|
|
let $cell = $(cell.node());
|
2019-12-20 21:46:36 +08:00
|
|
|
|
|
|
|
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, '', 'RepositoryDateTimeRangeValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryDateRangeValue = function(formId, columnId, cell) {
|
2019-12-17 20:42:25 +08:00
|
|
|
let $cell = $(cell.node());
|
2019-12-20 21:46:36 +08:00
|
|
|
|
|
|
|
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, 'dateonly', 'RepositoryDateRangeValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryTimeRangeValue = function(formId, columnId, cell) {
|
2019-12-17 20:42:25 +08:00
|
|
|
let $cell = $(cell.node());
|
2019-12-20 21:46:36 +08:00
|
|
|
|
|
|
|
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, 'timeonly', 'RepositoryTimeRangeValue');
|
2019-11-29 19:52:27 +08:00
|
|
|
};
|
2019-12-06 20:18:35 +08:00
|
|
|
|
2019-12-10 22:48:53 +08:00
|
|
|
$.fn.dataTable.render.editRepositoryChecklistValue = function(formId, columnId, cell) {
|
2019-12-11 21:49:14 +08:00
|
|
|
var $cell = $(cell.node());
|
|
|
|
var currentValue = $cell.find('.checklist-options').data('checklist-items');
|
|
|
|
ChecklistColumnHelper.initialChecklistEditMode(formId, columnId, $cell, currentValue);
|
2019-12-06 20:18:35 +08:00
|
|
|
};
|
2019-12-18 18:55:12 +08:00
|
|
|
|
2020-01-17 23:04:19 +08:00
|
|
|
$.fn.dataTable.render.editRepositoryNumberValue = function(formId, columnId, cell, $header) {
|
2019-12-18 18:55:12 +08:00
|
|
|
let $cell = $(cell.node());
|
2020-01-17 23:04:19 +08:00
|
|
|
let decimals = $header.data('metadata-decimals');
|
|
|
|
let number = $cell.find('.number-value').data('value');
|
|
|
|
|
|
|
|
if (!number) number = '';
|
2019-12-18 18:55:12 +08:00
|
|
|
|
|
|
|
$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"
|
2019-12-18 18:55:12 +08:00
|
|
|
form="${formId}"
|
2020-01-17 23:04:19 +08:00
|
|
|
type="text"
|
2020-02-12 18:55:10 +08:00
|
|
|
oninput="regexp = ${decimals} === 0 ? /[^0-9]/g : /[^0-9.]/g
|
|
|
|
this.value = this.value.replace(regexp, '');
|
2020-01-17 23:04:19 +08:00
|
|
|
this.value = this.value.match(/^\\d*(\\.\\d{0,${decimals}})?/)[0];"
|
2019-12-18 18:55:12 +08:00
|
|
|
name="repository_cells[${columnId}]"
|
2020-01-09 21:57:37 +08:00
|
|
|
placeholder="${I18n.t('repositories.table.number.enter_number')}"
|
2020-01-17 23:04:19 +08:00
|
|
|
value="${number}"
|
2019-12-18 18:55:12 +08:00
|
|
|
data-type="RepositoryNumberValue">
|
|
|
|
</div>`);
|
|
|
|
};
|
2022-01-19 20:19:56 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.editRepositoryStockValue = function(formId, columnId, cell) {
|
|
|
|
return cell.node();
|
|
|
|
};
|
2022-02-04 21:24:15 +08:00
|
|
|
|
2022-02-16 16:40:48 +08:00
|
|
|
$.fn.dataTable.render.editRepositoryStockConsumptionValue = function(formId, columnId, cell) {
|
2022-02-04 21:24:15 +08:00
|
|
|
return cell.node();
|
|
|
|
};
|