Commit 5ac5981d authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

URL-List Add basic Filter

parent 7a3c9ed0
...@@ -18,7 +18,12 @@ ...@@ -18,7 +18,12 @@
<div class="nav_content url_list container"> <div class="nav_content url_list container">
<form class="crib-url-list-content"> <form class="crib-url-list-content">
<h3>URL List</h3> <h3>URL List</h3>
<button type="submit" name="list-contents" class="btn btn-default">Refresh</button> <div class="form-group">
<label>Search:
<input name="search-pattern" class="search-pattern form-control" type="text" size="50" value="">
</label>
<button type="submit" name="list-contents" class="btn btn-default">Search</button>
</div>
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead> <thead>
<tr> <tr>
...@@ -32,9 +37,6 @@ ...@@ -32,9 +37,6 @@
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
<div>
<button type="submit" name="list-contents" class="btn btn-default">Refresh</button>
</div>
</form> </form>
</div> </div>
</body> </body>
......
...@@ -4,24 +4,29 @@ ...@@ -4,24 +4,29 @@
"use strict"; "use strict";
function displayURLList(gadget, event) { function displayURLList(gadget, event) {
var url_list; var url_list = {},
pattern = gadget.props.element.querySelector(".search-pattern").value;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return gadget.crib_sw_allDocs(); return gadget.crib_sw_allDocs();
}) })
.push(function (data) { .push(function (data) {
var promise_list = [], var promise_list = [],
tmp_url_list = [],
url; url;
if (data.hasOwnProperty("urls")) { if (data.hasOwnProperty("urls")) {
url_list = data.urls; tmp_url_list = data.urls;
} else { } else {
url_list = data; tmp_url_list = data;
} }
for (url in url_list) { for (url in tmp_url_list) {
if (url_list.hasOwnProperty(url)) { if (tmp_url_list.hasOwnProperty(url)) {
if (!pattern || (pattern && url.indexOf(pattern) != -1)) {
url_list[url] = "";
promise_list.push(gadget.getUrlFor({page: 'editor', url: url})); promise_list.push(gadget.getUrlFor({page: 'editor', url: url}));
} }
} }
}
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function (url_link_list) { .push(function (url_link_list) {
...@@ -92,6 +97,9 @@ ...@@ -92,6 +97,9 @@
}) })
.declareAcquiredMethod("crib_sw_allDocs", "crib_sw_allDocs") .declareAcquiredMethod("crib_sw_allDocs", "crib_sw_allDocs")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var gadget = this; var gadget = this;
if (options === undefined) if (options === undefined)
...@@ -99,6 +107,17 @@ ...@@ -99,6 +107,17 @@
gadget.props.options = options; gadget.props.options = options;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
if (options.pattern !== undefined) {
return gadget.setSetting("editor-pattern", options.pattern)
.push(function () {
return options.pattern;
});
}
return gadget.getSetting("editor-pattern", "");
})
.push(function (pattern) {
gadget.props.element.querySelector(".search-pattern", options.pattern)
.value = pattern;
return displayURLList(gadget, undefined); return displayURLList(gadget, undefined);
}) })
.push(function () { .push(function () {
...@@ -116,7 +135,13 @@ ...@@ -116,7 +135,13 @@
gadget.props.element.querySelector(".crib-url-list-content"), gadget.props.element.querySelector(".crib-url-list-content"),
'submit', 'submit',
false, false,
function (event) {displayURLList(gadget, event); } function (event) {
gadget.redirect({
page: "url_list",
pattern: gadget.props.element.querySelector(".search-pattern")
.value
});
}
); );
}); });
}); });
......
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