Ver código fonte

[fix] [minor] autosuggest show description

version-14
Rushabh Mehta 11 anos atrás
pai
commit
352c3d1fad
3 arquivos alterados com 21 adições e 19 exclusões
  1. +1
    -0
      public/js/wn/views/doclistview.js
  2. +16
    -11
      public/js/wn/views/listview.js
  3. +4
    -8
      webnotes/widgets/search.py

+ 1
- 0
public/js/wn/views/doclistview.js Ver arquivo

@@ -246,6 +246,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
init_minbar: function() {
var me = this;
this.appframe.add_icon_btn("2", 'icon-tag', wn._('Show Tags'), function() { me.toggle_tags(); });
this.wrapper.on("click", ".list-tag-preview", function() { me.toggle_tags(); });
if(this.can_delete || this.listview.settings.selectable) {
this.appframe.add_icon_btn("2", 'icon-remove', wn._('Delete'), function() { me.delete_items(); });
this.appframe.add_icon_btn("2", 'icon-ok', wn._('Select All'), function() {


+ 16
- 11
public/js/wn/views/listview.js Ver arquivo

@@ -159,24 +159,29 @@ wn.views.ListView = Class.extend({
}
});
var comments = data._comments ? JSON.parse(data._comments) : []
var comments = data._comments ? JSON.parse(data._comments) : [];
var tags = $.map(data._user_tags.split(","), function(v) { return v ? v : null; });
var timestamp_and_comment =
$('<div class="list-timestamp">')
.appendTo(row)
.html((comments.length ?
('<a style="margin-right: 10px;" href="#Form/'+
this.doctype + '/' + data.name
+'" title="'+
comments[comments.length-1].comment
+'"><i class="icon-comments"></i> '
+ comments.length + " " + (
comments.length===1 ? wn._("comment") : wn._("comments")) + '</a>')
: "")
.html(""
+ (tags.length ? (
'<span style="margin-right: 10px;" class="list-tag-preview">' + tags.join(", ") + '</span>'
): "")
+ (comments.length ?
('<a style="margin-right: 10px;" href="#Form/'+
this.doctype + '/' + data.name
+'" title="'+
comments[comments.length-1].comment
+'"><i class="icon-comments"></i> '
+ comments.length + " " + (
comments.length===1 ? wn._("comment") : wn._("comments")) + '</a>')
: "")
+ comment_when(data.modified));
// row #2
var row2 = $('<div class="row tag-row">\
var row2 = $('<div class="row tag-row" style="margin-bottom: 5px;">\
<div class="col-xs-12">\
<div class="col-xs-3"></div>\
<div class="col-xs-7">\


+ 4
- 8
webnotes/widgets/search.py Ver arquivo

@@ -17,7 +17,7 @@ except ImportError:
@webnotes.whitelist()
def search_link(doctype, txt, query=None, filters=None, page_len=20, searchfield="name"):
search_widget(doctype, txt, query, searchfield=searchfield, page_len=page_len, filters=filters)
webnotes.response['results'] = build_for_autosuggest(webnotes.response["values"], searchfield)
webnotes.response['results'] = build_for_autosuggest(webnotes.response["values"])
del webnotes.response["values"]

# this is called by the search box
@@ -29,7 +29,7 @@ def search_widget(doctype, txt, query=None, searchfield="name", start=0,
filters = json.loads(filters)

meta = webnotes.get_doctype(doctype)
if query and query.split()[0].lower()!="select":
# by method
webnotes.response["values"] = webnotes.get_method(query)(doctype, txt,
@@ -77,14 +77,10 @@ def get_std_fields_list(meta, key):

return ['`tab%s`.`%s`' % (meta[0].name, f.strip()) for f in sflist]

def build_for_autosuggest(res, searchfield):
searchfield = [s.strip() for s in searchfield.split(",")]
def build_for_autosuggest(res):
results = []
for r in res:
out = {}
for i, s in enumerate(searchfield):
if s=="name": s="value"
out[s] = r[i]
out = {"value": r[0], "description": ", ".join(r[1:])}
results.append(out)
return results



Carregando…
Cancelar
Salvar