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
use partials for rendering tabs content
Behrokh Satarnejadbabcc64c0982
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex 704f8186ff1..66a4ad88af3 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -52,18 +52,6 @@ class CustomStylesController < ApplicationControllerdef upsale; end- def branding- @custom_style = CustomStyle.current || CustomStyle.new- @current_theme = @custom_style.theme- @theme_options = options_for_theme_select- end-- def pdf_export_styles- @custom_style = CustomStyle.current || CustomStyle.new- @current_theme = @custom_style.theme- @theme_options = options_for_theme_select- end-def create@custom_style = CustomStyle.create(custom_style_params)if @custom_style.valid?diff --git a/app/helpers/custom_styles_helper.rb b/app/helpers/custom_styles_helper.rbindex 3e5ed244646..bc61421c8e3 100644--- a/app/helpers/custom_styles_helper.rb+++ b/app/helpers/custom_styles_helper.rb@@ -27,6 +27,29 @@#++module CustomStylesHelper+ def design_tabs+ [+ {+ name: "interface",+ partial: "custom_styles/interface",+ path: custom_style_path(tab: :interface),+ label: t(:"admin.custom_styles.tab_interface")+ },+ {+ name: "branding",+ partial: "custom_styles/branding",+ path: custom_style_path(tab: :branding),+ label: t(:"admin.custom_styles.tab_branding")+ },+ {+ name: "pdf_export_styles",+ partial: "custom_styles/pdf_export_styles",+ path: custom_style_path(tab: :pdf_export_styles),+ label: t(:'admin.custom_styles.tab_pdf_export_styles')+ }+ ]+ end+def apply_custom_styles?(skip_ee_check: OpenProject::Configuration.bim?)# Apply custom styles either if EE allows OR we are on a BIM edition with the BIM theme active.CustomStyle.current.present? &&diff --git a/app/views/custom_styles/branding.html.erb b/app/views/custom_styles/_branding.html.erbsimilarity index 86%rename from app/views/custom_styles/branding.html.erbrename to app/views/custom_styles/_branding.html.erbindex f8e3c6e255e..6225aa0e874 100644--- a/app/views/custom_styles/branding.html.erb+++ b/app/views/custom_styles/_branding.html.erb@@ -27,30 +27,6 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%=- render(Admin::DesignHeaderComponent.new(- title: t(:"admin.custom_styles.tab_branding"),- selected: 2,- ))-%>-<%= error_messages_for 'custom_style' %>-<%= form_tag update_design_themes_path, method: :post, class: "form" do %>- <section class="form--section">- <fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.color_theme') %></legend>- <div class="form--field">- <div class="form--field-container">- <%= styled_select_tag 'theme',- options_for_select(@theme_options, @current_theme),- container_class: '-slim' %>- </div>- </div>-- <%= styled_button_tag t(:button_save),- data:({ confirm: t('admin.custom_styles.theme_warning') } unless @current_theme.present?) %>- </fieldset>- </section>-<% end %><%= form_for @custom_style, url: custom_style_path, html: { multipart: true, class: "form -vertical" } do |f| %><section class="form--section"><fieldset class="form--fieldset">diff --git a/app/views/custom_styles/_interface.html.erb b/app/views/custom_styles/_interface.html.erbnew file mode 100644index 00000000000..b21d2dda7d2--- /dev/null+++ b/app/views/custom_styles/_interface.html.erb@@ -0,0 +1,45 @@+<%= form_tag update_design_colors_path, method: :post, class: "form" do %>+ <section class="form--section">+ <fieldset class="form--fieldset">+ <legend class="form--fieldset-legend"><%= I18n.t(:label_interface_colours) %></legend>+ <p> <%= t('label_interface_colours_description') %> </p>+ <% DesignColor.setables.each do |design_color| %>+ <div class="form--field -required">+ <label class="form--label"><%= I18n.t("admin.custom_styles.colors.#{design_color.variable}") %>:</label>+ <span class="form--field-container">+ <div class="form--field-affix">+ <%= icon_for_color(OpenStruct.new(variable: design_color.variable,+ hexcode: design_color.hexcode),+ data: { target: "#design_colors_" + design_color.variable }) %>+ </div>+ <span class="form--text-field-container">+ <%= styled_text_field_tag "design_colors[]" + design_color.variable,+ design_color.hexcode,+ class: 'design-color--variable-input',+ data: { 'variable-name': design_color.variable }+ %>+ </span>+ </span>+ <div class="form--field-instructions">+ <% instruction_key = "admin.custom_styles.instructions.#{design_color.variable}" %>+ <% if I18n.exists?(instruction_key, :en) %>+ <%= I18n.t(instruction_key) %>+ <% end %>+ </div>+ </div>+ <% end %>+ <button type="submit" class="button -hide-when-collapsed"><%= I18n.t(:button_save) %></button>+ </fieldset>+ </section>+ <%# Fill in the computed css variables in the inputs as their defaults %>+ <%= nonced_javascript_tag do %>+ var computedStyle = getComputedStyle(document.documentElement);+ document+ .querySelectorAll('.design-color--variable-input')+ .forEach(function(el) {+ if (!el.value || el.value === '') {+ el.placeholder = computedStyle.getPropertyValue('--' + el.dataset.variableName).trim();+ }+ });+ <% end %>+<% end %>diff --git a/app/views/custom_styles/pdf_export_styles.html.erb b/app/views/custom_styles/_pdf_export_styles.html.erbsimilarity index 86%rename from app/views/custom_styles/pdf_export_styles.html.erbrename to app/views/custom_styles/_pdf_export_styles.html.erbindex 1b90afbea2d..1e0e11c3216 100644--- a/app/views/custom_styles/pdf_export_styles.html.erb+++ b/app/views/custom_styles/_pdf_export_styles.html.erb@@ -27,29 +27,6 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%=- render(Admin::DesignHeaderComponent.new(- title: t(:"admin.custom_styles.tab_pdf_export_styles"),- selected: 3,- ))-%>-<%= error_messages_for 'custom_style' %>-<%= form_tag update_design_themes_path, method: :post, class: "form" do %>- <section class="form--section">- <fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.color_theme') %></legend>- <div class="form--field">- <div class="form--field-container">- <%= styled_select_tag 'theme',- options_for_select(@theme_options, @current_theme),- container_class: '-slim' %>- </div>- </div>- <%= styled_button_tag t(:button_save),- data:({ confirm: t('admin.custom_styles.theme_warning') } unless @current_theme.present?) %>- </fieldset>- </section>-<% end %><%= form_for @custom_style, url: custom_style_path, html: { multipart: true, class: "form -vertical" } do |f| %><section class="form--section"><fieldset class="form--fieldset">diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erbindex bb37fc3afa2..26f6f94a331 100644--- a/app/views/custom_styles/show.html.erb+++ b/app/views/custom_styles/show.html.erb@@ -27,12 +27,14 @@ See COPYRIGHT and LICENSE files for more details.++#%>+<% tabs = design_tabs %><%=render(Admin::DesignHeaderComponent.new(- title: t(:"admin.custom_styles.tab_interface"),- selected: 1,+ tabs: tabs,))%>++<%= error_messages_for 'custom_style' %><%= form_tag update_design_themes_path, method: :post, class: "form" do %><section class="form--section">@@ -51,48 +53,5 @@ See COPYRIGHT and LICENSE files for more details.</fieldset></section><% end %>-<%= form_tag update_design_colors_path, method: :post, class: "form" do %>- <section class="form--section">- <fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%= I18n.t(:label_interface_colours) %></legend>- <p> <%= t('label_interface_colours_description') %> </p>- <% DesignColor.setables.each do |design_color| %>- <div class="form--field -required">- <label class="form--label"><%= I18n.t("admin.custom_styles.colors.#{design_color.variable}") %>:</label>- <span class="form--field-container">- <div class="form--field-affix">- <%= icon_for_color(OpenStruct.new(variable: design_color.variable,- hexcode: design_color.hexcode),- data: { target: "#design_colors_" + design_color.variable }) %>- </div>- <span class="form--text-field-container">- <%= styled_text_field_tag "design_colors[]" + design_color.variable,- design_color.hexcode,- class: 'design-color--variable-input',- data: { 'variable-name': design_color.variable }- %>- </span>- </span>- <div class="form--field-instructions">- <% instruction_key = "admin.custom_styles.instructions.#{design_color.variable}" %>- <% if I18n.exists?(instruction_key, :en) %>- <%= I18n.t(instruction_key) %>- <% end %>- </div>- </div>- <% end %>- <button type="submit" class="button -hide-when-collapsed"><%= I18n.t(:button_save) %></button>- </fieldset>- </section>- <%# Fill in the computed css variables in the inputs as their defaults %>- <%= nonced_javascript_tag do %>- var computedStyle = getComputedStyle(document.documentElement);- document- .querySelectorAll('.design-color--variable-input')- .forEach(function(el) {- if (!el.value || el.value === '') {- el.placeholder = computedStyle.getPropertyValue('--' + el.dataset.variableName).trim();- }- });- <% end %>-<% end %>++<%= render_tabs design_tabs, with_tab_nav: false %>