Set table searchValue using table ref [SCI-10479]

This commit is contained in:
wandji20 2024-04-04 11:16:56 +01:00
parent d76fbf1eba
commit 3dea7c1e6d
3 changed files with 9 additions and 8 deletions

View file

@ -2,6 +2,7 @@
<div class="h-full">
<DataTable :columnDefs="columnDefs"
:tableId="'ReportTemplates'"
ref="table"
:dataUrl="dataSource"
:reloadingTable="reloadingTable"
:toolbarActions="toolbarActions"
@ -48,8 +49,12 @@ import UpdateReportModal from './modals/update.vue';
export default {
name: 'ReportsTable',
provide() {
return { initSearchValue: this.initSearchValue };
mounted() {
this.$nextTick(() => {
if (this.searchValue) {
this.$refs.table.searchValue = this.searchValue;
}
});
},
components: {
DataTable,
@ -64,7 +69,7 @@ export default {
type: String,
required: true
},
initSearchValue: {
searchValue: {
type: String,
default: ''
},

View file

@ -120,7 +120,6 @@ import RowMenuRenderer from './row_menu_renderer.vue';
export default {
name: 'App',
inject: ['initSearchValue'],
props: {
withCheckboxes: {
type: Boolean,
@ -335,9 +334,6 @@ export default {
mounted() {
this.navigatorCollapsed = document.querySelector('.sci--layout').getAttribute('data-navigator-collapsed') === 'true';
this.setGridColsClass();
if (this.initSearchValue) {
this.searchValue = this.initSearchValue;
}
window.addEventListener('resize', this.resize);
},

View file

@ -17,7 +17,7 @@
available-columns-url="<%= available_asset_type_columns_path %>"
available-rows-url="<%= available_rows_repositories_path %>"
data-source="<%= reports_path(format: :json) %>"
init-search-value="<%= params[:search] %>"
search-value="<%= params[:search] %>"
create-url="<%= new_report_path if can_create_reports?(current_team) %>"
/>
</div>