From e053a92425c0630f7e6a10782f1bf3b7281abc68 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 12 Apr 2012 00:21:58 +0200 Subject: [PATCH] Added App.ControllerTabs feature. --- .../_application_controller_generic.js.coffee | 22 ++++- .../app/controllers/_channel/chat.js.coffee | 21 ++-- .../app/controllers/_channel/email.js.coffee | 95 ++++++++++++++++++- .../app/controllers/_channel/web.js.coffee | 21 ++-- .../app/controllers/channel.js.coffee | 2 + .../app/controllers/settings.js.coffee | 2 + .../app/views/channel/chat.jst.eco | 13 --- .../app/views/channel/email.jst.eco | 40 +------- .../javascripts/app/views/channel/web.jst.eco | 22 ----- .../app/views/generic/tabs.jst.eco | 6 ++ 10 files changed, 145 insertions(+), 99 deletions(-) delete mode 100644 app/assets/javascripts/app/views/channel/chat.jst.eco delete mode 100644 app/assets/javascripts/app/views/channel/web.jst.eco create mode 100644 app/assets/javascripts/app/views/generic/tabs.jst.eco diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index ac2467f6c..0df43ad27 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -188,8 +188,6 @@ class App.ControllerLevel2 extends App.Controller constructor: -> super - return if !@authenticate() - render: -> @log 'ttt', @target, @ # set title @@ -227,4 +225,22 @@ class App.ControllerLevel2 extends App.Controller @el.find('.tabbable').addClass('hide') @el.find('#' + target).removeClass('hide') # window.scrollTo(0,0) - \ No newline at end of file + +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('
' + tab.target + '
') + 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') diff --git a/app/assets/javascripts/app/controllers/_channel/chat.js.coffee b/app/assets/javascripts/app/controllers/_channel/chat.js.coffee index b3448039b..2bc008515 100644 --- a/app/assets/javascripts/app/controllers/_channel/chat.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/chat.js.coffee @@ -1,18 +1,15 @@ $ = jQuery.sub() -class App.ChannelChat extends App.Controller - events: - 'click [data-toggle="tabnav"]': 'toggle', - +class App.ChannelChat extends App.ControllerTabs constructor: -> super - # render page - @render() + @tabs = [ + { + name: 'Settings', + target: 'setting', + controller: App.SettingsArea, params: { area: 'Chat::Base' }, + }, + ] - render: -> - - @html App.view('channel/chat')( - head: 'some header' - ) - + @render() diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index 733d2df4d..ccef65c00 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -1,6 +1,99 @@ $ = 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 = $('
') + 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: 'click [data-toggle="tabnav"]': 'toggle', diff --git a/app/assets/javascripts/app/controllers/_channel/web.js.coffee b/app/assets/javascripts/app/controllers/_channel/web.js.coffee index 7688ecbfb..fcbd2b5cc 100644 --- a/app/assets/javascripts/app/controllers/_channel/web.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/web.js.coffee @@ -1,18 +1,15 @@ $ = jQuery.sub() -class App.ChannelWeb extends App.Controller - events: - 'click [data-toggle="tabnav"]': 'toggle', - +class App.ChannelWeb extends App.ControllerTabs constructor: -> super - # render page - @render() + @tabs = [ + { + name: 'Settings', + target: 'w-setting', + controller: App.SettingsArea, params: { area: 'CustomerWeb::Base' }, + }, + ] - render: -> - - @html App.view('channel/web')( - head: 'some header' - ) - + @render() diff --git a/app/assets/javascripts/app/controllers/channel.js.coffee b/app/assets/javascripts/app/controllers/channel.js.coffee index f773e90a1..f3bc38d35 100644 --- a/app/assets/javascripts/app/controllers/channel.js.coffee +++ b/app/assets/javascripts/app/controllers/channel.js.coffee @@ -19,6 +19,8 @@ class Index extends App.ControllerLevel2 constructor: -> super + return if !@authenticate() + # render page @render() diff --git a/app/assets/javascripts/app/controllers/settings.js.coffee b/app/assets/javascripts/app/controllers/settings.js.coffee index 8e32f73ec..29da305ff 100644 --- a/app/assets/javascripts/app/controllers/settings.js.coffee +++ b/app/assets/javascripts/app/controllers/settings.js.coffee @@ -7,6 +7,8 @@ class Index extends App.ControllerLevel2 constructor: -> super + return if !@authenticate() + # system if @type is 'system' @menu = [ diff --git a/app/assets/javascripts/app/views/channel/chat.jst.eco b/app/assets/javascripts/app/views/channel/chat.jst.eco deleted file mode 100644 index 847e9bdab..000000000 --- a/app/assets/javascripts/app/views/channel/chat.jst.eco +++ /dev/null @@ -1,13 +0,0 @@ - -
-
-

Enable Chat

-

lala alals alals ala.

-
-

Default Greetings

-

lala alals alals ala.

-
-
-
diff --git a/app/assets/javascripts/app/views/channel/email.jst.eco b/app/assets/javascripts/app/views/channel/email.jst.eco index b060f2760..93f76beac 100644 --- a/app/assets/javascripts/app/views/channel/email.jst.eco +++ b/app/assets/javascripts/app/views/channel/email.jst.eco @@ -1,11 +1,4 @@ - -
-
+
@@ -31,8 +24,9 @@
-
-
+
+
+ @@ -76,29 +70,3 @@
Host
-
-

Max. Email Size

-

lala alals alals ala.

-
-

PostmasterFollowUpSearchIn

-

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.

-

o Body - Executes follow up mail body checks in mails that don't have a ticket number in the subject.

-

o Attachment - Executes follow up mail attachments checks in mails that don't have a ticket number in the subject.

-

o Raw - Executes follow up plain/raw mail checks in mails that don't have a ticket number in the subject.

-
-

FollowUpState

-

Defines the state of a ticket if it gets a follow-up.

-
-

Blocks Emails

-

Blocks all the incoming emails that do not have a valid ticket number in subject with From: @example.com address.

-

Subject

-

Defines the subject for rejected emails.

-

Body

-

Defines the body for rejected emails.

-
-

SendNoAutoResponseRegExp

-

If this regex matches, no message will be send by the autoresponder.

-

(MAILER-DAEMON|postmaster|abuse)@.+?\..+?

-
-
-
diff --git a/app/assets/javascripts/app/views/channel/web.jst.eco b/app/assets/javascripts/app/views/channel/web.jst.eco deleted file mode 100644 index 70ff9a64e..000000000 --- a/app/assets/javascripts/app/views/channel/web.jst.eco +++ /dev/null @@ -1,22 +0,0 @@ - -
-
-

Enable Ticket creation

-

lala alals alals ala.

-

Allowed attributes to set and default values

-

lala alals alals ala.

-
-

Enable view and update of Tickets

-

lala alals alals ala.

-

Allowed attributes to see

-

lala alals alals ala.

-

Allowed attributes to update

-

lala alals alals ala.

-
-

Enable view and update of Tickets

-

lala alals alals ala.

-
-
-
diff --git a/app/assets/javascripts/app/views/generic/tabs.jst.eco b/app/assets/javascripts/app/views/generic/tabs.jst.eco new file mode 100644 index 000000000..970945501 --- /dev/null +++ b/app/assets/javascripts/app/views/generic/tabs.jst.eco @@ -0,0 +1,6 @@ + +
\ No newline at end of file