mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-04-01 16:12:13 +02:00
Merge remote-tracking branch 'origin/inbox'
This commit is contained in:
commit
aa9bd028db
5 changed files with 78 additions and 13 deletions
app
assets
controllers/ajax
views/inbox
config
|
@ -14,12 +14,39 @@
|
||||||
complete: (jqxhr, status) ->
|
complete: (jqxhr, status) ->
|
||||||
btn.button "reset"
|
btn.button "reset"
|
||||||
|
|
||||||
|
|
||||||
|
($ document).on "click", "button#ib-delete-all", ->
|
||||||
|
if confirm 'Are you sure?'
|
||||||
|
btn = ($ this)
|
||||||
|
btn.button "loading"
|
||||||
|
succ = no
|
||||||
|
$.ajax
|
||||||
|
url: '/ajax/delete_all_inbox'
|
||||||
|
type: 'POST'
|
||||||
|
dataType: 'json'
|
||||||
|
success: (data, status, jqxhr) ->
|
||||||
|
if data.success
|
||||||
|
succ = yes
|
||||||
|
entries = ($ "div#entries")
|
||||||
|
entries.slideUp 400, ->
|
||||||
|
entries.html("Nothing to see here.")
|
||||||
|
entries.fadeIn()
|
||||||
|
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"
|
||||||
|
if succ
|
||||||
|
btn.attr "disabled", "disabled" # this doesn't really work like I wanted it to…
|
||||||
|
|
||||||
|
|
||||||
$(document).on "keydown", "textarea[name=ib-answer]", (evt) ->
|
$(document).on "keydown", "textarea[name=ib-answer]", (evt) ->
|
||||||
iid = $(this)[0].dataset.id
|
iid = $(this)[0].dataset.id
|
||||||
if evt.keyCode == 13 and evt.ctrlKey
|
if evt.keyCode == 13 and evt.ctrlKey
|
||||||
# trigger warning:
|
# trigger warning:
|
||||||
$("button[name=ib-answer][data-ib-id=#{iid}]").trigger 'click'
|
$("button[name=ib-answer][data-ib-id=#{iid}]").trigger 'click'
|
||||||
|
|
||||||
|
|
||||||
$(document).on "click", "button[name=ib-answer]", ->
|
$(document).on "click", "button[name=ib-answer]", ->
|
||||||
btn = $(this)
|
btn = $(this)
|
||||||
btn.button "loading"
|
btn.button "loading"
|
||||||
|
@ -48,6 +75,7 @@ $(document).on "click", "button[name=ib-answer]", ->
|
||||||
btn.button "reset"
|
btn.button "reset"
|
||||||
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
||||||
|
|
||||||
|
|
||||||
$(document).on "click", "button[name=ib-destroy]", ->
|
$(document).on "click", "button[name=ib-destroy]", ->
|
||||||
if confirm 'Are you sure?'
|
if confirm 'Are you sure?'
|
||||||
btn = $(this)
|
btn = $(this)
|
||||||
|
|
|
@ -45,3 +45,17 @@
|
||||||
.profile--panel .panel-body {
|
.profile--panel .panel-body {
|
||||||
padding-top: 0px;
|
padding-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inbox--panel .panel-heading {
|
||||||
|
color: $brand-info;
|
||||||
|
border-bottom: 2px solid $brand-info;
|
||||||
|
background-color: #fff;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning--panel .panel-heading {
|
||||||
|
color: $brand-danger;
|
||||||
|
border-bottom: 2px solid $brand-danger;
|
||||||
|
background-color: #fff;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
|
@ -85,4 +85,20 @@ class Ajax::InboxController < ApplicationController
|
||||||
@message = "Successfully deleted question."
|
@message = "Successfully deleted question."
|
||||||
@success = true
|
@success = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_all
|
||||||
|
begin
|
||||||
|
Inbox.where(user: current_user).each { |i| i.remove }
|
||||||
|
rescue
|
||||||
|
@status = :err
|
||||||
|
@message = "An error occurred"
|
||||||
|
@success = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@status = :okay
|
||||||
|
@message = "Successfully deleted questions."
|
||||||
|
@success = true
|
||||||
|
render 'ajax/inbox/remove'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
.container.j2-page
|
.container.j2-page
|
||||||
= render 'layouts/messages'
|
|
||||||
.alert.alert-info
|
|
||||||
.row
|
.row
|
||||||
.col-md-9.col-sm-8.col-xs-12
|
.col-md-3.col-xs-12.col-sm-3
|
||||||
Out of questions?
|
.panel.panel-default.inbox--panel
|
||||||
.col-md-3.col-sm-5.col-xs-12
|
.panel-heading
|
||||||
|
%h3.panel-title Out of questions?
|
||||||
|
.panel-body
|
||||||
%button.btn.btn-block.btn-info{type: :button, id: 'ib-generate-question'} Get new question
|
%button.btn.btn-block.btn-info{type: :button, id: 'ib-generate-question'} Get new question
|
||||||
|
.panel.panel-default.warning--panel
|
||||||
|
.panel-heading
|
||||||
|
%h3.panel-title Actions
|
||||||
|
.panel-body
|
||||||
|
%button.btn.btn-block.btn-danger{type: :button, id: 'ib-delete-all', disabled: (@inbox.empty? ? 'disabled' : nil)} Delete all questions
|
||||||
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
|
= render 'layouts/messages'
|
||||||
#entries
|
#entries
|
||||||
- @inbox.each do |i|
|
- @inbox.each do |i|
|
||||||
= render 'inbox/entry', i: i
|
= render 'inbox/entry', i: i
|
||||||
|
|
|
@ -46,6 +46,7 @@ Rails.application.routes.draw do
|
||||||
match '/answer', to: 'inbox#destroy', via: :post, as: :answer
|
match '/answer', to: 'inbox#destroy', via: :post, as: :answer
|
||||||
match '/generate_question', to: 'inbox#create', via: :post, as: :generate_question
|
match '/generate_question', to: 'inbox#create', via: :post, as: :generate_question
|
||||||
match '/delete_inbox', to: 'inbox#remove', via: :post, as: :delete_inbox
|
match '/delete_inbox', to: 'inbox#remove', via: :post, as: :delete_inbox
|
||||||
|
match '/delete_all_inbox', to: 'inbox#remove_all', via: :post, as: :delete_all_inbox
|
||||||
match '/destroy_answer', to: 'answer#destroy', via: :post, as: :destroy_answer
|
match '/destroy_answer', to: 'answer#destroy', via: :post, as: :destroy_answer
|
||||||
match '/create_friend', to: 'friend#create', via: :post, as: :create_friend
|
match '/create_friend', to: 'friend#create', via: :post, as: :create_friend
|
||||||
match '/destroy_friend', to: 'friend#destroy', via: :post, as: :destroy_friend
|
match '/destroy_friend', to: 'friend#destroy', via: :post, as: :destroy_friend
|
||||||
|
|
Loading…
Reference in a new issue