Skip to content

Commit

Permalink
[#2375] Rename confirm-delete module to confirm-action
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed Aug 13, 2012
1 parent 5654b6a commit b31316c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
@@ -1,11 +1,11 @@
this.ckan.module('confirm-delete', function (jQuery, _) {
this.ckan.module('confirm-action', function (jQuery, _) {
return {
/* An object of module options */
options: {
/* Locale options can be overidden with data-module-i18n attribute */
i18n: {
heading: _('Please Confirm Action'),
content: _('Are you sure you want to delete this item?'),
content: _('Are you sure you want to perform this action?'),
confirm: _('Confirm'),
cancel: _('Cancel')
},
Expand Down Expand Up @@ -35,7 +35,7 @@ this.ckan.module('confirm-delete', function (jQuery, _) {
},

/* Presents the user with a confirm dialogue to ensure that they wish to
* delete the current item.
* continue with the current action.
*
* Examples
*
Expand All @@ -50,11 +50,11 @@ this.ckan.module('confirm-delete', function (jQuery, _) {
this.modal.modal('show');
},

/* Performs the delete action for the current item.
/* Performs the action for the current item.
*
* Returns nothing.
*/
performDelete: function () {
performAction: function () {
// create a form and submit it to confirm the deletion
var form = jQuery('<form/>', {
action: this.el.attr('href'),
Expand Down Expand Up @@ -91,7 +91,7 @@ this.ckan.module('confirm-delete', function (jQuery, _) {

/* Event handler for the success event */
_onConfirmSuccess: function (event) {
this.performDelete();
this.performAction();
},

/* Event handler for the cancel event */
Expand Down
4 changes: 2 additions & 2 deletions ckan/public/base/test/index.html
Expand Up @@ -46,7 +46,7 @@
<script src="../javascript/modules/autocomplete.js"></script>
<script src="../javascript/modules/resource-form.js"></script>
<script src="../javascript/modules/resource-upload-field.js"></script>
<script src="../javascript/modules/confirm-delete.js"></script>
<script src="../javascript/modules/confirm-action.js"></script>
<script src="../javascript/modules/custom-fields.js"></script>
<script src="../javascript/modules/related-item.js"></script>

Expand All @@ -59,7 +59,7 @@
<script src="./spec/notify.spec.js"></script>
<script src="./spec/modules/resource-form.spec.js"></script>
<script src="./spec/modules/resource-upload-field.spec.js"></script>
<script src="./spec/modules/confirm-delete.spec.js"></script>
<script src="./spec/modules/confirm-action.spec.js"></script>
<script src="./spec/modules/basic-form.spec.js"></script>
<script src="./spec/modules/autocomplete.spec.js"></script>
<script src="./spec/modules/custom-fields.spec.js"></script>
Expand Down
@@ -1,14 +1,14 @@
/*globals describe beforeEach afterEach it assert sinon ckan jQuery */
describe('ckan.module.ConfirmDeleteModule()', function () {
var ConfirmDeleteModule = ckan.module.registry['confirm-delete'];
describe('ckan.module.ConfirmActionModule()', function () {
var ConfirmActionModule = ckan.module.registry['confirm-action'];

beforeEach(function () {
jQuery.fn.modal = sinon.spy();

this.el = document.createElement('button');
this.sandbox = ckan.sandbox();
this.sandbox.body = this.fixture;
this.module = new ConfirmDeleteModule(this.el, {}, this.sandbox);
this.module = new ConfirmActionModule(this.el, {}, this.sandbox);
});

afterEach(function () {
Expand Down Expand Up @@ -38,8 +38,8 @@ describe('ckan.module.ConfirmDeleteModule()', function () {
});
});

describe('.performDelete()', function () {
it('should submit the delete action');
describe('.performAction()', function () {
it('should submit the action');
});

describe('.createModal()', function () {
Expand Down Expand Up @@ -101,8 +101,8 @@ describe('ckan.module.ConfirmDeleteModule()', function () {
});

describe('._onConfirmSuccess()', function () {
it('should perform the delete action', function () {
var target = sinon.stub(this.module, 'performDelete');
it('should perform the action', function () {
var target = sinon.stub(this.module, 'performAction');
this.module._onConfirmSuccess(jQuery.Event('click'));
assert.called(target);
});
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/group/snippets/group_form.html
Expand Up @@ -73,7 +73,7 @@
{% block delete_button %}
{% if h.check_access('group_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this Group?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='group', action='delete', id=data.id %}" data-module="confirm-delete" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{% url_for controller='group', action='delete', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
<button class="btn btn-primary" name="save">{% block save_text %}{{ _('Save Group') }}{% endblock %}</button>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/snippets/package_form.html
Expand Up @@ -35,7 +35,7 @@
{% block delete_button %}
{% if h.check_access('package_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this dataset?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='package', action='delete', id=data.id %}" data-module="confirm-delete" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{% url_for controller='package', action='delete', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block cancel_button %}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/snippets/resource_form.html
Expand Up @@ -68,7 +68,7 @@
{% if data.id %}
{% if h.check_access('resource_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this resource?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='package', action='resource_delete', resource_id=data.id, id=pkg_name %}" data-module="confirm-delete" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{% url_for controller='package', action='resource_delete', resource_id=data.id, id=pkg_name %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endif %}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/related/snippets/related_form.html
Expand Up @@ -26,7 +26,7 @@
{% block delete_button %}
{% if h.check_access('related_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this related item?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='related', action='delete', related_id=data.id, id=c.pkg_id %}" data-module="confirm-delete" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{% url_for controller='related', action='delete', related_id=data.id, id=c.pkg_id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{{ h.nav_link(_('Cancel'), controller='related', action='list', id=c.id, class_='btn') }}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/snippets/scripts.html
Expand Up @@ -24,7 +24,7 @@
<script src="{% url_for_static '/base/javascript/modules/select-switch.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/slug-preview.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/basic-form.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/confirm-delete.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/confirm-action.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/api-info.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/autocomplete.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/custom-fields.js' %}"></script>
Expand Down

0 comments on commit b31316c

Please sign in to comment.