all repos — litestore @ 810802aa9c6a7fb37bd07bac21ba6e2ca69cfa84

A minimalist nosql document store.

Refactored search and Doclist component.
h3rald h3rald@h3rald.com
Sat, 16 May 2015 13:15:35 +0200
commit

810802aa9c6a7fb37bd07bac21ba6e2ca69cfa84

parent

799e26841ae3aca875528bd779a817a2d789019e

M admin/js/components/doclist.jsadmin/js/components/doclist.js

@@ -9,21 +9,22 @@

// Subcomponent app.doclist.panel = { - controller: function(args){ - return { - id: args.id, - tags: args.tags, - content: args.content - }; - }, - - view: function(ctrl){ + /** + * @typedef {Object} DoclistPanelConfig + * @prop {string} id + * @prop {string[]} tags + * @prop {string} content + * + * @param {Function} ctrl + * @param {DoclistPanelConfig} args + */ + view: function(ctrl, args){ var obj = {}; - var path = (ctrl.id.match(/\.html?$/)) ? "/html/" : "/document/view/"; - obj.title = m("a", {href: path+ctrl.id, config: m.route}, [ctrl.id]); + var path = (args.id.match(/\.html?$/)) ? "/html/" : "/document/view/"; + obj.title = m("a", {href: path+args.id, config: m.route}, [args.id]); obj.content = m("div", [ - m("p", [ctrl.content]), - m("p", ctrl.tags.map(function(tag){ + m("p", [args.content]), + m("p", args.tags.map(function(tag){ return w.taglink({name: tag, key: u.guid()}); })) ]);

@@ -31,28 +32,27 @@ return m(".row.search-result", m(".col-md-12", [w.panel(obj)]));

} }; - app.doclist.controller = function(args){ - return { - items: args.items, - title: args.title, - subtitle: args.subtitle, - querydata: args.querydata - }; - }; - - app.doclist.view = function(ctrl){ - var results = m(".row", [m(".col-md-12", ctrl.items.map(function(item){ + /** + * @param {Function} ctrl + * @param {Object} args + * @param {string} args.title + * @param {string} args.subtitle + * @param {array.} args.items + * @param {PaginatorConfig} args.querydata + */ + app.doclist.view = function(ctrl, args){ + var results = m(".row", [m(".col-md-12", args.items.map(function(item){ item.key = u.guid(); return m.component(app.doclist.panel, item); }))]); return m("section", [ - m(".row", [ctrl.title]), - m(".row", [ctrl.subtitle]), - m(".row.text-center", [w.paginator(ctrl.querydata)]), + m(".row", [args.title]), + m(".row", [args.subtitle]), + m(".row.text-center", [w.paginator(args.querydata)]), results, - m(".row.text-center", [w.paginator(ctrl.querydata)]) + m(".row.text-center", [w.paginator(args.querydata)]) ]); }; -}());+}());
M admin/js/components/navbar.jsadmin/js/components/navbar.js

@@ -66,7 +66,6 @@ vm.keySearch = function(el, isInitialized, context){

if (isInitialized) return; $(el).keypress(function(event){ if (isInitialized) return; - m.redraw.strategy("none"); vm.query($(el).val()); if (event.which == 13){ vm.search();

@@ -115,4 +114,4 @@ ])

]); } }; -}());+}());
M admin/js/components/widgets.jsadmin/js/components/widgets.js

@@ -37,12 +37,14 @@ return m.component(panel, obj);

}; /** + * @typedef {Object} PaginatorConfig + * @prop {string} baseurl + * @prop {int} total + * @prop {int} limit + * @prop {int} offset + * * Creates a Paginator component. - * @param {Object} obj - * @param {string} obj.baseurl - * @param {int} obj.total - * @param {int} obj.limit - * @param {int} obj.offset + * @param {PaginatorConfig} obj */ app.widgets.paginator = function(obj) { var paginator = {
M admin/js/modules/search.jsadmin/js/modules/search.js

@@ -36,4 +36,4 @@ };

u.layout(app.search); -}());+}());