diff --git a/Procfile.dev b/Procfile.dev index 714108d..ca7367d 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,3 @@ web: bin/rails server -p 3000 -b 0.0.0.0 js: yarn build --watch -# worker: redis-cli flushall ; bundle exec sidekiq -C config/sidekiq.yml +worker: redis-cli flushall ; bundle exec sidekiq -C config/sidekiq.yml diff --git a/app/assets/stylesheets/components/_index.scss b/app/assets/stylesheets/components/_index.scss index acdd200..778553c 100644 --- a/app/assets/stylesheets/components/_index.scss +++ b/app/assets/stylesheets/components/_index.scss @@ -7,3 +7,4 @@ @import "footer"; @import "card"; @import "popup"; +@import "modal"; diff --git a/app/assets/stylesheets/components/_modal.scss b/app/assets/stylesheets/components/_modal.scss new file mode 100644 index 0000000..04011ba --- /dev/null +++ b/app/assets/stylesheets/components/_modal.scss @@ -0,0 +1,17 @@ +.modal{ + height: auto; + bottom: 0; + top: 200px; +} + +.modal-content{ + top: 300px; + +} + +.modal-header { + position: sticky; + top: 0; + z-index: 1056; + background-color: #FFF; +} diff --git a/app/assets/stylesheets/config/_bootstrap_variables.scss b/app/assets/stylesheets/config/_bootstrap_variables.scss index e3684fe..227b22c 100755 --- a/app/assets/stylesheets/config/_bootstrap_variables.scss +++ b/app/assets/stylesheets/config/_bootstrap_variables.scss @@ -22,3 +22,4 @@ $border-radius-lg: 2px; $border-radius-sm: 2px; // Override other variables below! + diff --git a/app/assets/stylesheets/pages/_myleague.scss b/app/assets/stylesheets/pages/_myleague.scss index 45844a8..88322d1 100644 --- a/app/assets/stylesheets/pages/_myleague.scss +++ b/app/assets/stylesheets/pages/_myleague.scss @@ -135,7 +135,7 @@ table tbody tr { .card-challenges { position: relative; display: flex; -width: 88vw; +width: auto; flex-direction: column; justify-content: space-between; padding: 1rem; diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 4025e72..e96e816 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,19 +1,32 @@ class ChallengesController < ApplicationController before_action :set_league + before_action :set_challenge, only: [:show] def index @challenges = @league.user_league_challenges end def show - @challenge = Challenge.find(params[:id]) + @details_challenge = UserLeagueChallenge.joins(user_league: :league).includes(:user_league) + .where(challenge_id: @challenge.id, user_league: { league_id: @league.id }) + .order('progress DESC') + respond_to do |format| + format.html + format.text { render partial: "challenges/show_details_challenge", locals: { details_challenge: @details_challenge}, formats: [:html] } + end end + private def set_league @league = League.find(params[:league_id]) end + + def set_challenge + @challenge = Challenge.find(params[:id]) + end + end # Faire un tableau avec les kills / Hit diff --git a/app/controllers/leagues_controller.rb b/app/controllers/leagues_controller.rb index 1de235f..cb35eb6 100644 --- a/app/controllers/leagues_controller.rb +++ b/app/controllers/leagues_controller.rb @@ -9,10 +9,10 @@ def index def show @league_challenges = @league.challenges + @details_challenge = [] @user_challenges = UserLeagueChallenge.joins(user_league: [:league]).includes(:challenge) .where(user_leagues: { user_id: current_user, league_id: @league }) .order('progress DESC') - @url = "#{join_league_url}?token=#{@league.token}" @users = @league.users @league = League.find(params[:id]) diff --git a/app/javascript/controllers/league_controller.js b/app/javascript/controllers/league_controller.js index 37b1561..1ac8d28 100644 --- a/app/javascript/controllers/league_controller.js +++ b/app/javascript/controllers/league_controller.js @@ -4,7 +4,7 @@ import { createConsumer } from "@rails/actioncable" // Connects to data-controller="league" export default class extends Controller { static values = { leagueId: Number, currentUserId: Number } - static targets = ["userChallenges", "ranking", "players", "leagueChallenges"] + static targets = ["userChallenges", "ranking", "players", "leagueChallenges", "detailsChallenge"] initialize() { this.received = this.received.bind(this) @@ -14,6 +14,7 @@ export default class extends Controller { console.log("coucou") console.log(this.leagueIdValue) console.log(this.currentUserIdValue) + console.log(this.detailsChallengeTarget) this.channel = createConsumer().subscriptions.create( { channel: "LeagueChannel", id: this.leagueIdValue }, { received: this.received } @@ -61,4 +62,16 @@ export default class extends Controller { received(json) { this[json.key](json.data) } + + showDetails(event) { + console.log(event.currentTarget.dataset.cid) + const challengeId = event.currentTarget.dataset.cid + const url = `/leagues/${this.leagueIdValue}/challenges/${challengeId}` + fetch(url, {headers: {"Accept": "text/plain"}}) + .then(response => response.text()) + .then((data) => { + console.log(data) + this.detailsChallengeTarget.outerHTML = data; + }) + } } diff --git a/app/views/challenges/_show_details_challenge.erb b/app/views/challenges/_show_details_challenge.erb new file mode 100644 index 0000000..1d9e866 --- /dev/null +++ b/app/views/challenges/_show_details_challenge.erb @@ -0,0 +1,14 @@ +<% details_challenge.each do |challenge| %> +
<%= challenge.succes? ? "Completed" : "In progress" %>
+<%= user.user_leagues.count %>
-<%#= @league.game.name %> CS GO
-<%= user.completed_challenges_count %>
-<%= user.created_at.strftime("%B %Y") %>
-<%= user_challenge.challenge.description %>
-<%= user_challenge.challenge.description %>
+<%= @league.game.genre %>
<%#<%= @league.game.description %>
@@ -26,8 +26,13 @@ <%= render "league_challenges", challenges: @league_challenges, league: @league %><%= user.user_leagues.count %>
+<%#= @league.game.name %> CS GO
+<%= user.completed_challenges_count %>
+<%= user.created_at.strftime("%B %Y") %>
+<%= @user.user_leagues.count %>
-<%#= @league.game.name %> CS GO
-<%= @user.completed_challenges_count %>
-<%= @user.created_at.strftime("%B %Y") %>
-