Merge pull request #7157 from rekonder/aj_SCI_10284

Add comments and updated on columns to Project table [SCI-10284]
This commit is contained in:
aignatov-bio 2024-02-29 11:12:04 +01:00 committed by GitHub
commit d55ad14888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 57 additions and 4 deletions

View file

@ -57,7 +57,7 @@ import DueDateRenderer from './renderers/due_date.vue';
import DesignatedUsers from './renderers/designated_users.vue';
import TagsModal from './modals/tags.vue';
import TagsRenderer from './renderers/tags.vue';
import CommentsRenderer from './renderers/comments.vue';
import CommentsRenderer from '../shared/datatable/renderers/comments.vue';
import NewModal from './modals/new.vue';
import EditModal from './modals/edit.vue';
import MoveModal from './modals/move.vue';

View file

@ -67,6 +67,7 @@ import axios from '../../packs/custom_axios.js';
import DataTable from '../shared/datatable/table.vue';
import UsersRenderer from './renderers/users.vue';
import CommentsRenderer from '../shared/datatable/renderers/comments.vue';
import ProjectCard from './card.vue';
import ConfirmationModal from '../shared/confirmation_modal.vue';
import EditProjectModal from './modals/edit.vue';
@ -136,6 +137,11 @@ export default {
headerName: this.i18n.t('projects.index.card.start_date'),
sortable: true
},
{
field: 'updated_at',
headerName: this.i18n.t('projects.index.card.updated_at'),
sortable: true
},
{
field: 'users',
headerName: this.i18n.t('projects.index.card.users'),
@ -143,6 +149,13 @@ export default {
sortable: false,
minWidth: 210,
notSelectable: true
},
{
field: 'comments',
headerName: this.i18n.t('projects.index.card.comments'),
sortable: false,
cellRenderer: CommentsRenderer,
notSelectable: true
}];
if (this.currentViewMode === 'archived') {

View file

@ -1,9 +1,9 @@
<template>
<span v-if="!params.data.permissions.create_comments">0</span>
<span v-if="!params.data.permissions.create_comments && params.data.comments.count === 0">0</span>
<a v-else
href="#"
class="open-comments-sidebar" tabindex=0 :id="'comment-count-' + params.data.id"
data-object-type="MyModule" :data-object-id="params.data.id">
:data-object-type="objectType" :data-object-id="params.data.id">
<template v-if="params.data.comments.count > 0">
{{ params.data.comments.count }}
</template>
@ -26,6 +26,18 @@ export default {
required: true
}
},
computed: {
objectType() {
switch (this.params.data.type) {
case 'my_modules':
return 'MyModule';
case 'projects':
return 'Project';
default:
return '';
}
}
},
methods: {
openModal() {
this.params.dtComponent.$emit('openComments', null, [this.params.data]);

View file

@ -4,9 +4,11 @@ module Lists
class ProjectAndFolderSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
include Canaid::Helpers::PermissionsHelper
include CommentHelper
attributes :name, :code, :created_at, :archived_on, :users, :urls, :folder, :hidden,
:folder_info, :default_public_user_role_id, :team, :top_level_assignable
:folder_info, :default_public_user_role_id, :team, :top_level_assignable,
:comments, :updated_at, :permissions
def team
object.team.name
@ -36,6 +38,10 @@ module Lists
I18n.l(object.created_at, format: :full_date) if project?
end
def updated_at
I18n.l(object.updated_at, format: :full_date) if project?
end
def archived_on
I18n.l(object.archived_on, format: :full) if project? && object.archived_on
end
@ -51,6 +57,16 @@ module Lists
end
end
def comments
if project?
@user = scope[:user] || @instance_options[:user]
{
count: object.comments.count,
count_unseen: count_unseen_comments(object, @user)
}
end
end
def urls
urls_list = {
show: project? ? experiments_path(project_id: object) : project_folder_path(object),
@ -78,6 +94,12 @@ module Lists
urls_list
end
def permissions
{
create_comments: can_create_project_comments?(object)
}
end
def folder_info
if folder
I18n.t('projects.index.folder.description', projects_count: object.projects_count,

View file

@ -119,6 +119,10 @@ module Lists
@records = @records.sort_by { |project| project.users.count }
when 'users_DESC'
@records = @records.sort_by { |project| project.users.count }.reverse!
when 'updated_at_ASC'
@records = @records.sort_by(&:updated_at).reverse!
when 'updated_at_DESC'
@records = @records.sort_by(&:updated_at)
end
end

View file

@ -573,6 +573,8 @@ en:
users: "Access"
name: "Project name"
archived_date: "Archived on"
comments: 'Comments'
updated_at: 'Updated on'
end_of_list_placeholder: 'Youve reached the end of the list'
folder:
description: "%{projects_count} projects | %{folders_count} folders"