mirror of
https://github.com/humhub/humhub.git
synced 2025-02-24 11:14:00 +01:00
Allow text overwrite of content delete modal
This commit is contained in:
parent
a8d2c236b8
commit
86b192483e
@ -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,34 +64,43 @@ humhub.module('content', function (module, require, $) {
|
||||
|
||||
var modalOptions = options.modal || module.config.modal.deleteConfirm;
|
||||
|
||||
modal.confirm(modalOptions).then(function ($confirmed) {
|
||||
if (!$confirmed) {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
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.loader();
|
||||
var deleteUrl = that.data(DATA_CONTENT_DELETE_URL) || module.config.deleteUrl;
|
||||
if (deleteUrl) {
|
||||
client.post(deleteUrl, {
|
||||
data: {id: that.getKey()}
|
||||
}).then(function (response) {
|
||||
that.remove().then(function () {
|
||||
resolve(true);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
}).finally(function () {
|
||||
that.loader(false);
|
||||
});
|
||||
} else {
|
||||
reject('Content delete was called, but no url could be determined for ' + that.base);
|
||||
that.loader(false);
|
||||
}
|
||||
});
|
||||
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) {
|
||||
client.post(deleteUrl, {
|
||||
data: {id: that.getKey()}
|
||||
}).then(function (response) {
|
||||
that.remove().then(function () {
|
||||
resolve(true);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
}).finally(function () {
|
||||
that.loader(false);
|
||||
});
|
||||
} else {
|
||||
reject('Content delete was called, but no url could be determined for ' + that.base);
|
||||
that.loader(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract loader function which can be used to activate or deactivate a
|
||||
* loader within a content entry.
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user