implemented "ask your followers"
This commit is contained in:
parent
b3b29acd23
commit
58d0efc219
4
TODO
4
TODO
|
@ -1,5 +1,5 @@
|
|||
[001| 0%] user blocking (prohibits blocked user from asking question to that person and seeing their answers)
|
||||
[002| 0%] asking modal (ask all followers/one person a question with a modal you can open over the navbar)
|
||||
[002| 90%] asking modal (ask all followers/one person a question with a modal you can open over the navbar)
|
||||
[003| 0%] file uploads (for now only avatars, file uploads for embedding images in questions MAYBE LATER)
|
||||
[004| 0%] admin status page (like the one from justask2 in Python)
|
||||
[005| 0%] make the hamburger menu button glow or something if there are new questions in the inbox
|
||||
|
@ -10,4 +10,4 @@
|
|||
[010| 0%] locales (these can wait for now)
|
||||
[011| 0%] auto-posting to other services (twatter, fakelook)
|
||||
[012| 0%] open source the entire thing – in late 2015 or 2016 maybe.
|
||||
[013| 0%] restructure questions (has_many :answers) for less redundancy in the DB when implementing #002
|
||||
[013|100%] restructure questions (has_many :answers) for less redundancy in the DB when implementing #002
|
||||
|
|
|
@ -26,9 +26,9 @@ $(document).on "click", "button[name=qb-ask]", ->
|
|||
promote = btn[0].dataset.promote == "true"
|
||||
$("textarea[name=qb-question]").attr "readonly", "readonly"
|
||||
anonymousQuestion = if $("input[name=qb-anonymous]")[0] != undefined
|
||||
$("input[name=qb-anonymous]")[0].checked
|
||||
else
|
||||
true
|
||||
$("input[name=qb-anonymous]")[0].checked
|
||||
else
|
||||
true
|
||||
$.ajax
|
||||
url: '/ajax/ask' # TODO: find a way to use rake routes instead of hardcoding them here
|
||||
type: 'POST'
|
||||
|
@ -50,6 +50,30 @@ $(document).on "click", "button[name=qb-ask]", ->
|
|||
btn.button "reset"
|
||||
$("textarea[name=qb-question]").removeAttr "readonly"
|
||||
|
||||
$(document).on "click", "button[name=qb-all-ask]", ->
|
||||
btn = $(this)
|
||||
btn.button "loading"
|
||||
$("textarea[name=qb-all-question]").attr "readonly", "readonly"
|
||||
|
||||
$.ajax
|
||||
url: '/ajax/ask'
|
||||
type: 'POST'
|
||||
data:
|
||||
rcpt: "followers"
|
||||
question: $("textarea[name=qb-all-question]").val()
|
||||
anonymousQuestion: false
|
||||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("textarea[name=qb-all-question]").val ''
|
||||
$('#modal-ask-followers').modal('hide')
|
||||
showNotification data.message, data.success
|
||||
error: (jqxhr, status, error) ->
|
||||
console.log jqxhr, status, error
|
||||
showNotification "An error occurred, a developer should check the console for details", false
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
$("textarea[name=qb-question]").removeAttr "readonly"
|
||||
|
||||
$(document).on "keydown", "textarea[name=ib-answer]", (evt) ->
|
||||
iid = $(this)[0].dataset.id
|
||||
if evt.keyCode == 13 and evt.ctrlKey
|
||||
|
|
|
@ -12,7 +12,15 @@ class Ajax::QuestionController < ApplicationController
|
|||
current_user.increment! :asked_count unless params[:anonymousQuestion] == 'true'
|
||||
end
|
||||
|
||||
Inbox.create!(user_id: params[:rcpt], question_id: question.id, new: true)
|
||||
if params[:rcpt] == 'followers'
|
||||
unless current_user.nil?
|
||||
current_user.followers.each do |f|
|
||||
Inbox.create!(user_id: f.id, question_id: question.id, new: true)
|
||||
end
|
||||
end
|
||||
else
|
||||
Inbox.create!(user_id: params[:rcpt], question_id: question.id, new: true)
|
||||
end
|
||||
|
||||
@status = :okay
|
||||
@message = "Question asked successfully."
|
||||
|
|
|
@ -12,10 +12,10 @@ class Inbox < ActiveRecord::Base
|
|||
|
||||
def remove
|
||||
unless self.question.user.nil?
|
||||
self.question.user.decrement! :asked_count
|
||||
self.question.user.decrement! :asked_count if self.question.answers.count == 1
|
||||
end
|
||||
|
||||
self.question.destroy
|
||||
self.question.destroy if self.question.answers.count == 1
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Question < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
has_one :answer
|
||||
has_many :answers
|
||||
end
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
= nav_entry "Timeline", root_path
|
||||
%ul.nav.navbar-nav
|
||||
= nav_entry "Inbox", "/inbox", badge: inbox_count
|
||||
%ul.nav.navbar-right
|
||||
%button.btn.btn-primary.navbar-btn.btn-sm{"data-target" => "#modal-ask-followers", "data-toggle" => "modal", :type => "button"}
|
||||
%i.fa.fa-pencil-square-o.fa-spin
|
||||
%span.visible-xs Ask your followers
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}
|
||||
|
@ -27,3 +31,5 @@
|
|||
%ul.nav.navbar-nav.navbar-right
|
||||
= nav_entry "Sign in", new_user_session_path
|
||||
= nav_entry "Sign up", new_user_registration_path
|
||||
|
||||
= render 'shared/modal_ask_followers'
|
|
@ -39,13 +39,6 @@
|
|||
.col-md-6.col-sm-6.col-xs-6
|
||||
%h4.entry-text#answered-count= @user.answered_count
|
||||
%h6.entry-subtext Answers
|
||||
.row
|
||||
.col-md-6.col-sm-6.col-xs-6
|
||||
%h4.entry-text#asked-count= @user.commented_count
|
||||
%h6.entry-subtext Comments
|
||||
.col-md-6.col-sm-6.col-xs-6
|
||||
%h4.entry-text#answered-count= @user.smiled_count
|
||||
%h6.entry-subtext Smiles
|
||||
= render 'user/actions'
|
||||
.hidden-xs= render 'shared/links'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
|
|
Loading…
Reference in New Issue