Merge pull request #6303 from wandji20/wb-SCI-9157

Add export button to item card [SCI-9157]
This commit is contained in:
Alex Kriuchykhin 2023-10-03 12:52:03 +02:00 committed by GitHub
commit a000f0e67e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 9 deletions

View file

@ -95,7 +95,7 @@
<div v-if="customColumns?.length > 0" class="flex flex-col gap-4 w-[350px] h-auto">
<div v-for="(column, index) in customColumns" class="flex flex-col gap-4 w-[350px] h-auto">
<component :is="column.data_type" :key="index" :data_type="column.data_type" :colId="column.id"
:colName="column.name" :colVal="column.value" />
:colName="column.name" :colVal="column.value" :repositoryRowId="repositoryRowId" :permissions="permissions" />
<div id="dashed-divider" :class="{ 'hidden': index === customColumns.length - 1 }"
class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey">
</div>
@ -222,7 +222,8 @@ export default {
assignedModules: null,
isShowing: false,
assigned: 'Assigned to 3 private tasks that will not be displayed',
barCodeSrc: null
barCodeSrc: null,
permissions: null
}
},
created() {
@ -279,6 +280,7 @@ export default {
this.customColumns = result.custom_columns;
this.dataLoading = false
this.assignedModules = result.assigned_modules;
this.permissions = result.permissions
}
});
},

View file

@ -1,10 +1,18 @@
<template>
<div id="repository-stock-value-wrapper" class="flex flex-col min-min-h-[46px] h-auto gap-[6px]">
<div class="font-inter text-sm font-semibold leading-5">
{{ colName }}
<div class="font-inter text-sm font-semibold leading-5 relative">
<span>{{ colName }}</span>
<a style="text-decoration: none;"
class="absolute right-0 text-sn-science-blue visited:text-sn-science-blue hover:text-sn-science-blue font-inter text-sm font-normal cursor-pointer"
v-if="permissions?.can_export_repository_stock === true"
@click.prevent="exportConsumptionCallback"
:data-rows="JSON.stringify([repositoryRowId])"
>
{{ i18n.t('repositories.item_card.stock_export') }}
</a>
</div>
<div v-if="stock_formatted" class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
{{ stock_formatted }}
<div v-if="colVal.stock_formatted" class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
{{ colVal.stock_formatted }}
</div>
<div v-else class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
{{ i18n.t('repositories.item_card.repository_stock_value.no_stock') }}
@ -26,12 +34,29 @@ export default {
data_type: String,
colId: Number,
colName: String,
colVal: Object
colVal: Object,
repositoryRowId: null,
permissions: null
},
created() {
this.stock_formatted = this.colVal.stock_formatted
this.stock_amount = this.colVal.stock_amount
this.low_stock_threshold = this.colVal.low_stock_threshold
},
methods: {
exportConsumptionCallback(event) {
$('#exportStockConsumptionModal')
.one('show.bs.modal', function() {
$('#exportStockConsumptionModal').attr(
'data-rows',
$(event.target).attr('data-rows')
);
})
.one('hide.bs.modal', function() {
$('#exportStockConsumptionModal').attr('data-rows', null);
})
.modal('show');
}
}
}
</script>

View file

@ -2,6 +2,9 @@
json.id @repository_row.id
json.repository_name @repository.name
json.permissions do
json.can_export_repository_stock can_export_repository_stock?(@repository_row.repository)
end
json.default_columns do
json.name @repository_row.name
json.code @repository_row.code

View file

@ -2227,8 +2227,9 @@ en:
id: "Item ID"
added_on: "Added on"
added_at: "Added at"
added_by: 'Added by'
custom_columns_label: 'Custom columns'
added_by: "Added by"
custom_columns_label: "Custom columns"
stock_export: "Export"
no_custom_columns_label: 'This item has no custom columns'
repository_time_range_value:
no_time_range: 'No time range'