mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
move groups form to primer
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# -- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) the OpenProject GmbH
|
||||
#
|
||||
# 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-2013 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 COPYRIGHT and LICENSE files for more details.
|
||||
# ++
|
||||
module Groups
|
||||
class Form < ApplicationForm
|
||||
include CustomFields::CustomFieldRendering
|
||||
|
||||
form do |f|
|
||||
f.text_field(
|
||||
name: :lastname,
|
||||
label: Group.human_attribute_name(:name),
|
||||
required: true,
|
||||
input_width: :medium,
|
||||
autocomplete: "off"
|
||||
)
|
||||
|
||||
render_custom_fields(form: f)
|
||||
|
||||
f.submit(
|
||||
name: :submit,
|
||||
label: submit_label,
|
||||
scheme: :primary
|
||||
)
|
||||
end
|
||||
|
||||
def initialize(submit_label: I18n.t(:button_save))
|
||||
super()
|
||||
@submit_label = submit_label
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :submit_label
|
||||
|
||||
def custom_fields
|
||||
model.available_custom_fields
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
<%#-- copyright
|
||||
OpenProject is an open source project management software.
|
||||
Copyright (C) the OpenProject GmbH
|
||||
|
||||
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-2013 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 COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
|
||||
<%#
|
||||
needs locals:
|
||||
f: labelled form builder
|
||||
%>
|
||||
|
||||
<%= error_messages_for :group %>
|
||||
|
||||
<section class="form--section">
|
||||
<div class="form--field -required">
|
||||
<%= f.text_field :lastname,
|
||||
label: Group.human_attribute_name(:name),
|
||||
required: true,
|
||||
container_class: "-middle" %>
|
||||
</div>
|
||||
|
||||
<%= render partial: "customizable/form", locals: { form: f,
|
||||
all_fields: true,
|
||||
only_required: false } %>
|
||||
</section>
|
||||
@@ -27,7 +27,8 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
|
||||
++#%>
|
||||
|
||||
<%= labelled_tabular_form_for @group, url: group_path(@group), html: { method: :put }, as: :group do |f| %>
|
||||
<%= render partial: "form", locals: { f: f } %>
|
||||
<%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
|
||||
<% end %>
|
||||
<%=
|
||||
settings_primer_form_with(model: @group, url: group_path(@group), method: :put) do |f|
|
||||
render Groups::Form.new(f)
|
||||
end
|
||||
%>
|
||||
|
||||
@@ -41,7 +41,10 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
end
|
||||
%>
|
||||
|
||||
<%= labelled_tabular_form_for(@group) do |f| %>
|
||||
<%= render partial: "form", locals: { f: f } %>
|
||||
<div><%= f.button t(:button_create), class: "button -primary -with-icon icon-checkmark" %></div>
|
||||
<% end %>
|
||||
<%= error_messages_for @group %>
|
||||
|
||||
<%=
|
||||
settings_primer_form_with(model: @group) do |f|
|
||||
render Groups::Form.new(f, submit_label: I18n.t(:button_create))
|
||||
end
|
||||
%>
|
||||
|
||||
@@ -71,7 +71,7 @@ RSpec.describe "group memberships through groups page", :js do
|
||||
|
||||
# Should stay on the form page and show validation error
|
||||
expect(page).to have_text("New group")
|
||||
expect(page).to have_css(".Banner--error", text: /Department can't be blank./)
|
||||
expect(page).to have_field(custom_field.name, with: "", validation_error: "Value can't be blank.")
|
||||
|
||||
fill_in custom_field.name, with: "Engineering"
|
||||
|
||||
@@ -102,8 +102,8 @@ RSpec.describe "group memberships through groups page", :js do
|
||||
click_on "Save"
|
||||
|
||||
# Should stay on the form page and show validation error
|
||||
expect(page).to have_text("Updated Marketing Team")
|
||||
expect(page).to have_css(".Banner--error", text: /Department can't be blank./)
|
||||
expect(page).to have_field("Name", with: "Updated Marketing Team")
|
||||
expect(page).to have_field(custom_field.name, with: "", validation_error: "Value can't be blank.")
|
||||
|
||||
# Now provide a valid value
|
||||
fill_in custom_field.name, with: "Marketing & Sales"
|
||||
|
||||
Reference in New Issue
Block a user