Skip to content

Commit

Permalink
added markup for expertsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
StiftungAusNachlass committed Oct 24, 2024
1 parent 466d942 commit 986e439
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions src/webfrontend/CustomDataTypeGND.coffee
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,94 @@ class CustomDataTypeGND extends CustomDataTypeWithCommons
]


#######################################################################
# returns markup to display in expert search
#######################################################################
renderSearchInput: (data, opts) ->
that = @
if not data[@name()]
data[@name()] = {}

that.callFromExpertSearch = true

form = @renderEditorInput(data, '', {})

CUI.Events.listen
type: "data-changed"
node: form
call: =>
CUI.Events.trigger
type: "search-input-change"
node: form
CUI.Events.trigger
type: "editor-changed"
node: form
CUI.Events.trigger
type: "change"
node: form
CUI.Events.trigger
type: "input"
node: form

form.DOM

#######################################################################
# make searchfilter for expert-search
#######################################################################
getSearchFilter: (data, key=@name()) ->
that = @

objecttype = @path()
objecttype = objecttype.split('.')
objecttype = objecttype[0]

# search for empty values
if data[key+":unset"]
filter =
type: "in"
fields: [ @fullName()+".conceptURI" ]
in: [ null ]
filter._unnest = true
filter._unset_filter = true
return filter

# dropdown or popup without tree or use of searchbar: use sameas
filter =
type: "complex"
search: [
type: "in"
mode: "fulltext"
bool: "must"
phrase: false
fields: [ @path() + '.' + @name() + ".conceptURI" ]
]
if ! data[@name()]
filter.search[0].in = [ null ]
else if data[@name()]?.conceptURI
filter.search[0].in = [data[@name()].conceptURI]
else
filter = null

filter

#######################################################################
# make tag for expert-search
#######################################################################
getQueryFieldBadge: (data) ->
if ! data[@name()]
value = $$("field.search.badge.without")
else if ! data[@name()]?.conceptURI
value = $$("field.search.badge.without")
else
value = data[@name()].conceptName

name: @nameLocalized()
value: value


needsDirectRender: ->
return true

#######################################################################
# renders the "result" in original form (outside popover)
__renderButtonByData: (cdata) ->
Expand Down

0 comments on commit 986e439

Please sign in to comment.