Refactoring Admin menu #384

This commit is contained in:
Chrisbr 2014-07-30 12:03:16 +02:00
parent 518e1cc62b
commit d1f5b1e3cc
30 changed files with 865 additions and 190 deletions

View file

@ -121,3 +121,50 @@ body {
padding-top: 35px;
padding-bottom: 35px;
}
.dl-horizontal dt { white-space: normal; }
.equal, .equal > div[class*='col-'] {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex:1 0 auto;
}
.row-flex, .row-flex > div[class*='col-'] {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex:1 1 auto;
}
.row-flex-wrap {
-webkit-flex-flow: row wrap;
align-content: flex-start;
flex:0;
}
.row-flex > div[class*='col-'], .container-flex > div[class*='col-'] {
margin:-.2px; /* hack adjust for wrapping */
}
.container-flex > div[class*='col-'] div,.row-flex > div[class*='col-'] div {
width:100%;
}
.flex-col {
display: flex;
display: -webkit-flex;
flex: 1 100%;
flex-flow: column nowrap;
}
.flex-grow {
display: flex;
-webkit-flex: 2;
flex: 2;
}

View file

@ -0,0 +1,2 @@
class Admin::ConferenceBasicsController < Admin::ConferenceController
end

View file

@ -0,0 +1,2 @@
class Admin::ConferenceContactsController < Admin::ConferenceController
end

View file

@ -72,8 +72,8 @@ class Admin::ConferenceController < ApplicationController
end
def update
@conference = Conference.find_by(short_title: params[:id])
short_title = @conference.short_title
@conference = Conference.find_by(short_title: params[:conference_id])
old_short_title = @conference.short_title
@conference.assign_attributes(params[:conference])
notify_on_conf_dates_updates = (@conference.start_date_changed? || @conference.end_date_changed?)\
&& @conference.email_settings.send_on_updated_conference_dates\
@ -85,13 +85,22 @@ class Admin::ConferenceController < ApplicationController
&& !@conference.email_settings.updated_conference_registration_dates_subject.blank?\
&& @conference.email_settings.updated_conference_registration_dates_template
# Change :return_to if short_title changed
if @conference.short_title_changed?
session[:return_to] =
session[:return_to].gsub! old_short_title, params[:conference][:short_title] unless
session[:return_to].blank?
end
if @conference.update_attributes(params[:conference])
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
redirect_to(edit_admin_conference_path(id: @conference.short_title),
redirect_to(session[:return_to],
notice: 'Conference was successfully updated.') && return unless session[:return_to].blank?
redirect_to(admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.')
else
redirect_to(edit_admin_conference_path(id: short_title),
redirect_to(:back,
alert: 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}.")
end
@ -165,8 +174,7 @@ class Admin::ConferenceController < ApplicationController
end
def edit
@conferences = Conference.all
@conference = Conference.find_by(short_title: params[:id])
@conference = Conference.find_by(short_title: params[:conference_id])
respond_to do |format|
format.html
format.json { render json: @conference.to_json }

View file

@ -0,0 +1,63 @@
class Admin::PhotosController < ApplicationController
before_action :set_conference
before_action :set_photo, only: [:edit, :update, :destroy]
# GET /admin/photos
def index
@photos = @conference.photos.all
end
# GET /admin/photos/new
def new
@photo = @conference.photos.build
end
# GET /admin/photos/1/edit
def edit
end
# POST /admin/photos
def create
@photo = @conference.photos.build(photo_params)
if @photo.save
redirect_to admin_conference_photos_path, notice: 'Photo was successfully created.'
else
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
render :new
end
end
# PATCH/PUT /admin/photos/1
def update
if @photo.update(photo_params)
redirect_to admin_conference_photos_path, notice: 'Photo was successfully updated.'
else
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
render :edit
end
end
# DELETE /admin/photos/1
def destroy
@photo.destroy
redirect_to admin_conference_photos_path, notice: 'Photo was successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_conference
@conference = Conference.find_by(short_title: params[:conference_id])
end
# Use callbacks to share common setup or constraints between actions.
def set_photo
@photo = Photo.find_by(id: params[:id])
end
# Only allow a trusted parameter "white list" through.
def photo_params
params[:photo]
end
end

View file

@ -1,10 +0,0 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= image_tag(f.object.picture(:thumb)) unless f.object.picture.blank? %>
<%= f.input :picture, hint: 'This photo will appear in the gallery of the splash
so please give photos of banner sizes' %>
<%= f.input :description, :input_html => {:rows => 2 }, hint: 'This description will appear
at the bottom of each photo' %>
<%= remove_association_link :photo, f %>
<% end %>
</div>

View file

@ -8,7 +8,7 @@
= conference_progress['process'] + '%'
%li{'class'=>class_for_todo(conference_progress['registration'])}
%span{'class'=>icon_for_todo(conference_progress['registration'])}
= link_to 'Set up registration period', edit_admin_conference_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
= link_to 'Set up registration period', edit_admin_conference_conference_basics_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
%li{'class'=>class_for_todo(conference_progress['cfp'])}
%span{'class'=>icon_for_todo(conference_progress['cfp'])}
= link_to 'Set up call for papers', admin_conference_callforpapers_path(conference_progress['short_title'])
@ -29,4 +29,4 @@
= link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title'])
%li{class: class_for_todo(conference_progress['make_conference_public'])}
%span{'class'=>icon_for_todo(conference_progress['make_conference_public'])}
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title'])
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_conference_basics_path(conference_progress['short_title'])

View file

@ -1,50 +0,0 @@
.row
.col-md-8
= semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f|
= f.input :make_conference_public, hint: 'This will enable the visitors to view the splash page(the "View Conference" button will be visible now on the home page), it is recommended to enable this after you have finished setting up all the components for display'
= f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule'
= f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'"
= f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs"
= f.input :social_tag, :hint => "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'"
= f.input :contact_email, :hint => "Contact email address for your conference. Will be used as reply-to address in emails sent out by the system."
= f.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"}
= f.inputs name: 'Banner for Splash' do
= f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash'
= f.input :banner_photo, hint: 'This will be the top most component of the splash.This background cover will contain start_date and end_date of the conference and the description'
= f.input :description, hint: markdown_hint("This description will be shown at the bottom of the banner photo of the Splash."), input_html: { data: { provide: "markdown-editable" } }
= f.inputs :name => "Scheduling" do
= f.input :timezone, :as => :time_zone, :hint => "The conference time zone"
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
= f.inputs name: 'Registration' do
= f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page'
= f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" }
= f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" }
= f.input :registration_description, hint: markdown_hint("This description will appear in registration segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
= f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
= f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'
= f.input :lodging_description, hint: markdown_hint("This will appear in the lodging segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
= dynamic_association :photos, "Photos", f
= f.inputs :name => 'Social Media' do
- if !@conference.logo.blank?
= image_tag @conference.logo(:thumb)
= f.input :include_social_media_in_splash, hint: 'On setting this true you will enable the social media links to be displayed on the splash page'
= f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page."
= f.input :media_type, :as => :select, :label => "Conference Promo Media Type", :class=>"form-control", :collection => Conference.media_types.values, :include_blank => false, :hint => "This media-item will be used to represent this conference at various places in OSEM."
= f.input :media_id, :label => "Conference Promo Media ID", :as => :string
%p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/"
%p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id
%p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/
%p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/
%p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id
%p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol)
= f.input :facebook_url, hint: 'This will appear in the social media section as link to the Facebook page of your Conference'
= f.input :google_url, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference'
= f.input :twitter_url, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference'
= f.input :instagram_url, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference'
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -0,0 +1,30 @@
.row
.col-md-8
= semantic_form_for(@conference, url: admin_conference_conference_basics_path(@conference.short_title), html: { multipart: true }) do |f|
= f.input :make_conference_public, hint: 'This will enable the visitors to view the splash page(the "View Conference" button will be visible now on the home page), it is recommended to enable this after you have finished setting up all the components for display'
= f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule'
= f.input :title, hint: "The full name of the conference, such as 'OpenSUSE Conference 2013'"
= f.input :short_title, hint: "A short title, such as 'osc2013', to be used in URLs"
%p{'style'=>'color: red;'} Attention: If you alter the short title of the conference, all URLs will also change!
- if !@conference.logo.blank?
= image_tag @conference.logo(:thumb)
= f.input :logo, label: 'Conference Logo', hint: 'This will be displayed on the front page.'
= f.input :color, hint: 'The color will be used on the dashboard (e.g. line / pie charts).', input_html: { size: 6, type: 'color' }
= f.inputs name: 'Banner for Splash' do
= f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash'
= f.input :banner_photo, hint: 'This will be the top most component of the splash.This background cover will contain start_date and end_date of the conference and the description'
= f.input :description, hint: markdown_hint('This description will be shown at the bottom of the banner photo of the Splash.'), input_html: { rows: 5, data: { provide: '"markdown-editable" '} }
= f.inputs name: 'Scheduling' do
= f.input :timezone, as: :time_zone, hint: 'The conference time zone'
= f.input :start_date, as: :string, input_html: { id: 'conference-start-datepicker', readonly: 'readonly' }
= f.input :end_date, as: :string, input_html: { id: 'conference-end-datepicker', readonly: 'readonly' }
= f.inputs name: 'Media' do
= f.input :media_type, as: :select, label: 'Conference Promo Media Type', class: 'form-control', collection: Conference.media_types.values, include_blank: false, hint: 'This media-item will be used to represent this conference at various places in OSEM.'
= f.input :media_id, label: 'Conference Promo Media ID', as: :string
%p{ class: 'help-block media-type', id: 'youtube-help' } Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/"
%p{ class: 'help-block media-type', id: 'slideshare-help', style: 'display:none' } Go to your SlideShare, click on "share" -> "embed" and copy the id
%p{ class: 'help-block media-type', id: 'flickr-help', style: 'display:none' } Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/
%p{ class: 'help-block media-type', id: 'vimeo-help', style: 'display:none' } Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/
%p{ class: 'help-block media-type', id: 'speakerdeck-help', style: 'display:none' } Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id
%p{ class: 'help-block media-type', id: 'instagram-help', style: 'display:none' } Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol)
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,82 @@
.row{'style'=>'padding-top: 15px;'}
.col-md-6
%dl.dl-horizontal
%dt
Title
%dd
= @conference.title
%dt
Short Title
%dd
= @conference.short_title
%dt
Description
%dd
- unless @conference.description.blank?
= markdown(@conference.description)
- else
Not set!
%dt
Date
%dd
= date_string(@conference.start_date, @conference.end_date)
%dt
Color
%dd
%div.text-center{'style'=>"width: 25px; height: 25px; background: #{@conference.color};"}
.row.row-flex.row-flex-wrap
.col-md-4
.thumbnail.flex-col
%h3.text-center
Conference Logo
- if @conference.logo?
= image_tag(@conference.logo(:large), class: 'img-responsive')
.caption.flex-grow
.caption
%p
%dl.dl-horizontal
%dt
Filename
%dd
= @conference.logo_file_name
-else
%h4.text-center
Not set!
.col-md-4
.thumbnail.flex-col
%h3.text-center
Conference Banner
- if @conference.banner_photo?
= image_tag(@conference.banner_photo(:large), class: 'img-responsive')
.caption.flex-grow
.caption
%p
%dl.dl-horizontal
%dt
Filename
%dd
= @conference.banner_photo_file_name
- else
%h4.text-center
Not set!
.col-md-4
.thumbnail
%h3.text-center
Media
- unless @conference.media_id.blank?
.flexvideo
= render partial: 'shared/media_item', locals: { media_type: @conference.media_type, media_id: @conference.media_id }
.caption
%p
%dl.dl-horizontal
%dt
Media Type
%dd
= @conference.media_type
%dt
Media ID
%dd
= @conference.media_id
- else
%h4.text-center
Not set!

View file

@ -0,0 +1,16 @@
.row
.col-md-12
%ul.nav.nav-tabs{'role'=>'tablist'}
%li.active
%a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'}
Show
%li
%a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'}
Edit
.row
.col-md-12
.tab-content
.tab-pane.active#show
= render partial: 'show'
.tab-pane#edit
= render partial: 'form'

View file

@ -0,0 +1,13 @@
.row
.col-md-8
= semantic_form_for(@conference, :url => admin_conference_conference_basics_path(@conference.short_title),:html => {:multipart => true}) do |f|
= f.inputs :name => 'Contact' do
= f.input :contact_email, hint: 'Contact email address for your conference. Will be used as reply-to address in emails sent out by the system.'
= f.inputs :name => 'Social Media' do
= f.input :include_social_media_in_splash, hint: 'On setting this true you will enable the social media links to be displayed on the splash page'
= f.input :social_tag, hint: "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'"
= f.input :facebook_url, hint: 'This will appear in the social media section as link to the Facebook page of your Conference'
= f.input :google_url, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference'
= f.input :twitter_url, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference'
= f.input :instagram_url, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference'
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,31 @@
%ul.list-unstyled
- unless @conference.contact_email.blank?
%li
= link_to "#{ @conference.contact_email }" do
%i.fa.fa-envelope.fa-3x
= @conference.contact_email
- unless @conference.social_tag.blank?
%li
= link_to "#{ @conference.social_tag }" do
%i.fa.fa-thumbs-o-up.fa-3x
= "##{@conference.social_tag}"
- unless @conference.facebook_url.blank?
%li
= link_to "#{ @conference.facebook_url }" do
%i.fa.fa-facebook-square.fa-3x
= @conference.facebook_url
- unless @conference.twitter_url.blank?
%li
= link_to "#{ @conference.twitter_url }" do
%i.fa.fa-twitter.fa-3x
= @conference.twitter_url
- unless @conference.instagram_url.blank?
%li
= link_to "#{ @conference.instagram_url }" do
%i.fa.fa-instagram.fa-3x
= @conference.instagram_url
- unless @conference.google_url.blank?
%li
= link_to "#{ @conference.google_url }" do
%i.fa.fa-google.fa-3x
= @conference.google_url

View file

@ -0,0 +1,16 @@
.row
.col-md-12
%ul.nav.nav-tabs{'role'=>'tablist'}
%li.active
%a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'}
Show
%li
%a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'}
Edit
.row
.col-md-12
.tab-content
.tab-pane.active#show
= render partial: 'show'
.tab-pane#edit
= render partial: 'form'

View file

@ -0,0 +1,7 @@
= f.inputs do
- if !f.object.errors
= image_tag(f.object.picture(:thumb)) unless f.object.picture.blank?
= f.input :picture, hint: 'This photo will appear in the gallery of the splash so please give photos of banner sizes.'
= f.input :description, :input_html => {:rows => 2 }, hint: 'This description will appear at the bottom of each photo.'
.actions
= f.button 'Save Photo', :class => 'btn btn-primary'

View file

@ -0,0 +1,6 @@
%h1 Editing Photo
= semantic_form_for @photo, url: admin_conference_photo_path(conference_id: @conference.short_title, id: @photo.id) do |f|
= render 'form', f: f
= link_to 'Back', admin_conference_photos_path

View file

@ -0,0 +1,20 @@
%h1 Photos
- @photos.each_slice(3) do |slice|
.row.row-flex.row-flex-wrap
- slice.each do |photo|
.col-md-4
.thumbnail.flex-col
%h3.text-center
= photo.picture_file_name
= image_tag(photo.picture(:large), class: 'img-responsive', title: photo.description)
.caption.flex-grow
.caption
= link_to edit_admin_conference_photo_path(@conference.short_title, photo.id), class: 'btn btn-primary' do
%i.fa.fa-pencil-square-o
Edit
= link_to admin_conference_photo_path(@conference.short_title, photo.id), method: :delete, class: 'btn btn-danger' do
%i.fa.fa-times-circle
Delete
.row{'style'=>'padding-top: 10px;'}
.col-md-12
= link_to 'New Photo', new_admin_conference_photo_path, class: 'btn btn-primary'

View file

@ -0,0 +1,6 @@
%h1 New Photo
= semantic_form_for @photo, url: admin_conference_photos_path(conference_id: @conference.short_title) do |f|
= render 'form', f: f
= link_to 'Back', admin_conference_photos_path

View file

@ -20,10 +20,24 @@
%span.glyphicon.glyphicon-plus
New Conference
%hr
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))}"}
= link_to(admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-dashboard
Manage
%span.fa.fa-tachometer
Dashboard
%li{:class=> "#{active_nav_li(edit_admin_conference_conference_basics_path(@conference.short_title))}"}
= link_to(edit_admin_conference_conference_basics_path(@conference.short_title)) do
%span.fa.fa-home
Basics
%ul
%li{:class=> "#{active_nav_li(edit_admin_conference_conference_contacts_path(@conference.short_title))}"}
= link_to(edit_admin_conference_conference_contacts_path(@conference.short_title)) do
%span.fa.fa-envelope-o
Contact
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
= link_to(admin_conference_photos_path(@conference.short_title)) do
%span.fa.fa-file-image-o
Photos
%hr
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
= link_to(admin_conference_events_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment
@ -41,10 +55,6 @@
%span.glyphicon.glyphicon-bullhorn
Campaigns
%hr
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
= link_to(edit_admin_conference_path(@conference.short_title)) do
%span.glyphicon.glyphicon-cog
Settings
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
= link_to(admin_conference_targets_path(@conference.short_title)) do
%span.glyphicon.glyphicon-flag