Ticket #839 (closed Enhancement: fixed)

Opened 9 years ago

Last modified 9 years ago

Webclient: redesign search mode extension mechanism

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.7
Component: DeepaMehta Standard Distribution Version: 4.6.1
Keywords: Cc: dgf, Malte
Complexity: 3 Area: Application Framework / API
Module: deepamehta-webclient

Description

Providing a search mode implementation should be more easy for the plugin developer. The current approach based on events ("search", "searchmode_widget") doesn't represent the problem well.

Change History

comment:1 Changed 9 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 9 years ago by Malte

My reply to the ticket scope:

Webclient: redesign search mode extension mechanism

From my personal experience, implementing a search mode js- and java-wise is already easy but provides some challenges for the user-interface design of the search-dialog.

Just my two cents for consideration in a potential revision of "Search"-modes.

  • All third party search modes plugged in i know of _extend_ and not replace the "By Text" search mode about, 1-3 optional settings. For example, Wikidata is an extra "Source" and needs additionally a specific "Language" and "Type" as parameters for a "By Text" search)
  • Consider also searching tracks on "SoundCloud?" or Albums on "Bandcamp", "By Text", etc.
  • Similarly one could imagine that a "By Type" search is used to search for types (in terms of "Classes", "Schemas" or other "well defined model structures") from other "Sources"

I think a revision of the search dialog would be the most helpful thing one can currently do when aiming at supporting third party developers. I am sorry that atm i can not provide a idea on how one could exactly successfully do so but just wanted to give my input on this because currently i can not see the problem as described above.

Cheers & all the best!

comment:3 Changed 9 years ago by jri

These are good points but out of the scope of this ticket.
Consider opening a separate ticket, e.g. "Redesign the search widget to include external data sources".

The scope of this ticket is just the long overdue refactoring of the searchmode API, no new functionality.

comment:4 Changed 9 years ago by Jörg Richter <jri@…>

In 921d03463989f4e17a393482fabd8629d4365e47/deepamehta:

Webclient: revise searchmode extension API (#839).

Providing a search mode implementation is slightly more convenient for the plugin developer. She must no longer handle events but implements all the searchmode in a concise constructor function. Furthermore she can rely on a higher-level API and must not interact with the toolbar DOM.

BREAKING CHANGES

1 method dropped:

dm4c.do_search(searchmode)

Use dm4c.toolbar.do_search() instead (see below).

2 client-side events dropped:

search
searchmode_widget

A searchmode implementation is added to the Webclient's toolbar by calling dm4c.toolbar.add_searchmode(). You pass 2 parameters: an URI to identify your searchmode and a constructor function which contains all aspectes a searchmode is made of, that is 1) the label to display in the searchmode menu, 2) the searchmode widget, and 3) the actual search operation.

Example:

dm4c.toolbar.add_searchmode(MY_SEARCHMODE_URI, function() {

    this.label = "My searchmode label"

    this.widget = function() {
        ... build my widget
        return my_searchmode_widget
    }

    this.search = function() {
        ... doing my search
        return my_searchresult_topic
    }
})

You see you're no longer required to interact with the toolbar DOM, e.g. adding your searchmode to the menu. And you must no longer register event listeners and check if the event is directed to your very searchmode.

You can place the add_searchmode() call directly into your plugin's constructor function.

To select a searchmode by default (when the Webclient starts) your plugin can use a "init[x]" handler and call:

dm4c.toolbar.select_searchmode(MY_SEARCHMODE_URI)

Note: the dm4c.toolbar.select_searchmode() method exists like before but is no a high-level call. You must no longer care about manually choosing the searchmode from the searchmode menu.

Overview of the new searchmode API (5 methods)

Adds a searchmode to the searchmode menu

dm4c.toolbar.add_searchmode(searchmode_uri, constructor_func)

Selects a searchmode programmatically

dm4c.toolbar.select_searchmode(searchmode_uri)

Returns the URI of the selected searchmode

dm4c.toolbar.get_searchmode_uri()

Triggers the current search programmatically

dm4c.toolbar.do_search()

Enables/disables the toolbar's search button

dm4c.toolbar.enable_search_button(state)

For a detailed description see the API comments in:
https://github.com/jri/deepamehta/blob/master/modules/dm4-webclient/src/main/resources/web/script/gui/toolbar_panel.js

For example implementations see the "By Text" and "By Type" searchmodes:
https://github.com/jri/deepamehta/blob/master/modules/dm4-webclient/src/main/resources/web/script/internal_plugins/fulltext_plugin.js
https://github.com/jri/deepamehta/blob/master/modules/dm4-typesearch/src/main/resources/web/script/plugin.js

See #839.

Version 0, edited 9 years ago by Jörg Richter <jri@…> (next)

comment:5 Changed 9 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.