Allow text overwrite of content delete modal

This commit is contained in:
Lucas Bartholemy 2018-06-11 17:23:46 +02:00
parent a8d2c236b8
commit 86b192483e
2 changed files with 39 additions and 29 deletions

View File

@ -55,6 +55,7 @@ humhub.module('content', function (module, require, $) {
Content.prototype.delete = function (options) {
options = options || {};
var that = this;
return new Promise(function (resolve, reject) {
if (!that.hasAction('delete')) {
@ -63,12 +64,23 @@ humhub.module('content', function (module, require, $) {
var modalOptions = options.modal || module.config.modal.deleteConfirm;
if(options.$trigger && options.$trigger.is('[data-action-confirm]')) {
that.deleteContent(resolve, reject);
} else {
modal.confirm(modalOptions).then(function ($confirmed) {
if (!$confirmed) {
resolve(false);
return;
}
that.deleteContent(resolve, reject);
});
}
});
};
Content.prototype.deleteContent = function(resolve, reject) {
var that = this;
that.loader();
var deleteUrl = that.data(DATA_CONTENT_DELETE_URL) || module.config.deleteUrl;
if (deleteUrl) {
@ -87,8 +99,6 @@ humhub.module('content', function (module, require, $) {
reject('Content delete was called, but no url could be determined for ' + that.base);
that.loader(false);
}
});
});
};
/**

View File

@ -92,10 +92,10 @@ humhub.module('stream', function (module, require, $) {
return ['delete', 'edit'];
};
StreamEntry.prototype.delete = function () {
StreamEntry.prototype.delete = function (evt) {
// Either call delete of a nestet content component or call default content delete
var content = this.contentComponent();
var promise = (content && content.delete) ? content.delete() : this.super('delete');
var promise = (content && content.delete) ? content.delete(evt) : this.super('delete', evt);
var that = this;
var stream = this.stream();