Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[view/resource-upload][m]: very basic (but working and tested) upload…
… form (refs #29).
- Loading branch information
rgrp
committed
Aug 8, 2011
1 parent
0791071
commit 0c1ebfc
Showing
6 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CKAN.Templates.resourceUpload = ' \ | ||
<form action="" \ | ||
enctype="multipart/form-data" \ | ||
method="POST"> \ | ||
\ | ||
<div class="hidden-inputs"></div> \ | ||
<dl> \ | ||
<!--dt> \ | ||
<label>File name:</label> \ | ||
</dt> \ | ||
<dd> \ | ||
<input type="text" name="key" value="" /> \ | ||
</dd--> \ | ||
<dt> \ | ||
<label>File:</label> \ | ||
</dt> \ | ||
<dd> \ | ||
<input id="file" name="file" type="file" size="50" /> \ | ||
</dd> \ | ||
</dl> \ | ||
<div class="submit"> \ | ||
<input type="submit" value="Upload »" /> \ | ||
</div> \ | ||
</form> \ | ||
'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
this.CKAN || (this.CKAN = {}); | ||
this.CKAN.View || (this.CKAN.View = {}); | ||
|
||
(function (CKAN, $, _, Backbone, undefined) { | ||
CKAN.View.ResourceUpload = Backbone.View.extend({ | ||
tagName: 'div', | ||
|
||
// expects a client arguments in its options | ||
initialize: function(options) { | ||
this.el = $(this.el); | ||
this.client = options.client; | ||
_.bindAll(this, 'update', 'render'); | ||
}, | ||
|
||
render: function () { | ||
this.el.empty(); | ||
tmplData = { | ||
} | ||
var tmpl = $.tmpl(CKAN.Templates.resourceUpload, tmplData); | ||
this.el.html(tmpl); | ||
return this; | ||
}, | ||
|
||
// update with data from backend storage | ||
update: function() { | ||
var self = this; | ||
var key = 'xyz/abc'; | ||
this.client.getStorageAuthForm(key, { | ||
success: function(data) { | ||
_tmpl = '<input type="hidden" name="${name}" value="${value}" />'; | ||
self.el.find('form').attr('action', data.action); | ||
var $hidden = $(self.el.find('form div.hidden-inputs')[0]); | ||
$.each(data.fields, function(idx, item) { | ||
$hidden.append($.tmpl(_tmpl, item)); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
})(CKAN, $, _, Backbone, undefined); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters