2023-09-18 22:24:07 +08:00
|
|
|
/* global PrintModalComponent RepositoryDatatable HelperModule MyModuleRepositories */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2023-12-21 19:32:35 +08:00
|
|
|
$(document).on('click', '.relationships-info-link', (e) => {
|
|
|
|
const myModuleId = $('.my-module-content').data('task-id');
|
|
|
|
const repositoryRowURL = $(e.target).attr('href');
|
|
|
|
|
2023-10-02 22:11:32 +08:00
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
2023-11-14 23:58:10 +08:00
|
|
|
|
|
|
|
window.repositoryItemSidebarComponent.toggleShowHideSidebar(repositoryRowURL, myModuleId, 'relationships-section');
|
2023-10-02 22:11:32 +08:00
|
|
|
});
|
|
|
|
|
2023-11-10 16:19:45 +08:00
|
|
|
$(document).on('click', '.record-info-link', function (e) {
|
2023-10-19 22:35:23 +08:00
|
|
|
const myModuleId = $('.my-module-content').data('task-id');
|
2023-10-12 21:46:13 +08:00
|
|
|
const repositoryRowURL = $(this).attr('href');
|
|
|
|
|
2023-09-18 22:24:07 +08:00
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
|
2023-11-14 23:58:10 +08:00
|
|
|
window.repositoryItemSidebarComponent.toggleShowHideSidebar(repositoryRowURL, myModuleId, null);
|
2023-09-18 22:24:07 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '.print-label-button', function(e) {
|
2024-01-09 16:33:40 +08:00
|
|
|
$.removeData($(this)[0], 'rows');
|
|
|
|
|
2023-09-18 22:24:07 +08:00
|
|
|
var selectedRows = $(this).data('rows');
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
if (typeof PrintModalComponent !== 'undefined') {
|
2023-11-21 20:39:21 +08:00
|
|
|
PrintModalComponent.openModal();
|
2023-09-18 22:24:07 +08:00
|
|
|
if (selectedRows && selectedRows.length) {
|
|
|
|
$('#modal-info-repository-row').modal('hide');
|
2024-01-09 16:37:50 +08:00
|
|
|
PrintModalComponent.repository_id = $(this).data('repositoryId');
|
2023-09-18 22:24:07 +08:00
|
|
|
PrintModalComponent.row_ids = selectedRows;
|
|
|
|
} else {
|
2024-01-09 16:37:50 +08:00
|
|
|
PrintModalComponent.repository_id = RepositoryDatatable.repositoryId();
|
2023-09-18 22:24:07 +08:00
|
|
|
PrintModalComponent.row_ids = [...RepositoryDatatable.selectedRows()];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '.assign-inventory-button', function(e) {
|
|
|
|
e.preventDefault();
|
2023-10-12 21:46:13 +08:00
|
|
|
const assignUrl = $(this).attr('data-assign-url');
|
|
|
|
const repositoryRowId = $(this).attr('data-repository-row-id');
|
2023-09-18 22:24:07 +08:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: assignUrl,
|
|
|
|
type: 'POST',
|
|
|
|
data: { repository_row_id: repositoryRowId },
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
|
|
|
HelperModule.flashAlertMsg(data.flash, 'success');
|
|
|
|
$('#modal-info-repository-row').modal('hide');
|
|
|
|
if (typeof MyModuleRepositories !== 'undefined') {
|
|
|
|
MyModuleRepositories.reloadRepositoriesList(repositoryRowId);
|
|
|
|
}
|
2023-10-12 21:46:13 +08:00
|
|
|
window.repositoryItemSidebarComponent.reload();
|
2023-09-18 22:24:07 +08:00
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
HelperModule.flashAlertMsg(error.responseJSON.flash, 'danger');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-10-12 20:43:17 +08:00
|
|
|
|
|
|
|
$(document).on('click', '.export-consumption-button', function(e) {
|
|
|
|
const selectedRows = $(this).data('rows') || RepositoryDatatable.selectedRows();
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
window.initExportStockConsumptionModal();
|
|
|
|
|
|
|
|
if (window.exportStockConsumptionModalComponent) {
|
|
|
|
window.exportStockConsumptionModalComponent.fetchRepositoryData(
|
|
|
|
selectedRows,
|
|
|
|
{ repository_id: $(this).data('objectId') },
|
|
|
|
);
|
|
|
|
$('#modal-info-repository-row').modal('hide');
|
|
|
|
}
|
|
|
|
});
|
2023-10-27 16:31:38 +08:00
|
|
|
$(document).on('click', '.manage-repository-stock-value-link', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
window.initManageStockValueModalComponent();
|
|
|
|
if (window.manageStockModalComponent) {
|
|
|
|
const $link = $(e.target).parents('a')[0] ? $(e.target).parents('a') : $(e.target);
|
|
|
|
const stockValueUrl = $link.data('manage-stock-url');
|
|
|
|
let updateCallback;
|
|
|
|
if (stockValueUrl) {
|
|
|
|
updateCallback = (data) => {
|
|
|
|
if (!data?.value) return;
|
|
|
|
// reload dataTable
|
2024-01-09 23:53:46 +08:00
|
|
|
if ($('.dataTable.repository-dataTable')[0]) $('.dataTable.repository-dataTable').DataTable().ajax.reload(null, false);
|
2023-10-27 16:31:38 +08:00
|
|
|
// update item card stock column
|
2023-10-30 16:47:10 +08:00
|
|
|
window.manageStockCallback && window.manageStockCallback(data.value);
|
|
|
|
$link.data('manageStockUrl', data.value.stock_url)
|
2023-10-27 16:31:38 +08:00
|
|
|
};
|
|
|
|
window.manageStockModalComponent.showModal(stockValueUrl, updateCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-09-18 22:24:07 +08:00
|
|
|
}());
|