Browse Source

Moved to new sidebar, added drox widget and fixed autosize of tags.

Martin Edenhofer 11 years ago
parent
commit
283a3675d4

+ 1 - 1
app/assets/javascripts/app/controllers/_application_controller.js.coffee

@@ -244,7 +244,7 @@ class App.Controller extends Spine.Controller
     el.unbind()
 
     # start customer info controller
-    new App.UserInfo(
+    new App.UserWidget(
       el:       el
       user_id:  data.user_id
       callback: data.callback

+ 3 - 3
app/assets/javascripts/app/controllers/_application_controller_form.js.coffee

@@ -383,7 +383,8 @@ class App.ControllerForm extends App.Controller
           container = document.getElementById( attribute.id + "_tagsinput" )
           if reorder
             $('#' + attribute.id + "_tagsinput" ).height( 20 )
-          height = container.scrollHeight
+          height = container.scrollHeight || 45
+          console.log('siteUpdate', height)
           $('#' + attribute.id + "_tagsinput" ).height( height - 16 )
 
         onAddTag = =>
@@ -393,10 +394,9 @@ class App.ControllerForm extends App.Controller
           siteUpdate(true)
 
         $('#' + attribute.id + '_tagsinput').remove()
-        w = $('#' + attribute.id).width()
         h = $('#' + attribute.id).height()
         $('#' + attribute.id).tagsInput(
-          width: w + 'px'
+          width: '100%'
 #          height: (h + 30 )+ 'px'
           onAddTag:    onAddTag
           onRemoveTag: onRemoveTag

+ 10 - 0
app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee

@@ -199,6 +199,16 @@ class DestroyConfirm extends App.ControllerModal
     @modalHide()
     @item.destroy()
 
+class App.ControllerDrox extends App.Controller
+  constructor: ->
+    super
+
+  template: (data) ->
+    drox = $( App.view('generic/drox')(data) )
+    content = App.view(data.file)(data.params)
+    drox.find('.drox-body').append(content)
+    drox
+
 class App.ControllerLevel2 extends App.ControllerContent
   events:
     'click [data-toggle="tabnav"]': 'toggle',

+ 14 - 10
app/assets/javascripts/app/controllers/link_info_widget.js.coffee

@@ -1,4 +1,4 @@
-class App.LinkInfo extends App.Controller
+class App.LinkInfo extends App.ControllerDrox
   events:
     'click [data-type=add]': 'add',
     'click [data-type=edit]': 'edit',
@@ -8,7 +8,7 @@ class App.LinkInfo extends App.Controller
     super
     @fetch()
 
-  fetch: () =>
+  fetch: =>
     # fetch item on demand
     # get data
     @ajax(
@@ -29,7 +29,7 @@ class App.LinkInfo extends App.Controller
         @render()
     )
 
-  render: () =>
+  render: =>
 
     list = {}
     for item in @links
@@ -43,8 +43,12 @@ class App.LinkInfo extends App.Controller
         list[ item['link_type'] ].push ticket
 
     # insert data
-    @html App.view('link/info')(
-      links: list,
+    @html @template(
+      file:   'link/info'
+      header: 'Links'
+      edit:   true
+      params:
+        links: list
     )
 
     # show edit mode once enabled
@@ -61,12 +65,12 @@ class App.LinkInfo extends App.Controller
   edit: (e) =>
     e.preventDefault()
     @edit_mode = true
-    if $(e.target).parent().parent().find('[data-type=add]').hasClass('hide')
-      $(e.target).parent().parent().find('[data-type=remove]').removeClass('hide')
-      $(e.target).parent().parent().find('[data-type=add]').removeClass('hide')
+    if $(e.target).parents().find('[data-type=add]').hasClass('hide')
+      $(e.target).parents().find('[data-type=remove]').removeClass('hide')
+      $(e.target).parents().find('[data-type=add]').removeClass('hide')
     else
-      $(e.target).parent().parent().find('[data-type=remove]').addClass('hide')
-      $(e.target).parent().parent().find('[data-type=add]').addClass('hide')
+      $(e.target).parents().find('[data-type=remove]').addClass('hide')
+      $(e.target).parents().find('[data-type=add]').addClass('hide')
 
   remove: (e) =>
     e.preventDefault()

+ 78 - 0
app/assets/javascripts/app/controllers/organization_widget.js.coffee

@@ -0,0 +1,78 @@
+class App.OrganizationWidget extends App.Controller
+  events:
+    'focusout [data-type=update-org]':  'update',
+    'click [data-type=edit-org]':       'edit'
+
+  constructor: ->
+    super
+
+    # show organization
+    callback = (organization) =>
+      @render(organization)
+      if @callback
+        @callback(organization)
+
+      # subscribe and reload data / fetch new data if triggered
+      @subscribeId = organization.subscribe(@render)
+
+    App.Organization.retrieve( @organization_id, callback )
+
+  release: =>
+    App.Organization.unsubscribe(@subscribeId)
+
+  render: (organization) =>
+    if !organization
+      organization = @u
+
+    # get display data
+    organizationData = []
+    for item2 in App.Organization.configure_attributes
+      item = _.clone( item2 )
+
+      # check if value for _id exists
+      itemNameValue = item.name
+      itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
+      if itemNameValueNew of organization
+        item.name = itemNameValueNew
+
+      # add to show if value exists
+      if organization[item.name] || item.tag is 'textarea'
+
+        # do not show name / already show via diplayName()
+        if item.name isnt 'name'
+          if item.info
+            organizationData.push item
+
+    # insert userData
+    @html App.view('organization_widget')(
+      organization:     organization
+      organizationData: organizationData
+    )
+
+    ###
+    @userTicketPopups(
+      selector: '.user-tickets'
+      user_id:  user.id
+      position: 'right'
+    )
+    ###
+
+  update: (e) =>
+    note   = $(e.target).parent().find('[data-type=update]').val()
+    organization = App.Organization.find( @organization_id )
+    if organization.note isnt note
+      organization.updateAttributes( note: note )
+      @log 'notice', 'update', e, note, organization
+
+  edit: (e) =>
+    e.preventDefault()
+    new App.ControllerGenericEdit(
+      id: @organization_id,
+      genericObject: 'Organization',
+      pageData: {
+        title: 'Organizations',
+        object: 'Organization',
+        objects: 'Organizations',
+      },
+      callback: @render
+    )

+ 4 - 2
app/assets/javascripts/app/controllers/tag_widget.js.coffee

@@ -6,6 +6,8 @@ class App.TagWidget extends App.Controller
     # update box size
     @bind 'ui:rerender:content', =>
       @siteUpdate()
+    @bind 'ui:rerender:task', =>
+      @siteUpdate()
 
   load: =>
     @attribute_id = 'tags_' + @object.id + '_' + @object_type
@@ -29,11 +31,11 @@ class App.TagWidget extends App.Controller
       tag_id: @attribute_id
     )
     @el.find('#' + @attribute_id ).tagsInput(
-      width:       '236px'
+      width:       '100%'
       defaultText: App.i18n.translateContent('add a Tag')
       onAddTag:    @onAddTag
       onRemoveTag: @onRemoveTag
-#      height: '65px'
+      height:      '45px'
     )
     @delay @siteUpdate, 250
 

+ 6 - 3
app/assets/javascripts/app/controllers/template_widget.js.coffee

@@ -1,4 +1,4 @@
-class App.TemplateUI extends App.Controller
+class App.TemplateUI extends App.ControllerDrox
   events:
     'click [data-type=template_save]':   'create',
     'click [data-type=template_select]': 'select',
@@ -21,8 +21,11 @@ class App.TemplateUI extends App.Controller
       template = App.Template.find( @template_id )
 
     # insert data
-    @html App.view('template_widget')(
-      template: template,
+    @html @template(
+      file:   'template_widget'
+      header: 'Templates'
+      params:
+        template: template
     )
     new App.ControllerForm(
       el:        @el.find('#form-template')

+ 26 - 24
app/assets/javascripts/app/controllers/ticket_zoom.js.coffee

@@ -140,7 +140,6 @@ class App.TicketZoom extends App.Controller
     @frontendTimeUpdate()
 
     @TicketTitle()
-    @TicketInfo()
     @TicketAction()
     @ArticleView()
 
@@ -177,13 +176,6 @@ class App.TicketZoom extends App.Controller
       el:       @el.find('.ticket-title')
     )
 
-  TicketInfo: =>
-    # show ticket info
-    new TicketInfo(
-      ticket:   @ticket
-      el:       @el.find('.ticket-info')
-    )
-
   ArticleView: =>
     # show article
     new ArticleView(
@@ -248,16 +240,27 @@ class TicketTitle extends App.Controller
     App.Event.trigger 'task:render'
 
 
-class TicketInfo extends App.Controller
+class TicketInfo extends App.ControllerDrox
   constructor: ->
     super
     @render()
 
   render: ->
-    @html App.view('ticket_zoom/ticket_info')(
-      ticket: @ticket
+    @html @template(
+      file:   'ticket_zoom/ticket_info'
+      header: '#' + @ticket.number
+      params:
+        ticket: @ticket
     )
 
+    # start tag controller
+    if !@isRole('Customer')
+      new App.TagWidget(
+        el:           @el.find('.tag_info')
+        object_type:  'Ticket'
+        object:        @ticket
+      )
+
 class TicketAction extends App.Controller
   constructor: ->
     super
@@ -267,30 +270,29 @@ class TicketAction extends App.Controller
 
     @html App.view('ticket_zoom/ticket_action')()
 
+    # show ticket info
+    new TicketInfo(
+      ticket:   @ticket
+      el:       @el.find('.ticket_info')
+    )
+
     # start customer info controller
     if !@isRole('Customer')
-      new App.UserInfo(
+      new App.UserWidget(
         el:      @el.find('.customer_info')
         user_id: @ticket.customer_id
         ticket:  @ticket
       )
 
     # start action controller
+    ###
     if !@isRole('Customer')
       new TicketActionRow(
         el:      @el.find('.action_info')
         ticket:  @ticket
         zoom:    @ui
       )
-
-    # start tag controller
-    if !@isRole('Customer')
-      new App.TagWidget(
-        el:           @el.find('.tag_info')
-        object_type:  'Ticket'
-        object:        @ticket
-      )
-
+    ###
     # start link info controller
     if !@isRole('Customer')
       new App.LinkInfo(
@@ -423,9 +425,9 @@ class Edit extends App.Controller
       if !@autosaveLast || ( diff && !_.isEmpty( diff ) )
         @autosaveLast = currentData
         @log 'notice', 'form hash changed', diff, currentData
-        @el.find('.ticket-update').parent().addClass('form-changed')
-        @el.find('.ticket-update').parent().parent().find('.reset-message').show()
-        @el.find('.ticket-update').parent().parent().find('.reset-message').removeClass('hide')
+        @el.find('.edit-ticket').addClass('form-changed')
+        @el.find('.edit-ticket').find('.reset-message').show()
+        @el.find('.edit-ticket').find('.reset-message').removeClass('hide')
         App.TaskManager.update( @task_key, { 'state': currentData })
     @interval( update, 3000, 'autosave' )
 

+ 0 - 132
app/assets/javascripts/app/controllers/user_info_widget.js.coffee

@@ -1,132 +0,0 @@
-class App.UserInfo extends App.Controller
-  events:
-    'focusout [data-type=update-user]': 'update_user',
-    'focusout [data-type=update-org]':  'update_org',
-    'click [data-type=edit-user]':      'edit_user'
-    'click [data-type=edit-org]':       'edit_org'
-    'click .nav li > a':                'toggle'
-
-  constructor: ->
-    super
-
-    # show user
-    callback = (user) =>
-      @render(user)
-      if @callback
-        @callback(user)
-
-      # subscribe and reload data / fetch new data if triggered
-      @subscribeId = user.subscribe(@render)
-
-    App.User.retrieve( @user_id, callback )
-
-  release: =>
-    App.User.unsubscribe(@subscribeId)
-
-  toggle: (e) ->
-    e.preventDefault()
-    @el.find('.nav li.active').removeClass('active')
-    $(e.target).parent('li').addClass('active')
-    area = $(e.target).data('area')
-    @el.find('.user-info, .org-info').addClass('hide')
-    @el.find('.' + area ).removeClass('hide')
-
-  render: (user) =>
-    if !user
-      user = @u
-
-    # get display data
-    userData = []
-    for item2 in App.User.configure_attributes
-      item = _.clone( item2 )
-
-      # check if value for _id exists
-      itemNameValue = item.name
-      itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
-      if itemNameValueNew of user
-        item.name = itemNameValueNew
-
-      # add to show if value exists
-      if user[item.name] || item.tag is 'textarea'
-
-        # do not show firstname and lastname / already show via diplayName()
-        if item.name isnt 'firstname' && item.name isnt 'lastname' && item.name isnt 'organization'
-          if item.info
-            userData.push item
-
-    if user.organization_id
-      organization = App.Organization.find( user.organization_id )
-      organizationData = []
-      for item2 in App.Organization.configure_attributes
-        item = _.clone( item2 )
-
-        # check if value for _id exists
-        itemNameValue = item.name
-        itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
-        if itemNameValueNew of user
-          item.name = itemNameValueNew
-
-        # add to show if value exists
-        if organization[item.name] || item.tag is 'textarea'
-
-          # do not show name / already show via diplayName()
-          if item.name isnt 'name'
-            if item.info
-              organizationData.push item
-
-    # insert userData
-    @html App.view('user_info')(
-      user:             user
-      userData:         userData
-      organization:     organization
-      organizationData: organizationData
-    )
-
-    @userTicketPopups(
-      selector: '.user-tickets'
-      user_id:  user.id
-      position: 'right'
-    )
-
-  update_user: (e) =>
-    note = $(e.target).parent().find('[data-type=update-user]').val()
-    user = App.User.find( @user_id )
-    if user.note isnt note
-      user.updateAttributes( note: note )
-      @log 'notice', 'update', e, note, user
-
-  edit_user: (e) =>
-    e.preventDefault()
-    new App.ControllerGenericEdit(
-      id: @user_id,
-      genericObject: 'User',
-      required: 'quick',
-      pageData: {
-        title: 'Users',
-        object: 'User',
-        objects: 'Users',
-      },
-      callback: @render
-    )
-
-  update_org: (e) =>
-    note   = $(e.target).parent().find('[data-type=update-org]').val()
-    org_id = $(e.target).parents().find('[data-type=edit-org]').data('id')
-    organization = App.Organization.find( org_id )
-    if organization.note isnt note
-      organization.updateAttributes( note: note )
-      @log 'notice', 'update', e, note, organization
-
-  edit_org: (e) =>
-    e.preventDefault()
-    id = $(e.target).data('id')
-    new App.ControllerGenericEdit(
-      id: id,
-      genericObject: 'Organization',
-      pageData: {
-        title: 'Organizations',
-        object: 'Organization',
-        objects: 'Organizations',
-      },
-      callback: @render
-    )

+ 89 - 0
app/assets/javascripts/app/controllers/user_widget.js.coffee

@@ -0,0 +1,89 @@
+class App.UserWidget extends App.ControllerDrox
+  events:
+    'focusout [data-type=update]': 'update',
+    'click [data-type=edit]':      'edit'
+
+  constructor: ->
+    super
+
+    # show user
+    callback = (user) =>
+      @render(user)
+      if @callback
+        @callback(user)
+
+      # subscribe and reload data / fetch new data if triggered
+      @subscribeId = user.subscribe(@render)
+
+    App.User.retrieve( @user_id, callback )
+
+  release: =>
+    App.User.unsubscribe(@subscribeId)
+
+  render: (user) =>
+    if !user
+      user = @u
+
+    # get display data
+    userData = []
+    for item2 in App.User.configure_attributes
+      item = _.clone( item2 )
+
+      # check if value for _id exists
+      itemNameValue = item.name
+      itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
+      if itemNameValueNew of user
+        item.name = itemNameValueNew
+
+      # add to show if value exists
+      if user[item.name] || item.tag is 'textarea'
+
+        # do not show firstname and lastname / already show via diplayName()
+        if item.name isnt 'firstname' && item.name isnt 'lastname'
+          if item.info
+            userData.push item
+
+    # insert userData
+    @html @template(
+      file:   'user_widget'
+      header: 'Customer'
+      edit:   true
+      params:
+        user:     user
+        userData: userData
+    )
+
+    @userTicketPopups(
+      selector: '.user-tickets'
+      user_id:  user.id
+      position: 'right'
+    )
+
+
+    if user.organization_id
+      @el.append('<div class="org-info"></div>')
+      new App.OrganizationWidget(
+        organization_id: user.organization_id
+        el:              @el.find('.org-info')
+      )
+
+  update: (e) =>
+    note = $(e.target).parent().find('[data-type=update]').val()
+    user = App.User.find( @user_id )
+    if user.note isnt note
+      user.updateAttributes( note: note )
+      @log 'notice', 'update', e, note, user
+
+  edit: (e) =>
+    e.preventDefault()
+    new App.ControllerGenericEdit(
+      id: @user_id,
+      genericObject: 'User',
+      required: 'quick',
+      pageData: {
+        title: 'Users',
+        object: 'User',
+        objects: 'Users',
+      },
+      callback: @render
+    )

Some files were not shown because too many files changed in this diff