OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Clean up and move table to cell
Oliver Günther4c3d3ffdab54
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 13483bf5d62..5890254fd1a 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -783,6 +783,7 @@ en:type: "Type"updated_at: "Updated on"updated_on: "Updated on"+ uploader: "Uploader"user: "User"version: "Version"work_package: "Work package"diff --git a/modules/ifc_models/app/cells/ifc_models/models/row_cell.rb b/modules/ifc_models/app/cells/ifc_models/models/row_cell.rbnew file mode 100644index 00000000000..96aa3f23e3f--- /dev/null+++ b/modules/ifc_models/app/cells/ifc_models/models/row_cell.rb@@ -0,0 +1,62 @@+module IFCModels+ module Models+ class RowCell < ::RowCell+ include ::IconsHelper+ include ::AvatarHelper+ include ::Redmine::I18n++ def title+ link_to model.title,+ ifc_models_project_ifc_model_path(model.project, model)+ end++ def updated_at+ format_date(model.updated_at)+ end++ def uploader+ icon = avatar model.uploader, class: 'avatar-mini'+ icon + model.uploader.name+ end++ def processing+ if model.xkt_attachment.present?+ I18n.t('ifc_models.processing_state.completed')+ else+ I18n.t('ifc_models.processing_state.in_progress')+ end+ end++ ###++ def button_links+ if User.current.allowed_to?(:manage_ifc_models, model.project)+ [edit_link, delete_link]+ else+ []+ end+ end++ def delete_link+ link_to '',+ ifc_models_project_ifc_model_path(model.project, model),+ class: 'icon icon-delete',+ data: {confirm: I18n.t(:text_are_you_sure)},+ method: :delete+ end++ def edit_link+ link_to '',+ edit_ifc_models_project_ifc_model_path(model.project, model),+ class: 'icon icon-edit',+ accesskey: accesskey(:edit)+ end++ def deletion_blocked?+ return false if table.admin_table?++ device.default && table.enforced?+ end+ end+ end+enddiff --git a/modules/ifc_models/app/cells/ifc_models/models/table_cell.rb b/modules/ifc_models/app/cells/ifc_models/models/table_cell.rbnew file mode 100644index 00000000000..babd2de698e--- /dev/null+++ b/modules/ifc_models/app/cells/ifc_models/models/table_cell.rb@@ -0,0 +1,37 @@+module IFCModels+ module Models+ class TableCell < ::TableCell+ include ::IconsHelper+ columns :title, :updated_at, :uploader, :processing++ def initial_sort+ [:updated_at, :desc]+ end++ def sortable?+ false+ end++ def inline_create_link+ link_to(new_ifc_models_project_ifc_model_path,+ class: 'wp-inline-create--add-link',+ title: I18n.t('ifc_models.label_new_ifc_model')) do+ op_icon('icon icon-add')+ end+ end++ def empty_row_message+ I18n.t 'ifc_models.no_results'+ end++ def headers+ [+ ['title', caption: IFCModel.human_attribute_name(:title)],+ ['updated_at', caption: IFCModel.human_attribute_name(:updated_at)],+ ['uploader', caption: IFCModel.human_attribute_name(:uploader)],+ ['processing', caption: I18n.t('ifc_models.processing_state.label')],+ ]+ end+ end+ end+enddiff --git a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rbindex 25b0a80fa2e..6dc62efe1dc 100644--- a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb+++ b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb@@ -32,30 +32,28 @@ module ::IFCModelsclass IFCModelsController < BaseControllerinclude PaginationHelper- before_action :find_project_by_project_id, only: [:index, :new, :create, :show, :edit, :update, :destroy]- before_action :find_ifc_model_object, except: [:index, :new, :create]+ before_action :find_project_by_project_id, only: %i[index new create show edit update destroy]+ before_action :find_ifc_model_object, except: %i[index new create]before_action :authorizemenu_item :ifc_modelsdef index- @ifc_models = @project.ifc_models.order('created_at DESC').page(page_param).per_page(per_page_param)- render 'ifc_models/index'+ @ifc_models = @project+ .ifc_models+ .order('created_at DESC')+ .includes(:uploader, :project)+ .page(page_param)+ .per_page(per_page_param)enddef new@ifc_model = @project.ifc_models.build(ifc_model_params)- render 'ifc_models/new'end- def edit- render 'ifc_models/edit'- end-- def show- render 'ifc_models/show'- end+ def edit; end+ def show; enddef create@ifc_model = @project.ifc_models.build(uploader: User.current)@@ -63,7 +61,7 @@ module ::IFCModelsif add_attachment && @ifc_model.saveredirect_to action: :show, id: @ifc_model.idelse- render 'ifc_models/new'+ render action: :newendend@@ -71,7 +69,7 @@ module ::IFCModelsif @ifc_model.update(ifc_model_params)redirect_to action: :show, id: @ifc_model.idelse- render 'ifc_models/new'+ render action: :editendend@@ -85,9 +83,9 @@ module ::IFCModelsdef add_attachmentif (file = ifc_model_params['ifc_attachment']) && file && file.size.positive?@ifc_model.attachments.build(file: file,- container: @ifc_model,- description: 'IFC attachment',- author: User.current)+ container: @ifc_model,+ description: 'IFC attachment',+ author: User.current)@ifc_model.title = file.original_filenameelseflash[:error] = t('ifc_models.could_not_save_file')diff --git a/modules/ifc_models/app/models/ifc_models/ifc_model.rb b/modules/ifc_models/app/models/ifc_models/ifc_model.rbindex b94f09a5e20..5705267d1ff 100644--- a/modules/ifc_models/app/models/ifc_models/ifc_model.rb+++ b/modules/ifc_models/app/models/ifc_models/ifc_model.rb@@ -2,7 +2,7 @@ module IFCModelsclass IFCModel < ActiveRecord::Baseacts_as_attachable delete_permission: :manage_ifc_models- has_one :project+ belongs_to :projectbelongs_to :uploader, class_name: 'User', foreign_key: 'uploader_id'def ifc_attachmentdiff --git a/modules/ifc_models/app/views/ifc_models/_form.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/_form.html.erbsimilarity index 100%rename from modules/ifc_models/app/views/ifc_models/_form.html.erbrename to modules/ifc_models/app/views/ifc_models/ifc_models/_form.html.erbdiff --git a/modules/ifc_models/app/views/ifc_models/edit.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/edit.html.erbsimilarity index 96%rename from modules/ifc_models/app/views/ifc_models/edit.html.erbrename to modules/ifc_models/app/views/ifc_models/ifc_models/edit.html.erbindex 5124e1b9e98..d8d327fe7e1 100644--- a/modules/ifc_models/app/views/ifc_models/edit.html.erb+++ b/modules/ifc_models/app/views/ifc_models/ifc_models/edit.html.erb@@ -33,6 +33,6 @@ See doc/COPYRIGHT.rdoc for more details.<%= toolbar title: IFCModels::IFCModel.model_name.human %><%= labelled_tabular_form_for @ifc_model, url: ifc_models_project_ifc_model_path(@project, @ifc_model), method: 'PATCH' do |f| -%>- <%= render partial: "ifc_models/form", locals: { f: f } %>+ <%= render partial: 'form', locals: { f: f } %><%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %><% end %>diff --git a/modules/ifc_models/app/views/ifc_models/ifc_models/index.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/index.html.erbnew file mode 100644index 00000000000..b8fd0273a3e--- /dev/null+++ b/modules/ifc_models/app/views/ifc_models/ifc_models/index.html.erb@@ -0,0 +1,45 @@+<%#-- copyright+OpenProject is a project management system.+Copyright (C) 2012-2018 the OpenProject Foundation (OPF)++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2017 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See docs/COPYRIGHT.rdoc for more details.++++#%>+<% html_title(t('ifc_models.label_ifc_models')) -%>++<%= toolbar title: t('ifc_models.label_ifc_models') do %>+ <% if User.current.allowed_to?(:manage_ifc_models, @project) %>+ <li class="toolbar-item">+ <%= link_to new_ifc_models_project_ifc_model_path,+ { class: 'button -alt-highlight',+ aria: { label: t(:label_project_new) },+ title: t(:label_project_new) } do %>+ <%= op_icon('button--icon icon-add') %>+ <span class="button--text"><%= ::IFCModels::IFCModel.model_name.human %></span>+ <% end %>+ </li>+ <% end %>+<% end %>++<%= cell ::IFCModels::Models::TableCell, @ifc_models %>diff --git a/modules/ifc_models/app/views/ifc_models/new.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/new.html.erbsimilarity index 95%rename from modules/ifc_models/app/views/ifc_models/new.html.erbrename to modules/ifc_models/app/views/ifc_models/ifc_models/new.html.erbindex acf9b6dc6c1..db0a64bdd16 100644--- a/modules/ifc_models/app/views/ifc_models/new.html.erb+++ b/modules/ifc_models/app/views/ifc_models/ifc_models/new.html.erb@@ -32,6 +32,6 @@ See doc/COPYRIGHT.rdoc for more details.<%= toolbar title: t('ifc_models.label_new_ifc_model') %><%= labelled_tabular_form_for @ifc_model, url: ifc_models_project_ifc_models_path(@project), html: { multipart: true } do |f| -%>- <%= render :partial => 'ifc_models/form', locals: { f: f } %>+ <%= render :partial => 'form', locals: { f: f } %><%= styled_button_tag l(:button_create), class: "-highlight -with-icon icon-checkmark" %><% end %>diff --git a/modules/ifc_models/app/views/ifc_models/show.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/show.html.erbsimilarity index 100%rename from modules/ifc_models/app/views/ifc_models/show.html.erbrename to modules/ifc_models/app/views/ifc_models/ifc_models/show.html.erbdiff --git a/modules/ifc_models/app/views/ifc_models/index.html.erb b/modules/ifc_models/app/views/ifc_models/index.html.erbdeleted file mode 100644index 7f5792f0cc3..00000000000--- a/modules/ifc_models/app/views/ifc_models/index.html.erb+++ /dev/null@@ -1,107 +0,0 @@-<%#-- copyright-OpenProject is a project management system.-Copyright (C) 2012-2018 the OpenProject Foundation (OPF)--This program is free software; you can redistribute it and/or-modify it under the terms of the GNU General Public License version 3.--OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-Copyright (C) 2006-2017 Jean-Philippe Lang-Copyright (C) 2010-2013 the ChiliProject Team--This program is free software; you can redistribute it and/or-modify it under the terms of the GNU General Public License-as published by the Free Software Foundation; either version 2-of the License, or (at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program; if not, write to the Free Software-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.--See docs/COPYRIGHT.rdoc for more details.--++#%>-<% html_title(t('ifc_models.label_ifc_models')) -%>--<%= toolbar title: t('ifc_models.label_ifc_models') do %>- <% if User.current.allowed_to?(:manage_ifc_models, @project) %>- <li class="toolbar-item">- <%= link_to new_ifc_models_project_ifc_model_path,- { class: 'button -alt-highlight',- aria: { label: t(:label_project_new) },- title: t(:label_project_new) } do %>- <%= op_icon('button--icon icon-add') %>- <span class="button--text"><%= IFCModels::IFCModel.model_name.human %></span>- <% end %>- </li>- <% end %>-<% end %>--<% if @ifc_models.any? %>- <table class="generic-table" id="project-table">- <thead>- <tr>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <%= IFCModels::IFCModel.human_attribute_name(:title) %>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <%= t('ifc_models.uploaded_at')%>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <%= t('ifc_models.uploader')%>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <%= t('ifc_models.processing_state.label')%>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- </div>- </div>- </th>- </tr>- </thead>- <tbody>- <% @ifc_models.each do |ifc_model| %>- <tr class="basics">- <td><%= link_to(ifc_model.title, ifc_models_project_ifc_model_path(@project, ifc_model)) %></td>- <td><%= format_date(ifc_model.created_at) %></td>- <td><%= link_to_user(ifc_model.uploader.name) %></td>- <td><%= ifc_model.xkt_attachment.present? ? t('ifc_models.processing_state.completed') : t('ifc_models.processing_state.in_progress') %></td>- <td class="buttons">- <% if authorize_for('ifc_models/ifc_models', :edit) %>- <%= link_to('', edit_ifc_models_project_ifc_model_path(@project, ifc_model), class: 'icon icon-edit', accesskey: accesskey(:edit)) %>- <% end %>- <% if authorize_for('ifc_models/ifc_models', :destroy) %>- <%= link_to('', ifc_models_project_ifc_model_path(@project, ifc_model), class: 'icon icon-delete', data: { confirm: l(:text_are_you_sure) }, method: :delete) %>- <% end %>- </td>- </tr>- <% end %>- </tbody>- </table>- <%= pagination_links_full @ifc_models %>-<% else %>- <%= no_results_box({}) %>-<% end %>diff --git a/modules/ifc_models/config/locales/en.yml b/modules/ifc_models/config/locales/en.ymlindex de696358dd0..7614fa47f91 100644--- a/modules/ifc_models/config/locales/en.yml+++ b/modules/ifc_models/config/locales/en.yml@@ -3,6 +3,7 @@ en:ifc_models:label_ifc_models: 'IFC models'label_new_ifc_model: 'New IFC model'+ no_results: "No IFC models have been uploaded in this project."could_not_save_file': 'Could not save the file.'processing_state:label: 'Processing?'