Skip to content

Commit

Permalink
Missing confirm warning from publish/unpublish (#71)
Browse files Browse the repository at this point in the history
* Ensure legacy edit form JS included from versioned-admin

This legacy JS file provide the functionality to display popup warning
before publish or unpublish data object, such as, not inline elemental
block.

* Build JS assets for commit PR/71
  • Loading branch information
satrun77 authored Sep 6, 2021
1 parent ae3e2a1 commit 0e9d378
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions client/src/bundles/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ require('../legacy/ArchiveAdmin/ArchiveAdmin');
// To do: determine better way of using webpack to pull in optional javascript
require('../legacy/HistoryViewer/HistoryViewerEntwine');

// Legacy publish/unpublish popup confirmation - copy from versioned-admin
require('../legacy/VersionedEditForm/VersionedEditForm');

require('boot');
62 changes: 62 additions & 0 deletions client/src/legacy/VersionedEditForm/VersionedEditForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import i18n from 'i18n';
import jQuery from 'jquery';

jQuery.entwine('ss', ($) => {
/**
* Class: .cms-edit-form .btn-toolbar #Form_ItemEditForm_action_doUnpublish
* Informing the user about the unpublish action while requiring confirmation
*/
$('.cms-edit-form .btn-toolbar #Form_ItemEditForm_action_doUnpublish').entwine({

/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick(e) {
const message = i18n._t(
'VersionedEditForm.PUBLISH_CONFIRM_MESSAGE',
'Are you sure you want to remove your record from the published site?\n\nThis record will still be available in the CMS as draft.'
);

if (confirm(message)) {
// Add a loading indicator and continue
this.parents('form:first').addClass('loading');

return this._super(e);
}

return false;
}
});

/**
* Class: .cms-edit-form .btn-toolbar #Form_ItemEditForm_action_doArchive
*
* Informing the user about the archive action while requiring confirmation
*/
$('.cms-edit-form .btn-toolbar #Form_ItemEditForm_action_doArchive').entwine({
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick(e) {
const message = i18n._t(
'VersionedEditForm.ARCHIVE_CONFIRM_MESSAGE',
'Warning: This record will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?'
);

if (confirm(message)) {
// Add a loading indicator and continue
this.parents('form:first').addClass('loading');

return this._super(e);
}

return false;
}
});
});

0 comments on commit 0e9d378

Please sign in to comment.