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 @@
<a href="{{url_string}}" style="display: block; text-align: center; font-size: 1.7em;">{{url_string}}</a>
<form class="view-web-page-form">
<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">
<label data-i18n="Title:">Title:</label>
<input type="text" name="title" value="{{title}}">
......
......@@ -222,7 +222,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>cedric.le.ninivin</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.24259.25538.21094</string> </value>
<value> <string>960.50196.61213.58965</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1493732989.43</float>
<float>1500208665.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -6,7 +6,7 @@
function getSearchedString() {
var regex = new RegExp("[\\#?&]search=([^&]*)"),
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) {
......@@ -66,23 +66,43 @@
})
.push(function () {
var search = window.decodeURIComponent(getSearchedString()),
query = "";
query = "",
command = "",
parameter = "",
index;
if (search) {
query = {
query: '(title:"%' + search + '%" OR url_string:"%' + search + '%" OR description:"%' + search + '%") AND portal_type:"' + portal_type + '"',
select_list: ['title', 'url_string', 'description'],
};
if (search.startsWith("!")) {
index = search.indexOf(" ");
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)
.push(function (query_result) {
var result_list_length = query_result.data.rows.length;
// if 0 result, let's search with a real search engine
if (result_list_length === 0 && option.search_engine !== '') {
window.location.href = option.search_engine + window.encodeURIComponent(search);
}
// if 1 result, we go there
else if (result_list_length === 1 && option.auto_redirect === true) {
window.location.href = query_result.data.rows[0].value.url_string;
} else if (result_list_length === 1
&& (option.auto_redirect === true || command !== "")) {
// if 1 result, and redirect or command ,we go there
window.location.href = query_result.data.rows[0].value.url_string
+ parameter;
}
else {
return gadget.getUrlFor({page: "bookmark_list", search: window.encodeURIComponent(search)})
......@@ -91,7 +111,7 @@
});
}
});
}
}
});
})
.onEvent("submit", function () {
......
......@@ -222,7 +222,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>cedric.le.ninivin</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>960.32759.37420.3857</string> </value>
<value> <string>960.50255.3559.58845</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1499162533.71</float>
<float>1500212133.56</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -85,6 +85,9 @@
search_page: 'bookmark_list',
search: options.search,
column_list: [{
select: 'reference',
title: 'Reference'
}, {
select: 'title',
title: 'Title'
}, {
......@@ -96,7 +99,7 @@
}],
query: {
query: 'portal_type:("' + gadget.props.portal_type + '")',
select_list: ['title', 'url_string', 'description'],
select_list: ['reference', 'title', 'url_string', 'description'],
limit: [0, 30],
sort_on: [["modification_date", "descending"]]
}
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>960.50478.26108.37085</string> </value>
<value> <string>960.50482.54730.15138</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1500225770.04</float>
<float>1500225946.73</float>
<string>UTC</string>
</tuple>
</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