How can I add 'Comment' column in the file list view? #1118

This commit is contained in:
Karel Pičman 2022-10-11 09:54:56 +02:00
parent e1061c6a98
commit 1b83a2c52b
18 changed files with 83 additions and 37 deletions

View File

@ -47,7 +47,7 @@ class DmsfFolder < ActiveRecord::Base
INVALID_CHARACTERS = '\[\]\/\\\?":<>#%\*' INVALID_CHARACTERS = '\[\]\/\\\?":<>#%\*'
STATUS_DELETED = 1 STATUS_DELETED = 1
STATUS_ACTIVE = 0 STATUS_ACTIVE = 0
AVAILABLE_COLUMNS = %w(id title size modified version workflow author).freeze AVAILABLE_COLUMNS = %w(id title size modified version workflow author description comment).freeze
DEFAULT_COLUMNS = %w(title size modified version workflow author).freeze DEFAULT_COLUMNS = %w(title size modified version workflow author).freeze
def self.visible_condition(system=true) def self.visible_condition(system=true)

View File

@ -29,14 +29,16 @@ class DmsfQuery < Query
# Standard columns # Standard columns
self.available_columns = [ self.available_columns = [
QueryColumn.new(:id, sortable: 'id', caption: +'#'), QueryColumn.new(:id, sortable: 'id', caption: +'#'),
DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true, caption: :label_column_title), DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true, caption: :label_column_title),
QueryColumn.new(:size, sortable: 'size', caption: :label_column_size), QueryColumn.new(:size, sortable: 'size', caption: :label_column_size),
DmsfModifiedQueryColumn.new(:modified, sortable: 'updated', caption: :label_column_modified), DmsfModifiedQueryColumn.new(:modified, sortable: 'updated', caption: :label_column_modified),
DmsfVersionQueryColumn.new(:version, sortable: %(major_version minor_version patch_version), DmsfVersionQueryColumn.new(:version, sortable: %(major_version minor_version patch_version),
caption: :label_column_version), caption: :label_column_version),
QueryColumn.new(:workflow, sortable: 'workflow', caption: :label_column_workflow), QueryColumn.new(:workflow, sortable: 'workflow', caption: :label_column_workflow),
QueryColumn.new(:author, sortable: %(firstname lastname), caption: :label_column_author) QueryColumn.new(:author, sortable: %(firstname lastname), caption: :label_column_author),
QueryColumn.new(:description, sortable: 'description', caption: :label_column_description),
QueryColumn.new(:comment, sortable: 'comment', caption: :label_column_comment)
] ]
def initialize(attributes=nil, *args) def initialize(attributes=nil, *args)
@ -254,26 +256,28 @@ class DmsfQuery < Query
cf_columns << ",NULL AS cf_#{id}" cf_columns << ",NULL AS cf_#{id}"
end end
scope = Project.select(%{ scope = Project.select(%{
projects.id AS id, projects.id AS id,
projects.id AS project_id, projects.id AS project_id,
CAST(NULL AS #{get_integer_type}) AS revision_id, CAST(NULL AS #{get_integer_type}) AS revision_id,
projects.name AS title, projects.name AS title,
projects.identifier AS filename, projects.identifier AS filename,
CAST(NULL AS #{get_integer_type}) AS size, CAST(NULL AS #{get_integer_type}) AS size,
projects.updated_on AS updated, projects.updated_on AS updated,
CAST(NULL AS #{get_integer_type}) AS major_version, CAST(NULL AS #{get_integer_type}) AS major_version,
CAST(NULL AS #{get_integer_type}) AS minor_version, CAST(NULL AS #{get_integer_type}) AS minor_version,
CAST(NULL AS #{get_integer_type}) AS patch_version, CAST(NULL AS #{get_integer_type}) AS patch_version,
CAST(NULL AS #{get_integer_type}) AS workflow, CAST(NULL AS #{get_integer_type}) AS workflow,
CAST(NULL AS #{get_integer_type}) AS workflow_id, CAST(NULL AS #{get_integer_type}) AS workflow_id,
'' AS firstname, '' AS firstname,
'' AS lastname, '' AS lastname,
CAST(NULL AS #{get_integer_type}) AS author, CAST(NULL AS #{get_integer_type}) AS author,
'project' AS type, 'project' AS type,
CAST(0 AS #{get_integer_type}) AS deleted, CAST(0 AS #{get_integer_type}) AS deleted,
'' as customized_type, '' AS customized_type,
0 as customized_id, 0 AS customized_id,
0 AS sort#{cf_columns}}).visible projects.description AS description,
'' AS comment,
0 AS sort#{cf_columns}}).visible
if dmsf_folder_id || deleted if dmsf_folder_id || deleted
scope.none scope.none
else else
@ -307,6 +311,8 @@ class DmsfQuery < Query
dmsf_folders.deleted AS deleted, dmsf_folders.deleted AS deleted,
'DmsfFolder' AS customized_type, 'DmsfFolder' AS customized_type,
dmsf_folders.id AS customized_id, dmsf_folders.id AS customized_id,
dmsf_folders.description AS description,
'' AS comment,
1 AS sort#{cf_columns}}). 1 AS sort#{cf_columns}}).
joins('LEFT JOIN users ON dmsf_folders.user_id = users.id') joins('LEFT JOIN users ON dmsf_folders.user_id = users.id')
return scope.none unless project return scope.none unless project
@ -350,8 +356,10 @@ class DmsfQuery < Query
users.id AS author, users.id AS author,
'folder-link' AS type, 'folder-link' AS type,
dmsf_links.deleted AS deleted, dmsf_links.deleted AS deleted,
'DmsfFolder' as customized_type, 'DmsfFolder' AS customized_type,
dmsf_folders.id as customized_id, dmsf_folders.id AS customized_id,
dmsf_folders.description AS description,
'' AS comment,
1 AS sort#{cf_columns}}). 1 AS sort#{cf_columns}}).
joins('LEFT JOIN dmsf_folders ON dmsf_links.target_id = dmsf_folders.id'). joins('LEFT JOIN dmsf_folders ON dmsf_links.target_id = dmsf_folders.id').
joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)') joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)')
@ -395,8 +403,10 @@ class DmsfQuery < Query
users.id AS author, users.id AS author,
'file' AS type, 'file' AS type,
dmsf_files.deleted AS deleted, dmsf_files.deleted AS deleted,
'DmsfFileRevision' as customized_type, 'DmsfFileRevision' AS customized_type,
dmsf_file_revisions.id as customized_id, dmsf_file_revisions.id AS customized_id,
dmsf_file_revisions.description AS description,
dmsf_file_revisions.comment AS comment,
2 AS sort#{cf_columns}}). 2 AS sort#{cf_columns}}).
joins(:dmsf_file_revisions). joins(:dmsf_file_revisions).
joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id '). joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id ').
@ -441,8 +451,10 @@ class DmsfQuery < Query
users.id AS author, users.id AS author,
'file-link' AS type, 'file-link' AS type,
dmsf_links.deleted AS deleted, dmsf_links.deleted AS deleted,
'DmsfFileRevision' as customized_type, 'DmsfFileRevision' AS customized_type,
dmsf_file_revisions.id as customized_id, dmsf_file_revisions.id AS customized_id,
dmsf_file_revisions.description AS description,
dmsf_file_revisions.comment AS comment,
2 AS sort#{cf_columns}}). 2 AS sort#{cf_columns}}).
joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id'). joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id').
joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id'). joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').
@ -489,8 +501,10 @@ class DmsfQuery < Query
users.id AS author, users.id AS author,
'url-link' AS type, 'url-link' AS type,
dmsf_links.deleted AS deleted, dmsf_links.deleted AS deleted,
'' as customized_type, '' AS customized_type,
0 as customized_id, 0 AS customized_id,
'' AS description,
'' AS comment,
2 AS sort#{cf_columns}}). 2 AS sort#{cf_columns}}).
joins('LEFT JOIN users ON dmsf_links.user_id = users.id ') joins('LEFT JOIN users ON dmsf_links.user_id = users.id ')
if deleted if deleted

View File

@ -456,6 +456,8 @@ cs:
label_column_version: Verze label_column_version: Verze
label_column_workflow: Schvalování label_column_workflow: Schvalování
label_column_author: Autor label_column_author: Autor
label_column_description: Popis
label_column_comment: Komentář
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -452,6 +452,8 @@ de:
label_column_version: Version label_column_version: Version
label_column_workflow: Workflow label_column_workflow: Workflow
label_column_author: Autor label_column_author: Autor
label_column_description: Beschreibung
label_column_comment: Kommentar
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ en:
label_column_version: Version label_column_version: Version
label_column_workflow: Workflow label_column_workflow: Workflow
label_column_author: Author label_column_author: Author
label_column_description: Beschreibung
label_column_comment: Kommentar
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ es:
label_column_version: Versión label_column_version: Versión
label_column_workflow: Flujo label_column_workflow: Flujo
label_column_author: Autor label_column_author: Autor
label_column_description: Descripción
label_column_comment: Comentario
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -435,6 +435,8 @@ fa:
label_column_version: نسخه label_column_version: نسخه
label_column_workflow: روال تایید label_column_workflow: روال تایید
label_column_author: نویسنده label_column_author: نویسنده
label_column_description: توضیحات
label_column_comment: توضیح
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ fr:
label_column_version: Version label_column_version: Version
label_column_workflow: Flux label_column_workflow: Flux
label_column_author: Auteur label_column_author: Auteur
label_column_description: Description
label_column_comment: Commentaire
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -455,6 +455,8 @@ hu:
label_column_version: Verzió label_column_version: Verzió
label_column_workflow: Workflow label_column_workflow: Workflow
label_column_author: Szerző label_column_author: Szerző
label_column_description: Leírás
label_column_comment: Megjegyzés
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ it: # Italian strings thx 2 Matteo Arceci!
label_column_version: Versija label_column_version: Versija
label_column_workflow: Darbų eiga label_column_workflow: Darbų eiga
label_column_author: Autorius label_column_author: Autorius
label_column_description: Descrizione
label_column_comment: Komentaras
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -457,6 +457,8 @@ ja:
label_column_version: バージョン label_column_version: バージョン
label_column_workflow: ワークフロー label_column_workflow: ワークフロー
label_column_author: 作成者 label_column_author: 作成者
label_column_description: 説明
label_column_comment: コメント
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ ko:
label_column_version: 버전 label_column_version: 버전
label_column_workflow: 업무흐름 label_column_workflow: 업무흐름
label_column_author: 저자 label_column_author: 저자
label_column_description: 설명
label_column_comment: Comment
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ nl:
label_column_version: Versie label_column_version: Versie
label_column_workflow: Workflow label_column_workflow: Workflow
label_column_author: Auteur label_column_author: Auteur
label_column_description: Beschrijving
label_column_comment: Commentaar
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ pl:
label_column_version: Wersja label_column_version: Wersja
label_column_workflow: Akceptacje label_column_workflow: Akceptacje
label_column_author: Autor label_column_author: Autor
label_column_description: Opis
label_column_comment: Komentarz
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ pt-BR:
label_column_version: Versão label_column_version: Versão
label_column_workflow: Fluxo label_column_workflow: Fluxo
label_column_author: Autor label_column_author: Autor
label_column_description: Descrição
label_column_comment: Comentário
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ sl:
label_column_version: Verzija label_column_version: Verzija
label_column_workflow: Potek dela label_column_workflow: Potek dela
label_column_author: Avtor label_column_author: Avtor
label_column_description: Opis
label_column_comment: Komentar
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -455,6 +455,8 @@ zh-TW:
label_column_version: 版本 label_column_version: 版本
label_column_workflow: 流程 label_column_workflow: 流程
label_column_author: 作者 label_column_author: 作者
label_column_description: 描述
label_column_comment: 回應
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.

View File

@ -456,6 +456,8 @@ zh:
label_column_version: 版本 label_column_version: 版本
label_column_workflow: 工作流程 label_column_workflow: 工作流程
label_column_author: 作者 label_column_author: 作者
label_column_description: 描述
label_column_comment: 注释
label_dmsf_global_menu_disabled: Global DMS menu disabled label_dmsf_global_menu_disabled: Global DMS menu disabled
note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu. note_dmsf_global_menu_disabled: If yes, DMS menu item is not present in the top menu.