2024-01-06 01:58:12 +08:00
|
|
|
<template>
|
|
|
|
<div class="h-full">
|
|
|
|
<DataTable :columnDefs="columnDefs"
|
2024-01-15 21:44:14 +08:00
|
|
|
tableId="Repositories"
|
2024-01-06 01:58:12 +08:00
|
|
|
:dataUrl="dataSource"
|
|
|
|
:reloadingTable="reloadingTable"
|
|
|
|
:currentViewMode="currentViewMode"
|
|
|
|
:toolbarActions="toolbarActions"
|
|
|
|
:activePageUrl="activePageUrl"
|
|
|
|
:archivedPageUrl="archivedPageUrl"
|
|
|
|
:actionsUrl="actionsUrl"
|
|
|
|
@archive="archive"
|
|
|
|
@restore="restore"
|
|
|
|
@delete="deleteRepository"
|
|
|
|
@update="update"
|
|
|
|
@duplicate="duplicate"
|
|
|
|
@export="exportRepositories"
|
|
|
|
@share="share"
|
|
|
|
@create="newRepository = true"
|
|
|
|
@tableReloaded="reloadingTable = false"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<ConfirmationModal
|
|
|
|
:title="deleteModal.title"
|
|
|
|
:description="deleteModal.description"
|
|
|
|
confirmClass="btn btn-danger"
|
|
|
|
:confirmText="i18n.t('repositories.index.modal_delete.delete')"
|
|
|
|
ref="deleteModal"
|
2024-05-23 19:12:05 +08:00
|
|
|
:e2eAttributes="deleteModal.e2eAttributes"
|
2024-01-06 01:58:12 +08:00
|
|
|
></ConfirmationModal>
|
2024-04-10 22:55:49 +08:00
|
|
|
<ExportRepositoryModal
|
|
|
|
v-if="exportRepository"
|
|
|
|
:rows="exportRepository"
|
|
|
|
:exportAction="exportAction"
|
|
|
|
@close="exportRepository = null; exportAction = null"
|
|
|
|
@export="updateTable"
|
|
|
|
></ExportRepositoryModal>
|
2024-01-06 01:58:12 +08:00
|
|
|
<NewRepositoryModal
|
|
|
|
v-if="newRepository"
|
|
|
|
:createUrl="createUrl"
|
|
|
|
@close="newRepository = false"
|
|
|
|
@create="updateTable" />
|
|
|
|
<EditRepositoryModal
|
|
|
|
v-if="editRepository"
|
|
|
|
:repository="editRepository"
|
|
|
|
@close="editRepository = null"
|
|
|
|
@update="updateTable" />
|
|
|
|
<DuplicateRepositoryModal
|
|
|
|
v-if="duplicateRepository"
|
|
|
|
:repository="duplicateRepository"
|
|
|
|
@close="duplicateRepository = null"
|
|
|
|
@duplicate="updateTable" />
|
|
|
|
<ShareRepositoryModal
|
|
|
|
v-if="shareRepository"
|
|
|
|
:repository="shareRepository"
|
|
|
|
@close="shareRepository = null"
|
|
|
|
@share="updateTable" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
/* global HelperModule */
|
|
|
|
|
|
|
|
import axios from '../../packs/custom_axios.js';
|
|
|
|
import ConfirmationModal from '../shared/confirmation_modal.vue';
|
2024-04-10 22:55:49 +08:00
|
|
|
import ExportRepositoryModal from './modals/export.vue';
|
2024-01-06 01:58:12 +08:00
|
|
|
import NewRepositoryModal from './modals/new.vue';
|
|
|
|
import EditRepositoryModal from './modals/edit.vue';
|
|
|
|
import DuplicateRepositoryModal from './modals/duplicate.vue';
|
|
|
|
import ShareRepositoryModal from './modals/share.vue';
|
|
|
|
import DataTable from '../shared/datatable/table.vue';
|
2024-09-03 19:22:57 +08:00
|
|
|
import NameRenderer from './renderers/name.vue';
|
2024-01-06 01:58:12 +08:00
|
|
|
|
|
|
|
export default {
|
2024-02-27 21:30:04 +08:00
|
|
|
name: 'RepositoriesTable',
|
2024-01-06 01:58:12 +08:00
|
|
|
components: {
|
|
|
|
DataTable,
|
|
|
|
ConfirmationModal,
|
2024-04-10 22:55:49 +08:00
|
|
|
ExportRepositoryModal,
|
2024-01-06 01:58:12 +08:00
|
|
|
NewRepositoryModal,
|
|
|
|
EditRepositoryModal,
|
|
|
|
DuplicateRepositoryModal,
|
2024-09-03 19:22:57 +08:00
|
|
|
ShareRepositoryModal,
|
|
|
|
NameRenderer
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
dataSource: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
actionsUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
createUrl: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
currentViewMode: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
activePageUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
archivedPageUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
reloadingTable: false,
|
2024-04-10 22:55:49 +08:00
|
|
|
exportRepository: null,
|
2024-01-06 01:58:12 +08:00
|
|
|
newRepository: false,
|
|
|
|
editRepository: null,
|
|
|
|
duplicateRepository: null,
|
|
|
|
shareRepository: null,
|
2024-04-10 22:55:49 +08:00
|
|
|
exportAction: null,
|
2024-01-06 01:58:12 +08:00
|
|
|
deleteModal: {
|
|
|
|
title: '',
|
2024-05-16 20:34:59 +08:00
|
|
|
description: '',
|
2024-05-23 19:12:05 +08:00
|
|
|
e2eAttributes: {
|
|
|
|
modalName: '',
|
|
|
|
title: '',
|
|
|
|
close: '',
|
|
|
|
cancel: '',
|
|
|
|
confirm: ''
|
2024-05-24 19:26:58 +08:00
|
|
|
}
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
exportModal: {
|
|
|
|
title: '',
|
|
|
|
description: ''
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
columnDefs() {
|
|
|
|
const columns = [{
|
|
|
|
field: 'name',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.name'),
|
|
|
|
sortable: true,
|
|
|
|
notSelectable: true,
|
2024-09-03 19:22:57 +08:00
|
|
|
cellRenderer: 'NameRenderer'
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
2024-02-09 07:32:43 +08:00
|
|
|
{
|
|
|
|
field: 'code',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.id'),
|
|
|
|
sortable: true
|
|
|
|
},
|
2024-01-06 01:58:12 +08:00
|
|
|
{
|
|
|
|
field: 'nr_of_rows',
|
2024-02-07 19:23:21 +08:00
|
|
|
headerName: this.i18n.t('libraries.index.table.number_of_items'),
|
|
|
|
sortable: true
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'shared_label',
|
2024-05-22 21:56:03 +08:00
|
|
|
headerName: this.i18n.t('libraries.index.table.shared'),
|
|
|
|
sortable: true
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'team',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.ownership'),
|
2024-03-01 19:16:04 +08:00
|
|
|
sortable: true
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'created_at',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.added_on'),
|
|
|
|
sortable: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'created_by',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.added_by'),
|
2024-03-01 19:16:04 +08:00
|
|
|
sortable: true
|
2024-01-06 01:58:12 +08:00
|
|
|
}];
|
|
|
|
|
|
|
|
if (this.currentViewMode === 'archived') {
|
|
|
|
columns.push({
|
|
|
|
field: 'archived_on',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.archived_on'),
|
|
|
|
sortable: true
|
|
|
|
});
|
|
|
|
columns.push({
|
|
|
|
field: 'archived_by',
|
|
|
|
headerName: this.i18n.t('libraries.index.table.archived_by'),
|
2024-03-01 19:16:04 +08:00
|
|
|
sortable: true
|
2024-01-06 01:58:12 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return columns;
|
|
|
|
},
|
|
|
|
toolbarActions() {
|
|
|
|
const left = [];
|
2024-04-18 22:19:18 +08:00
|
|
|
if (this.createUrl && this.currentViewMode !== 'archived') {
|
2024-01-06 01:58:12 +08:00
|
|
|
left.push({
|
|
|
|
name: 'create',
|
|
|
|
icon: 'sn-icon sn-icon-new-task',
|
|
|
|
label: this.i18n.t('libraries.index.no_libraries.create_new_button'),
|
|
|
|
type: 'emit',
|
|
|
|
path: this.createUrl,
|
|
|
|
buttonStyle: 'btn btn-primary'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
left,
|
|
|
|
right: []
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateTable() {
|
|
|
|
this.reloadingTable = true;
|
|
|
|
this.newRepository = false;
|
|
|
|
this.editRepository = null;
|
|
|
|
this.duplicateRepository = null;
|
|
|
|
this.shareRepository = null;
|
2024-04-10 22:55:49 +08:00
|
|
|
this.exportRepository = null;
|
|
|
|
this.exportAction = null;
|
2024-01-06 01:58:12 +08:00
|
|
|
},
|
|
|
|
archive(event, rows) {
|
|
|
|
axios.post(event.path, { repository_ids: rows.map((row) => row.id) }).then((response) => {
|
|
|
|
this.updateTable();
|
|
|
|
HelperModule.flashAlertMsg(response.data.message, 'success');
|
|
|
|
}).catch((error) => {
|
|
|
|
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
restore(event, rows) {
|
|
|
|
axios.post(event.path, { repository_ids: rows.map((row) => row.id) }).then((response) => {
|
|
|
|
this.updateTable();
|
|
|
|
HelperModule.flashAlertMsg(response.data.message, 'success');
|
|
|
|
}).catch((error) => {
|
|
|
|
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async deleteRepository(event, rows) {
|
|
|
|
const [repository] = rows;
|
2024-05-23 19:12:05 +08:00
|
|
|
this.deleteModal.e2eAttributes = {
|
|
|
|
modalName: 'e2e-MD-deleteInventory',
|
|
|
|
title: 'e2e-TX-deleteInventoryModal-title',
|
|
|
|
close: 'e2e-BT-deleteInventoryModal-close',
|
|
|
|
cancel: 'e2e-BT-deleteInventoryModal-cancel',
|
|
|
|
confirm: 'e2e-BT-deleteInventoryModal-delete'
|
2024-05-24 19:26:58 +08:00
|
|
|
};
|
2024-01-06 01:58:12 +08:00
|
|
|
this.deleteModal.title = this.i18n.t('repositories.index.modal_delete.title_html', { name: repository.name });
|
|
|
|
this.deleteModal.description = `
|
2024-05-16 20:34:59 +08:00
|
|
|
<p data-e2e="e2e-TX-deleteInventoryModal-info">${this.i18n.t('repositories.index.modal_delete.message_html', { name: repository.name })}</p>
|
|
|
|
<div class="alert alert-danger" role="alert" data-e2e="e2e-TX-deleteInventoryModal-warning">
|
2024-01-06 01:58:12 +08:00
|
|
|
<span class="fas fa-exclamation-triangle"></span>
|
|
|
|
${this.i18n.t('repositories.index.modal_delete.alert_heading')}
|
|
|
|
<ul>
|
|
|
|
<li>${this.i18n.t('repositories.index.modal_delete.alert_line_1')}</li>
|
|
|
|
<li>${this.i18n.t('repositories.index.modal_delete.alert_line_2')}</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ok = await this.$refs.deleteModal.show();
|
|
|
|
if (ok) {
|
|
|
|
axios.delete(event.path).then((response) => {
|
|
|
|
this.updateTable();
|
|
|
|
HelperModule.flashAlertMsg(response.data.message, 'success');
|
|
|
|
}).catch((error) => {
|
|
|
|
HelperModule.flashAlertMsg(error.response.data.error, 'danger');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2024-04-10 22:55:49 +08:00
|
|
|
exportRepositories(action, rows) {
|
|
|
|
this.exportRepository = rows;
|
|
|
|
this.exportAction = action;
|
|
|
|
},
|
2024-01-06 01:58:12 +08:00
|
|
|
update(_event, rows) {
|
|
|
|
const [repository] = rows;
|
|
|
|
this.editRepository = repository;
|
|
|
|
},
|
|
|
|
duplicate(_event, rows) {
|
|
|
|
const [repository] = rows;
|
|
|
|
this.duplicateRepository = repository;
|
|
|
|
},
|
|
|
|
share(_event, rows) {
|
|
|
|
const [repository] = rows;
|
|
|
|
this.shareRepository = repository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|