From 54428ff4f179b17cd926d27d7650189e5c9a7e90 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 16 Feb 2024 12:01:20 +0100 Subject: [PATCH 1/2] Fix routes for experiments my modules [SCI-10207] --- app/controllers/experiments_controller.rb | 8 ++++++++ app/controllers/my_modules_controller.rb | 7 +++++++ config/routes.rb | 8 ++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index 6c94aa622..9a2630d47 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -74,6 +74,8 @@ class ExperimentsController < ApplicationController .select('COUNT(DISTINCT comments.id) as task_comments_count') .select('my_modules.*').group(:id) end + + save_view_type('canvas') end def my_modules @@ -456,6 +458,12 @@ class ExperimentsController < ApplicationController params.require(:experiment).require(:view_type) end + def save_view_type(view_type) + view_state = @experiment.current_view_state(current_user) + view_state.state['my_modules']['view_type'] = view_type + view_state.save! + end + def check_read_permissions current_team_switch(@experiment.project.team) if current_team != @experiment.project.team render_403 unless can_read_experiment?(@experiment) || diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 2dab50511..771cbfabd 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -38,6 +38,7 @@ class MyModulesController < ApplicationController meta: pagination_dict(my_modules) end format.html do + save_view_type('table') render 'my_modules/index' end end @@ -573,6 +574,12 @@ class MyModulesController < ApplicationController end end + def save_view_type(view_type) + view_state = @experiment.current_view_state(current_user) + view_state.state['my_modules']['view_type'] = view_type + view_state.save! + end + def log_activity(type_of, my_module = nil, message_items = {}) my_module ||= @my_module message_items = { my_module: my_module.id }.merge(message_items) diff --git a/config/routes.rb b/config/routes.rb index cefe812ee..fe224074b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -376,7 +376,9 @@ Rails.application.routes.draw do end get 'project_folders/:project_folder_id', to: 'projects#index', as: :project_folder_projects - resources :experiments, only: %i(index update) do + get 'projects/:project_id', to: 'experiments#index' + get 'projects/:project_id/experiments', to: 'experiments#index', as: :experiments + resources :experiments, only: %i(update) do collection do get 'inventory_assigning_experiment_filter' get 'clone_modal', action: :clone_modal @@ -421,7 +423,9 @@ Rails.application.routes.draw do # Show action is a popup (JSON) for individual module in full-zoom canvas, # as well as 'module info' page for single module (HTML) - resources :my_modules, path: '/modules', only: [:show, :update, :index] do + get 'experiments/:experiment_id/table', to: 'my_modules#index' + get 'experiments/:experiment_id/modules', to: 'my_modules#index', as: :my_modules + resources :my_modules, path: '/modules', only: [:show, :update] do post 'save_table_state', on: :collection, defaults: { format: 'json' } collection do From c893ee19f986293792714d763c12aaed5e563974 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 19 Feb 2024 13:01:37 +0100 Subject: [PATCH 2/2] Small table fixes [SCI-10211] --- app/assets/stylesheets/shared/ag_table.scss | 5 ++- app/javascript/vue/experiments/list.vue | 3 +- app/javascript/vue/projects/list.vue | 37 +++++++++--------- .../vue/shared/datatable/action_toolbar.vue | 2 +- app/javascript/vue/shared/datatable/table.vue | 2 +- .../vue/shared/datatable/tableHeader.js | 3 +- .../vue/shared/datatable/toolbar.vue | 3 +- .../assets/stylesheets/fonts/SN-icon-font.eot | Bin 30766 -> 31442 bytes .../assets/stylesheets/fonts/SN-icon-font.svg | 2 + .../assets/stylesheets/fonts/SN-icon-font.ttf | Bin 30580 -> 31256 bytes .../stylesheets/fonts/SN-icon-font.woff | Bin 30656 -> 31332 bytes .../stylesheets/fonts/SN-icon-font.woff2 | Bin 12964 -> 13284 bytes vendor/assets/stylesheets/sn-icon-font.css | 18 ++++++--- 13 files changed, 45 insertions(+), 30 deletions(-) diff --git a/app/assets/stylesheets/shared/ag_table.scss b/app/assets/stylesheets/shared/ag_table.scss index 9282f8783..c4cf3c1a0 100644 --- a/app/assets/stylesheets/shared/ag_table.scss +++ b/app/assets/stylesheets/shared/ag_table.scss @@ -15,7 +15,6 @@ --ag-icon-font-code-checkbox-indeterminate: asset-url("checkbox/indeterminate.svg"); --ag-input-focus-box-shadow: none; --ag-cell-horizontal-padding: .75rem; - border: 0; .ag-cell { @@ -31,6 +30,10 @@ cursor: pointer; } + .ag-header-cell-resize { + width: 1rem; + } + .ag-input-field-input:focus { outline: none !important; outline-offset: 0 !important; diff --git a/app/javascript/vue/experiments/list.vue b/app/javascript/vue/experiments/list.vue index 2a12a44a8..e90658f57 100644 --- a/app/javascript/vue/experiments/list.vue +++ b/app/javascript/vue/experiments/list.vue @@ -122,7 +122,8 @@ export default { { field: 'created_at', headerName: this.i18n.t('experiments.card.start_date'), - sortable: true + sortable: true, + minWidth: 130 }, { field: 'updated_at', diff --git a/app/javascript/vue/projects/list.vue b/app/javascript/vue/projects/list.vue index a6d767423..e46e19907 100644 --- a/app/javascript/vue/projects/list.vue +++ b/app/javascript/vue/projects/list.vue @@ -88,7 +88,7 @@ export default { NewProjectModal, NewFolderModal, MoveModal, - AccessModal, + AccessModal }, props: { dataSource: { type: String, required: true }, @@ -102,7 +102,7 @@ export default { userRolesUrl: { type: String }, currentFolderId: { type: String }, foldersTreeUrl: { type: String }, - moveToUrl: { type: String }, + moveToUrl: { type: String } }, data() { return { @@ -121,17 +121,18 @@ export default { flex: 1, headerName: this.i18n.t('projects.index.card.name'), sortable: true, - cellRenderer: this.nameRenderer, + cellRenderer: this.nameRenderer }, { field: 'code', headerName: this.i18n.t('projects.index.card.id'), - sortable: true, + sortable: true }, { field: 'created_at', headerName: this.i18n.t('projects.index.card.start_date'), sortable: true, + minWidth: 130 }, { field: 'users', @@ -140,15 +141,15 @@ export default { sortable: false, minWidth: 210, notSelectable: true - }, - ], + } + ] }; }, computed: { viewRenders() { return [ { type: 'table' }, - { type: 'cards' }, + { type: 'cards' } ]; }, toolbarActions() { @@ -160,7 +161,7 @@ export default { label: this.i18n.t('projects.index.new'), type: 'emit', path: this.createUrl, - buttonStyle: 'btn btn-primary', + buttonStyle: 'btn btn-primary' }); } if (this.createFolderUrl) { @@ -170,32 +171,32 @@ export default { label: this.i18n.t('projects.index.new_folder'), type: 'emit', path: this.createFolderUrl, - buttonStyle: 'btn btn-light', + buttonStyle: 'btn btn-light' }); } return { left, - right: [], + right: [] }; }, filters() { const filters = [ { key: 'query', - type: 'Text', + type: 'Text' }, { key: 'created_at', type: 'DateRange', - label: this.i18n.t('filters_modal.created_on.label'), - }, + label: this.i18n.t('filters_modal.created_on.label') + } ]; if (this.currentViewMode === 'archived') { filters.push({ key: 'archived_at', type: 'DateRange', - label: this.i18n.t('filters_modal.archived_on.label'), + label: this.i18n.t('filters_modal.archived_on.label') }); } @@ -206,13 +207,13 @@ export default { optionRenderer: this.usersFilterRenderer, labelRenderer: this.usersFilterRenderer, label: this.i18n.t('projects.index.filters_modal.members.label'), - placeholder: this.i18n.t('projects.index.filters_modal.members.placeholder'), + placeholder: this.i18n.t('projects.index.filters_modal.members.placeholder') }); filters.push({ key: 'folder_search', type: 'Checkbox', - label: this.i18n.t('projects.index.filters_modal.folders.label'), + label: this.i18n.t('projects.index.filters_modal.folders.label') }); return filters; @@ -241,7 +242,7 @@ export default { access(event, rows) { this.accessModalParams = { object: rows[0], - roles_path: this.userRolesUrl, + roles_path: this.userRolesUrl }; }, async archive(event, rows) { @@ -302,7 +303,7 @@ export default { if (ok) { axios.post(event.path, { project_ids: rows.filter((row) => !row.folder).map((row) => row.id), - project_folder_ids: rows.filter((row) => row.folder).map((row) => row.id), + project_folder_ids: rows.filter((row) => row.folder).map((row) => row.id) }).then((response) => { this.reloadingTable = true; HelperModule.flashAlertMsg(response.data.message, 'success'); diff --git a/app/javascript/vue/shared/datatable/action_toolbar.vue b/app/javascript/vue/shared/datatable/action_toolbar.vue index e0a428815..3d44e8bd0 100644 --- a/app/javascript/vue/shared/datatable/action_toolbar.vue +++ b/app/javascript/vue/shared/datatable/action_toolbar.vue @@ -8,7 +8,7 @@ {{ i18n.t('action_toolbar.no_actions') }}