2020-01-21 17:49:45 +08:00
|
|
|
/* global I18n twemoji */
|
2019-12-11 22:08:18 +08:00
|
|
|
|
2019-10-25 20:30:45 +08:00
|
|
|
$.fn.dataTable.render.RepositoryAssetValue = function(data) {
|
2019-11-06 18:44:00 +08:00
|
|
|
var asset = data.value;
|
2022-06-08 19:35:06 +08:00
|
|
|
if (asset.id) {
|
|
|
|
return `
|
|
|
|
<div class="asset-value-cell">
|
|
|
|
${asset.icon_html}
|
|
|
|
<div>
|
|
|
|
<a class="file-preview-link"
|
|
|
|
id="modal_link${asset.id}"
|
|
|
|
data-no-turbolink="true"
|
|
|
|
data-id="true"
|
|
|
|
data-status="asset-present"
|
|
|
|
data-preview-url="${asset.preview_url}"
|
|
|
|
href="${asset.url}"
|
|
|
|
>
|
|
|
|
${asset.file_name}
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-01-29 21:56:03 +08:00
|
|
|
</div>
|
2022-06-08 19:35:06 +08:00
|
|
|
`;
|
|
|
|
}
|
|
|
|
return `<div class="processing-error">
|
|
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
|
|
${I18n.t('my_modules.repository.full_view.error')}
|
|
|
|
</div>`;
|
2019-10-25 20:30:45 +08:00
|
|
|
};
|
|
|
|
|
2019-10-28 21:52:46 +08:00
|
|
|
$.fn.dataTable.render.defaultRepositoryAssetValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
2019-10-25 20:30:45 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryTextValue = function(data) {
|
2020-12-15 19:23:19 +08:00
|
|
|
var text = $(`<span class="text-value">${data.value.view}</span>`);
|
|
|
|
text.attr('data-edit-value', data.value.edit);
|
2020-06-11 22:10:38 +08:00
|
|
|
return text.prop('outerHTML');
|
2019-10-25 20:30:45 +08:00
|
|
|
};
|
|
|
|
|
2019-10-28 21:52:46 +08:00
|
|
|
$.fn.dataTable.render.defaultRepositoryTextValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
2019-10-25 20:30:45 +08:00
|
|
|
$.fn.dataTable.render.RepositoryListValue = function(data) {
|
2019-12-02 18:03:05 +08:00
|
|
|
return `<span data-value-id="${data.value.id}" class="list-label">${data.value.text}</span>`;
|
2019-10-25 20:30:45 +08:00
|
|
|
};
|
2019-10-28 21:52:46 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryListValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
2019-11-06 18:44:00 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryStatusValue = function(data) {
|
2019-12-02 18:03:05 +08:00
|
|
|
return `
|
2020-01-21 17:49:45 +08:00
|
|
|
<div class="repository-status-value-container" title="${data.value.icon} ${data.value.status}">
|
|
|
|
<span class="repository-status-value-icon">${twemoji.parse(data.value.icon)}</span>
|
2019-12-02 18:03:05 +08:00
|
|
|
<span data-value-id="${data.value.id}" class="status-label">${data.value.status}</span>
|
2020-01-21 17:49:45 +08:00
|
|
|
</div>
|
2019-12-02 18:03:05 +08:00
|
|
|
`;
|
2019-11-06 18:44:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryStatusValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
2019-11-27 20:06:46 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryDateValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryDateValue = function(data) {
|
2022-03-09 21:18:34 +08:00
|
|
|
let reminderClass = data.value.reminder ? 'reminder' : '';
|
|
|
|
return `<span class="${reminderClass}
|
|
|
|
date-cell-value" data-datetime="${data.value.datetime}"
|
|
|
|
data-date="${data.value.formatted}">${data.value.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryDateTimeValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryDateTimeValue = function(data) {
|
2022-03-09 21:18:34 +08:00
|
|
|
let reminderClass = data.value.reminder ? 'reminder' : '';
|
|
|
|
return `<span class="${reminderClass} date-time-cell-value"
|
|
|
|
data-time="${data.value.time_formatted}"
|
2020-01-15 19:16:17 +08:00
|
|
|
data-datetime="${data.value.datetime}"
|
2019-12-16 22:21:50 +08:00
|
|
|
data-date="${data.value.date_formatted}">${data.value.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryTimeValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryTimeValue = function(data) {
|
2020-01-15 19:16:17 +08:00
|
|
|
return `<span data-time="${data.value.formatted}"
|
2019-12-16 22:21:50 +08:00
|
|
|
data-datetime="${data.value.datetime}">${data.value.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryTimeRangeValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryTimeRangeValue = function(data) {
|
2019-12-17 20:42:25 +08:00
|
|
|
return `<span data-time="${data.value.start_time.formatted}"
|
|
|
|
data-datetime="${data.value.start_time.datetime}">${data.value.start_time.formatted}</span> -
|
|
|
|
<span data-time="${data.value.end_time.formatted}"
|
|
|
|
data-datetime="${data.value.end_time.datetime}">${data.value.end_time.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryDateTimeRangeValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryDateTimeRangeValue = function(data) {
|
2019-12-17 18:27:07 +08:00
|
|
|
return `<span data-time="${data.value.start_time.time_formatted}"
|
|
|
|
data-datetime="${data.value.start_time.datetime}"
|
|
|
|
data-date="${data.value.start_time.date_formatted}">${data.value.start_time.formatted}</span> -
|
|
|
|
<span data-time="${data.value.end_time.time_formatted}"
|
|
|
|
data-datetime="${data.value.end_time.datetime}"
|
|
|
|
data-date="${data.value.end_time.date_formatted}">${data.value.end_time.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryDateRangeValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryDateRangeValue = function(data) {
|
2019-12-17 20:42:25 +08:00
|
|
|
return `<span data-datetime="${data.value.start_time.datetime}"
|
|
|
|
data-date="${data.value.start_time.formatted}">${data.value.start_time.formatted}</span> -
|
|
|
|
<span data-datetime="${data.value.end_time.datetime}"
|
|
|
|
data-date="${data.value.end_time.formatted}">${data.value.end_time.formatted}</span>`;
|
2019-11-27 20:06:46 +08:00
|
|
|
};
|
2019-12-06 20:18:35 +08:00
|
|
|
|
2019-12-10 22:48:53 +08:00
|
|
|
$.fn.dataTable.render.RepositoryChecklistValue = function(data) {
|
2019-12-11 21:49:14 +08:00
|
|
|
var render = '—';
|
|
|
|
var options = data.value;
|
2019-12-11 22:08:18 +08:00
|
|
|
var optionsList;
|
|
|
|
if (options.length === 1) {
|
2019-12-11 21:49:14 +08:00
|
|
|
render = `<span class="checklist-options" data-checklist-items='${JSON.stringify(options)}'>
|
|
|
|
${options[0].label}
|
2019-12-11 22:08:18 +08:00
|
|
|
</span>`;
|
2019-12-11 21:49:14 +08:00
|
|
|
} else if (options.length > 1) {
|
2019-12-11 22:08:18 +08:00
|
|
|
optionsList = $(' <ul class="dropdown-menu checklist-dropdown-menu" role="menu"></ul');
|
2019-12-11 21:49:14 +08:00
|
|
|
$.each(options, function(i, option) {
|
2019-12-11 22:08:18 +08:00
|
|
|
$(`<li class="checklist-item">${option.label}</li>`).appendTo(optionsList);
|
|
|
|
});
|
2019-12-11 21:49:14 +08:00
|
|
|
|
|
|
|
render = `
|
2019-12-18 18:55:12 +08:00
|
|
|
<span class="dropdown checklist-dropdown">
|
2019-12-11 21:49:14 +08:00
|
|
|
<span data-toggle="dropdown" class="checklist-options" aria-haspopup="true" data-checklist-items='${JSON.stringify(options)}'>
|
|
|
|
${options.length} ${I18n.t('libraries.manange_modal_column.checklist_type.multiple_options')}
|
|
|
|
</span>
|
|
|
|
${optionsList[0].outerHTML}
|
2019-12-11 22:08:18 +08:00
|
|
|
</span>`;
|
2019-12-11 21:49:14 +08:00
|
|
|
}
|
|
|
|
return render;
|
2019-12-06 20:18:35 +08:00
|
|
|
};
|
|
|
|
|
2019-12-10 22:48:53 +08:00
|
|
|
$.fn.dataTable.render.defaultRepositoryChecklistValue = function() {
|
|
|
|
return '—';
|
2019-12-06 20:18:35 +08:00
|
|
|
};
|
2019-12-18 18:55:12 +08:00
|
|
|
|
|
|
|
$.fn.dataTable.render.defaultRepositoryNumberValue = function() {
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryNumberValue = function(data) {
|
2020-01-15 19:16:17 +08:00
|
|
|
return `<span class="number-value" data-value="${data.value}">
|
2020-01-10 17:40:22 +08:00
|
|
|
${data.value}
|
|
|
|
</span>`;
|
2019-12-18 18:55:12 +08:00
|
|
|
};
|
2020-04-24 21:43:10 +08:00
|
|
|
|
2022-03-09 21:13:48 +08:00
|
|
|
$.fn.dataTable.render.AssignedTasksValue = function(data, row) {
|
|
|
|
let tasksLinkHTML;
|
|
|
|
|
2020-04-24 21:43:10 +08:00
|
|
|
if (data.tasks > 0) {
|
|
|
|
let tooltip = I18n.t('repositories.table.assigned_tooltip', {
|
|
|
|
tasks: data.tasks,
|
|
|
|
experiments: data.experiments,
|
|
|
|
projects: data.projects
|
2020-04-28 18:41:59 +08:00
|
|
|
});
|
2022-03-09 21:13:48 +08:00
|
|
|
tasksLinkHTML = `<div class="assign-counter-container dropdown" title="${tooltip}"
|
2020-04-24 21:43:10 +08:00
|
|
|
data-task-list-url="${data.task_list_url}">
|
|
|
|
<a href="#" class="assign-counter has-assigned"
|
|
|
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">${data.tasks}</a>
|
|
|
|
<div class="dropdown-menu" role="menu">
|
2020-05-22 20:36:28 +08:00
|
|
|
<div class="sci-input-container right-icon">
|
2023-05-26 07:14:27 +08:00
|
|
|
<input id="searchAssignedTasks" type="text" class="sci-input-field search-tasks"
|
2023-03-21 22:24:40 +08:00
|
|
|
placeholder="${I18n.t('repositories.table.assigned_search')}"></input>
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-close-remove clear-search"></i>
|
2020-04-28 18:41:59 +08:00
|
|
|
</div>
|
2020-04-24 21:43:10 +08:00
|
|
|
<div class="tasks"></div>
|
|
|
|
</div>
|
2020-04-28 18:41:59 +08:00
|
|
|
</div>`;
|
2022-03-09 21:13:48 +08:00
|
|
|
} else {
|
|
|
|
tasksLinkHTML = "<div class='assign-counter-container'><span class='assign-counter'>0</span></div>";
|
|
|
|
}
|
|
|
|
if (row.hasActiveReminders) {
|
2022-04-09 00:08:55 +08:00
|
|
|
return `<div class="dropdown row-reminders-dropdown" data-row-reminders-url="${row.rowRemindersUrl}" tabindex='-1'>
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-notifications dropdown-toggle row-reminders-icon" data-toggle="dropdown"
|
2022-04-09 00:08:55 +08:00
|
|
|
id="rowReminders${row.DT_RowId}}"></i>
|
2022-03-09 22:09:49 +08:00
|
|
|
<ul class="dropdown-menu" role="menu" aria-labelledby="rowReminders${row.DT_RowId}">
|
|
|
|
</ul>
|
|
|
|
</div>`
|
2022-03-09 21:13:48 +08:00
|
|
|
+ tasksLinkHTML;
|
2020-04-24 21:43:10 +08:00
|
|
|
}
|
2022-03-09 21:13:48 +08:00
|
|
|
|
|
|
|
return tasksLinkHTML;
|
2020-04-24 21:43:10 +08:00
|
|
|
};
|
2022-01-18 20:17:05 +08:00
|
|
|
|
2022-03-08 21:52:45 +08:00
|
|
|
$.fn.dataTable.render.RepositoryStockValue = function(data) {
|
|
|
|
if (data) {
|
|
|
|
if (data.value) {
|
|
|
|
if (data.stock_managable) {
|
2022-04-14 20:27:31 +08:00
|
|
|
return `<a class="manage-repository-stock-value-link stock-value-view-render stock-${data.stock_status}">
|
2022-03-08 21:52:45 +08:00
|
|
|
${data.value.stock_formatted}
|
|
|
|
</a>`;
|
|
|
|
}
|
|
|
|
return `<span class="stock-value-view-render
|
2022-04-25 21:23:12 +08:00
|
|
|
${data.displayWarnings ? `stock-${data.stock_status}` : ''}">
|
2022-01-19 20:19:56 +08:00
|
|
|
${data.value.stock_formatted}
|
2022-03-08 21:52:45 +08:00
|
|
|
</span>`;
|
|
|
|
}
|
|
|
|
if (data.stock_managable) {
|
|
|
|
return `<a class="manage-repository-stock-value-link not-assigned-stock">
|
|
|
|
<i class="fas fa-box-open"></i>
|
|
|
|
${I18n.t('libraries.manange_modal_column.stock_type.add_stock')}
|
|
|
|
</a>`;
|
2022-01-19 20:19:56 +08:00
|
|
|
}
|
|
|
|
}
|
2022-01-20 19:44:57 +08:00
|
|
|
return `<span class="empty-stock-render">
|
2022-01-19 20:19:56 +08:00
|
|
|
${I18n.t('libraries.manange_modal_column.stock_type.no_item_stock')}
|
|
|
|
</span>`;
|
|
|
|
};
|
2022-01-18 20:17:05 +08:00
|
|
|
|
2022-02-16 16:40:48 +08:00
|
|
|
$.fn.dataTable.render.defaultRepositoryStockValue = function() {
|
|
|
|
return $.fn.dataTable.render.RepositoryStockValue();
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.dataTable.render.RepositoryStockConsumptionValue = function(data = {}) {
|
2022-04-20 17:07:26 +08:00
|
|
|
// covers case of snapshots
|
2022-04-25 21:23:12 +08:00
|
|
|
if (!data.stock_present && data.value && data.value.consumed_stock !== null) {
|
2022-04-20 17:07:26 +08:00
|
|
|
return `<span class="empty-consumed-stock-render">${data.value.consumed_stock_formatted}</span>`;
|
|
|
|
}
|
2022-04-14 20:27:31 +08:00
|
|
|
if (!data.stock_present) {
|
|
|
|
return '<span class="empty-consumed-stock-render"> - </span>';
|
2022-01-25 19:12:55 +08:00
|
|
|
}
|
2022-04-25 21:23:12 +08:00
|
|
|
if (!data.consumptionManagable && data.value && !data.value.consumed_stock) {
|
2022-04-14 20:27:31 +08:00
|
|
|
return `<span class="consumption-locked">
|
|
|
|
${I18n.t('libraries.manange_modal_column.stock_type.stock_consumption_locked')}
|
|
|
|
</span>`;
|
|
|
|
}
|
2022-04-25 21:23:12 +08:00
|
|
|
if (!data.consumptionPermitted || !data.consumptionManagable) {
|
2022-04-14 20:27:31 +08:00
|
|
|
return `<span class="empty-consumed-stock-render">${data.value.consumed_stock_formatted}</span>`;
|
|
|
|
}
|
|
|
|
if (!data.value.consumed_stock) {
|
2022-01-28 18:10:56 +08:00
|
|
|
return `<a href="${data.updateStockConsumptionUrl}" class="manage-repository-consumed-stock-value-link">
|
2022-01-25 19:12:55 +08:00
|
|
|
<i class="fas fa-vial"></i>
|
|
|
|
${I18n.t('libraries.manange_modal_column.stock_type.add_stock_consumption')}
|
|
|
|
</a>`;
|
|
|
|
}
|
2022-04-14 20:27:31 +08:00
|
|
|
return `<a href="${data.updateStockConsumptionUrl}"
|
|
|
|
class="manage-repository-consumed-stock-value-link stock-value-view-render">
|
|
|
|
${data.value.consumed_stock_formatted}
|
|
|
|
</a>`;
|
2022-01-25 19:12:55 +08:00
|
|
|
};
|
|
|
|
|
2022-02-16 16:40:48 +08:00
|
|
|
$.fn.dataTable.render.defaultRepositoryStockConsumptionValue = function() {
|
|
|
|
return $.fn.dataTable.render.RepositoryStockConsumptionValue();
|
2022-01-18 20:17:05 +08:00
|
|
|
};
|