/* global I18n twemoji */
$.fn.dataTable.render.RepositoryAssetValue = function(data) {
var asset = data.value;
if (asset.id) {
return `
`;
}
return `
${I18n.t('my_modules.repository.full_view.error')}
`;
};
$.fn.dataTable.render.defaultRepositoryAssetValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryTextValue = function(data) {
var text = $(`${data.value.view}`);
text.attr('data-edit-value', data.value.edit);
return text.prop('outerHTML');
};
$.fn.dataTable.render.defaultRepositoryTextValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryListValue = function(data) {
return `${data.value.text}`;
};
$.fn.dataTable.render.defaultRepositoryListValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryStatusValue = function(data) {
return `
${twemoji.parse(data.value.icon)}
${data.value.status}
`;
};
$.fn.dataTable.render.defaultRepositoryStatusValue = function() {
return '';
};
$.fn.dataTable.render.defaultRepositoryDateValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryDateValue = function(data) {
let reminderClass = data.value.reminder ? 'reminder' : '';
return `${data.value.formatted}`;
};
$.fn.dataTable.render.defaultRepositoryDateTimeValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryDateTimeValue = function(data) {
let reminderClass = data.value.reminder ? 'reminder' : '';
return `${data.value.formatted}`;
};
$.fn.dataTable.render.defaultRepositoryTimeValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryTimeValue = function(data) {
return `${data.value.formatted}`;
};
$.fn.dataTable.render.defaultRepositoryTimeRangeValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryTimeRangeValue = function(data) {
return `${data.value.start_time.formatted} -
${data.value.end_time.formatted}`;
};
$.fn.dataTable.render.defaultRepositoryDateTimeRangeValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryDateTimeRangeValue = function(data) {
return `${data.value.start_time.formatted} -
${data.value.end_time.formatted}`;
};
$.fn.dataTable.render.defaultRepositoryDateRangeValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryDateRangeValue = function(data) {
return `${data.value.start_time.formatted} -
${data.value.end_time.formatted}`;
};
$.fn.dataTable.render.RepositoryChecklistValue = function(data) {
var render = '—';
var options = data.value;
var optionsList;
if (options.length === 1) {
render = `
${options[0].label}
`;
} else if (options.length > 1) {
optionsList = $(' ${option.label}`).appendTo(optionsList);
});
render = `
${options.length} ${I18n.t('libraries.manange_modal_column.checklist_type.multiple_options')}
${optionsList[0].outerHTML}
`;
}
return render;
};
$.fn.dataTable.render.defaultRepositoryChecklistValue = function() {
return '—';
};
$.fn.dataTable.render.defaultRepositoryNumberValue = function() {
return '';
};
$.fn.dataTable.render.RepositoryNumberValue = function(data) {
return `
${data.value}
`;
};
$.fn.dataTable.render.AssignedTasksValue = function(data, row) {
let tasksLinkHTML;
if (data.tasks > 0) {
let tooltip = I18n.t('repositories.table.assigned_tooltip', {
tasks: data.tasks,
experiments: data.experiments,
projects: data.projects
});
tasksLinkHTML = ``;
} else {
tasksLinkHTML = "0
";
}
if (row.hasActiveReminders) {
return `
`
+ tasksLinkHTML;
}
return tasksLinkHTML;
};
$.fn.dataTable.render.RepositoryStockValue = function(data) {
if (data) {
if (data.value) {
if (data.stock_managable) {
return `
${data.value.stock_formatted}
`;
}
return `
${data.value.stock_formatted}
`;
}
if (data.stock_managable) {
return `
${I18n.t('libraries.manange_modal_column.stock_type.add_stock')}
`;
}
}
return `
${I18n.t('libraries.manange_modal_column.stock_type.no_item_stock')}
`;
};
$.fn.dataTable.render.defaultRepositoryStockValue = function() {
return $.fn.dataTable.render.RepositoryStockValue();
};
$.fn.dataTable.render.RepositoryStockConsumptionValue = function(data = {}) {
// covers case of snapshots
if (!data.stock_present && data.value && data.value.consumed_stock !== null) {
return `${data.value.consumed_stock_formatted}`;
}
if (!data.stock_present) {
return ' - ';
}
if (!data.consumptionManagable && data.value && !data.value.consumed_stock) {
return `
${I18n.t('libraries.manange_modal_column.stock_type.stock_consumption_locked')}
`;
}
if (!data.consumptionPermitted || !data.consumptionManagable) {
return `${data.value.consumed_stock_formatted}`;
}
if (!data.value.consumed_stock) {
return `
${I18n.t('libraries.manange_modal_column.stock_type.add_stock_consumption')}
`;
}
return `
${data.value.consumed_stock_formatted}
`;
};
$.fn.dataTable.render.defaultRepositoryStockConsumptionValue = function() {
return $.fn.dataTable.render.RepositoryStockConsumptionValue();
};