From 1b83a2c52b8426669e1cfdfe86eb2551ec7df022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 11 Oct 2022 09:54:56 +0200 Subject: [PATCH] How can I add 'Comment' column in the file list view? #1118 --- app/models/dmsf_folder.rb | 2 +- app/models/dmsf_query.rb | 86 +++++++++++++++++++++++---------------- config/locales/cs.yml | 2 + config/locales/de.yml | 2 + config/locales/en.yml | 2 + config/locales/es.yml | 2 + config/locales/fa.yml | 2 + config/locales/fr.yml | 2 + config/locales/hu.yml | 2 + config/locales/it.yml | 2 + config/locales/ja.yml | 2 + config/locales/ko.yml | 2 + config/locales/nl.yml | 2 + config/locales/pl.yml | 2 + config/locales/pt-BR.yml | 2 + config/locales/sl.yml | 2 + config/locales/zh-TW.yml | 2 + config/locales/zh.yml | 2 + 18 files changed, 83 insertions(+), 37 deletions(-) diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 500325a9..63d99065 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -47,7 +47,7 @@ class DmsfFolder < ActiveRecord::Base INVALID_CHARACTERS = '\[\]\/\\\?":<>#%\*' STATUS_DELETED = 1 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 def self.visible_condition(system=true) diff --git a/app/models/dmsf_query.rb b/app/models/dmsf_query.rb index b4f0ad4d..ce3e798a 100644 --- a/app/models/dmsf_query.rb +++ b/app/models/dmsf_query.rb @@ -29,14 +29,16 @@ class DmsfQuery < Query # Standard columns self.available_columns = [ - QueryColumn.new(:id, sortable: 'id', caption: +'#'), - DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true, caption: :label_column_title), - QueryColumn.new(:size, sortable: 'size', caption: :label_column_size), - DmsfModifiedQueryColumn.new(:modified, sortable: 'updated', caption: :label_column_modified), - DmsfVersionQueryColumn.new(:version, sortable: %(major_version minor_version patch_version), - caption: :label_column_version), - QueryColumn.new(:workflow, sortable: 'workflow', caption: :label_column_workflow), - QueryColumn.new(:author, sortable: %(firstname lastname), caption: :label_column_author) + QueryColumn.new(:id, sortable: 'id', caption: +'#'), + DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true, caption: :label_column_title), + QueryColumn.new(:size, sortable: 'size', caption: :label_column_size), + DmsfModifiedQueryColumn.new(:modified, sortable: 'updated', caption: :label_column_modified), + DmsfVersionQueryColumn.new(:version, sortable: %(major_version minor_version patch_version), + caption: :label_column_version), + QueryColumn.new(:workflow, sortable: 'workflow', caption: :label_column_workflow), + 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) @@ -254,26 +256,28 @@ class DmsfQuery < Query cf_columns << ",NULL AS cf_#{id}" end scope = Project.select(%{ - projects.id AS id, - projects.id AS project_id, - CAST(NULL AS #{get_integer_type}) AS revision_id, - projects.name AS title, - projects.identifier AS filename, - CAST(NULL AS #{get_integer_type}) AS size, - projects.updated_on AS updated, - 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 patch_version, - CAST(NULL AS #{get_integer_type}) AS workflow, - CAST(NULL AS #{get_integer_type}) AS workflow_id, - '' AS firstname, - '' AS lastname, - CAST(NULL AS #{get_integer_type}) AS author, - 'project' AS type, - CAST(0 AS #{get_integer_type}) AS deleted, - '' as customized_type, - 0 as customized_id, - 0 AS sort#{cf_columns}}).visible + projects.id AS id, + projects.id AS project_id, + CAST(NULL AS #{get_integer_type}) AS revision_id, + projects.name AS title, + projects.identifier AS filename, + CAST(NULL AS #{get_integer_type}) AS size, + projects.updated_on AS updated, + 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 patch_version, + CAST(NULL AS #{get_integer_type}) AS workflow, + CAST(NULL AS #{get_integer_type}) AS workflow_id, + '' AS firstname, + '' AS lastname, + CAST(NULL AS #{get_integer_type}) AS author, + 'project' AS type, + CAST(0 AS #{get_integer_type}) AS deleted, + '' AS customized_type, + 0 AS customized_id, + projects.description AS description, + '' AS comment, + 0 AS sort#{cf_columns}}).visible if dmsf_folder_id || deleted scope.none else @@ -307,6 +311,8 @@ class DmsfQuery < Query dmsf_folders.deleted AS deleted, 'DmsfFolder' AS customized_type, dmsf_folders.id AS customized_id, + dmsf_folders.description AS description, + '' AS comment, 1 AS sort#{cf_columns}}). joins('LEFT JOIN users ON dmsf_folders.user_id = users.id') return scope.none unless project @@ -350,8 +356,10 @@ class DmsfQuery < Query users.id AS author, 'folder-link' AS type, dmsf_links.deleted AS deleted, - 'DmsfFolder' as customized_type, - dmsf_folders.id as customized_id, + 'DmsfFolder' AS customized_type, + dmsf_folders.id AS customized_id, + dmsf_folders.description AS description, + '' AS comment, 1 AS sort#{cf_columns}}). 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)') @@ -395,8 +403,10 @@ class DmsfQuery < Query users.id AS author, 'file' AS type, dmsf_files.deleted AS deleted, - 'DmsfFileRevision' as customized_type, - dmsf_file_revisions.id as customized_id, + 'DmsfFileRevision' AS customized_type, + dmsf_file_revisions.id AS customized_id, + dmsf_file_revisions.description AS description, + dmsf_file_revisions.comment AS comment, 2 AS sort#{cf_columns}}). joins(:dmsf_file_revisions). joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id '). @@ -441,8 +451,10 @@ class DmsfQuery < Query users.id AS author, 'file-link' AS type, dmsf_links.deleted AS deleted, - 'DmsfFileRevision' as customized_type, - dmsf_file_revisions.id as customized_id, + 'DmsfFileRevision' AS customized_type, + dmsf_file_revisions.id AS customized_id, + dmsf_file_revisions.description AS description, + dmsf_file_revisions.comment AS comment, 2 AS sort#{cf_columns}}). 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'). @@ -489,8 +501,10 @@ class DmsfQuery < Query users.id AS author, 'url-link' AS type, dmsf_links.deleted AS deleted, - '' as customized_type, - 0 as customized_id, + '' AS customized_type, + 0 AS customized_id, + '' AS description, + '' AS comment, 2 AS sort#{cf_columns}}). joins('LEFT JOIN users ON dmsf_links.user_id = users.id ') if deleted diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 7cb6e99d..eee854f6 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -456,6 +456,8 @@ cs: label_column_version: Verze label_column_workflow: Schvalování label_column_author: Autor + label_column_description: Popis + label_column_comment: Komentář 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. diff --git a/config/locales/de.yml b/config/locales/de.yml index 9bbe0d62..ea57b990 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -452,6 +452,8 @@ de: label_column_version: Version label_column_workflow: Workflow label_column_author: Autor + label_column_description: Beschreibung + label_column_comment: Kommentar 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. diff --git a/config/locales/en.yml b/config/locales/en.yml index 68944608..00da2821 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -456,6 +456,8 @@ en: label_column_version: Version label_column_workflow: Workflow label_column_author: Author + label_column_description: Beschreibung + label_column_comment: Kommentar 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. diff --git a/config/locales/es.yml b/config/locales/es.yml index bf02b3ff..805083a4 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -456,6 +456,8 @@ es: label_column_version: Versión label_column_workflow: Flujo label_column_author: Autor + label_column_description: Descripción + label_column_comment: Comentario 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. diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 156ce3d7..6efc6045 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -435,6 +435,8 @@ fa: label_column_version: نسخه label_column_workflow: روال تایید label_column_author: نویسنده + label_column_description: توضیحات + label_column_comment: توضیح 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. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6737de5f..af7c46e3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -456,6 +456,8 @@ fr: label_column_version: Version label_column_workflow: Flux label_column_author: Auteur + label_column_description: Description + label_column_comment: Commentaire 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. diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 9526f627..8b0ca9bc 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -455,6 +455,8 @@ hu: label_column_version: Verzió label_column_workflow: Workflow label_column_author: Szerző + label_column_description: Leírás + label_column_comment: Megjegyzés 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. diff --git a/config/locales/it.yml b/config/locales/it.yml index 7c3d1d8b..199423bc 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -456,6 +456,8 @@ it: # Italian strings thx 2 Matteo Arceci! label_column_version: Versija label_column_workflow: Darbų eiga label_column_author: Autorius + label_column_description: Descrizione + label_column_comment: Komentaras 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. diff --git a/config/locales/ja.yml b/config/locales/ja.yml index ce5cd766..f336d0ab 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -457,6 +457,8 @@ ja: label_column_version: バージョン label_column_workflow: ワークフロー label_column_author: 作成者 + label_column_description: 説明 + label_column_comment: コメント 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. diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 6b0c048a..63a41cb0 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -456,6 +456,8 @@ ko: label_column_version: 버전 label_column_workflow: 업무흐름 label_column_author: 저자 + label_column_description: 설명 + label_column_comment: Comment 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. diff --git a/config/locales/nl.yml b/config/locales/nl.yml index a831a25d..aa15e577 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -456,6 +456,8 @@ nl: label_column_version: Versie label_column_workflow: Workflow label_column_author: Auteur + label_column_description: Beschrijving + label_column_comment: Commentaar 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. diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 76a51010..3a0fc422 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -456,6 +456,8 @@ pl: label_column_version: Wersja label_column_workflow: Akceptacje label_column_author: Autor + label_column_description: Opis + label_column_comment: Komentarz 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. diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 0273c23a..d9db5a24 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -456,6 +456,8 @@ pt-BR: label_column_version: Versão label_column_workflow: Fluxo label_column_author: Autor + label_column_description: Descrição + label_column_comment: Comentário 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. diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 939ba22e..406b4992 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -456,6 +456,8 @@ sl: label_column_version: Verzija label_column_workflow: Potek dela label_column_author: Avtor + label_column_description: Opis + label_column_comment: Komentar 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. diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index bafb0244..14862916 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -455,6 +455,8 @@ zh-TW: label_column_version: 版本 label_column_workflow: 流程 label_column_author: 作者 + label_column_description: 描述 + label_column_comment: 回應 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. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4280b5f4..2a79255e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -456,6 +456,8 @@ zh: label_column_version: 版本 label_column_workflow: 工作流程 label_column_author: 作者 + label_column_description: 描述 + label_column_comment: 注释 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.