From 38024d563a0796b8549aa18d9d1125473197c7ae Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 10 Nov 2023 13:34:36 +0100 Subject: [PATCH] Add initial table [SCI-9680] --- app/assets/stylesheets/projects.scss | 5 - app/assets/stylesheets/shared/cards.scss | 1 - app/controllers/label_templates_controller.rb | 2 +- app/controllers/projects_controller.rb | 15 ++- .../packs/vue/label_templates_table.js | 6 +- app/javascript/packs/vue/projects_list.js | 11 ++ app/javascript/vue/projects/list.vue | 100 ++++++++++++++++ .../vue/projects/renderers/users.vue | 39 +++++++ .../vue/shared/confirmation_modal.vue | 2 +- .../shared/datatable/row_menu_renderer.vue | 62 ++++++++++ app/javascript/vue/shared/datatable/table.vue | 42 ++++++- app/javascript/vue/shared/menu_dropdown.vue | 8 +- app/models/user_assignment.rb | 5 + .../lists/project_and_folder_serializer.rb | 51 ++++++++ app/services/lists/projects_service.rb | 110 ++++++++++++++++++ app/services/toolbars/projects_service.rb | 33 +++--- app/views/projects/index.html.erb | 14 +++ app/views/projects/index/_header.html.erb | 3 - config/webpack/webpack.config.js | 3 +- 19 files changed, 463 insertions(+), 49 deletions(-) create mode 100644 app/javascript/packs/vue/projects_list.js create mode 100644 app/javascript/vue/projects/list.vue create mode 100644 app/javascript/vue/projects/renderers/users.vue create mode 100644 app/javascript/vue/shared/datatable/row_menu_renderer.vue create mode 100644 app/serializers/lists/project_and_folder_serializer.rb create mode 100644 app/services/lists/projects_service.rb diff --git a/app/assets/stylesheets/projects.scss b/app/assets/stylesheets/projects.scss index 60a1c18bb..40027d4ab 100644 --- a/app/assets/stylesheets/projects.scss +++ b/app/assets/stylesheets/projects.scss @@ -568,11 +568,6 @@ li.module-hover { // New projects page .projects-index { - --content-header-size: 9em; - .content-header { - height: var(--content-header-size); - } - .project-users-list { hr { margin: .5em 0; diff --git a/app/assets/stylesheets/shared/cards.scss b/app/assets/stylesheets/shared/cards.scss index c9a4e67af..216fa62ea 100644 --- a/app/assets/stylesheets/shared/cards.scss +++ b/app/assets/stylesheets/shared/cards.scss @@ -3,7 +3,6 @@ // scss-lint:disable SelectorFormat .cards-wrapper { - --content-header-size: 9em; --card-min-width: 200px; --list-columns-number: 5; align-items: center; diff --git a/app/controllers/label_templates_controller.rb b/app/controllers/label_templates_controller.rb index 7b242dcf5..8727edcce 100644 --- a/app/controllers/label_templates_controller.rb +++ b/app/controllers/label_templates_controller.rb @@ -146,7 +146,7 @@ class LabelTemplatesController < ApplicationController actions: Toolbars::LabelTemplatesService.new( current_user, - label_template_ids: params[:item_ids].split(',') + label_template_ids: JSON.parse(params[:items]).map { |i| i['id'] } ).actions } end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f7afbf919..52ffbcedd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -30,13 +30,21 @@ class ProjectsController < ApplicationController before_action :set_current_projects_view_type, only: %i(index cards) layout 'fluid' - def index; end + def index + respond_to do |format| + format.json do + projects = Lists::ProjectsService.new(current_team, current_user, current_folder, params).call + render json: projects, each_serializer: Lists::ProjectAndFolderSerializer, user: current_user, meta: pagination_dict(projects) + end + format.html do; end + end + end def cards overview_service = ProjectsOverviewService.new(current_team, current_user, current_folder, params) title = params[:view_mode] == 'archived' ? t('projects.index.head_title_archived') : t('projects.index.head_title') - if filters_included? + if false && filters_included? render json: { toolbar_html: render_to_string(partial: 'projects/index/toolbar'), filtered: true, @@ -385,8 +393,7 @@ class ProjectsController < ApplicationController actions: Toolbars::ProjectsService.new( current_user, - project_ids: params[:project_ids].split(','), - project_folder_ids: params[:project_folder_ids].split(',') + items: JSON.parse(params[:items]), ).actions } end diff --git a/app/javascript/packs/vue/label_templates_table.js b/app/javascript/packs/vue/label_templates_table.js index adffc56a4..493507715 100644 --- a/app/javascript/packs/vue/label_templates_table.js +++ b/app/javascript/packs/vue/label_templates_table.js @@ -1,12 +1,10 @@ import { createApp } from 'vue/dist/vue.esm-bundler.js'; import PerfectScrollbar from 'vue3-perfect-scrollbar'; import LabelTemplatesTable from '../../vue/label_template/table.vue'; -import { handleTurbolinks } from './helpers/turbolinks.js'; +import { mountWithTurbolinks } from './helpers/turbolinks.js'; const app = createApp(); app.component('LabelTemplatesTable', LabelTemplatesTable); app.config.globalProperties.i18n = window.I18n; app.use(PerfectScrollbar); -app.mount('#labelTemplatesTable'); -handleTurbolinks(app); - +mountWithTurbolinks(app, '#labelTemplatesTable'); diff --git a/app/javascript/packs/vue/projects_list.js b/app/javascript/packs/vue/projects_list.js new file mode 100644 index 000000000..d91c08d8b --- /dev/null +++ b/app/javascript/packs/vue/projects_list.js @@ -0,0 +1,11 @@ +import { createApp } from 'vue/dist/vue.esm-bundler.js'; +import PerfectScrollbar from 'vue3-perfect-scrollbar'; +import ProjectsList from '../../vue/projects/list.vue'; +import { mountWithTurbolinks } from './helpers/turbolinks.js'; + +const app = createApp(); +app.component('ProjectsList', ProjectsList); +app.config.globalProperties.i18n = window.I18n; +app.use(PerfectScrollbar); +mountWithTurbolinks(app, '#ProjectsList'); + diff --git a/app/javascript/vue/projects/list.vue b/app/javascript/vue/projects/list.vue new file mode 100644 index 000000000..0f583ca11 --- /dev/null +++ b/app/javascript/vue/projects/list.vue @@ -0,0 +1,100 @@ + + + diff --git a/app/javascript/vue/projects/renderers/users.vue b/app/javascript/vue/projects/renderers/users.vue new file mode 100644 index 000000000..ccef45228 --- /dev/null +++ b/app/javascript/vue/projects/renderers/users.vue @@ -0,0 +1,39 @@ + + + \ No newline at end of file diff --git a/app/javascript/vue/shared/confirmation_modal.vue b/app/javascript/vue/shared/confirmation_modal.vue index 19b6f6498..0a3b0181e 100644 --- a/app/javascript/vue/shared/confirmation_modal.vue +++ b/app/javascript/vue/shared/confirmation_modal.vue @@ -19,7 +19,7 @@ diff --git a/app/javascript/vue/shared/datatable/table.vue b/app/javascript/vue/shared/datatable/table.vue index c88cc75e9..09326bacc 100644 --- a/app/javascript/vue/shared/datatable/table.vue +++ b/app/javascript/vue/shared/datatable/table.vue @@ -1,21 +1,24 @@