Skip to content

Commit

Permalink
[#1425][m]: Redesigned front-end for dataset deletion. Closes #1425.
Browse files Browse the repository at this point in the history
  • Loading branch information
teajaymars committed Jan 26, 2012
1 parent 68a15ec commit f3a4c3d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ckan/public/css/style.css
Expand Up @@ -963,6 +963,9 @@ ul.dataset-edit-nav li a:hover {
.dataset-edit-form .resource-add .fileinfo {
margin: 7px 0;
}
.dataset-edit-form button.dataset-delete {
vertical-align: top;
}


/* ================================ */
Expand Down
16 changes: 14 additions & 2 deletions ckan/public/scripts/application.js
Expand Up @@ -80,6 +80,18 @@
el: $el
});
view.render();

// Set up dataset delete button
var select = $('select.dataset-delete');
select.attr('disabled','disabled');
select.css({opacity: 0.3});
$('button.dataset-delete').click(function(e) {
select.removeAttr('disabled');
select.fadeTo('fast',1.0);
$(e.target).css({opacity:0});
$(e.target).attr('disabled','disabled');
return false;
});
}
var isGroupEdit = $('body.group.edit').length > 0;
if (isGroupEdit) {
Expand Down Expand Up @@ -497,7 +509,7 @@ CKAN.View.DatasetEditForm = Backbone.View.extend({
parentDiv.append(messageDiv);
$('#unsaved-warning').append(parentDiv);
console.log($('#unsaved-warning'));
messageDiv.show(1200);
messageDiv.show(200);

boundToUnload = true;
window.onbeforeunload = function () {
Expand All @@ -507,7 +519,7 @@ CKAN.View.DatasetEditForm = Backbone.View.extend({
}
}();

$form.find('input').live('change', function(e) {
$form.find('input,select').live('change', function(e) {
$target = $(e.target);
// Entering text in the 'add' box does not represent a change
if ($target.closest('.resource-add').length==0) {
Expand Down
1 change: 1 addition & 0 deletions ckan/templates/package/edit.html
Expand Up @@ -23,6 +23,7 @@
<li><a href="#section-resources">Resources</a></li>
<li><a href="#section-groups">Groups &amp; Tags</a></li>
<li><a href="#section-extras">Extras</a></li>
<li py:if="c.is_sysadmin or c.auth_for_change_state"><a href="#section-delete">Delete</a></li>
</ul>
</li>
</py:match>
Expand Down
21 changes: 13 additions & 8 deletions ckan/templates/package/new_package_form.html
Expand Up @@ -165,14 +165,6 @@ <h3>Tags</h3>
<dd class="instructions basic">A number representing the version (if applicable)</dd>
<dd class="hints">e.g. 1.2.0</dd>

<dt py:if="c.is_sysadmin or c.auth_for_change_state"><label class="field_opt" for="state">State</label></dt>
<dd py:if="c.is_sysadmin or c.auth_for_change_state">
<select id="state" name="state" >
<option py:attrs="{'selected': 'selected' if data.get('state') == 'active' else None}" value="active">active</option>
<option py:attrs="{'selected': 'selected' if data.get('state') == 'deleted' else None}" value="deleted">deleted</option>
</select>
</dd>

</dl>
</fieldset>

Expand All @@ -199,6 +191,19 @@ <h3>Tags</h3>
</py:with>
</dl>
</fieldset>
<fieldset id='delete' py:if="c.is_sysadmin or c.auth_for_change_state">
<dl>
<dt>Delete</dt>
<dd>
<p>Do you really want to change the state of this dataset? &nbsp;&nbsp;<button class="dataset-delete pretty-button">Yes!</button></p>
This dataset is&nbsp;&nbsp;
<select class="dataset-delete" id="state" name="state" style="display:inline;">
<option py:attrs="{'selected': 'selected' if data.get('state') == 'active' else None}" value="active">active</option>
<option py:attrs="{'selected': 'selected' if data.get('state') == 'deleted' else None}" value="deleted">deleted</option>
</select>
</dd>
</dl>
</fieldset>

<div id="unsaved-warning"></div>

Expand Down

0 comments on commit f3a4c3d

Please sign in to comment.