Trigger getting started with backbone

This commit is contained in:
Benjamin Neff 2016-09-19 00:12:38 +02:00 committed by Steffen van Bergerem
parent 14304f3620
commit b8c76a3317
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
9 changed files with 13 additions and 19 deletions

View file

@ -18,7 +18,6 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
// initiate all the popover message boxes // initiate all the popover message boxes
show: function() { show: function() {
app.publisher.open();
this._addPopover(this.firstMessage, { this._addPopover(this.firstMessage, {
trigger: "manual", trigger: "manual",
id: "first_message_explain", id: "first_message_explain",

View file

@ -91,6 +91,7 @@ app.views.Publisher = Backbone.View.extend({
this.initSubviews(); this.initSubviews();
this.checkSubmitAvailability(); this.checkSubmitAvailability();
this.triggerGettingStarted();
return this; return this;
}, },
@ -184,7 +185,10 @@ app.views.Publisher = Backbone.View.extend({
// show the "getting started" popups around the publisher // show the "getting started" popups around the publisher
triggerGettingStarted: function() { triggerGettingStarted: function() {
this.viewGettingStarted.show(); if (gon.preloads.getting_started) {
this.open();
this.viewGettingStarted.show();
}
}, },
createStatusMessage : function(evt) { createStatusMessage : function(evt) {

View file

@ -28,7 +28,8 @@ class StreamsController < ApplicationController
end end
def multi def multi
stream_responder(Stream::Multi) gon.preloads[:getting_started] = current_user.getting_started
stream_responder(Stream::Multi)
end end
def commented def commented

View file

@ -50,8 +50,4 @@ module InterimStreamHackinessHelper
def publisher_public def publisher_public
publisher_method(:public) publisher_method(:public)
end end
def publisher_explain
publisher_method(:explain)
end
end end

View file

@ -1,9 +1,3 @@
-if publisher_explain
:javascript
$(document).ready(function() {
if( app.publisher ) app.publisher.triggerGettingStarted();
});
.row.publisher#publisher{class: ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")} .row.publisher#publisher{class: ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")}
.content_creation .content_creation
= form_for(StatusMessage.new) do |status| = form_for(StatusMessage.new) do |status|

View file

@ -1,12 +1,11 @@
class Publisher class Publisher
attr_accessor :user, :open, :prefill, :public, :explain attr_accessor :user, :open, :prefill, :public
def initialize(user, opts={}) def initialize(user, opts={})
self.user = user self.user = user
self.open = opts[:open] self.open = opts[:open]
self.prefill = opts[:prefill] self.prefill = opts[:prefill]
self.public = opts[:public] self.public = opts[:public]
self.explain = opts[:explain]
end end
def text def text

View file

@ -23,9 +23,10 @@ class Stream::Multi < Stream::Base
end end
private private
def publisher_opts def publisher_opts
if welcome? if welcome?
{open: true, prefill: publisher_prefill, public: true, explain: true} {open: true, prefill: publisher_prefill, public: true}
else else
super super
end end

View file

@ -23,7 +23,7 @@ describe Publisher do
end end
end end
["open", "public", "explain"].each do |property| %w(open public).each do |property|
describe "##{property}" do describe "##{property}" do
it 'defaults to closed' do it 'defaults to closed' do
expect(@publisher.send("#{property}".to_sym)).to be_falsey expect(@publisher.send("#{property}".to_sym)).to be_falsey

View file

@ -26,7 +26,7 @@ describe Stream::Multi do
prefill_text = "sup?" prefill_text = "sup?"
allow(@stream).to receive(:welcome?).and_return(true) allow(@stream).to receive(:welcome?).and_return(true)
allow(@stream).to receive(:publisher_prefill).and_return(prefill_text) allow(@stream).to receive(:publisher_prefill).and_return(prefill_text)
expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true, explain: true) expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true)
end end
it 'provides no opts if welcome? is not set' do it 'provides no opts if welcome? is not set' do