[ckan-changes] commit/ckan: 14 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Sep 12 20:13:33 UTC 2011
14 new changesets in ckan:
http://bitbucket.org/okfn/ckan/changeset/02b66baa84be/
changeset: 02b66baa84be
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 11:15:03
summary: [ux,package/edit][s]: Embedding JSON representation of the dataset into the edit form's header.
affected #: 3 files (173 bytes)
--- a/ckan/controllers/package.py Fri Sep 09 15:56:20 2011 +0100
+++ b/ckan/controllers/package.py Mon Sep 12 10:15:03 2011 +0100
@@ -379,6 +379,7 @@
abort(404, _('Package not found'))
c.pkg = context.get("package")
+ c.pkg_json = json.dumps(data)
try:
check_access('package_update',context)
--- a/ckan/public/scripts/application.js Fri Sep 09 15:56:20 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 10:15:03 2011 +0100
@@ -28,6 +28,7 @@
if (isDatasetEdit) {
// Set up hashtag nagivigation
CKAN.Utils.setupDatasetEditNavigation();
+
// Set up edit table expanding
$('a.resource-expand-link').live('click', function(e) {
e.preventDefault();
@@ -43,6 +44,9 @@
model: null,
el: $el
});
+
+ var _dataset = new CKAN.Model.Dataset(preload_dataset);
+
view.render();
}
});
--- a/ckan/templates/package/edit.html Fri Sep 09 15:56:20 2011 +0100
+++ b/ckan/templates/package/edit.html Mon Sep 12 10:15:03 2011 +0100
@@ -12,6 +12,9 @@
<!-- Flexitable --><script type="text/javascript" src="${g.site_url}/scripts/flexitable.js"></script><link rel="stylesheet" href="${g.site_url}/css/flexitable.css" />
+ <script>
+ var preload_dataset = ${c.pkg_json};
+ </script></py:def><py:match path="primarysidebar">
http://bitbucket.org/okfn/ckan/changeset/ea6ced1501d0/
changeset: ea6ced1501d0
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 13:27:29
summary: [ux,package/edit][s]: Selectively refactored to use Backbone in resource editing process.
affected #: 2 files (2.0 KB)
--- a/ckan/public/scripts/application.js Mon Sep 12 10:15:03 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 12:27:29 2011 +0100
@@ -29,25 +29,14 @@
// Set up hashtag nagivigation
CKAN.Utils.setupDatasetEditNavigation();
- // Set up edit table expanding
- $('a.resource-expand-link').live('click', function(e) {
- e.preventDefault();
- $tr = $(e.target).closest('.resource-summary');
- $tr.find('a.resource-expand-link').toggle();
- $tr.find('.resource-summary').toggle();
- $tr.find('.resource-expanded').toggle();
- });
-
- // Create Backbone view for adding resources
- var $el=$('.resource-add');
- var view=new CKAN.View.ResourceAdd({
- model: null,
+ var _dataset = new CKAN.Model.Dataset(preload_dataset);
+ var $el=$('form#dataset-edit');
+ var view=new CKAN.View.DatasetEdit({
+ model: _dataset,
el: $el
});
+ view.render();
- var _dataset = new CKAN.Model.Dataset(preload_dataset);
-
- view.render();
}
});
}(jQuery));
@@ -410,9 +399,106 @@
});
+CKAN.View.DatasetEdit = Backbone.View.extend({
+ initialize: function() {
+ _.bindAll(this, 'render');
+
+ // Create Backbone view for adding resources
+ var $el=this.el.find('.resource-add');
+ var view=new CKAN.View.ResourceAdd({
+ collection: this.model.get('resources'),
+ el: $el
+ });
+ view.render();
+
+ // Create Resource Edit list
+ var $el=this.el.find('.resource-table.edit');
+ var view=new CKAN.View.ResourceEditList({
+ collection: this.model.get('resources'),
+ el: $el
+ });
+
+ // Set up edit table expanding
+ this.el.find('a.resource-expand-link').live('click', function(e) {
+ e.preventDefault();
+ $tr = $(e.target).closest('.resource-summary');
+ $tr.find('a.resource-expand-link').toggle();
+ $tr.find('.resource-summary').toggle();
+ $tr.find('.resource-expanded').toggle();
+ });
+ },
+
+ render: function() {
+ },
+
+ events: {
+ }
+
+});
+
+
+CKAN.View.ResourceEditList = Backbone.View.extend({
+ initialize: function() {
+ _.bindAll(this, 'render');
+ this.collection.bind('add', this.render);
+ this.subViews = [];
+ },
+
+ render: function() {
+ var self = this;
+
+ // TODO sort out your iteration methods
+ $.each(this.subViews, function(idx,view) {
+ view.remove();
+ });
+ // Have to trash entire content; some stuff was there on page load
+ this.el.find('tbody').empty();
+
+ this.subViews = [];
+ this.collection.each(function(resource, idx) {
+ // TODO tidy up so the view creates its own elements
+ var $tr = $('<tr />');
+ $tr.addClass('resource-summary');
+ self.el.find('tbody').append($tr);
+ var _view = new CKAN.View.ResourceEdit({
+ model: resource,
+ el: $tr,
+ position: idx
+ });
+ _view.render();
+ self.subViews.push(_view);
+ });
+ },
+
+ events: {
+
+ }
+});
+
+CKAN.View.ResourceEdit = Backbone.View.extend({
+ initialize: function() {
+ _.bindAll(this, 'render');
+ this.position = this.options.position;
+ },
+
+ render: function() {
+ var tmplData = {
+ resource: this.model.toTemplateJSON(),
+ num: this.position
+ };
+ var $newRow = $.tmpl(CKAN.Templates.resourceEntry, tmplData);
+ this.el.html($newRow);
+
+ },
+
+ events: {
+
+ }
+});
+
CKAN.View.ResourceAdd = Backbone.View.extend({
initialize: function() {
- _.bindAll(this, 'render');
+ _.bindAll(this, 'render', 'addNewResource');
},
render: function() {
@@ -435,6 +521,7 @@
clickAdd: function(e) {
e.preventDefault();
+
var action = $(e.target).attr('action');
this.el.find('.tabs a').removeClass('selected');
this.el.find('.tabs a[action='+action+']').addClass('selected');
@@ -445,7 +532,6 @@
this.el.append($subPane);
var resource = new CKAN.Model.Resource({
- 'dataset': this.model
});
resource.bind('change', this.addNewResource);
// Open sub-pane
@@ -471,6 +557,11 @@
},
addNewResource: function(resource) {
+ this.collection.add(resource);
+ return;
+
+ // TODO old code:
+
var maxId = 0;
var ids = $.map($('.resource-table').find('input'), function(item, idx) {
var thisId = parseInt($(item).attr('name').split('__')[1]);
--- a/ckan/public/scripts/templates.js Mon Sep 12 10:15:03 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 12:27:29 2011 +0100
@@ -73,43 +73,41 @@
CKAN.Templates.resourceEntry = ' \
- <tr class="resource-summary"> \
- <td class="resource-expand-link"> \
- <a class="resource-expand-link" href="#"><img src="/images/icons/edit-expand.png" /></a> \
- <a class="resource-expand-link" href="#" style="display: none;"><img src="/images/icons/edit-collapse.png" /></a> \
- </td> \
- <td class="resource-summary resource-url"> \
- ${resource.url} \
- </td> \
- <td class="resource-summary resource-format"> \
- ${resource.format} \
- </td> \
- <td class="resource-summary resource-description"> \
- ${resource.description} \
- </td> \
- <td class="resource-expanded" colspan="3" style="display: none;"> \
- <dl> \
- <dt><label class="field_opt">Url</label></dt> \
- <dd> \
- <input name="resources__${num}__url" type="text" value="${resource.url}" class="long" /> \
- </dd> \
- <dt><label class="field_opt">Format</label></dt> \
- <dd> \
- <input name="resources__${num}__format" type="text" value="${resource.format}" class="long" /> \
- </dd> \
- <dt><label class="field_opt">Description</label></dt> \
- <dd> \
- <input name="resources__${num}__description" type="text" value="${resource.description}" class="long" /> \
- </dd> \
- <dt><label class="field_opt">Hash</label></dt> \
- <dd> \
- <input name="resources__${num}__hash" type="text" value="${resource.hash}" class="long" /> \
- </dd> \
- <dt><label class="field_opt">Id</label></dt> \
- <dd> \
- <input name="resources__${num}__id" disabled="disabled" type="text" value="${resource.id}" class="long disabled" /> \
- </dd> \
- </dl> \
- </td> \
- </tr> \
+ <td class="resource-expand-link"> \
+ <a class="resource-expand-link" href="#"><img src="/images/icons/edit-expand.png" /></a> \
+ <a class="resource-expand-link" href="#" style="display: none;"><img src="/images/icons/edit-collapse.png" /></a> \
+ </td> \
+ <td class="resource-summary resource-url"> \
+ ${resource.url} \
+ </td> \
+ <td class="resource-summary resource-format"> \
+ ${resource.format} \
+ </td> \
+ <td class="resource-summary resource-description"> \
+ ${resource.description} \
+ </td> \
+ <td class="resource-expanded" colspan="3" style="display: none;"> \
+ <dl> \
+ <dt><label class="field_opt">Url</label></dt> \
+ <dd> \
+ <input name="resources__${num}__url" type="text" value="${resource.url}" class="long" /> \
+ </dd> \
+ <dt><label class="field_opt">Format</label></dt> \
+ <dd> \
+ <input name="resources__${num}__format" type="text" value="${resource.format}" class="long" /> \
+ </dd> \
+ <dt><label class="field_opt">Description</label></dt> \
+ <dd> \
+ <input name="resources__${num}__description" type="text" value="${resource.description}" class="long" /> \
+ </dd> \
+ <dt><label class="field_opt">Hash</label></dt> \
+ <dd> \
+ <input name="resources__${num}__hash" type="text" value="${resource.hash}" class="long" /> \
+ </dd> \
+ <dt><label class="field_opt">Id</label></dt> \
+ <dd> \
+ <input name="resources__${num}__id" disabled="disabled" type="text" value="${resource.id}" class="long disabled" /> \
+ </dd> \
+ </dl> \
+ </td> \
';
http://bitbucket.org/okfn/ckan/changeset/754d595b3cba/
changeset: 754d595b3cba
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 13:39:31
summary: [ux,package/edit][s]: Minor refactor; glitchfixing edit form ui
affected #: 1 file (478 bytes)
--- a/ckan/public/scripts/application.js Mon Sep 12 12:27:29 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 12:39:31 2011 +0100
@@ -498,7 +498,7 @@
CKAN.View.ResourceAdd = Backbone.View.extend({
initialize: function() {
- _.bindAll(this, 'render', 'addNewResource');
+ _.bindAll(this, 'render', 'addNewResource', 'reset');
},
render: function() {
@@ -509,30 +509,29 @@
'click input[name=reset]': 'reset'
},
- reset: function(e) {
- e.preventDefault();
+ reset: function() {
this.el.find('.tabs a').removeClass('selected');
- this.deleteSubpane();
- },
-
- deleteSubpane: function() {
- this.el.find('.resource-add-subpane').remove();
+ if (this.subView != null) {
+ this.subView.remove();
+ this.subView = null;
+ }
+ return false;
},
clickAdd: function(e) {
e.preventDefault();
+ this.reset();
+
var action = $(e.target).attr('action');
this.el.find('.tabs a').removeClass('selected');
this.el.find('.tabs a[action='+action+']').addClass('selected');
- this.deleteSubpane();
-
var $subPane = $('<div />').addClass('resource-add-subpane');
this.el.append($subPane);
- var resource = new CKAN.Model.Resource({
- });
+ var resource = new CKAN.Model.Resource({});
+
resource.bind('change', this.addNewResource);
// Open sub-pane
if (action=='upload-file') {
@@ -553,26 +552,11 @@
});
}
this.subView.render();
- return false;
},
addNewResource: function(resource) {
this.collection.add(resource);
- return;
-
- // TODO old code:
-
- var maxId = 0;
- var ids = $.map($('.resource-table').find('input'), function(item, idx) {
- var thisId = parseInt($(item).attr('name').split('__')[1]);
- maxId=Math.max(maxId, thisId);
- });
- var tmplData = {
- resource: resource.toTemplateJSON(),
- num: maxId+1
- };
- var $newRow = $.tmpl(CKAN.Templates.resourceEntry, tmplData);
- $('.resource-table tbody').append($newRow);
+ this.reset();
}
});
http://bitbucket.org/okfn/ckan/changeset/3f68645b2b2a/
changeset: 3f68645b2b2a
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 14:31:59
summary: [ux,package/new][s]: Correctly reflecting changes in the resource form in the summary view.
affected #: 2 files (1.0 KB)
--- a/ckan/public/scripts/application.js Mon Sep 12 12:39:31 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 13:31:59 2011 +0100
@@ -405,30 +405,24 @@
// Create Backbone view for adding resources
var $el=this.el.find('.resource-add');
- var view=new CKAN.View.ResourceAdd({
+ this.addView=new CKAN.View.ResourceAdd({
collection: this.model.get('resources'),
el: $el
});
- view.render();
// Create Resource Edit list
var $el=this.el.find('.resource-table.edit');
- var view=new CKAN.View.ResourceEditList({
+ this.resourceList=new CKAN.View.ResourceEditList({
collection: this.model.get('resources'),
el: $el
});
-
- // Set up edit table expanding
- this.el.find('a.resource-expand-link').live('click', function(e) {
- e.preventDefault();
- $tr = $(e.target).closest('.resource-summary');
- $tr.find('a.resource-expand-link').toggle();
- $tr.find('.resource-summary').toggle();
- $tr.find('.resource-expanded').toggle();
- });
+
+ this.render();
},
render: function() {
+ this.addView.render();
+ this.resourceList.render();
},
events: {
@@ -477,8 +471,11 @@
CKAN.View.ResourceEdit = Backbone.View.extend({
initialize: function() {
- _.bindAll(this, 'render');
+ _.bindAll(this, 'render', 'toggleExpanded');
+ this.model.bind('change', this.render);
this.position = this.options.position;
+
+ this.expanded = false;
},
render: function() {
@@ -489,11 +486,55 @@
var $newRow = $.tmpl(CKAN.Templates.resourceEntry, tmplData);
this.el.html($newRow);
+ if (this.expanded) {
+ this.el.find('a.resource-expand-link').hide();
+ this.el.find('.resource-summary').hide();
+ }
+ else {
+ this.el.find('a.resource-collapse-link').hide();
+ this.el.find('.resource-expanded').hide();
+ }
},
events: {
+ 'click a.resource-expand-link': 'toggleExpanded',
+ 'click a.resource-collapse-link': 'toggleExpanded'
+ },
+ saveData: function() {
+ this.model.set(this.getData(), {
+ error: function(model, error) {
+ var msg = 'Failed to save, possibly due to invalid data ';
+ msg += JSON.stringify(error);
+ alert(msg);
+ }
+ });
+ return false;
+ },
+
+ getData: function() {
+ var _data = $(this.el).find('input').serializeArray();
+ modelData = {};
+ $.each(_data, function(idx, value) {
+ modelData[value.name.split('__')[2]] = value.value
+ });
+ return modelData;
+ },
+
+ toggleExpanded: function(e) {
+ e.preventDefault();
+
+ this.expanded = !this.expanded;
+ // Closing the form; update the model fields
+ if (!this.expanded) {
+ this.saveData();
+ // Model might not have changed
+ this.render();
+ } else {
+ this.render();
+ }
}
+
});
CKAN.View.ResourceAdd = Backbone.View.extend({
--- a/ckan/public/scripts/templates.js Mon Sep 12 12:39:31 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 13:31:59 2011 +0100
@@ -75,7 +75,7 @@
CKAN.Templates.resourceEntry = ' \
<td class="resource-expand-link"> \
<a class="resource-expand-link" href="#"><img src="/images/icons/edit-expand.png" /></a> \
- <a class="resource-expand-link" href="#" style="display: none;"><img src="/images/icons/edit-collapse.png" /></a> \
+ <a class="resource-collapse-link" href="#"><img src="/images/icons/edit-collapse.png" /></a> \
</td> \
<td class="resource-summary resource-url"> \
${resource.url} \
@@ -86,7 +86,7 @@
<td class="resource-summary resource-description"> \
${resource.description} \
</td> \
- <td class="resource-expanded" colspan="3" style="display: none;"> \
+ <td class="resource-expanded" colspan="3"> \
<dl> \
<dt><label class="field_opt">Url</label></dt> \
<dd> \
http://bitbucket.org/okfn/ckan/changeset/69e13831788b/
changeset: 69e13831788b
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 15:50:20
summary: [ux,package/edit][s]: Fix bug. Add then edit resource had problems.
affected #: 1 file (136 bytes)
--- a/ckan/public/scripts/application.js Mon Sep 12 13:31:59 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 14:50:20 2011 +0100
@@ -571,14 +571,14 @@
var $subPane = $('<div />').addClass('resource-add-subpane');
this.el.append($subPane);
- var resource = new CKAN.Model.Resource({});
+ var tempResource = new CKAN.Model.Resource({});
- resource.bind('change', this.addNewResource);
+ tempResource.bind('change', this.addNewResource);
// Open sub-pane
if (action=='upload-file') {
this.subView = new CKAN.View.ResourceUpload({
el: $subPane,
- model: resource,
+ model: tempResource,
// TODO: horrible reverse depedency ...
client: CKAN.UI.workspace.client
});
@@ -586,7 +586,7 @@
else if (action=='link-file' || action=='link-api') {
this.subView = new CKAN.View.ResourceAddLink({
el: $subPane,
- model: resource,
+ model: tempResource,
mode: (action=='link-file')? 'file' : 'api',
// TODO: horrible reverse depedency ...
client: CKAN.UI.workspace.client
@@ -595,7 +595,10 @@
this.subView.render();
},
- addNewResource: function(resource) {
+ addNewResource: function(tempResource) {
+ // Deep-copy the tempResource we had bound to
+ var resource=new CKAN.Model.Resource(tempResource.toJSON());
+
this.collection.add(resource);
this.reset();
}
http://bitbucket.org/okfn/ckan/changeset/4021b7800024/
changeset: 4021b7800024
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 16:24:50
summary: [ux,package/edit][s]: Resources flag themselves as having unsaved changes.
affected #: 3 files (452 bytes)
--- a/ckan/public/scripts/application.js Mon Sep 12 14:50:20 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 15:24:50 2011 +0100
@@ -433,49 +433,53 @@
CKAN.View.ResourceEditList = Backbone.View.extend({
initialize: function() {
- _.bindAll(this, 'render');
- this.collection.bind('add', this.render);
- this.subViews = [];
+ _.bindAll(this, 'render', 'addRow');
+ this.collection.bind('add', this.addRow);
},
render: function() {
var self = this;
- // TODO sort out your iteration methods
- $.each(this.subViews, function(idx,view) {
- view.remove();
- });
// Have to trash entire content; some stuff was there on page load
this.el.find('tbody').empty();
-
- this.subViews = [];
- this.collection.each(function(resource, idx) {
- // TODO tidy up so the view creates its own elements
- var $tr = $('<tr />');
- $tr.addClass('resource-summary');
- self.el.find('tbody').append($tr);
- var _view = new CKAN.View.ResourceEdit({
- model: resource,
- el: $tr,
- position: idx
- });
- _view.render();
- self.subViews.push(_view);
+ this.collection.each(this.addRow);
+ },
+
+ nextIndex: function() {
+ var maxId=-1;
+ this.el.find('input').each(function(idx,input) {
+ var myId = parseInt($(input).attr('name').split('__')[1])
+ maxId = Math.max(myId, maxId);
});
+ return maxId+1;
+ },
+
+ addRow: function(resource) {
+ // TODO tidy up so the view creates its own elements
+ var $tr = $('<tr />');
+ this.el.find('tbody').append($tr);
+ var _view = new CKAN.View.ResourceEdit({
+ model: resource,
+ el: $tr,
+ position: this.nextIndex()
+ });
+ _view.render();
},
events: {
-
}
});
CKAN.View.ResourceEdit = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'render', 'toggleExpanded');
+ var self = this;
+ this.model.bind('change', function() { self.hasChanged=true; });
this.model.bind('change', this.render);
this.position = this.options.position;
- this.expanded = false;
+ this.expanded = this.model.isNew();
+ this.hasChanged = this.model.isNew();
},
render: function() {
@@ -494,6 +498,10 @@
this.el.find('a.resource-collapse-link').hide();
this.el.find('.resource-expanded').hide();
}
+
+ if (!this.hasChanged) {
+ this.el.find('span.resource-is-changed').hide();
+ }
},
events: {
--- a/ckan/public/scripts/templates.js Mon Sep 12 14:50:20 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 15:24:50 2011 +0100
@@ -110,4 +110,7 @@
</dd> \
</dl> \
</td> \
+ <td class="resource-is-changed"> \
+ <span class="resource-is-changed">!!!</span> \
+ </td> \
';
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 14:50:20 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 15:24:50 2011 +0100
@@ -79,6 +79,7 @@
<th class="field_req resource-url">URL*</th><th class="field_opt resource-format">Format</th><th class="field_opt resource-description">Description</th>
+ <th class="field_opt resource-is-changed"></th></tr></thead><tbody>
@@ -121,6 +122,8 @@
</dd></dl></td>
+ <td class="resource-is-changed">
+ </td></tr></py:for></tbody>
http://bitbucket.org/okfn/ckan/changeset/f8a6bcf15422/
changeset: f8a6bcf15422
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 16:36:25
summary: [ux,package/edit][s]: Lovely plus sign when a resource is modified.
affected #: 3 files (173 bytes)
--- a/ckan/public/css/style.css Mon Sep 12 15:24:50 2011 +0100
+++ b/ckan/public/css/style.css Mon Sep 12 15:36:25 2011 +0100
@@ -785,6 +785,11 @@
padding-top: 6px;
text-align: center;
}
+th.resource-is-changed, td.resource-is-changed {
+ text-align: center;
+ padding: 8px 0 0 0;
+ width: 20px;
+}
/* ====================== */
/* = Add Resources Page = */
/* ====================== */
--- a/ckan/public/scripts/application.js Mon Sep 12 15:24:50 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 15:36:25 2011 +0100
@@ -500,7 +500,7 @@
}
if (!this.hasChanged) {
- this.el.find('span.resource-is-changed').hide();
+ this.el.find('img.resource-is-changed').hide();
}
},
--- a/ckan/public/scripts/templates.js Mon Sep 12 15:24:50 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 15:36:25 2011 +0100
@@ -111,6 +111,6 @@
</dl> \
</td> \
<td class="resource-is-changed"> \
- <span class="resource-is-changed">!!!</span> \
+ <img src="/images/icons/add.png" title="This resource has unsaved changes." class="resource-is-changed" /> \
</td> \
';
http://bitbucket.org/okfn/ckan/changeset/641c0ea30364/
changeset: 641c0ea30364
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 16:45:52
summary: [ux,package/edit][xs]: Hide the id field.
affected #: 2 files (36 bytes)
--- a/ckan/public/scripts/templates.js Mon Sep 12 15:36:25 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 15:45:52 2011 +0100
@@ -106,7 +106,7 @@
</dd> \
<dt><label class="field_opt">Id</label></dt> \
<dd> \
- <input name="resources__${num}__id" disabled="disabled" type="text" value="${resource.id}" class="long disabled" /> \
+ <input name="resources__${num}__id" type="hidden" value="${resource.id}" class="long disabled" /> \
</dd> \
</dl> \
</td> \
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 15:36:25 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 15:45:52 2011 +0100
@@ -118,7 +118,7 @@
</dd><dt><label class="field_opt">Id</label></dt><dd>
- <input name="resources__${num}__id" disabled="disabled" type="text" value="${res.get('id', '')}" class="long disabled" />
+ <input name="resources__${num}__id" type="hidden" value="${res.get('id', '')}" class="long disabled" /></dd></dl></td>
http://bitbucket.org/okfn/ckan/changeset/956e0805be91/
changeset: 956e0805be91
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 17:03:54
summary: [ux,package/edit][s]: More core fields in the expanded view (not yet linked to db)
affected #: 2 files (1.5 KB)
--- a/ckan/public/scripts/templates.js Mon Sep 12 15:45:52 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 16:03:54 2011 +0100
@@ -92,6 +92,26 @@
<dd> \
<input name="resources__${num}__url" type="text" value="${resource.url}" class="long" /> \
</dd> \
+ <dt>Type</dt> \
+ <dd> \
+ ${resource.type} \
+ </dd> \
+ <dt>Mimetype</dt> \
+ <dd> \
+ ${resource.mimetype} \
+ </dd> \
+ <dt>Mimetype-inner</dt> \
+ <dd> \
+ ${resource.mimetypeInner} \
+ </dd> \
+ <dt>Size</dt> \
+ <dd> \
+ ${resource.size} \
+ </dd> \
+ <dt>Last Modified</dt> \
+ <dd> \
+ ${resource.lastModified} \
+ </dd> \
<dt><label class="field_opt">Format</label></dt> \
<dd> \
<input name="resources__${num}__format" type="text" value="${resource.format}" class="long" /> \
@@ -104,11 +124,8 @@
<dd> \
<input name="resources__${num}__hash" type="text" value="${resource.hash}" class="long" /> \
</dd> \
- <dt><label class="field_opt">Id</label></dt> \
- <dd> \
- <input name="resources__${num}__id" type="hidden" value="${resource.id}" class="long disabled" /> \
- </dd> \
</dl> \
+ <input name="resources__${num}__id" type="hidden" value="${resource.id}" class="long disabled" /> \
</td> \
<td class="resource-is-changed"> \
<img src="/images/icons/add.png" title="This resource has unsaved changes." class="resource-is-changed" /> \
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 15:45:52 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 16:03:54 2011 +0100
@@ -98,30 +98,6 @@
<td class="resource-summary resource-description">
${res.get('description', '')}
</td>
- <td class="resource-expanded" colspan="3" style="display: none;">
- <dl>
- <dt><label class="field_opt">Url</label></dt>
- <dd>
- <input name="resources__${num}__url" type="text" value="${res.get('url', '')}" class="long" />
- </dd>
- <dt><label class="field_opt">Format</label></dt>
- <dd>
- <input name="resources__${num}__format" type="text" value="${res.get('format', '')}" class="long" />
- </dd>
- <dt><label class="field_opt">Description</label></dt>
- <dd>
- <input name="resources__${num}__description" type="text" value="${res.get('description', '')}" class="long" />
- </dd>
- <dt><label class="field_opt">Hash</label></dt>
- <dd>
- <input name="resources__${num}__hash" type="text" value="${res.get('hash', '')}" class="long" />
- </dd>
- <dt><label class="field_opt">Id</label></dt>
- <dd>
- <input name="resources__${num}__id" type="hidden" value="${res.get('id', '')}" class="long disabled" />
- </dd>
- </dl>
- </td><td class="resource-is-changed"></td></tr>
http://bitbucket.org/okfn/ckan/changeset/04c0af26e5b6/
changeset: 04c0af26e5b6
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 17:06:03
summary: [ux][s]: Stripped flexitable from the system.
affected #: 4 files (406 bytes)
--- a/ckan/templates/package/edit.html Mon Sep 12 16:03:54 2011 +0100
+++ b/ckan/templates/package/edit.html Mon Sep 12 16:06:03 2011 +0100
@@ -9,9 +9,6 @@
<py:def function="body_class">hide-sidebar</py:def><py:def function="optional_head">
- <!-- Flexitable -->
- <script type="text/javascript" src="${g.site_url}/scripts/flexitable.js"></script>
- <link rel="stylesheet" href="${g.site_url}/css/flexitable.css" /><script>
var preload_dataset = ${c.pkg_json};
</script>
--- a/ckan/templates/package/form_extra_fields.html Mon Sep 12 16:03:54 2011 +0100
+++ b/ckan/templates/package/form_extra_fields.html Mon Sep 12 16:06:03 2011 +0100
@@ -32,7 +32,7 @@
</py:for></dl><!--
- <table class="flexitable">
+ <table><thead><tr><th>Key</th><th>Value</th></tr></thead>
--- a/ckan/templates/package/form_resources.html Mon Sep 12 16:03:54 2011 +0100
+++ b/ckan/templates/package/form_resources.html Mon Sep 12 16:06:03 2011 +0100
@@ -1,6 +1,6 @@
<table xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude"
- class="flexitable">
+ ><thead><tr>
--- a/ckan/templates/package/new.html Mon Sep 12 16:03:54 2011 +0100
+++ b/ckan/templates/package/new.html Mon Sep 12 16:06:03 2011 +0100
@@ -13,10 +13,6 @@
<script type="text/javascript" src="${g.site_url}/scripts/reveal_instructions.js"></script><link rel="stylesheet" href="${g.site_url}/css/reveal_instructions.css" />
- <!-- Flexitable -->
- <script type="text/javascript" src="${g.site_url}/scripts/flexitable.js"></script>
- <link rel="stylesheet" href="${g.site_url}/css/flexitable.css" />
-
<!-- Auto-generate 'name' field --><script type="text/javascript">
jQuery(document).ready(function($) {
http://bitbucket.org/okfn/ckan/changeset/692b4a274a5b/
changeset: 692b4a274a5b
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 18:05:28
summary: [ux][s]: Can't leave the page accidently.
affected #: 3 files (494 bytes)
--- a/ckan/public/scripts/application.js Mon Sep 12 16:06:03 2011 +0100
+++ b/ckan/public/scripts/application.js Mon Sep 12 17:05:28 2011 +0100
@@ -36,7 +36,6 @@
el: $el
});
view.render();
-
}
});
}(jQuery));
@@ -403,6 +402,22 @@
initialize: function() {
_.bindAll(this, 'render');
+ var boundToUnload = false;
+ this.el.change(function() {
+ if (!boundToUnload) {
+ boundToUnload = true;
+ window.onbeforeunload = function () {
+ return "You have unsaved changes. Hit Save Changes at the bottom of the page to submit them.";
+ };
+ }
+ });
+ this.el.submit(function() {
+ // Don't stop us leaving
+ window.onbeforeunload = null;
+ });
+
+
+
// Create Backbone view for adding resources
var $el=this.el.find('.resource-add');
this.addView=new CKAN.View.ResourceAdd({
@@ -418,8 +433,10 @@
});
this.render();
+
},
+
render: function() {
this.addView.render();
this.resourceList.render();
--- a/ckan/public/scripts/templates.js Mon Sep 12 16:06:03 2011 +0100
+++ b/ckan/public/scripts/templates.js Mon Sep 12 17:05:28 2011 +0100
@@ -102,7 +102,7 @@
</dd> \
<dt>Mimetype-inner</dt> \
<dd> \
- ${resource.mimetypeInner} \
+ ${resource.mimetype_inner} \
</dd> \
<dt>Size</dt> \
<dd> \
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 16:06:03 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 17:05:28 2011 +0100
@@ -227,7 +227,6 @@
under the <a href="http://opendatacommons.org/licenses/odbl/1.0/">Open Database License</a>. Please <strong>refrain</strong> from editing this page if you are <strong>not</strong> happy to do this.
</p><input id="save" class="pretty primary" name="save" type="submit" value="Save Changes" />
- <input id="cancel" class="pretty" name="cancel" type="reset" value="Cancel" /></div>
http://bitbucket.org/okfn/ckan/changeset/40e35377f590/
changeset: 40e35377f590
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 18:11:10
summary: [ux,test][s]: Tiny fix to restore tests passing.
affected #: 1 file (1.1 KB)
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 17:05:28 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 17:11:10 2011 +0100
@@ -98,6 +98,30 @@
<td class="resource-summary resource-description">
${res.get('description', '')}
</td>
+ <td class="resource-expanded" colspan="3" style="display: none;">
+ <dl>
+ <dt><label class="field_opt">Url</label></dt>
+ <dd>
+ <input name="resources__${num}__url" type="text" value="${res.get('url', '')}" class="long" />
+ </dd>
+ <dt><label class="field_opt">Format</label></dt>
+ <dd>
+ <input name="resources__${num}__format" type="text" value="${res.get('format', '')}" class="long" />
+ </dd>
+ <dt><label class="field_opt">Description</label></dt>
+ <dd>
+ <input name="resources__${num}__description" type="text" value="${res.get('description', '')}" class="long" />
+ </dd>
+ <dt><label class="field_opt">Hash</label></dt>
+ <dd>
+ <input name="resources__${num}__hash" type="text" value="${res.get('hash', '')}" class="long" />
+ </dd>
+ <dt><label class="field_opt">Id</label></dt>
+ <dd>
+ <input name="resources__${num}__id" type="hidden" value="${res.get('id', '')}" class="long disabled" />
+ </dd>
+ </dl>
+ </td><td class="resource-is-changed"></td></tr>
http://bitbucket.org/okfn/ckan/changeset/f9bee5c66710/
changeset: f9bee5c66710
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 18:37:47
summary: [ux,package/new][s]: Massively simplified the form. Removed description;tags;homepage using CSS.
affected #: 2 files (1.2 KB)
--- a/ckan/public/css/style.css Mon Sep 12 17:11:10 2011 +0100
+++ b/ckan/public/css/style.css Mon Sep 12 17:37:47 2011 +0100
@@ -798,6 +798,38 @@
width: 60%;
}
+body.package.new dt.homepage-label,
+body.package.new dd.homepage-field,
+body.package.new dd.homepage-instructions
+{
+ display: none;
+}
+body.package.new dt.tags-label,
+body.package.new dd.tags-field,
+body.package.new dd.tags-instructions
+{
+ display: none;
+}
+body.package.new dt.description-label,
+body.package.new dd.description-field,
+body.package.new dd.description-instructions
+{
+ display: none;
+}
+
+body.package.new dt.name-label {
+ font-size: 10px;
+}
+
+body.package.new .instructions {
+ font-size: 10px;
+}
+
+body.package.new input#name {
+ font-size: 8px;
+
+ background: #eee;
+}
/* =============================== */
--- a/ckan/templates/package/new_package_form.html Mon Sep 12 17:11:10 2011 +0100
+++ b/ckan/templates/package/new_package_form.html Mon Sep 12 17:37:47 2011 +0100
@@ -15,32 +15,32 @@
<fieldset id="basic-information"><dl>
- <dt><label class="field_opt" for="title">Title</label></dt>
- <dd><input id="title" name="title" type="text" value="${data.get('title', '')}"/></dd>
- <dd class="instructions basic">A short descriptive title for the dataset.</dd>
- <dd class="instructions further">It should not be a description though - save that for the Notes field. Do not give a trailing full stop.</dd>
- <dd class="field_error" py:if="errors.get('title', '')">${errors.get('title', '')}</dd>
+ <dt class="title-label"><label class="field_opt" for="title">Title</label></dt>
+ <dd class="title-field"><input id="title" tabindex="1" name="title" type="text" value="${data.get('title', '')}"/></dd>
+ <dd class="title-instructions instructions basic">A short descriptive title for the dataset.</dd>
+ <dd class="title-instructions instructions further">It should not be a description though - save that for the Notes field. Do not give a trailing full stop.</dd>
+ <dd class="title-instructions field_error" py:if="errors.get('title', '')">${errors.get('title', '')}</dd>
- <dt><label class="field_req" for="name">Name *</label></dt>
- <dd><input id="name" maxlength="100" name="name" type="text" value="${data.get('name', '')}" /></dd>
- <dd class="instructions basic">A unique identifier for the dataset.</dd>
- <dd class="instructions further">It should be broadly humanly readable, in the spirit of Semantic Web URIs. Only use an acronym if it is widely recognised. Renaming is possible but discouraged.</dd>
- <dd class="hints">2+ characters, lowercase, using only 'a-z0-9' and '-_'</dd>
- <dd class="field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</dd>
+ <dt class="name-label"><label class="field_req" for="name">Slug *</label></dt>
+ <dd class="name-field"><input id="name" tabindex="999" maxlength="100" name="name" type="text" value="${data.get('name', '')}" /></dd>
+ <dd class="name-instructions instructions basic">A unique identifier for the dataset.</dd>
+ <dd class="name-instructions instructions further">It should be broadly humanly readable, in the spirit of Semantic Web URIs. Only use an acronym if it is widely recognised. Renaming is possible but discouraged.</dd>
+ <dd class="name-instructions hints">2+ characters, lowercase, using only 'a-z0-9' and '-_'</dd>
+ <dd class="name-instructions field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</dd>
- <dt><label class="field_opt" for="url">Home Page</label></dt>
- <dd><input id="url" name="url" type="text" value="${data.get('url', '')}"/></dd>
- <dd class="instructions basic">The URL for the web page describing the data (not the data itself).</dd>
- <dd class="hints">e.g. http://www.example.com/growth-figures.html</dd>
- <dd class="field_error" py:if="errors.get('url', '')">${errors.get('url', '')}</dd>
+ <dt class="homepage-label"><label class="field_opt" for="url">Home Page</label></dt>
+ <dd class="homepage-field"><input id="url" tabindex="2" name="url" type="text" value="${data.get('url', '')}"/></dd>
+ <dd class="homepage-instructions instructions basic">The URL for the web page describing the data (not the data itself).</dd>
+ <dd class="homepage-instructions hints">e.g. http://www.example.com/growth-figures.html</dd>
+ <dd class="homepage-instructions field_error" py:if="errors.get('url', '')">${errors.get('url', '')}</dd>
- <dt><label class="field_opt" for="notes">Description</label></dt>
- <dd><div class="markdown-editor">
+ <dt class="description-label"><label class="field_opt" for="notes">Description</label></dt>
+ <dd class="description-field"><div class="markdown-editor"><ul class="tabs"><li><a href="#" action="write" class="selected">Write</a></li><li><a href="#" action="preview">Preview</a></li></ul>
- <textarea class="markdown-input" name="notes" id="notes" placeholder="Start with a summary sentence ...">${data.get('notes','')}</textarea>
+ <textarea class="markdown-input" tabindex="3" name="notes" id="notes" placeholder="Start with a summary sentence ...">${data.get('notes','')}</textarea><div class="markdown-preview" style="display: none;"></div><span class="hints">You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> here.</span><!--
@@ -49,24 +49,24 @@
--></div></dd>
- <dt><label class="field_opt" for="license_id">Licence</label></dt>
- <dd>
- <select id="license_id" name="license_id">
+ <dt class="license-label"><label class="field_opt" for="license_id">License</label></dt>
+ <dd class="license-field">
+ <select id="license_id" tabindex="4" name="license_id"><py:for each="licence_desc, licence_id in c.licences"><option value="${licence_id}" py:attrs="{'selected': 'selected' if data.get('license_id', '') == licence_id else None}" >${licence_desc}</option></py:for></select></dd>
- <dd class="instructions basic">The licence under which the dataset is released.</dd>
+ <dd class="license-instructions instructions basic">The licence under which the dataset is released.</dd>
- <dt><label class="field_opt" for="tags">Tags</label></dt>
- <dd>
- <input class="long autocomplete-tag" id="tag_string" name="tag_string" size="60" type="text"
+ <dt class="tags-label"><label class="field_opt" for="tags">Tags</label></dt>
+ <dd class="tags-field">
+ <input class="long autocomplete-tag" tabindex="5" id="tag_string" name="tag_string" size="60" type="text"
value="${data.get('tag_string') or ' '.join([tag['name'] for tag in data.get('tags', [])])}" /></dd>
- <dd class="instructions basic">Terms that may link this dataset to similar ones. For more information on conventions, see <a href="http://wiki.okfn.org/ckan/doc/faq#TagConventions">this wiki page</a>.</dd>
- <dd class="hints">e.g. pollution rivers water-quality</dd>
- <dd class="field_error" py:if="errors.get('tag_string', '')">${errors.get('tag_string', '')}</dd>
+ <dd class="tags-instructions instructions basic">Terms that may link this dataset to similar ones. For more information on conventions, see <a href="http://wiki.okfn.org/ckan/doc/faq#TagConventions">this wiki page</a>.</dd>
+ <dd class="tags-instructions hints">e.g. pollution rivers water-quality</dd>
+ <dd class="tags-instructions field_error" py:if="errors.get('tag_string', '')">${errors.get('tag_string', '')}</dd></dl></fieldset>
@@ -250,7 +250,7 @@
<strong>Important:</strong> By submitting content, you agree to release your contributions
under the <a href="http://opendatacommons.org/licenses/odbl/1.0/">Open Database License</a>. Please <strong>refrain</strong> from editing this page if you are <strong>not</strong> happy to do this.
</p>
- <input id="save" class="pretty primary" name="save" type="submit" value="Save Changes" />
+ <input id="save" tabindex="99" class="pretty primary" name="save" type="submit" value="Save Changes" /></div>
http://bitbucket.org/okfn/ckan/changeset/b0850567d76d/
changeset: b0850567d76d
branch: feature-1294-ux-improvements-dataset
user: zephod
date: 2011-09-12 18:48:56
summary: [ux,package/new][s]: Really super slick minimal add-dataset route.
affected #: 2 files (357 bytes)
--- a/ckan/controllers/package.py Mon Sep 12 17:37:47 2011 +0100
+++ b/ckan/controllers/package.py Mon Sep 12 17:48:56 2011 +0100
@@ -506,12 +506,12 @@
'''
assert action in ('new', 'edit')
if action == 'new':
- msg = _('Congratulations, your dataset has been created. ' \
- 'You\'ll probably want to <a href="%s">upload or link ' \
- 'some data</a> now.')
+ msg = _('<span class="new-dataset">Congratulations, your dataset has been created. ' \
+ '<a href="%s">Upload or link ' \
+ 'some data now »</a></span>')
msg = msg % h.url_for(controller='package', action='edit',
id=pkgname, anchor='section-resources')
- h.flash_notice(msg,allow_html=True)
+ h.flash_success(msg,allow_html=True)
url = request.params.get('return_to') or \
config.get('package_%s_return_url' % action)
if url:
--- a/ckan/public/css/style.css Mon Sep 12 17:37:47 2011 +0100
+++ b/ckan/public/css/style.css Mon Sep 12 17:48:56 2011 +0100
@@ -200,7 +200,8 @@
/* Notices */
-.notice a, .notice a:visited {
+.notice a, .notice a:visited,
+.success a, .success a:visited {
text-decoration: underline;
}
@@ -798,6 +799,10 @@
width: 60%;
}
+/* ==================== */
+/* = Add Dataset Page = */
+/* ==================== */
+
body.package.new dt.homepage-label,
body.package.new dd.homepage-field,
body.package.new dd.homepage-instructions
@@ -816,6 +821,12 @@
{
display: none;
}
+body.package.new dt.license-label,
+body.package.new dd.license-field,
+body.package.new dd.license-instructions
+{
+ display: none;
+}
body.package.new dt.name-label {
font-size: 10px;
@@ -831,6 +842,12 @@
background: #eee;
}
+.success .new-dataset {
+ font-size: 150%;
+}
+.success .new-dataset a {
+ font-weight: bold;
+}
/* =============================== */
/* = Mini-Tabs [Markdown Editor] = */
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list