From 3131f945c47769e39d6bbfaf36cb64c0febf7559 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 20 Sep 2014 20:30:47 +0200 Subject: [PATCH] Added new sidebars. --- .../controllers/organization_zoom.js.coffee | 48 +++++++++-- .../app/controllers/user_zoom.js.coffee | 83 +++++++++++++++++-- .../app/views/organization_zoom.jst.eco | 19 ++--- .../javascripts/app/views/user_zoom.jst.eco | 21 +++-- 4 files changed, 136 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/app/controllers/organization_zoom.js.coffee b/app/assets/javascripts/app/controllers/organization_zoom.js.coffee index 6303dc42e..025bf41fa 100644 --- a/app/assets/javascripts/app/controllers/organization_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/organization_zoom.js.coffee @@ -1,4 +1,7 @@ class App.OrganizationZoom extends App.Controller + elements: + '.tabsSidebar' : 'sidebar' + constructor: (params) -> super @@ -67,10 +70,9 @@ class App.OrganizationZoom extends App.Controller ui: @ ) - new Widgets( - el: @el.find('.widgets') + new Sidebar( + el: @sidebar organization: organization - ui: @ ) class Overviews extends App.Controller @@ -122,16 +124,48 @@ class Overviews extends App.Controller @el.find( '#sortable-sidebar' ).sortable( dndOptions ) -class Widgets extends App.Controller +class Sidebar extends App.Controller constructor: -> super + + # render ui @render() render: -> - new App.WidgetOrganization( - el: @el - organization_id: @organization.id + items = [] + + editOrganization = (e, el) => + new App.ControllerGenericEdit( + id: @organization.id + genericObject: 'Organization' + pageData: + title: 'Organizations' + object: 'Organization' + objects: 'Organizations' + ) + showOrganization = (el) => + new App.WidgetOrganization( + el: el + organization_id: @organization.id + ) + items.push { + head: 'Organization' + name: 'organization' + icon: 'group' + actions: [ + { + name: 'Edit Organization' + class: 'glyphicon glyphicon-edit' + callback: editOrganization + }, + ] + callback: showOrganization + } + + new App.Sidebar( + el: @el + items: items ) class ActionRow extends App.Controller diff --git a/app/assets/javascripts/app/controllers/user_zoom.js.coffee b/app/assets/javascripts/app/controllers/user_zoom.js.coffee index 5bb26fcdc..cbb133974 100644 --- a/app/assets/javascripts/app/controllers/user_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/user_zoom.js.coffee @@ -1,11 +1,13 @@ class App.UserZoom extends App.Controller + elements: + '.tabsSidebar' : 'sidebar' + constructor: (params) -> super # check authentication return if !@authenticate() - @navupdate '#' App.User.full( @user_id, @render ) @@ -67,10 +69,10 @@ class App.UserZoom extends App.Controller ui: @ ) - new Widgets( - el: @el.find('.widgets') - user: user - ui: @ + new Sidebar( + el: @sidebar + user: user + textModule: @textModule ) class Overviews extends App.Controller @@ -141,16 +143,79 @@ class Overviews extends App.Controller @el.find( '#sortable' ).sortable( dndOptions ) @el.find( '#sortable-sidebar' ).sortable( dndOptions ) -class Widgets extends App.Controller +class Sidebar extends App.Controller constructor: -> super + + # render ui @render() render: -> - new App.WidgetUser( - el: @el - user_id: @user.id + items = [] + + showCustomer = (el) => + new App.WidgetUser( + el: el + user_id: @user.id + ) + + editCustomer = (e, el) => + new App.ControllerGenericEdit( + id: @user.id + genericObject: 'User' + screen: 'edit' + pageData: + title: 'Users' + object: 'User' + objects: 'Users' + ) + items.push { + head: 'Customer' + name: 'customer' + icon: 'person' + actions: [ + { + name: 'Edit Customer' + class: 'glyphicon glyphicon-edit' + callback: editCustomer + }, + ] + callback: showCustomer + } + + if @user.organization_id + editOrganization = (e, el) => + new App.ControllerGenericEdit( + id: @user.organization_id + genericObject: 'Organization' + pageData: + title: 'Organizations' + object: 'Organization' + objects: 'Organizations' + ) + showOrganization = (el) => + new App.WidgetOrganization( + el: el + organization_id: @user.organization_id + ) + items.push { + head: 'Organization' + name: 'organization' + icon: 'group' + actions: [ + { + name: 'Edit Organization' + class: 'glyphicon glyphicon-edit' + callback: editOrganization + }, + ] + callback: showOrganization + } + + new App.Sidebar( + el: @el + items: items ) class ActionRow extends App.Controller diff --git a/app/assets/javascripts/app/views/organization_zoom.jst.eco b/app/assets/javascripts/app/views/organization_zoom.jst.eco index c58b66d87..780dbaab6 100644 --- a/app/assets/javascripts/app/views/organization_zoom.jst.eco +++ b/app/assets/javascripts/app/views/organization_zoom.jst.eco @@ -1,13 +1,12 @@ - -
+
+
+ + +
- +
-
- -
\ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/user_zoom.jst.eco b/app/assets/javascripts/app/views/user_zoom.jst.eco index c58b66d87..f9903a4cb 100644 --- a/app/assets/javascripts/app/views/user_zoom.jst.eco +++ b/app/assets/javascripts/app/views/user_zoom.jst.eco @@ -1,13 +1,16 @@ - -
+
+
+ + +
- +
-
+
-
\ No newline at end of file + \ No newline at end of file