diff --git a/app/assets/stylesheets/admin_type_de_champ.scss b/app/assets/stylesheets/admin_type_de_champ.scss index e4a9b92e9..bc2613075 100644 --- a/app/assets/stylesheets/admin_type_de_champ.scss +++ b/app/assets/stylesheets/admin_type_de_champ.scss @@ -23,6 +23,10 @@ } #liste_champ{ + .form-inline { + margin-bottom: 30px; + } + .show_inline { display: inline-block !important; } @@ -30,4 +34,16 @@ .form-group.drop_down_list{ display: none; } -} \ No newline at end of file + + .form-group { + vertical-align: top; + margin-right: 15px; + } + + .description { + padding: 0; + textarea { + padding: 6px 12px; + } + } +} diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb index ffe824855..d54293195 100644 --- a/app/decorators/type_de_champ_decorator.rb +++ b/app/decorators/type_de_champ_decorator.rb @@ -3,11 +3,19 @@ class TypeDeChampDecorator < Draper::Decorator delegate_all def button_up params - h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post if display_up_button?(params[:index], params[:private]) + h.link_to '', params[:url], class: up_classes, + id: "btn_up_#{params[:index]}", + remote: true, + method: :post, + style: display_up_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;' end def button_down params - h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post if display_down_button?(params[:index], params[:private]) + h.link_to '', params[:url], class: down_classes, + id: "btn_down_#{params[:index]}", + remote: true, + method: :post, + style: display_down_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;' end private diff --git a/spec/decorators/type_de_champ_decorator_spec.rb b/spec/decorators/type_de_champ_decorator_spec.rb index 7ab455e00..dd5d75307 100644 --- a/spec/decorators/type_de_champ_decorator_spec.rb +++ b/spec/decorators/type_de_champ_decorator_spec.rb @@ -16,8 +16,8 @@ describe TypeDeChampDecorator do subject { type_de_champ_0.decorate } let(:button_up) { type_de_champ_.decorate } - it 'returns a button up' do - expect(subject.button_up(params)).to be(nil) + it 'hide a button up' do + expect(subject.button_up(params)).to include('visibility: hidden') end it 'returns a button down' do expect(subject.button_down(params)).to match(/fa-chevron-down/) @@ -45,11 +45,12 @@ describe TypeDeChampDecorator do it 'returns a button up' do expect(subject.button_up(params)).to match(/fa-chevron-up/) end - it 'returns a button down' do - expect(subject.button_down(params)).to be(nil) + + it 'hide a button down' do + expect(subject.button_down(params)).to include('visibility: hidden') end end end -end \ No newline at end of file +end diff --git a/spec/views/admin/types_de_champ/show.html.haml_spec.rb b/spec/views/admin/types_de_champ/show.html.haml_spec.rb index bed11f3d4..acac3297a 100644 --- a/spec/views/admin/types_de_champ/show.html.haml_spec.rb +++ b/spec/views/admin/types_de_champ/show.html.haml_spec.rb @@ -33,8 +33,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do end context 'when there is only one field in database' do let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } - it { expect(subject).not_to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_down_1') } end @@ -42,9 +42,9 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) } it { expect(subject).to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).to have_css('#btn_up_1') } - it { expect(subject).not_to have_css('#btn_down_1') } + it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') } end end -end \ No newline at end of file +end diff --git a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb index 829050748..510224e9c 100644 --- a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb +++ b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb @@ -30,7 +30,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do describe 'mandatory checkbox' do it 'no mandatory checkbox are present' do - expect(subject).not_to have_css('.form-group.mandatory') + expect(subject).to have_css('.form-group.mandatory[style*="visibility: hidden"]') end end @@ -41,8 +41,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do end context 'when there is only one field in database' do let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) } - it { expect(subject).not_to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_down_1') } end @@ -50,10 +50,10 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) } it { expect(subject).to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).to have_css('#btn_up_1') } - it { expect(subject).not_to have_css('#btn_down_1') } + it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') } end end end -end \ No newline at end of file +end