Init version of first steps. Improved clues (disable navbar highlighting until clues are gone).

This commit is contained in:
Martin Edenhofer 2016-02-11 02:57:27 +01:00
parent 100cca46d0
commit 78226efcbc
8 changed files with 259 additions and 78 deletions

View file

@ -111,7 +111,11 @@ class App.Controller extends Spine.Controller
App.Event.trigger 'notifyDesktop', data
# add @navupdate methode to update navigation
navupdate: (url) ->
navupdate: (url, force = false) ->
# ignore navupdate untill #clues are gone
return if !force && window.location.hash is '#clues'
App.Event.trigger 'navupdate', url
# show navigation

View file

@ -0,0 +1,33 @@
class App.DashboardFirstSteps extends App.Controller
events:
'click a': 'scrollIntoView'
constructor: ->
super
@load()
load: =>
@ajax(
id: 'first_steps'
type: 'GET'
url: @apiPath + '/first_steps'
success: (data) =>
@render(data)
)
render: (data) ->
@html App.view('dashboard/first_steps')(
data: data
)
scrollIntoView: (e) ->
href = $(e.currentTarget).attr('href')
return if !href
return if href is '#'
delay = ->
element = $("[href='#{href}']").get(0)
return if !element
element.scrollIntoView()
@delay(delay, 20)

View file

@ -0,0 +1,21 @@
class Index extends App.Controller
constructor: ->
super
@navupdate '#', true
@clues()
clues: =>
new App.FirstStepsClues(
el: @el
onComplete: =>
@ajax(
id: 'preferences'
type: 'PUT'
url: @apiPath + '/users/preferences'
data: JSON.stringify({user:{intro:true}})
processData: true
)
@navigate '#'
)
App.Config.set( 'clues', Index, 'Routes' )

View file

@ -23,23 +23,30 @@ class App.Dashboard extends App.Controller
render: ->
@html App.view('dashboard')(
localEl = $( App.view('dashboard')(
head: 'Dashboard'
isAdmin: @isRole('Admin')
)
) )
new App.DashboardStats(
el: @$('.stat-widgets')
el: localEl.find('.stat-widgets')
)
new App.DashboardActivityStream(
el: @$('.sidebar')
el: localEl.find('.sidebar')
limit: 25
)
new App.DashboardFirstSteps(
el: localEl.find('.first-steps-widgets')
)
@html localEl
mayBeClues: =>
return if !@clueAccess
return if !@activeState
return if @Config.get('switch_back_to_possible')
preferences = @Session.get('preferences')
@clueAccess = false
return if preferences['intro']
@ -49,17 +56,7 @@ class App.Dashboard extends App.Controller
@clueAccess = false
if e
e.preventDefault()
new App.FirstStepsClues(
el: @el
onComplete: =>
@ajax(
id: 'preferences'
type: 'PUT'
url: @apiPath + '/users/preferences'
data: JSON.stringify({user:{intro:true}})
processData: true
)
)
@navigate '#clues'
active: (state) =>
@activeState = state

View file

@ -3,69 +3,8 @@
<div class="tab active" data-area="stat-widgets"><%- @T('My Stats') %></div>
<div class="tab" data-area="first-steps-widgets"><%- @T('First Steps') %></div>
</div>
<div class="tab-content first-steps-widgets hidden">
<div class="box box--paper">
<% if @isAdmin: %>
<h3><%- @T('Configuration') %></h3>
<a class="todo is-done">
<%- @Icon('checkmark') %>
<%- @T('Branding') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Your Email Configuration') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Invite Agents/Colleges') %>
</a>
<% end %>
<h3><%- @T('How to use it') %></h3>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Intro') %></a>
</a>
<a class="todo is-done">
<%- @Icon('checkmark') %>
<%- @T('Create a Test Ticket') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Create new Overviews') %>
</a>
<a class="todo is-done">
<%- @Icon('checkmark') %>
<%- @T('Create Text Modues') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Create Macros') %>
</a>
<% if @isAdmin: %>
<h3><%- @T('Additionals Channels') %></h3>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Twitter') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Facebook') %>
</a>
<a class="todo is-done">
<%- @Icon('checkmark') %>
<%- @T('Chat') %>
</a>
<a class="todo">
<%- @Icon('small-dot') %>
<%- @T('Widget') %>
</a>
<% end %>
</div>
</div>
<div class="tab-content first-steps-widgets hidden"></div>
<div class="tab-content stat-widgets three-columns horizontal"></div>
</div>
<div class="sidebar optional">
<h2><%- @T('Activity Stream') %></h2>

View file

@ -0,0 +1,15 @@
<div class="box box--paper">
<% for area in @data: %>
<h3><%- @T(area.name) %></h3>
<% for item in area.items: %>
<a class="todo <% if item.checked: %>is-done<% end %>" href="<%- item.location %>">
<% if item.checked: %>
<%- @Icon('checkmark') %>
<% else: %>
<%- @Icon('small-dot') %>
<% end %>
<%- @T(item.name) %>
</a>
<% end %>
<% end %>
</div>

View file

@ -0,0 +1,166 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class FirstStepsController < ApplicationController
before_action :authentication_check
def index
result = []
if !current_user.role?(%w(Agent Admin))
render json: result
return
end
invite_agents = false
#if User.of_role('Agent').count > 2
# invite_agents = true
#end
invite_customers = false
#if User.of_role('Customer').count > 2
# invite_customers = true
#end
chat_active = false
if Setting.get('chat')
chat_active = true
end
from_active = false
if Setting.get('form_ticket_create')
from_active = true
end
twitter_active = false
if Channel.where(area: 'Twitter::Account').count > 0
twitter_active = true
end
facebook_active = false
if Channel.where(area: 'Facebook::Account').count > 0
facebook_active = true
end
email_active = false
if Channel.where(area: 'Email::Account').count > 0
email_active = true
end
text_module_active = false
if TextModule.count > 0
text_module_active = true
end
macro_active = false
if Macro.count > 1
macro_active = true
end
if current_user.role?('Admin')
result = [
{
name: 'Configuration',
items: [
{
name: 'Branding',
checked: true,
location: '#settings/branding',
},
{
name: 'Your Email Configuration',
checked: email_active,
location: '#channels/email',
},
{
name: 'Invite Agents/Colleges to help working on Tickets',
checked: invite_agents,
location: '#invite_agent',
},
{
name: 'Invite Customers to create issues in Zammad',
checked: invite_customers,
location: '#invite_customer',
},
],
},
{
name: 'How to use it',
items: [
{
name: 'Intro',
checked: true,
location: '#clues',
},
{
name: 'Create a Test Ticket',
checked: false,
location: '#create_test_ticket',
},
{
name: 'Create Overviews',
checked: false,
location: '#manage/overviews',
},
{
name: 'Create Text Modues',
checked: text_module_active,
location: '#manage/text_modules',
},
{
name: 'Create Macros',
checked: macro_active,
location: '#manage/macros',
},
],
},
{
name: 'Additionals Channels',
items: [
{
name: 'Twitter',
checked: twitter_active,
location: '#channels/twitter',
},
{
name: 'Facebook',
checked: facebook_active,
location: '#channels/facebook',
},
{
name: 'Chat',
checked: chat_active,
location: '#channels/chat',
},
{
name: 'Online Forms',
checked: from_active,
location: '#channels/form',
},
],
},
]
render json: result
return
end
result = [
{
name: 'How to use it',
items: [
{
name: 'Intro',
checked: true,
location: '#clues',
},
{
name: 'Create a Test Ticket',
checked: false,
location: '#create_test_ticket',
},
{
name: 'Invite Customers to create issues in Zammad',
checked: invite_customers,
location: '#invite_customer',
},
],
},
]
render json: result
end
end

View file

@ -0,0 +1,6 @@
Zammad::Application.routes.draw do
api_path = Rails.configuration.api_path
match api_path + '/first_steps', to: 'first_steps#index', via: :get
end