mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-25 14:36:41 +08:00
Add stock table renders [SCI-6412] (#3787)
Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
parent
01f1b5bd10
commit
05547da457
7 changed files with 88 additions and 1 deletions
|
@ -135,3 +135,8 @@ $.fn.dataTable.render.editRepositoryNumberValue = function(formId, columnId, cel
|
|||
data-type="RepositoryNumberValue">
|
||||
</div>`);
|
||||
};
|
||||
|
||||
$.fn.dataTable.render.editRepositoryStockValue = function(formId, columnId, cell) {
|
||||
return cell.node();
|
||||
};
|
||||
|
||||
|
|
|
@ -88,3 +88,7 @@ $.fn.dataTable.render.newRepositoryDateRangeValue = function(formId, columnId, $
|
|||
$.fn.dataTable.render.newRepositoryTimeRangeValue = function(formId, columnId, $cell) {
|
||||
DateTimeHelper.initDateTimeRangeEditMode(formId, columnId, $cell, 'timeonly', 'RepositoryTimeRangeValue');
|
||||
};
|
||||
|
||||
$.fn.dataTable.render.newRepositoryStockValue = function() {
|
||||
return '';
|
||||
};
|
||||
|
|
|
@ -181,7 +181,30 @@ $.fn.dataTable.render.AssignedTasksValue = function(data) {
|
|||
return "<div class='assign-counter-container'><span class='assign-counter'>0</span></div>";
|
||||
};
|
||||
|
||||
$.fn.dataTable.render.RepositoryStockValue = function(data) {
|
||||
let canManage = $('.repository-table > table').data('editable');
|
||||
if (data) {
|
||||
if (canManage) {
|
||||
return `<a class="manage-repository-stock-value-link stock-value-view-render
|
||||
${data.value.stock_amount <= 0 ? 'stock-alert' : ''}" data-manage-url="">
|
||||
${data.value.stock_formatted}
|
||||
</a>`;
|
||||
}
|
||||
return `<span class="stock-value-view-render
|
||||
${data.value.stock_amount <= 0 ? 'stock-alert' : ''}" data-manage-url="">
|
||||
${data.value.stock_formatted}
|
||||
</span>`;
|
||||
} else if (canManage) {
|
||||
return `<a class="manage-repository-stock-value-link not-assigned-stock" data-manage-url="">
|
||||
<i class="fas fa-box-open"></i>
|
||||
${I18n.t('libraries.manange_modal_column.stock_type.add_stock')}
|
||||
</a>`;
|
||||
}
|
||||
return `<span class="empty-stock-render" data-manage-url="">
|
||||
${I18n.t('libraries.manange_modal_column.stock_type.no_item_stock')}
|
||||
</span>`;
|
||||
};
|
||||
|
||||
$.fn.dataTable.render.defaultRepositoryStockValue = function() {
|
||||
return '';
|
||||
return $.fn.dataTable.render.RepositoryStockValue();
|
||||
};
|
||||
|
|
|
@ -159,6 +159,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Stock
|
||||
.stock-value-view-render {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
};
|
||||
|
||||
&.stock-alert {
|
||||
color: $brand-danger;
|
||||
|
||||
&::before {
|
||||
@include font-awesome;
|
||||
content: $font-fas-exclamation-triangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.not-assigned-stock {
|
||||
color: $color-black;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
};
|
||||
}
|
||||
|
||||
.empty-stock-render {
|
||||
color: $color-silver-chalice;
|
||||
}
|
||||
|
||||
// DateTime
|
||||
.datetime-container {
|
||||
display: flex;
|
||||
|
|
|
@ -247,6 +247,16 @@ class User < ApplicationRecord
|
|||
foreign_key: 'last_modified_by_id',
|
||||
inverse_of: :last_modified_by,
|
||||
dependent: :nullify
|
||||
has_many :created_repository_stock_value,
|
||||
class_name: 'RepositoryStockValue',
|
||||
foreign_key: 'created_by_id',
|
||||
inverse_of: :created_by,
|
||||
dependent: :nullify
|
||||
has_many :modified_repository_stock_value,
|
||||
class_name: 'RepositoryStockValue',
|
||||
foreign_key: 'created_by_id',
|
||||
inverse_of: :last_modified_by,
|
||||
dependent: :nullify
|
||||
has_many :created_repository_checklist_types,
|
||||
class_name: 'RepositoryChecklistItem',
|
||||
foreign_key: 'created_by_id',
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module RepositoryDatatable
|
||||
class RepositoryStockValueSerializer < RepositoryBaseValueSerializer
|
||||
def value
|
||||
{
|
||||
stock_formatted: object.formatted,
|
||||
stock_amount: object.data
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1598,6 +1598,8 @@ en:
|
|||
all_options: 'All options'
|
||||
stock_units: 'Stock units'
|
||||
units_description: 'These units will appear when managing your stock. You can always add, remove or rename them in the list.'
|
||||
add_stock: 'Add stock'
|
||||
no_item_stock: 'No item stock'
|
||||
checklist_type:
|
||||
multiple_options: 'selected'
|
||||
all_options: 'All options'
|
||||
|
|
Loading…
Add table
Reference in a new issue