mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 16:45:18 +08:00
Add export stock consumption buttons and permission helper [SCI-9022] (#6040)
This commit is contained in:
parent
fe58d9c864
commit
56e411f35e
8 changed files with 38 additions and 97 deletions
|
@ -438,7 +438,7 @@ var RepositoryDatatable = (function(global) {
|
|||
}
|
||||
|
||||
function initExportActions() {
|
||||
$(document).on('click', '#exportRepositoriesButton', function(e) {
|
||||
$(document).on('click', '#exportRepositoryRowsButton', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
.export-consumption-button {
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer[data-assign-item-button="true"] {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
|
|
@ -98,4 +98,8 @@ Canaid::Permissions.register_for(Repository) do
|
|||
can :manage_repository_stock do |user, repository|
|
||||
RepositoryBase.stock_management_enabled? && can_manage_repository_rows?(user, repository)
|
||||
end
|
||||
|
||||
can :export_repository_stock do |user, repository|
|
||||
can_read_repository?(user, repository) && repository.has_stock_management?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,8 @@ module Toolbars
|
|||
edit_action,
|
||||
assign_action,
|
||||
duplicate_action,
|
||||
export_action,
|
||||
export_items_action,
|
||||
export_consumption_action,
|
||||
print_label_action,
|
||||
archive_action,
|
||||
delete_action
|
||||
|
@ -101,15 +102,28 @@ module Toolbars
|
|||
}
|
||||
end
|
||||
|
||||
def export_action
|
||||
def export_items_action
|
||||
return unless can_read_repository?(@repository)
|
||||
|
||||
{
|
||||
name: 'export',
|
||||
label: I18n.t('repositories.export_record'),
|
||||
name: 'export_records',
|
||||
label: I18n.t('repositories.export_records'),
|
||||
icon: 'sn-icon sn-icon-export',
|
||||
button_class: 'export-repository-row-btn',
|
||||
button_id: 'exportRepositoriesButton',
|
||||
button_id: 'exportRepositoryRowsButton',
|
||||
type: :legacy
|
||||
}
|
||||
end
|
||||
|
||||
def export_consumption_action
|
||||
return unless can_export_repository_stock?(@repository)
|
||||
|
||||
{
|
||||
name: 'export_consumption',
|
||||
label: I18n.t('repositories.export_stock_consumption'),
|
||||
icon: 'sn-icon sn-icon-reports',
|
||||
button_class: 'export-repository-stock-consumption-btn',
|
||||
button_id: 'exportStockConsumptionButton',
|
||||
type: :legacy
|
||||
}
|
||||
end
|
||||
|
|
|
@ -112,6 +112,11 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="modal-footer" data-assign-item-button="<%= @my_module.present? %>">
|
||||
<% if can_export_repository_stock?(@repository_row.repository) %>
|
||||
<button type="button" class="btn btn-secondary export-consumption-button" data-rows="[<%= @repository_row.id %>]">
|
||||
<%= t('repository_row.modal_info.export_consumption_label') %>
|
||||
</button>
|
||||
<% end %>
|
||||
<% if @my_module %>
|
||||
<button type="button" class="btn btn-secondary print-label-button" data-rows="[<%= @repository_row.id %>]"><%= t('repository_row.modal_print_label.print_label') %></button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.close')%></button>
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<% if @repository.active? %>
|
||||
<%= t('repositories.show.archived_view_label.active', repository_name: @repository.name) %>
|
||||
<% else %>
|
||||
<table>
|
||||
<tr>
|
||||
<td><%= t('repositories.show.archived_view_label.archived_on') %></td>
|
||||
<td><%= I18n.l(@repository.archived_on, format: :full) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t('repositories.show.archived_view_label.archived_by') %></td>
|
||||
<td><%= @repository.archived_by.full_name %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
|
@ -1,71 +0,0 @@
|
|||
<% if can_manage_repository_rows?(@repository) %>
|
||||
<span id="editDeleteCopy" data-toggle="buttons" style="display:none">
|
||||
<% if can_manage_repository_rows?(@repository) %>
|
||||
<button type="button" title="<%= t('repositories.show.button_tooltip.edit') %>"
|
||||
class="btn btn-light editAdd auto-shrink-button"
|
||||
id="editRepositoryRecord" data-view-mode="active">
|
||||
<span class="sn-icon sn-icon-edit"></span>
|
||||
<span class="button-text"><%= t("repositories.edit_record") %></span>
|
||||
</button>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if can_create_repository_rows?(@repository) %>
|
||||
<button type="button"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="<%= t('repositories.show.button_tooltip.duplicate') %>"
|
||||
class="btn btn-light copyRow auto-shrink-button"
|
||||
id="copyRepositoryRecords" disabled data-view-mode="active">
|
||||
<span class="sn-icon sn-icon-duplicate"></span>
|
||||
<span class="button-text"><%= t("repositories.copy_record") %></span>
|
||||
</button>
|
||||
<% end %>
|
||||
<button class="btn btn-light auto-shrink-button"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="<%= t('repositories.show.button_tooltip.export') %>"
|
||||
id="exportRepositoriesButton">
|
||||
<span class="sn-icon sn-icon-export"></span>
|
||||
<span class="button-text"><%= t("repositories.index.options_dropdown.export_items") %></span>
|
||||
</button>
|
||||
<%= render partial: 'repositories/toolbar/print_label_button' %>
|
||||
<% if can_delete_repository_rows?(@repository) %>
|
||||
<button type="button"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="<%= t('repositories.show.button_tooltip.archive') %>"
|
||||
class="btn btn-light auto-shrink-button"
|
||||
id="archiveRepositoryRecordsButton" disabled data-view-mode="active">
|
||||
<span class="sn-icon sn-icon-archive"></span>
|
||||
<span class="button-text"><%= t'repositories.archive_record' %></span>
|
||||
</button>
|
||||
<% end %>
|
||||
<button type="button" class="btn btn-light auto-shrink-button" id="restoreRepositoryRecords" disabled data-view-mode="archived">
|
||||
<span class="sn-icon sn-icon-restore"></span>
|
||||
<span class="button-text"><%= t("repositories.restore_record") %></span>
|
||||
</button>
|
||||
<% if can_delete_repository_rows?(@repository) %>
|
||||
<button type="button" class="btn btn-light auto-shrink-buttons" id="deleteRepositoryRecords" disabled data-view-mode="archived">
|
||||
<span class="sn-icon sn-icon-delete"></span>
|
||||
<span class="button-text"><%= t("repositories.delete_record") %></span>
|
||||
</button>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
<span id="saveCancel" data-toggle="buttons" style="display:none">
|
||||
<button type="button" class="btn btn-success prevent-shrink" id="saveRecord" data-view-mode="active">
|
||||
<span class="fas fa-save"></span>
|
||||
<%= t("repositories.save_record") %>
|
||||
</button>
|
||||
<button type="button" class="btn btn-light prevent-shrink" id="cancelSave" data-view-mode="active">
|
||||
<span class="sn-icon sn-icon-close"></span>
|
||||
<%= t("repositories.cancel_save") %>
|
||||
</button>
|
||||
</span>
|
||||
<% elsif @repository.shared_with_read?(current_team) %>
|
||||
<p class="view-only-label"><%= t('repositories.index.view_only_permission_label') %></p>
|
||||
<%= render partial: 'repositories/toolbar/print_label_button' %>
|
||||
<% elsif can_read_repository?(@repository) %>
|
||||
<%= render partial: 'repositories/toolbar/print_label_button' %>
|
||||
<% end %>
|
|
@ -1891,11 +1891,6 @@ en:
|
|||
error_searching: "Error searching, please try again"
|
||||
button_tooltip:
|
||||
new: "Create new item"
|
||||
edit: "Edit item"
|
||||
duplicate: "Duplicate"
|
||||
export: "Export"
|
||||
print_label: "Print label"
|
||||
archive: "Archive"
|
||||
import: "Import"
|
||||
filters: "Filters"
|
||||
search: "Quick search"
|
||||
|
@ -2064,7 +2059,8 @@ en:
|
|||
archive_record: "Archive"
|
||||
restore_record: "Restore"
|
||||
print_label: "Print label"
|
||||
export_record: "Export"
|
||||
export_records: "Export items"
|
||||
export_stock_consumption: "Export consumption"
|
||||
save_record: "Save"
|
||||
cancel_save: "Cancel"
|
||||
hide_reminders: "Clear all reminders"
|
||||
|
@ -2343,6 +2339,7 @@ en:
|
|||
assign_to_task_error:
|
||||
no_access: "You can only view this task"
|
||||
already_assigned: "This item is already assigned to this task"
|
||||
export_consumption_label: "Export consumption"
|
||||
modal_print_label:
|
||||
head_title: "Print label - %{repository_row}"
|
||||
head_title_multiple: "Print label - %{repository_rows} rows"
|
||||
|
|
Loading…
Add table
Reference in a new issue