Preview procedure logo on edit procedure page for admin

This commit is contained in:
Xavier J 2016-06-06 18:25:51 +02:00
parent e6b5698008
commit 69f9c52b02
12 changed files with 37 additions and 40 deletions

View file

@ -60,7 +60,7 @@ class Admin::ProceduresController < AdminController
end
flash.notice = 'Préocédure modifiée'
redirect_to admin_procedures_path
redirect_to edit_admin_procedure_path(id: @procedure.id)
end
def archive

View file

@ -36,7 +36,7 @@ class ProcedureLogoUploader < CarrierWave::Uploader::Base
if Features.remote_storage
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
else
filename = "logo.#{file.extension.downcase}"
filename = "logo-#{secure_token}.#{file.extension.downcase}"
end
end
filename

View file

@ -1,9 +1,4 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: 'Accompagnateurs'}
=render partial: 'admin/procedures/head', locals: {active: 'Accompagnateurs'}
#accompagnateur_form
.row

View file

@ -1,9 +1,4 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: 'Pieces'}
=render partial: 'admin/procedures/head', locals: {active: 'Pieces'}
#piece_justificative_form
= render 'form'

View file

@ -1,9 +1,4 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: 'Prévisualisation'}
=render partial: 'admin/procedures/head', locals: {active: 'Prévisualisation'}
#previsualisation
=render 'users/description/show'

View file

@ -0,0 +1,8 @@
%h2.text-info
-unless @procedure.logo.blank?
= image_tag @procedure.logo, style: 'width: 30px'
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: active}

View file

@ -14,7 +14,9 @@
.row
.col-md-6.col-lg-6
%h4 Logo de la procédure
= f.file_field(:logo, accept: 'image/png, image/jpg,image/jpeg')
- unless @procedure.logo.blank?
= image_tag @procedure.logo, {style: 'height: 40px; display: inline; margin-right: 6px', id: 'preview_procedure_logo'}
= f.file_field(:logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display:inline')
%div{style:'margin-top:5px'}
%i

View file

@ -1,9 +1,4 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'navbar', locals: {active: 'Description'}
= render partial: 'head', locals: {active: 'Description'}
#procedure_new.section.section-label
= form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f|

View file

@ -1,10 +1,5 @@
#procedure_show
%h2.text-info
=@facade.procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'navbar', locals: {active: 'Informations'}
=render partial: 'head', locals: {active: 'Informations'}
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
%button#archive.btn.btn-small.btn-default.text-info{type: :button}

View file

@ -1,9 +1,4 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: 'Champs'}
=render partial: 'admin/procedures/head', locals: {active: 'Champs'}
#liste_champ
= render partial: 'form'

View file

@ -192,7 +192,7 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.cadastre).to be_truthy }
end
it { expect(subject).to redirect_to(admin_procedures_path) }
it { expect(subject).to redirect_to(edit_admin_procedure_path id: procedure.id) }
it { expect(flash[:notice]).to be_present }
end

View file

@ -0,0 +1,17 @@
require 'spec_helper'
describe 'admin/procedures/edit.html.haml', type: :view do
let(:logo) { Rack::Test::UploadedFile.new("./spec/support/files/logo_test_procedure.png", 'image/png') }
let(:procedure) { create(:procedure, logo: logo) }
before do
assign(:procedure, procedure)
render
end
context 'when procedure logo is present' do
it 'display on the page' do
expect(rendered).to have_selector('#preview_procedure_logo')
end
end
end