Skip to content

Commit

Permalink
Don't show initiative state field instead of showing it disabled (dec…
Browse files Browse the repository at this point in the history
…idim#11518)

* Don't show initiative state field instead of showing it disabled

* Don't show the field in the edit form neither

* Add tests

* Lint files

* Update decidim-initiatives/app/views/decidim/initiatives/initiatives/_form.html.erb

Co-authored-by: Alexandru Emil Lupu <[email protected]>

---------

Co-authored-by: Alexandru Emil Lupu <[email protected]>
  • Loading branch information
fblupi and alecslupu committed Aug 24, 2023
1 parent 860418b commit 295c7a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@
help_text: t("attachment_legend", scope: "decidim.initiatives.form") %>
<% end %>
<%= f.select :state,
Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] },
{},
{ disabled: !@form.state_updatable? } %>
<% if @form.state_updatable? %>
<%= f.select :state, Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] }, {} %>
<% end %>

<div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
<%= link_to :back, class: "button button__sm md:button__lg button__text-secondary" do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<%= form.text_field :hashtag, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
<%= form.select :state,
Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] },
{},
{ disabled: [email protected]_updatable? } %>
<% if @form.state_updatable? %>
<%= form.select :state, Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] }, {} %>
<% end %>
<% unless single_initiative_type? %>
<%= form.select :type_id,
Expand All @@ -26,9 +25,7 @@
} %>
<% end %>
<%= form.select :scope_id,
@form.available_scopes.map { |scope| [translated_attribute(scope.scope_name), scope&.scope&.id] },
{ disabled: [email protected]_updatable? } %>
<%= form.select :scope_id, @form.available_scopes.map { |scope| [translated_attribute(scope.scope_name), scope.scope&.id] }, {}, { disabled: [email protected]_updatable? } %>
<% if can_edit_custom_signature_end_date?(current_initiative) %>
<%= form.date_field :signature_end_date, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
Expand Down
8 changes: 8 additions & 0 deletions decidim-initiatives/spec/system/create_initiative_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,10 @@
expect(page).to have_xpath("//textarea[@id='initiative_description']", visible: :all)
end

it "does not have status field" do
expect(page).not_to have_xpath("//select[@id='initiative_state']")
end

it "offers contextual help" do
within ".callout.secondary" do
expect(page).to have_content("Review the content of your initiative.")
Expand Down Expand Up @@ -511,6 +515,10 @@
expect(page).to have_xpath("//textarea[@id='initiative_description']", visible: :all)
end

it "does not have status field" do
expect(page).not_to have_xpath("//select[@id='initiative_state']")
end

it "offers contextual help" do
within ".callout.secondary" do
expect(page).to have_content("Review the content of your initiative.")
Expand Down
4 changes: 4 additions & 0 deletions decidim-initiatives/spec/system/edit_initiative_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
end
end

it "does not have status field" do
expect(page).not_to have_xpath("//select[@id='initiative_state']")
end

context "when initiative is published" do
let(:initiative) { create(:initiative, author: user, scoped_type:, organization:) }

Expand Down

0 comments on commit 295c7a1

Please sign in to comment.