Skip to content

Commit

Permalink
[build][xs]: build ckanjs.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
rufuspollock committed Jun 5, 2012
1 parent de704d4 commit 58d60ae
Showing 1 changed file with 52 additions and 9 deletions.
61 changes: 52 additions & 9 deletions pkg/ckanjs.js
Expand Up @@ -264,7 +264,9 @@ this.CKAN.Client = (function (CKAN, $, _, Backbone, undefined) {
});
// TODO: exclude the group we filtered by ...
var groupObjs = _.map(groups, function(groupInfo) {
return self.getGroupById(groupInfo.id);
var group = self.getGroupById(groupInfo.id);
group.set({filtered_dataset_count: groupInfo.count});
return group;
});
return groupObjs;
}
Expand Down Expand Up @@ -629,6 +631,7 @@ CKAN.Model = function ($, _, Backbone, undefined) {
var showdown = new Showdown.converter();
out.descriptionHTML = showdown.makeHtml(description ? description : '');
out.snippet = this.makeSnippet(out.descriptionHTML);
out.dataset_count = this.get('filtered_dataset_count') || this.get('packages').length;
return out;
},

Expand All @@ -641,6 +644,12 @@ CKAN.Model = function ($, _, Backbone, undefined) {
}
});

Model.GroupCollection = Backbone.Collection.extend({
constructor: function GroupCollection(models, options) {
Backbone.Collection.prototype.constructor.apply(this, arguments);
}
});

// Collection for managing results from the CKAN search API. An additional
// `options.total` parameter can be provided on initialisation to
// indicate how many models there are on the server in total. This can
Expand Down Expand Up @@ -683,8 +692,8 @@ CKAN.UI = function($) {
apiKey: ''
};

var config = options.config || defaultConfig;
this.client = new CKAN.Client(config);
this.config = options.config || defaultConfig;
this.client = new CKAN.Client(this.config);
if (options.fixtures && options.fixtures.datasets) {
$.each(options.fixtures.datasets, function(idx, obj) {
var collection = self.client.cache.dataset;
Expand Down Expand Up @@ -718,7 +727,7 @@ CKAN.UI = function($) {

var configView = new CKAN.View.ConfigView({
el: $('#config-page'),
config: config
config: this.config
});
$(document).bind('config:update', function(e, cfg) {
self.client.configure(cfg);
Expand Down Expand Up @@ -822,11 +831,6 @@ CKAN.UI = function($) {
}
});

my.initialize = function(options) {
my.workspace = new my.Workspace(options);
Backbone.history.start()
};

return my;
}(jQuery);

Expand Down Expand Up @@ -1477,6 +1481,45 @@ Handlebars.registerHelper('eachkeys', function(context, options) {
var CKAN = CKAN || {};
CKAN.View = CKAN.View || {};

(function(my, $) {

my.GroupSummaryList = Backbone.View.extend({
className: 'groups list',

template: '\
{{#groups}} \
<div class="span4"> \
<div class="well group summary"> \
<h3> \
{{title}} \
</h3> \
<p>{{snippet}}</p> \
<span class="dataset-count">Datasets {{dataset_count}}</span> \
</div> \
</div> \
{{/groups}} \
',

initialize: function() {
this.el = $(this.el);
_.bindAll(this, 'render');
this.collection.bind('change', this.render);
},

render: function() {
var tmplData = {
groups: this.collection.map(function(x) { return x.toTemplateJSON()})
};
var html = Mustache.render(this.template, tmplData);
this.el.html(html);
}
});

}(CKAN.View, jQuery));

var CKAN = CKAN || {};
CKAN.View = CKAN.View || {};

(function(my, $) {
// Flash a notification message
//
Expand Down

0 comments on commit 58d60ae

Please sign in to comment.