How to add task in taskbar

Hi I am trying to add a preview of my data in the taskabar on the left hand side I managed to do it however after refreshing the page I cannot access this tab it keeps loading.
image

zammad/app/assets/javascripts/app/controllers/user_profile.coffee at develop · zammad/zammad · GitHub

I did everything as in this file however it still does not work 100%

Without any code it’s hard to guess. Maybe the meta data is wrong or App.TaskManager.touch(@taskKey) is missing?

Here is a simple example of the profile page:

http://127.0.0.1:3000/#example/profile/2
http://127.0.0.1:3000/#example/profile/3
http://127.0.0.1:3000/#example/profile/4

app/assets/javascripts/app/controllers/example_profile.coffee

class App.ExampleProfile extends App.Controller
  @requiredPermission: ['ticket.agent']

  constructor: (params) ->
    super

    @render()

  meta: =>
    meta =
      url: @url()
      id:  @user_id
      head: "example #{@user_id}"
      title: "example #{@user_id}"
      active: true
      iconClass: 'user'
    meta

  url: =>
    '#example/profile/' + @user_id

  show: =>
    @navupdate(url: '#', type: 'menu')

  render: (user) =>
    @html "test #{@user_id}"

class Router extends App.ControllerPermanent
  @requiredPermission: ['ticket.agent']

  constructor: (params) ->
    super

    # check authentication
    @authenticateCheckRedirect()

    # cleanup params
    clean_params =
      user_id:  params.user_id

    App.TaskManager.execute(
      key:        "Example-#{@user_id}"
      controller: 'ExampleProfile'
      params:     clean_params
      show:       true
    )

App.Config.set('example/profile/:user_id', Router, 'Routes')
class App.AssetOverview extends App.Controller
  @requiredPermission: ['ticket.agent', 'admin.user']

  constructor: (params) ->
    super
    App.Asset.full(@asset_id, @render)

  meta: =>
    meta =
      url: @url()
      id:  @asset_id

    if App.Asset.exists(@asset_id)
      asset = App.Asset.find(@asset_id)
      icon = asset.icon()

      meta.head       = asset.displayName()
      meta.title      = asset.displayName()
      meta.iconClass  = icon
      meta.active     = true
    meta

  url: =>
    '#orders/assets/overview/' + @asset_id

  show: =>
    App.OnlineNotification.seen('AssetOverview', @asset_id)
    @navupdate(url: '#', type: 'menu')

  changed: ->
    false

  render: (asset) =>
    if !@doNotLog
      @doNotLog = 1
      @recentView('AssetOverview', @asset_id)

    elLocal = $(App.view('asset_overview/index')())

    new App.AssetOverviewTabs(
      el = elLocal
    );

    @html elLocal

    new App.UpdateTastbar(
      genericObject: asset
    )

  setPosition: (position) =>
    @$('.assetOverview').scrollTop(position)

  currentPosition: =>
    @$('.assetOverview').scrollTop()

class Router extends App.ControllerPermanent
  @requiredPermission: ['admin.assets']

  constructor: (params) ->
    super

    # check authentication
    @authenticateCheckRedirect()

    # cleanup params
    clean_params = 
      asset_id: params.asset_id

    App.TaskManager.execute(
      key: "AssetOverview-#{@asset_id}"
      controller: 'AssetOverview'
      params: clean_params
      show: true
    )

App.Config.set('orders/assets/overview/:asset_id', Router, 'Routes')

sorry, I’m on my phone and I accidentally replied without comment, where should I define this taskmanager?App.TaskManager.touch(@taskKey)

I also noticed when I was trying to fix this error that when the user writes App.User.all() to the console in the constructor, it is always full, as if it had been loaded somewhere before, which I don’t have in my case and I think this may also be a problem

Please slow down a bit. Bumping the same thread with 3 consecutive answers to yourself can be very noisy to others.

  1. How does your models/assets.coffee look like? Does it have an icon?
  2. Do you see the ajax request working?
  3. Is the content rendered?
class App.Asset extends App.Model
  @configure 'Asset','form_id', 'name', 'serial_number', 'organization', 'user', 'invoices_id', 'attachments_id', 'asset_model', 'seller_model', 'purchase_date', 'purchase_cost', 'description'
  @extend Spine.Model.Ajax
  @url: @apiPath + '/assets'
  @configure_attributes = [
    { name: 'name', display: __('Nazwa'), tag: 'input', null: false, },
    { name: 'serial_number', display: __('Numer seryjny'), tag: 'input',null: false },
    { name: 'organization', display: __('Organization'), tag: 'autocompletion_ajax_customer_organization', multiple: false, null: false, relation: 'Organization', },
    { name: 'user_ids', display: __('User'), tag: 'autocompletion_ajax', relation: 'User', null: true, },
    { name: 'invoice_id', display: __('Faktura'), tag: 'file_upload',form_id: @form_id, null: true, },
    { name: 'attachments_id', display: __('Załączniki'), tag: 'file_upload', form_id: @form_id, null: true,  },
    { name: 'asset_model_id', display: __('Aktywo'), tag: 'autocompletion_ajax', relation: 'AssetModel', null: true, },
    { name: 'seller_model_id', display: __('Sprzedawca'), tag: 'autocompletion_ajax', relation: 'SellerModel', null: true,},
    { name: 'purchase_date', display: __('Data kupna'), tag: 'date', class: 'input', null: true },
    { name: 'purchase_cost', display: __('Koszt kupna'), tag: 'decimal', null: true},
    { name: 'description', display: __('Opis'), tag: 'textarea',upload:true, class: 'input', null: true},
  ]
  @configure_overview = [
    'name', 'serial_number', 'organization', 'user_id', 'invoice_id', 'attachments_id', 'asset_model_id', 'seller_model_id', 'purchase_date', 'purchase_cost', 'description'
  ]
  @configure_preview = [
    'name', 'serial_number', 'organization', 'user_id', 'invoice_id', 'attachments_id', 'asset_model_id', 'seller_model_id', 'purchase_date', 'purchase_cost', 'description'
  ]
  icon: ->
    'overviews'

  displayName: ->
    if !_.isEmpty(@name)
      name = @name
  1. I don’t know which query you mean
  2. Yes, it is displayed when you first enter the controller, but when you later change it to, for example, dashboard, it no longer displays, only the link changes.

I have found a solution to the problem. I was missing App.TaskManager.touch(@taskKey) as you wrote thanks a lot for your help

My code as if someone was ever looking for answers

class App.AssetOverview extends App.Controller
  @requiredPermission: ['ticket.agent', 'admin.user']

  constructor: (params) ->
    super
    App.Asset.full(@asset_id, @render)

  meta: =>
    meta =
      url: @url()
      id:  @asset_id

    if App.Asset.exists(@asset_id)
      asset = App.Asset.find(@asset_id)
      icon = asset.icon()

      meta.head       = asset.displayName()
      meta.title      = asset.displayName()
      meta.iconClass  = icon
      meta.active     = true
    meta

  url: =>
    '#orders/assets/overview/' + @asset_id

  show: =>
    App.OnlineNotification.seen('AssetOverview', @asset_id)
    @navupdate(url: '#', type: 'menu')

  changed: ->
    false

  render: (asset) =>
    if !@doNotLog
      @doNotLog = 1
      @recentView('AssetOverview', @asset_id)

    elLocal = $(App.view('asset_overview/index')())

    new App.UserProfileObject(
      el:        elLocal.find('.js-object-container')
      object_id: asset.id
      taskKey:  @taskKey
    )

    @html elLocal

    new App.UpdateTastbar(
      genericObject: asset
    )

  setPosition: (position) =>
    @$('.assetOverview').scrollTop(position)

  currentPosition: =>
    @$('.assetOverview').scrollTop()

class Router extends App.ControllerPermanent
  @requiredPermission: ['admin.assets']

  constructor: (params) ->
    super

    # check authentication
    @authenticateCheckRedirect()

    # cleanup params
    clean_params = 
      asset_id: params.asset_id

    App.TaskManager.execute(
      key: "AssetOverview-#{@asset_id}"
      controller: 'AssetOverview'
      params: clean_params
      show: true
    )

App.Config.set('orders/assets/overview/:asset_id', Router, 'Routes')

class App.AssetProfileObject extends App.ControllerObserver

  model: 'Asset'
  observeNot:
    form_id: true
    name: true 
    serial_number: true
    organization: true
    user: true
    invoices_id: true
    attachments_id: true
    asset_model: true
    seller_model: true
    purchase_date: true
    purchase_cost: true
    description: true
    created_at: true
    created_by_id: true
    updated_at: true
    updated_by_id: true

  render: =>

    App.TaskManager.touch(@taskKey)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.