Commit d3dc4648 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_officejs: Bookmark, add possibility to use commands

erp5_officejs: Change command symbol from "$" to "!"

erp5_officejs: bookmark list, add reference column
parent 771d3f73
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
<a href="{{url_string}}" style="display: block; text-align: center; font-size: 1.7em;">{{url_string}}</a> <a href="{{url_string}}" style="display: block; text-align: center; font-size: 1.7em;">{{url_string}}</a>
<form class="view-web-page-form"> <form class="view-web-page-form">
<div class="center"> <div class="center">
<div class="ui-field-contain">
<label data-i18n="Reference:">Reference:</label>
<input type="text" name="reference" value="{{reference}}">
</div>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label data-i18n="Title:">Title:</label> <label data-i18n="Title:">Title:</label>
<input type="text" name="title" value="{{title}}"> <input type="text" name="title" value="{{title}}">
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>cedric.le.ninivin</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.24259.25538.21094</string> </value> <value> <string>960.50196.61213.58965</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1493732989.43</float> <float>1500208665.49</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
function getSearchedString() { function getSearchedString() {
var regex = new RegExp("[\\#?&]search=([^&]*)"), var regex = new RegExp("[\\#?&]search=([^&]*)"),
results = regex.exec(window.location.hash); results = regex.exec(window.location.hash);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); return results === null ? "" : decodeURIComponent(results[1].trim().replace(/\+/g, " "));
} }
function updateSearchUrl(event) { function updateSearchUrl(event) {
...@@ -66,23 +66,43 @@ ...@@ -66,23 +66,43 @@
}) })
.push(function () { .push(function () {
var search = window.decodeURIComponent(getSearchedString()), var search = window.decodeURIComponent(getSearchedString()),
query = ""; query = "",
command = "",
parameter = "",
index;
if (search) { if (search) {
query = { if (search.startsWith("!")) {
query: '(title:"%' + search + '%" OR url_string:"%' + search + '%" OR description:"%' + search + '%") AND portal_type:"' + portal_type + '"', index = search.indexOf(" ");
select_list: ['title', 'url_string', 'description'], if (index !== -1) {
}; command = search.substring(1, index);
parameter = search.substr(index + 1);
} else {
command = search.substr(1);
parameter = "";
}
query = {
query: '(reference:"' + command + '")'
+ ' AND portal_type:"' + portal_type + '"',
select_list: ['url_string']
};
} else {
query = {
query: '(title:"%' + search + '%" OR url_string:"%' + search + '%" OR description:"%' + search + '%") AND portal_type:"' + portal_type + '"',
select_list: ['title', 'url_string', 'description'],
};
}
return gadget.jio_allDocs(query) return gadget.jio_allDocs(query)
.push(function (query_result) { .push(function (query_result) {
var result_list_length = query_result.data.rows.length; var result_list_length = query_result.data.rows.length;
// if 0 result, let's search with a real search engine // if 0 result, let's search with a real search engine
if (result_list_length === 0 && option.search_engine !== '') { if (result_list_length === 0 && option.search_engine !== '') {
window.location.href = option.search_engine + window.encodeURIComponent(search); window.location.href = option.search_engine + window.encodeURIComponent(search);
} } else if (result_list_length === 1
// if 1 result, we go there && (option.auto_redirect === true || command !== "")) {
else if (result_list_length === 1 && option.auto_redirect === true) { // if 1 result, and redirect or command ,we go there
window.location.href = query_result.data.rows[0].value.url_string; window.location.href = query_result.data.rows[0].value.url_string
+ parameter;
} }
else { else {
return gadget.getUrlFor({page: "bookmark_list", search: window.encodeURIComponent(search)}) return gadget.getUrlFor({page: "bookmark_list", search: window.encodeURIComponent(search)})
...@@ -91,7 +111,7 @@ ...@@ -91,7 +111,7 @@
}); });
} }
}); });
} }
}); });
}) })
.onEvent("submit", function () { .onEvent("submit", function () {
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>cedric.le.ninivin</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.32759.37420.3857</string> </value> <value> <string>960.50255.3559.58845</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1499162533.71</float> <float>1500212133.56</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -85,6 +85,9 @@ ...@@ -85,6 +85,9 @@
search_page: 'bookmark_list', search_page: 'bookmark_list',
search: options.search, search: options.search,
column_list: [{ column_list: [{
select: 'reference',
title: 'Reference'
}, {
select: 'title', select: 'title',
title: 'Title' title: 'Title'
}, { }, {
...@@ -96,7 +99,7 @@ ...@@ -96,7 +99,7 @@
}], }],
query: { query: {
query: 'portal_type:("' + gadget.props.portal_type + '")', query: 'portal_type:("' + gadget.props.portal_type + '")',
select_list: ['title', 'url_string', 'description'], select_list: ['reference', 'title', 'url_string', 'description'],
limit: [0, 30], limit: [0, 30],
sort_on: [["modification_date", "descending"]] sort_on: [["modification_date", "descending"]]
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.50478.26108.37085</string> </value> <value> <string>960.50482.54730.15138</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1500225770.04</float> <float>1500225946.73</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment