Skip to content

Commit

Permalink
Merge branch 'master' into attachment-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
taitus committed Dec 18, 2017
2 parents c667ae2 + d67e23c commit a0393f3
Show file tree
Hide file tree
Showing 36 changed files with 869 additions and 428 deletions.
76 changes: 71 additions & 5 deletions app/assets/javascripts/events.js.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,50 @@
$(function(){

function toggle_hidden(id) {
var hiddenField = $(id),
val = hiddenField.val();
hiddenField.val(val === "true" ? "false" : "true");
}

function cancel_hidden(id) {
var hiddenField = $(id)
hiddenField.val("false");
}

$('#accept_link').bind('click', function(e){
e.preventDefault();

cancel_hidden('#event_decline')
cancel_hidden('#event_cancel')
toggle_hidden('#event_accept')

$('#cancel-reason').hide()
$('#decline-reason').hide()
$('#accept-reason').toggle();
});

$('#decline_link').bind('click', function(e){
e.preventDefault();
$('#decline_link').hide();
$('#decline-reason').show();

toggle_hidden('#event_decline')
cancel_hidden('#event_cancel')
cancel_hidden('#event_accept')

$('#cancel-reason').hide()
$('#accept-reason').hide()
$('#decline-reason').toggle();
});

$('#cancel_link').bind('click', function(e){
e.preventDefault();

cancel_hidden('#event_decline')
toggle_hidden('#event_cancel')
cancel_hidden('#event_accept')

$('#decline-reason').hide()
$('#accept-reason').hide()
$('#cancel-reason').toggle();
});

$('.fdatepicker').fdatepicker({
Expand All @@ -28,7 +70,7 @@ $(function(){
tinyMCE.triggerSave();
id = "#event_" + arg
content = $(id).val();
if ($(element).is(':checked') && (content == ''))
if (($(element).val() == 'true') && (content == ''))
{return false }
else
{ return true }
Expand Down Expand Up @@ -67,6 +109,9 @@ $(function(){
"event[published_at]" : {
required : true
},
"event[accept]" : {
checkMessage : "accepted_reasons"
},
"event[decline]" : {
checkMessage : "declined_reasons"
},
Expand Down Expand Up @@ -106,6 +151,9 @@ $(function(){
"event[event_agents_attributes][0][name]" : {
valueNotEquals: "<%= I18n.translate('backend.event.event_agent_needed')%>"
},
"event[accept]" : {
checkMessage : "<%= I18n.translate('backend.event.accept_reasons_needed')%>"
},
"event[decline]" : {
checkMessage : "<%= I18n.translate('backend.event.decline_reasons_needed')%>"
},
Expand Down Expand Up @@ -134,12 +182,14 @@ $(function(){

$("#event_lobby_activity_true").click(function(){
$(".lobby-organization-autocomplete").show();
$('.lobby-scheduled').show();
});

if ($("#event_lobby_activity_true").is(":checked")) {
fill_autocomplete_organization_name();
fill_represented_entities_select_options();
fill_agents_select_options();
$('.lobby-scheduled').show();
if ($("#new_event").length > 0) {
$('#event_represented_entities_link').trigger('click');
$('#event_agents_link').trigger('click');
Expand All @@ -148,6 +198,7 @@ $(function(){
$(".lobby-organization-autocomplete").hide();
$('.represented-entities-block').hide();
$('.agents-block').hide();
$('.lobby-scheduled').hide();
fill_autocomplete_organization_name();
fill_represented_entities_select_options();
fill_agents_select_options();
Expand All @@ -157,6 +208,7 @@ $(function(){
$(".lobby-organization-autocomplete").hide();
$('.represented-entities-block').hide();
$('.agents-block').hide();
$('.lobby-scheduled').hide();
$("#lobby-activity-event #category-block").hide();
$('#event_organization_name').val('');
$('#lobby-activity-event .link_to_remove_association').trigger('click');
Expand Down Expand Up @@ -190,6 +242,20 @@ $(function(){
$("#decline-reason").hide();
});

$('#accept-reason').hide();

$("#event_accept_true").click(function(){
$("#accept-reason").show();
});

if ($("#event_accept_true").is(":checked")) {
$("#accept-reason").show();
};

$("#event_accept_false").click(function(){
$("#accept-reason").hide();
});

});

function fill_represented_entities_select_options() {
Expand Down Expand Up @@ -227,9 +293,9 @@ function fill_agents_select_options() {
var select = $('#nested-event-agents select:last');
if (agents.length > 0) {
$.each(agents, function(id, agent){
select.append($('<option>', { value: agent.name, text: agent.name }));
select.append($('<option>', { value: agent.name+" "+agent.first_surname+" "+agent.second_surname, text: agent.name+" "+agent.first_surname+" "+agent.second_surname }));
if (agents.length == 1) {
$('#nested-event-agents select').val(agent.name);
$('#nested-event-agents select').val(agent.name+" "+agent.first_surname+" "+agent.second_surname);
}
});
}else {
Expand Down
116 changes: 110 additions & 6 deletions app/assets/stylesheets/all.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7032,12 +7032,15 @@ header{
line-height: 48px;
font-family: 'Open Sans';
display: block;
margin-bottom: 50px; }

}
@media only screen and (max-width: 40em) {
.title-l {
font-size: 26px;
line-height: 28px;
margin-bottom: 20px; } }
margin-bottom: 20px;
}
}

.title-m {
font-size: 28px;
Expand Down Expand Up @@ -7285,7 +7288,7 @@ button, a {
}
.title-l {
font-weight: 700;
margin-bottom: 70px;
// margin-bottom: 70px;
}
select {
height: 3.1125rem;
Expand Down Expand Up @@ -7343,12 +7346,10 @@ select {

.top_bar_box {
padding: 35px 0 100px;
//background: #004A83;
background: #003df6;
padding: 0;
}
.sub_top_bar_box{
// background: #0363a7;
background: #0000e1;
ul{
margin-bottom:0;
Expand All @@ -7366,7 +7367,6 @@ select {
}
}
}

.header-title{
background: #f5f7f8;
text-align: center;
Expand Down Expand Up @@ -7627,3 +7627,107 @@ header .top-bar{
margin-top: 1.8rem;
}
}

.help-text{
font-size: 0.7rem;
font-style: italic;
}

fieldset.attachments{
hr:last-child{
display: none;
}
}

.visit-organizations-list{
select {
height: 2.8rem;
}

.button.small{
padding-left: 1rem;
padding-right: 1rem;
}
.result-l{
font-weight: normal;
}
.result-l,
.export {
margin-top: 1.3rem;
}

.export{
a{
margin-top:0.6rem;
span{
display: inline-block;
font-size: 13px;
margin-left:3px;
margin-right:3px;
}
}
}
.list-organizations{
padding: 0;
}
.box .post{
border-bottom: 0;
margin-bottom:0;
padding: 1.6rem 1rem;
}

article{
&:nth-child(odd){
background: #f8f8f8;
}
&:nth-child(even){
background: #f1f1f1;
}
}
}

.no-padding{
padding: 0;
}

@media only screen and (min-width: 40.0625em) {
.visit-organizations-list{
.title-s{
font-size: 13px;
}
.order-select{
padding: 0;
}
}
}

@media screen and (min-width: 40em) {
.buttons-action{
padding: 0;
}
}

@media screen and (min-width: 40em) and (max-width: 63.9375em) {
.visit-organizations-list{
.title-s{
font-size: 12px;
}
.buttons-action{
text-align: right;
.button.small {
padding-left: 0.8rem;
padding-right: 0.8rem;
}
}
.result-l{
font-size: 1.4rem;
}
}
}

@media screen and (max-width: 39.9375em) {
.order-select{
padding: 0;
margin-bottom:0;
}
}
2 changes: 1 addition & 1 deletion app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class AgentsController < AdminController
respond_to :json

def index
@agents = Agent.select('id', 'name').by_organization(params[:organization_id]).order(:name)
@agents = Agent.select('id', 'name', 'first_surname', 'second_surname').by_organization(params[:organization_id]).order(:name)
render :json => @agents
end
end
13 changes: 9 additions & 4 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ def create
end
end

def edit
def new
if current_user.lobby? && current_user.organization.agents.empty?
redirect_to edit_admin_organization_path(id: current_user.organization_id, show: 'agents'), alert: t('backend.event.add_agents')
end
end

def edit; end

def update
@event.user = current_user
if @event.update_attributes(event_params)
Expand All @@ -45,8 +50,8 @@ def get_title

def event_params
params.require(:event).permit(:title, :description, :location, :scheduled, :position_id, :search_title, :search_person,
:lobby_activity, :notes, :status, :reasons, :published_at, :cancel, :decline, :declined_reasons,:organization_id,
:organization_name, :lobby_scheduled, :general_remarks, :lobby_contact_firstname,
:lobby_activity, :notes, :status, :reasons, :published_at, :cancel, :decline, :declined_reasons, :organization_id,
:organization_name, :lobby_scheduled, :general_remarks, :lobby_contact_firstname, :accept, :accepted_reasons,
:lobby_contact_lastname, :lobby_contact_phone, :lobby_contact_email, :manager_general_remarks,
event_represented_entities_attributes: [:id, :name, :_destroy],
event_agents_attributes: [:id, :name, :_destroy],
Expand Down Expand Up @@ -78,7 +83,7 @@ def set_event

def find_holder_id_by_name(name)
holder_ids = Holder.by_name(name).pluck(:id)
array_position = Position.where("positions.holder_id IN (?)", holder_ids)
Position.where("positions.holder_id IN (?)", holder_ids)
end

def enum_status(array_status)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class HomepageController < ApplicationController
def index
end

def index; end

end
2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def search(params)
fulltext(params[:keyword], :fields => [:agent_second_surname]) if params[:keyword].present?
end
order_by :created_at, :desc
paginate page: params[:format].present? ? 1 : params[:page] || 1, per_page: params[:format].present? ? 1000 : 10
paginate page: params[:format].present? ? 1 : params[:page] || 1, per_page: params[:format].present? ? 1000 : 20
end
end

Expand Down
4 changes: 0 additions & 4 deletions app/helpers/admin/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ def admin_or_mananger_edit?
(current_user.admin? || current_user.user?) && params[:action] == "edit"
end

def event_edit?
params[:action] == "edit"
end

def calculate_firstname(event)
if event.lobby_contact_firstname.present?
event.lobby_contact_firstname
Expand Down
15 changes: 5 additions & 10 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@ def form_field_errors(form, field)
end

def export_link(url)
link_to url, class: "right dib dn hide-for-small-only" do
content_tag(:span, "", class: "icon icon__export") + t('main.export')
link_to url, class: "right hide-for-small-only" do
content_tag(:div) do
concat(content_tag(:span, "", class: "icon icon__export"))
concat(content_tag(:span, t('main.export')))
end
end
end

def canceled_event(event)
!event.canceled_at.nil?
end

def declined_event(event)
!event.declined_at.nil?
end

end

0 comments on commit a0393f3

Please sign in to comment.