mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-22 13:04:30 +08:00
Add repository item card to storage container [SCI-11048]
This commit is contained in:
parent
e20467bf51
commit
f4e1498df1
6 changed files with 55 additions and 16 deletions
|
@ -7,4 +7,4 @@ const app = createApp();
|
||||||
app.component('StorageLocationsContainer', StorageLocationsContainer);
|
app.component('StorageLocationsContainer', StorageLocationsContainer);
|
||||||
app.config.globalProperties.i18n = window.I18n;
|
app.config.globalProperties.i18n = window.I18n;
|
||||||
app.use(PerfectScrollbar);
|
app.use(PerfectScrollbar);
|
||||||
mountWithTurbolinks(app, '#StorageLocationsContainer');
|
window.StorageLocationsContainer = mountWithTurbolinks(app, '#StorageLocationsContainer');
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
<div v-for="(position) in location.positions" :key="position.id">
|
<div v-for="(position) in location.positions" :key="position.id">
|
||||||
<div v-if="position.metadata.position" class="flex items-center font-sm gap-1 uppercase bg-sn-grey-300 rounded pl-1.5 pr-2">
|
<div v-if="position.metadata.position" class="flex items-center font-sm gap-1 uppercase bg-sn-grey-300 rounded pl-1.5 pr-2">
|
||||||
{{ formatPosition(position.metadata.position) }}
|
{{ formatPosition(position.metadata.position) }}
|
||||||
<i v-if="repositoryRow.permissions.can_manage" class="sn-icon sn-icon-unlink-italic-s cursor-pointer"></i>
|
<i v-if="repositoryRow.permissions.can_manage"
|
||||||
|
@click="unassignRow(location.id, position.id)"
|
||||||
|
class="sn-icon sn-icon-unlink-italic-s cursor-pointer"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -41,8 +43,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AssignModal from '../storage_locations/modals/assign.vue';
|
import AssignModal from '../storage_locations/modals/assign.vue';
|
||||||
|
import axios from '../../packs/custom_axios.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
storage_location_path
|
storage_location_path,
|
||||||
|
unassign_rows_storage_location_path
|
||||||
} from '../../routes.js';
|
} from '../../routes.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -71,6 +76,15 @@ export default {
|
||||||
},
|
},
|
||||||
numberToLetter(number) {
|
numberToLetter(number) {
|
||||||
return String.fromCharCode(96 + number);
|
return String.fromCharCode(96 + number);
|
||||||
|
},
|
||||||
|
unassignRow(locationId, rowId) {
|
||||||
|
axios.post(unassign_rows_storage_location_path({ id: locationId }), { ids: [rowId] })
|
||||||
|
.then(() => {
|
||||||
|
this.$emit('reloadRow');
|
||||||
|
if (window.StorageLocationsContainer) {
|
||||||
|
window.StorageLocationsContainer.$refs.container.reloadingTable = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,6 +63,7 @@ import AssignModal from './modals/assign.vue';
|
||||||
import ImportModal from './modals/import.vue';
|
import ImportModal from './modals/import.vue';
|
||||||
import ConfirmationModal from '../shared/confirmation_modal.vue';
|
import ConfirmationModal from '../shared/confirmation_modal.vue';
|
||||||
import RemindersRender from './renderers/reminders.vue';
|
import RemindersRender from './renderers/reminders.vue';
|
||||||
|
import ItemNameRenderer from './renderers/item_name_renderer.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StorageLocationsContainer',
|
name: 'StorageLocationsContainer',
|
||||||
|
@ -72,7 +73,8 @@ export default {
|
||||||
AssignModal,
|
AssignModal,
|
||||||
ConfirmationModal,
|
ConfirmationModal,
|
||||||
RemindersRender,
|
RemindersRender,
|
||||||
ImportModal
|
ImportModal,
|
||||||
|
ItemNameRenderer
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
canManage: {
|
canManage: {
|
||||||
|
@ -144,7 +146,7 @@ export default {
|
||||||
field: 'row_name',
|
field: 'row_name',
|
||||||
headerName: this.i18n.t('storage_locations.show.table.row_name'),
|
headerName: this.i18n.t('storage_locations.show.table.row_name'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
cellRenderer: this.rowNameRenderer
|
cellRenderer: ItemNameRenderer
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'stock',
|
field: 'stock',
|
||||||
|
@ -182,16 +184,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
rowNameRenderer(params) {
|
updateTable() {
|
||||||
const { row_name: rowName, hidden } = params.data;
|
this.reloadingTable = true;
|
||||||
if (hidden) {
|
|
||||||
return `
|
|
||||||
<span class="text-sn-grey-700">
|
|
||||||
<i class="sn-icon sn-icon-locked-task"></i> ${this.i18n.t('storage_locations.show.hidden')}
|
|
||||||
</span>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
return rowName;
|
|
||||||
},
|
},
|
||||||
handleTableReload(items) {
|
handleTableReload(items) {
|
||||||
this.reloadingTable = false;
|
this.reloadingTable = false;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<template>
|
||||||
|
<span>
|
||||||
|
<span v-if="params.data.hidden" class="text-sn-grey-700">
|
||||||
|
<i class="sn-icon sn-icon-locked-task"></i>
|
||||||
|
{{ i18n.t('storage_locations.show.hidden') }}
|
||||||
|
</span>
|
||||||
|
<a
|
||||||
|
:href="params.data.row_url"
|
||||||
|
class="record-info-link"
|
||||||
|
:title="params.data.row_name"
|
||||||
|
>
|
||||||
|
{{ params.data.row_name }}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ItemNameRenderer',
|
||||||
|
props: {
|
||||||
|
params: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -6,7 +6,7 @@ module Lists
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
attributes :created_by, :created_on, :position, :row_id, :row_name, :hidden, :position_formatted, :stock,
|
attributes :created_by, :created_on, :position, :row_id, :row_name, :hidden, :position_formatted, :stock,
|
||||||
:have_reminders, :reminders_url
|
:have_reminders, :reminders_url, :row_url
|
||||||
|
|
||||||
def row_id
|
def row_id
|
||||||
object.repository_row.code
|
object.repository_row.code
|
||||||
|
@ -38,6 +38,10 @@ module Lists
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def row_url
|
||||||
|
repository_repository_row_path(object.repository_row.repository, object.repository_row)
|
||||||
|
end
|
||||||
|
|
||||||
def hidden
|
def hidden
|
||||||
!can_read_repository?(object.repository_row.repository)
|
!can_read_repository?(object.repository_row.repository)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<div class="content-body" data-e2e="e2e-CO-storageLocations-box">
|
<div class="content-body" data-e2e="e2e-CO-storageLocations-box">
|
||||||
<div id="StorageLocationsContainer" class="fixed-content-body">
|
<div id="StorageLocationsContainer" class="fixed-content-body">
|
||||||
<storage-locations-container
|
<storage-locations-container
|
||||||
|
ref="container"
|
||||||
actions-url="<%= actions_toolbar_storage_location_storage_location_repository_rows_path(@storage_location) %>"
|
actions-url="<%= actions_toolbar_storage_location_storage_location_repository_rows_path(@storage_location) %>"
|
||||||
data-source="<%= storage_location_storage_location_repository_rows_path(@storage_location) %>"
|
data-source="<%= storage_location_storage_location_repository_rows_path(@storage_location) %>"
|
||||||
:can-manage="<%= can_manage_storage_location?(@storage_location) %>"
|
:can-manage="<%= can_manage_storage_location?(@storage_location) %>"
|
||||||
|
|
Loading…
Add table
Reference in a new issue