diff --git a/app/assets/javascripts/app/controllers/organization_profile.coffee b/app/assets/javascripts/app/controllers/organization_profile.coffee index f3ffc80a9..61e8e6ce2 100644 --- a/app/assets/javascripts/app/controllers/organization_profile.coffee +++ b/app/assets/javascripts/app/controllers/organization_profile.coffee @@ -14,10 +14,15 @@ class App.OrganizationProfile extends App.Controller if App.Organization.exists(@organization_id) organization = App.Organization.find(@organization_id) + icon = organization.icon() + + if organization.active is false + icon = 'inactive-' + icon meta.head = organization.displayName() meta.title = organization.displayName() - meta.iconClass = organization.icon() + meta.iconClass = icon + meta.active = organization.active meta url: => diff --git a/app/assets/javascripts/app/controllers/user_profile.coffee b/app/assets/javascripts/app/controllers/user_profile.coffee index 3b3ed3ee7..43f11effb 100644 --- a/app/assets/javascripts/app/controllers/user_profile.coffee +++ b/app/assets/javascripts/app/controllers/user_profile.coffee @@ -15,10 +15,15 @@ class App.UserProfile extends App.Controller if App.User.exists(@user_id) user = App.User.find(@user_id) + icon = user.icon() + + if user.active is false + icon = 'inactive-' + icon meta.head = user.displayName() meta.title = user.displayName() - meta.iconClass = user.icon() + meta.iconClass = icon + meta.active = user.active meta url: => diff --git a/app/assets/javascripts/app/lib/app_post/global_search.coffee b/app/assets/javascripts/app/lib/app_post/global_search.coffee index ff8bf69dd..0ce040a4d 100644 --- a/app/assets/javascripts/app/lib/app_post/global_search.coffee +++ b/app/assets/javascripts/app/lib/app_post/global_search.coffee @@ -9,7 +9,6 @@ class App.GlobalSearch extends App.Controller search: (params) => query = params.query - # use cache for search result currentTime = new Date if @searchResultCache[query] && @searchResultCache[query].time > currentTime.setSeconds(currentTime.getSeconds() - 20) diff --git a/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee b/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee index 0bb7d24c7..b8df9112d 100644 --- a/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee +++ b/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee @@ -20,7 +20,10 @@ class App.SingleObjectPopoverProvider extends App.PopoverProvider buildTitleFor: (elem) -> object = @constructor.klass.find(@objectIdFor(elem)) - App.Utils.htmlEscape(@displayTitleUsing(object)) + title = App.Utils.htmlEscape(@displayTitleUsing(object)) + if object.active is false + title = '' + title + '' + title buildContentFor: (elem) -> id = @objectIdFor(elem) diff --git a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee index 31646f8b3..d3cb7225d 100644 --- a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee @@ -240,8 +240,9 @@ class App.SearchableSelect extends Spine.Controller @invisiblePart.text('') selectItem: (event) -> - return if !event.currentTarget.textContent - @input.val event.currentTarget.textContent.trim() + currentText = event.currentTarget.querySelector('span.searchableSelect-option-text').textContent.trim() + return if !currentText + @input.val currentText @input.trigger('change') @shadowInput.val event.currentTarget.getAttribute('data-value') @shadowInput.trigger('change') @@ -351,7 +352,7 @@ class App.SearchableSelect extends Spine.Controller event.preventDefault() if @currentItem || !@attribute.unknown - valueName = @currentItem.text().trim() + valueName = @currentItem.children('span.searchableSelect-option-text').text().trim() value = @currentItem.attr('data-value') @input.val valueName @shadowInput.val value @@ -427,7 +428,7 @@ class App.SearchableSelect extends Spine.Controller @currentItem.addClass 'is-active' if autocomplete - @autocomplete @currentItem.attr('data-value'), @currentItem.text().trim() + @autocomplete @currentItem.attr('data-value'), @currentItem.children('span.searchableSelect-option-text').text().trim() highlightItem: (event) => @unhighlightCurrentItem() diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 39b8105d8..617df5219 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -1311,6 +1311,14 @@ class App.Utils autocomplete: { source: source minLength: 2 + create: -> + $(@).data('ui-autocomplete')._renderItem = (ul, item) -> + option_html = App.Utils.htmlEscape(item.label) + additional_class = '' + if item.inactive + option_html += '' + App.i18n.translateContent('inactive') + '' + additional_class = 'is-inactive' + return $('
  • ').addClass(additional_class).append(option_html).appendTo(ul) }, ).on('tokenfield:createtoken', (e) -> if type is 'email' && !e.attrs.value.match(/@/) || e.attrs.value.match(/\s/) diff --git a/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee b/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee index b8c078407..4513a0a3d 100644 --- a/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/z_searchable_ajax_select.coffee @@ -38,7 +38,6 @@ class App.SearchableAjaxSelect extends App.SearchableSelect success: (data, status, xhr) => # cache search result @searchResultCache[cacheKey] = data - @renderResponse(data, query) # if delegate is given and provides getAjaxAttributes method, try to extend ajax call @@ -81,7 +80,6 @@ class App.SearchableAjaxSelect extends App.SearchableSelect category = undefined if result.type is 'KnowledgeBase::Answer::Translation' && result.subtitle category = result.subtitle - if result { category: category @@ -103,6 +101,7 @@ class App.SearchableAjaxSelect extends App.SearchableSelect { name: name value: object.id + inactive: object.active == false } showLoader: => diff --git a/app/assets/javascripts/app/models/organization.coffee b/app/assets/javascripts/app/models/organization.coffee index 969091f13..c0d91e42e 100644 --- a/app/assets/javascripts/app/models/organization.coffee +++ b/app/assets/javascripts/app/models/organization.coffee @@ -41,11 +41,18 @@ Using **Organisations** you can **group** customers. This has among others two i data searchResultAttributes: -> + classList = ['organization', 'organization-popover' ] + icon = 'organization' + + if @active is false + classList.push 'is-inactive' + icon = 'inactive-' + icon + display: "#{@displayName()}" id: @id - class: 'organization organization-popover' + class: classList.join(' ') url: @uiUrl() - icon: 'organization' + icon: icon activityMessage: (item) -> return if !item diff --git a/app/assets/javascripts/app/models/user.coffee b/app/assets/javascripts/app/models/user.coffee index 8ff31425c..8f1f6aff8 100644 --- a/app/assets/javascripts/app/models/user.coffee +++ b/app/assets/javascripts/app/models/user.coffee @@ -156,11 +156,18 @@ class App.User extends App.Model data searchResultAttributes: -> + classList = ['user', 'user-popover'] + icon = 'user' + + if @active is false + classList.push 'is-inactive' + icon = 'inactive-' + icon + display: "#{@displayName()}" id: @id - class: 'user user-popover' + class: classList.join(' ') url: @uiUrl() - icon: 'user' + icon: icon activityMessage: (item) -> return if !item diff --git a/app/assets/javascripts/app/views/generic/object_search/item_object.jst.eco b/app/assets/javascripts/app/views/generic/object_search/item_object.jst.eco index 53bb48d4b..c55a32771 100644 --- a/app/assets/javascripts/app/views/generic/object_search/item_object.jst.eco +++ b/app/assets/javascripts/app/views/generic/object_search/item_object.jst.eco @@ -1,4 +1,4 @@ -
  • +
  • <%- @Icon(@icon, 'recipientList-icon') %>
    @@ -9,10 +9,10 @@ <%= @object.displayName() %> <% end %> <% if @object.organization: %> - - <%= @object.organization.displayName() %> + - <%= @object.organization.displayName() %> <% end %> <% if @object.active is false: %>
    <%- @Ti('inactive') %>
    <% end %> -
  • \ No newline at end of file + diff --git a/app/assets/javascripts/app/views/generic/object_search/item_organization.jst.eco b/app/assets/javascripts/app/views/generic/object_search/item_organization.jst.eco index 7f9e13d9a..cc2fe25cc 100644 --- a/app/assets/javascripts/app/views/generic/object_search/item_organization.jst.eco +++ b/app/assets/javascripts/app/views/generic/object_search/item_organization.jst.eco @@ -1,4 +1,4 @@ -
  • +
  • <% if @organization.active is false: %> <%- @Icon('inactive-organization', 'recipientList-icon') %> @@ -14,4 +14,4 @@
    <%- @Ti('inactive') %>
    <% end %> <%- @Icon('arrow-right', 'recipientList-arrow') %> -
  • \ No newline at end of file + diff --git a/app/assets/javascripts/app/views/generic/searchable_select_option.jst.eco b/app/assets/javascripts/app/views/generic/searchable_select_option.jst.eco index 8ec9a7e09..4343f64c7 100644 --- a/app/assets/javascripts/app/views/generic/searchable_select_option.jst.eco +++ b/app/assets/javascripts/app/views/generic/searchable_select_option.jst.eco @@ -1,9 +1,14 @@ diff --git a/app/assets/javascripts/app/views/navigation/result.jst.eco b/app/assets/javascripts/app/views/navigation/result.jst.eco index af4749fc0..e9394b908 100644 --- a/app/assets/javascripts/app/views/navigation/result.jst.eco +++ b/app/assets/javascripts/app/views/navigation/result.jst.eco @@ -11,4 +11,4 @@ <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/assets/javascripts/app/views/organization_profile/index.jst.eco b/app/assets/javascripts/app/views/organization_profile/index.jst.eco index f8bb2fda5..c3b372716 100644 --- a/app/assets/javascripts/app/views/organization_profile/index.jst.eco +++ b/app/assets/javascripts/app/views/organization_profile/index.jst.eco @@ -3,11 +3,15 @@
    - <%- @Icon('organization') %> + <% if @organization.active is true: %> + <%- @Icon('organization') %> + <% else: %> + <%- @Icon('inactive-organization') %> + <% end %>

    - \ No newline at end of file + diff --git a/app/assets/javascripts/app/views/popover/organization.jst.eco b/app/assets/javascripts/app/views/popover/organization.jst.eco index 9f6bbef46..7bfcd1d5e 100644 --- a/app/assets/javascripts/app/views/popover/organization.jst.eco +++ b/app/assets/javascripts/app/views/popover/organization.jst.eco @@ -5,7 +5,7 @@
    <% for user in @object.members: %> -
    <%= user.displayName() %>
    +
    <%= user.displayName() %>
    <% end %>
    <% end %> diff --git a/app/assets/javascripts/app/views/popover/user.jst.eco b/app/assets/javascripts/app/views/popover/user.jst.eco index b2bc622c7..8094a401d 100644 --- a/app/assets/javascripts/app/views/popover/user.jst.eco +++ b/app/assets/javascripts/app/views/popover/user.jst.eco @@ -1,5 +1,5 @@ <% if @object['organization']: %> -
    <%= @object.organization.displayName() %>
    +
    <%= @object.organization.displayName() %>
    <% end %> <%- @V('popover/single_object_generic', object: @object, attributes: @attributes) %> diff --git a/app/assets/javascripts/app/views/widget/organization.jst.eco b/app/assets/javascripts/app/views/widget/organization.jst.eco index 1e315d651..37a6d4629 100644 --- a/app/assets/javascripts/app/views/widget/organization.jst.eco +++ b/app/assets/javascripts/app/views/widget/organization.jst.eco @@ -1,7 +1,11 @@ - +