Skip to content

Commit

Permalink
Merge branch 'master' into dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
lordinatrice authored Jun 13, 2019
2 parents d7bb464 + e47137b commit 23ebcff
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 44 deletions.
Binary file added app/assets/images/emoji/010-relaxed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions app/assets/stylesheets/components/_button.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.validatechallenge {
color: white;
padding: 20px;
Expand Down Expand Up @@ -34,7 +35,7 @@
color:white;
}

#newchallenge {
.newchallenge {
color: white;
background-color: $navbar;
margin: 10px 10px;
Expand All @@ -44,9 +45,12 @@
// animation-play-state: paused;
}

#newchallenge:hover {
.newchallenge:hover {
// border: 0.5px solid $dashboard;
color: white;
opacity: 0.9;
transform: scale(1.1);
text-decoration: none;
// animation-play-state: play;
}
// landing button
Expand Down Expand Up @@ -142,6 +146,7 @@
margin: auto 0;
text-transform: uppercase;
color: white;
text-decoration: none;
}

&:hover {
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/components/_card_role_model.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
display: inline-block;
margin-bottom: 10px;
}
a {
text-decoration: none;
}
}

// .model_profile_card .card_image {
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/pages/_dashboard.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.titles {
display: flex;
justify-content: space-between;
Expand Down
44 changes: 35 additions & 9 deletions app/controllers/role_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,45 @@ def index
first_name ILIKE :query \
OR last_name ILIKE :query \
"
end
if params[:query].present? && params[:gender].present? && params[:gender] != 'Gender' && params[:sector].present? && params[:sector] != 'Sector'
@role_models_unfiltered = RoleModel.where([sql_query, query: "%#{params[:query]}%"]).where(gender: params[:gender])
@role_models = []
@role_models_unfiltered.to_a.each do |r|
sector = r.sector
sector_as_array = sector.split(',')
@role_models << r if sector_as_array.include?(params[:sector])
end
elsif params[:query].present? && params[:sector].present? && params[:sector] != 'Sector' && params[:gender] == ''
@role_models_unfiltered = RoleModel.where([sql_query, query: "%#{params[:query]}%"])
@role_models = []
@role_models_unfiltered.to_a.each do |r|
sector = r.sector
sector_as_array = sector.split(',')
@role_models << r if sector_as_array.include?(params[:sector])
end
elsif params[:query].present? && params[:gender].present? && params[:gender] != 'Gender' && params[:sector] == ''
@role_models = RoleModel.where([sql_query, query: "%#{params[:query]}%"]).where(gender: params[:gender])
elsif params[:gender].present? && params[:gender] != 'Gender' && params[:sector].present? && params[:sector] != 'Sector'
@role_models_unfiltered = RoleModel.where(gender: params[:gender])
@role_models = []
@role_models_unfiltered.to_a.each do |r|
sector = r.sector
sector_as_array = sector.split(',')
@role_models << r if sector_as_array.include?(params[:sector])
end
elsif params[:query].present?
@role_models = RoleModel.where(sql_query, query: "%#{params[:query]}%")
elsif params[:sector].present? && params[:sector] != 'Sector'
@role_models = RoleModel.where(sector: params[:sector])
@role_models = []
RoleModel.all.each do |r|
sector = r.sector
sector_as_array = sector.split(',')
@role_models << r if sector_as_array.include?(params[:sector])
end
elsif params[:gender].present? && params[:gender] != 'Gender'
@role_models = RoleModel.where(gender: params[:gender])
elsif params[:query].present? && params[:sector].present? && params[:sector] != 'Sector'
@role_models = RoleModel.where([sql_query, query: "%#{params[:query]}%"], sector: params[:sector])
elsif params[:query].present? && params[:gender].present? && params[:gender] != 'Gender'
@role_models = RoleModel.where([sql_query, query: "%#{params[:query]}%"], gender: params[:gender])
elsif params[:query].present? && params[:gender].present? && params[:gender] != 'Gender' && params[:sector].present? && params[:sector] != 'Sector'
@role_models = RoleModel.where([sql_query, query: "%#{params[:query]}%"], gender: params[:gender], sector: params[:sector])
elsif params[:gender].present? && params[:gender] != 'Gender' && params[:sector].present? && params[:sector] != 'Sector'
@role_models = RoleModel.where(gender: params[:gender], sector: params[:sector])

else
@role_models = RoleModel.all
@bookmarkeds = Bookmarked.where(user: current_user)
Expand Down
4 changes: 2 additions & 2 deletions app/models/role_model.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class RoleModel < ApplicationRecord
SECTOR = ["Tech", "Acting", "Dance", "Digital", "Mathematics", "Physics", "Sports", "Business", "Entrepreneurship", "Entertainment"]
SECTOR = ["Physics", "Chemistry", "Law", "Politics" "Tech", "Music", "Acting", "Film Directing", "Production", "Animation", "Fictional", "Writing", "Artist", "Programming", "Mathematics", "Environment", "Sports", "Business", "Entrepreneurship", "Entertainment"]
GENDER = ["Male", "Female", "Other"]
has_many :challenges
has_many :bookmarkeds, dependent: :destroy
validates :last_name, presence: true
validates :sector, presence: true, inclusion: { in: SECTOR }
validates :sector, presence: true
validates :gender, presence: true, inclusion: { in: GENDER }

def gender?
Expand Down
1 change: 0 additions & 1 deletion app/views/pages/_non_done_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</div>
<!-- </div> -->
</a>

</div>


19 changes: 13 additions & 6 deletions app/views/pages/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@

<div>
<div class="dashboard-element">

<div class="titles">
<h5><em>Ongoing challenges</em> (<%= @undone_participations.length %>)</h5>
</div>
<% if @undone_participations.empty? %>
<div class="d-flex justify-content-center align-items-center">
<%= link_to "Challenge me", challenges_home_path, id:"newchallenge" %>
<%= link_to "Challenge me", challenges_home_path, class:"newchallenge" %>
<%= image_tag "emoji/026-grinning.png", size: 50 %>

<!-- <div class="scrollbar scrollbar-primary"> -->
<%else%>
<div class="force-overflow">
Expand Down Expand Up @@ -91,10 +92,16 @@
</div>
<div class="modal-body">
<%= simple_form_for participation, remote: false do |f| %>
<%= f.input :feedback, as: :text, label: 'Go on and describe your experience !', error: 'Be able to look back and analyse your experience is a huge part of building self confidence. Put a feedback !', placeholder: 'I was not sure I could it, I waited a lot, then I pulled myself out there and I felt great afterward, because I could push myself.' %>
<%= f.input :appreciation, collection: (1..5).to_a, label: 'How much did you appreciate this challenge ?', input_html: {class: "modal-rating"} %>
<%= f.input :difficulty, collection: (1..5).to_a, label: 'How much did you find it difficult ?', input_html: {class: "modal-rating"} %>
<%= f.submit "Validate", id:"btn-confetti#{participation.id}", class: "btn-3d"%>
<%= f.input :feedback, as: :text, label: 'Description', error: 'Put a feedback !', placeholder: 'Really great challenge...' %>
<div class="d-flex justify-content-around">
<%= f.input :appreciation, collection: (1..5).to_a, label: content_tag(:i, "" , class: "fas fa-heart") + " LIKE", input_html: {class: "modal-rating"} %>
<%= f.input :difficulty, collection: (1..5).to_a, label: image_tag('dragon_logo.png', size: "20") + " DIFFICULTY", input_html: {class: "modal-rating"} %>
</div>

<div class="d-flex justify-content-left. align-items-center">
<%= f.submit "Validate", id:"btn-confetti#{participation.id}", class: "newchallenge"%>
<%= image_tag "emoji/102-love.png", size: 50 %>
</div>
<% end %>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions app/views/role_models/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
<%= form_tag role_models_path, method: :get do %>
<div id= "search-data" class="search-form-control form-group search-data" data-role_models_search="<%= @role_models_search.to_json %>">
<div class="row d-flex text-align-center">
<div class="col-7 d-flex">
<div class="col-7 d-flex justify-content-around align-items-center">
<%= link_to role_models_path do %>
<%= image_tag "emoji/010-relaxed.png", size: 50, style: "transform: rotatey(180deg); margin-right: 20px;" %>
<% end %>
<%= text_field_tag :query, params[:query], id:"search-bar",
class: "form-control string required search-input", type: "text",
placeholder: "Find an inspiring model 🤗", autocomplete: :on %>
placeholder: "Find an role inspiring model", autocomplete: :on %>
</div>
<div class="col-2">
<%= select_tag(:sector, options_for_select(RoleModel::SECTOR), prompt: 'Sector', class: "form-control")%>
Expand Down Expand Up @@ -80,7 +83,7 @@
<%= link_to '', role_model_path(role_model), class: "stretched-link" %>
<%= image_tag(role_model.picture, class:"avatar-large card_image", alt: "avatar-large" ) if role_model.picture %>
<h5 class="card-title"><%= role_model.first_name %> <%= role_model.last_name %></h5>
<p class="card-subtitle mb-2 text-muted "><%= role_model.sector %></p>
<p class="card-subtitle mb-2 text-muted "><%= role_model.sector.split(',').join(', ')%></p>
</blockquote>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/role_models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div>
<h4 class="card-title"><%= @role_model.first_name %> <%= @role_model.last_name %></h4>
<p class="card-subtitle mb-2 text-muted "><%= @role_model.sector %></p>
<p class="card-subtitle mb-2 text-muted "><%= @role_model.sector.split(',').join(', ') %></p>
<hr>
<div id="bookmark-link">
<%= render "role_models/bookmark_link" %>
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@
create_table "role_models", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.string "sector"
t.string "gender"
t.string "description"
t.string "picture"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "status"
t.string "sector"
end

create_table "users", force: :cascade do |t|
Expand Down
Loading

0 comments on commit 23ebcff

Please sign in to comment.