Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:hpi-swt2/workshop-portal into 238_Ev…
Browse files Browse the repository at this point in the history
…ent_Description_Textfield
  • Loading branch information
corinnaj committed Jan 23, 2017
2 parents f2666d7 + 2a94f7c commit 655ef7f
Show file tree
Hide file tree
Showing 54 changed files with 968 additions and 156 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ gem 'figaro'
gem 'active_attr'

#to only display a limited number of items on an index page
gem 'will_paginate', '~> 3.1.0'
gem 'will_paginate-bootstrap'

# Markdown renderer
gem 'redcarpet'
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.1.5)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand Down Expand Up @@ -351,7 +353,7 @@ DEPENDENCIES
turbolinks
twitter-bootstrap-rails
web-console (~> 2.0)
will_paginate (~> 3.1.0)
will_paginate-bootstrap

RUBY VERSION
ruby 2.2.2p95
Expand Down
137 changes: 137 additions & 0 deletions app/assets/javascripts/bootstrap-colorselector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* A colorselector for Twitter Bootstrap which lets you select a color from a predefined set of colors only.
* https://github.com/flaute/bootstrap-colorselector
*
* Copyright (C) 2014 Flaute
*
* Licensed under the MIT license
*/

(function($) {
"use strict";

var ColorSelector = function(select, options) {
this.options = options;
this.$select = $(select);
this._init();
};

ColorSelector.prototype = {

constructor : ColorSelector,

_init : function() {

var callback = this.options.callback;

var selectValue = this.$select.val();
var selectColor = this.$select.find("option:selected").data("color");

var $markupUl = $("<ul>").addClass("dropdown-menu").addClass("dropdown-caret");
var $markupDiv = $("<div>").addClass("dropdown").addClass("dropdown-colorselector");
var $markupSpan = $("<span>").addClass("btn-colorselector").css("background-color", selectColor);
var $markupA = $("<a>").attr("data-toggle", "dropdown").addClass("dropdown-toggle").attr("href", "#").append($markupSpan);

// create an li-tag for every option of the select
$("option", this.$select).each(function() {

var option = $(this);
var value = option.attr("value");
var color = option.data("color");
var title = option.text();

// create a-tag
var $markupA = $("<a>").addClass("color-btn");
if (option.prop("selected") === true || selectValue === color) {
$markupA.addClass("selected");
}
$markupA.css("background-color", color);
$markupA.attr("href", "#").attr("data-color", color).attr("data-value", value).attr("title", title);

// create li-tag
$markupUl.append($("<li>").append($markupA));
});

// append the colorselector
$markupDiv.append($markupA);
// append the colorselector-dropdown
$markupDiv.append($markupUl);

// hide the select
this.$select.hide();

// insert the colorselector
this.$selector = $($markupDiv).insertAfter(this.$select);

// register change handler
this.$select.on("change", function() {

var value = $(this).val();
var color = $(this).find("option[value='" + value + "']").data("color");
var title = $(this).find("option[value='" + value + "']").text();

// remove old and set new selected color
$(this).next().find("ul").find("li").find(".selected").removeClass("selected");
$(this).next().find("ul").find("li").find("a[data-color='" + color + "']").addClass("selected");

$(this).next().find(".btn-colorselector").css("background-color", color);

callback(value, color, title);
});

// register click handler
$markupUl.on('click.colorselector', $.proxy(this._clickColor, this));
},

_clickColor : function(e) {

var a = $(e.target);

if (!a.is(".color-btn")) {
return false;
}

this.$select.val(a.data("value")).change();

e.preventDefault();
return true;
},

setColor : function(color) {
// find value for color
var value = $(this.$selector).find("li").find("a[data-color='" + color + "']").data("value");
this.setValue(value);
},

setValue : function(value) {
this.$select.val(value).change();
},

};

$.fn.colorselector = function(option) {
var args = Array.apply(null, arguments);
args.shift();

return this.each(function() {

var $this = $(this), data = $this.data("colorselector"), options = $.extend({}, $.fn.colorselector.defaults, $this.data(), typeof option == "object" && option);

if (!data) {
$this.data("colorselector", (data = new ColorSelector(this, options)));
}
if (typeof option == "string") {
data[option].apply(data, args);
}
});
};

$.fn.colorselector.defaults = {
callback : function(value, color, title) {
},
colorsPerRow : 8
};

$.fn.colorselector.Constructor = ColorSelector;

})(jQuery, window, document);
121 changes: 121 additions & 0 deletions app/assets/stylesheets/bootstrap-colorselector.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* A colorselector for Twitter Bootstrap which lets you select a color from a predefined set of colors only.
* https://github.com/flaute/bootstrap-colorselector
*
* Copyright (C) 2014 Flaute
*
* Licensed under the MIT license
*/

/* colorselector dropdown */
.dropdown-colorselector>.dropdown-menu {
top: 80%;
left: -7px;
padding: 4px;
min-width: 130px;
max-width: 130px;
}

/*
.dropdown-colorselector>.dropdown-menu.pull-right {
right: -7px;
left: auto;
}
*/
.dropdown-colorselector>.dropdown-menu>li {
display: block;
float: left;
width: 20px;
height: 20px;
margin: 2px;
}

.dropdown-colorselector>.dropdown-menu>li>.color-btn {
display: block;
width: 20px;
height: 20px;
margin: 0;
padding: 0;
border-radius: 0;
position: relative;
-webkit-transition: all ease 0.1s;
transition: all ease 0.1s;
}

.dropdown-colorselector>.dropdown-menu>li>.color-btn:hover {
text-decoration: none;
opacity: 0.8;
filter: alpha(opacity = 80);
-webkit-transform: scale(1.08);
-ms-transform: scale(1.08);
transform: scale(1.08);
}

.dropdown-colorselector>.dropdown-menu>li>.color-btn.selected:after {
content: "\e013";
font-family: 'Glyphicons Halflings';
display: inline-block;
font-size: 11px;
color: #FFF;
position: absolute;
left: 0;
right: 0;
text-align: center;
line-height: 20px;
}

.dropdown-colorselector>.dropdown-menu>li>.color-btn[data-value="0"]:after {
content: "\e014";
font-family: 'Glyphicons Halflings';
display: inline-block;
font-size: 14px;
color: #000;
position: absolute;
left: 0;
right: 0;
text-align: center;
line-height: 20px;
}

.btn-colorselector {
display: inline-block;
width: 20px;
height: 20px;
background-color: #DDD;
vertical-align: middle;
border-radius: 0;
}

.dropdown-menu.dropdown-caret:before {
border-bottom: 7px solid rgba(0, 0, 0, 0.2);
border-left: 7px solid transparent;
border-right: 7px solid transparent;
content: "";
display: inline-block;
left: 9px;
position: absolute;
top: -7px;
}

.dropdown-menu.dropdown-caret:after {
border-bottom: 6px solid #FFFFFF;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
content: "";
display: inline-block;
left: 10px;
position: absolute;
top: -6px;
}

/*
.dropdown-menu.pull-right.dropdown-caret:before {
left: auto;
right: 9px;
}
.dropdown-menu.pull-right.dropdown-caret:after {
left: auto;
right: 10px;
}
*/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/participants.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#participants_download_submit_button {
float: right;
}
8 changes: 8 additions & 0 deletions app/controllers/application_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ def new
flash.keep(:event_id)
return redirect_to new_profile_path, :alert => message
end

@application_letter = ApplicationLetter.new
last_application_letter = ApplicationLetter.where(user: current_user).order("created_at").last
if last_application_letter
attrs_to_fill_in = last_application_letter.attributes
.slice("grade", "coding_skills", "emergency_number", "vegetarian", "vegan", "allergic", "allergies")
@application_letter.attributes = attrs_to_fill_in
flash.now[:notice] = I18n.t('application_letters.fields_filled_in')
end
authorize! :new, @application_letter
if params[:event_id]
@application_letter.event_id = params[:event_id]
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class EventsController < ApplicationController

# GET /events
def index
@events = Event.sorted_by_start_date(!can?(:edit, Event)).reverse
@events = Event.sorted_by_start_date(!can?(:view_unpublished, Event))
end

# GET /events/1
Expand All @@ -30,9 +30,6 @@ def edit
# POST /events
def create
@event = Event.new(event_params)

@event.draft = (params[:draft] != nil)

if @event.save
redirect_to @event, notice: I18n.t('.events.notices.created')
else
Expand All @@ -43,9 +40,6 @@ def create
# PATCH/PUT /events/1
def update
attrs = event_params

@event.draft = (params[:commit] == "draft")

if @event.update(attrs)
redirect_to @event, notice: I18n.t('events.notices.updated')
else
Expand Down Expand Up @@ -233,7 +227,7 @@ def set_event

# Only allow a trusted parameter "white list" through.
def event_params
params.require(:event).permit(:name, :description, :max_participants, :participants_are_unlimited, :kind, :organizer, :knowledge_level, :application_deadline, :custom_application_fields => [], date_ranges_attributes: [:start_date, :end_date, :id])
params.require(:event).permit(:name, :description, :max_participants, :participants_are_unlimited, :kind, :organizer, :knowledge_level, :application_deadline, :published, :custom_application_fields => [], date_ranges_attributes: [:start_date, :end_date, :id])
end

# Generate all names to print from the query-params
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/participant_groups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ParticipantGroupsController < ApplicationController

load_and_authorize_resource

# PATCH/PUT /participant_group/1/group
def update
begin
if @participant_group.update_attributes(participant_group_params)
redirect_to :back, notice: I18n.t('participant_groups.update.successful')
else
redirect_to :back, alert: I18n.t('participant_groups.update.failed')
end
rescue ActionController::RedirectBackError
redirect_to root_path
end
end

private

def participant_group_params
params.require(:participant_group).permit(:group)
end
end
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ProfilesController < ApplicationController
load_and_authorize_resource

before_action :set_profile, only: [:show, :edit, :update]
before_action :set_profile, only: [:show, :edit, :update, :destroy]

# GET /profiles/1
def show
Expand Down
Loading

0 comments on commit 655ef7f

Please sign in to comment.