Added App.ControllerTabs feature.

This commit is contained in:
Martin Edenhofer 2012-04-12 00:21:58 +02:00
parent b99fd95120
commit e053a92425
10 changed files with 145 additions and 99 deletions

View file

@ -188,8 +188,6 @@ class App.ControllerLevel2 extends App.Controller
constructor: -> constructor: ->
super super
return if !@authenticate()
render: -> render: ->
@log 'ttt', @target, @ @log 'ttt', @target, @
# set title # set title
@ -228,3 +226,21 @@ class App.ControllerLevel2 extends App.Controller
@el.find('#' + target).removeClass('hide') @el.find('#' + target).removeClass('hide')
# window.scrollTo(0,0) # window.scrollTo(0,0)
class App.ControllerTabs extends App.Controller
constructor: ->
super
render: ->
@html App.view('generic/tabs')(
tabs: @tabs,
)
@el.find('.nav-tabs li:first').addClass('active')
for tab in @tabs
@el.find('.tab-content').append('<div class="tab-pane" id="' + tab.target + '">' + tab.target + '</div>')
if tab.controller
params = tab.params || {}
params.el = @el.find( '#' + tab.target )
new tab.controller( params )
@el.find('.tab-content .tab-pane:first').addClass('active')

View file

@ -1,18 +1,15 @@
$ = jQuery.sub() $ = jQuery.sub()
class App.ChannelChat extends App.Controller class App.ChannelChat extends App.ControllerTabs
events:
'click [data-toggle="tabnav"]': 'toggle',
constructor: -> constructor: ->
super super
# render page @tabs = [
{
name: 'Settings',
target: 'setting',
controller: App.SettingsArea, params: { area: 'Chat::Base' },
},
]
@render() @render()
render: ->
@html App.view('channel/chat')(
head: 'some header'
)

View file

@ -1,6 +1,99 @@
$ = jQuery.sub() $ = jQuery.sub()
class App.ChannelEmail extends App.Controller class App.ChannelEmail extends App.ControllerTabs
constructor: ->
super
@tabs = [
{
name: 'Inbound',
target: 'c-inbound',
},
{
name: 'Outbound',
target: 'c-outbound',
},
{
name: 'Adresses',
target: 'c-address',
},
{
name: 'Filter',
target: 'c-filter',
},
{
name: 'Settings',
target: 'c-setting',
controller: App.SettingsArea, params: { area: 'Email::Base' },
},
]
# App.Channel.bind 'refresh change', @render
# App.Channel.fetch()
@render()
render2: =>
settings = App.Setting.all()
html = $('<div></div>')
for setting in settings
if setting.area is @area
item = new App.SettingsAreaItem( setting: setting )
html.append( item.el )
@html html
class App.SettingsAreaItem2 extends App.Controller
events:
'submit form': 'update',
constructor: ->
super
@render()
render: =>
# defaults
for item in @setting.options['form']
if typeof @setting.state.value is 'object'
item['default'] = @setting.state.value[item.name]
else
item['default'] = @setting.state.value
# form
@configure_attributes = @setting.options['form']
form = @formGen( model: { configure_attributes: @configure_attributes, className: '' }, autofocus: false )
# item
@html App.view('settings/item')(
setting: @setting,
form: form,
)
update: (e) =>
e.preventDefault()
params = @formParam(e.target)
@log 'submit', @setting, params, e.target
if typeof @setting.state.value is 'object'
state = {
value: params
}
else
state = {
value: params[@setting.name]
}
@setting['state'] = state
@setting.save(
success: =>
# login check
auth = new App.Auth
auth.loginCheck()
)
class App.ChannelEmail2 extends App.Controller
events: events:
'click [data-toggle="tabnav"]': 'toggle', 'click [data-toggle="tabnav"]': 'toggle',

View file

@ -1,18 +1,15 @@
$ = jQuery.sub() $ = jQuery.sub()
class App.ChannelWeb extends App.Controller class App.ChannelWeb extends App.ControllerTabs
events:
'click [data-toggle="tabnav"]': 'toggle',
constructor: -> constructor: ->
super super
# render page @tabs = [
{
name: 'Settings',
target: 'w-setting',
controller: App.SettingsArea, params: { area: 'CustomerWeb::Base' },
},
]
@render() @render()
render: ->
@html App.view('channel/web')(
head: 'some header'
)

View file

@ -19,6 +19,8 @@ class Index extends App.ControllerLevel2
constructor: -> constructor: ->
super super
return if !@authenticate()
# render page # render page
@render() @render()

View file

@ -7,6 +7,8 @@ class Index extends App.ControllerLevel2
constructor: -> constructor: ->
super super
return if !@authenticate()
# system # system
if @type is 'system' if @type is 'system'
@menu = [ @menu = [

View file

@ -1,13 +0,0 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#" data-toggle="tab">Settings</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="1">
<h2>Enable Chat</h2>
<p>lala alals alals ala.</p>
<hr/>
<h2>Default Greetings</h2>
<p>lala alals alals ala.</p>
<hr/>
</div>
</div>

View file

@ -1,10 +1,3 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#channel-inbound" data-toggle="tab">Inbound</a></li>
<li><a href="#channel-outbound" data-toggle="tab">Outbound</a></li>
<li><a href="#channel-filter" data-toggle="tab">Filter</a></li>
<li><a href="#channel-settings" data-toggle="tab">Settings</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="channel-inbound"> <div class="tab-pane active" id="channel-inbound">
<table class="table table-striped"> <table class="table table-striped">
@ -31,8 +24,9 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="tab-pane" id="channel-outbound"> <div class="tab-pane" id="channel-outbound">
<table class="table table-striped"> <table class="table table-striped">
<tr> <tr>
<th>Host</th> <th>Host</th>
@ -76,29 +70,3 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="tab-pane" id="channel-settings">
<h2>Max. Email Size</h2>
<p>lala alals alals ala.</p>
<hr/>
<h2>PostmasterFollowUpSearchIn</h2>
<p>o References - Executes follow up checks on In-Reply-To or References headers for mails that don't have a ticket number in the subject.</p>
<p>o Body - Executes follow up mail body checks in mails that don't have a ticket number in the subject.</p>
<p>o Attachment - Executes follow up mail attachments checks in mails that don't have a ticket number in the subject.</p>
<p>o Raw - Executes follow up plain/raw mail checks in mails that don't have a ticket number in the subject.</p>
<hr/>
<h2>FollowUpState</h2>
<p>Defines the state of a ticket if it gets a follow-up.</p>
<hr/>
<h2>Blocks Emails</h2>
<p>Blocks all the incoming emails that do not have a valid ticket number in subject with From: @example.com address.</p>
<h2>Subject</h2>
<p>Defines the subject for rejected emails.</p>
<h2>Body</h2>
<p>Defines the body for rejected emails.</p>
<hr/>
<h2>SendNoAutoResponseRegExp</h2>
<p>If this regex matches, no message will be send by the autoresponder.</p>
<p>(MAILER-DAEMON|postmaster|abuse)@.+?\..+?</p>
<hr/>
</div>
</div>

View file

@ -1,22 +0,0 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#" data-toggle="tab">Settings</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="1">
<h2>Enable Ticket creation</h2>
<p>lala alals alals ala.</p>
<h3>Allowed attributes to set and default values</h3>
<p>lala alals alals ala.</p>
<hr/>
<h2>Enable view and update of Tickets</h2>
<p>lala alals alals ala.</p>
<h3>Allowed attributes to see</h3>
<p>lala alals alals ala.</p>
<h3>Allowed attributes to update</h3>
<p>lala alals alals ala.</p>
<hr/>
<h2>Enable view and update of Tickets</h2>
<p>lala alals alals ala.</p>
<hr/>
</div>
</div>

View file

@ -0,0 +1,6 @@
<ul class="nav nav-tabs">
<% for tab in @tabs: %>
<li><a href="#<%= tab.target %>" data-toggle="tab"><%= tab.name %></a></li>
<% end %>
</ul>
<div class="tab-content"></div>